Merge lp:~thomas-voss/compiz-core/GoogleTest into lp:compiz-core/0.9.5

Proposed by Sam Spilsbury
Status: Superseded
Proposed branch: lp:~thomas-voss/compiz-core/GoogleTest
Merge into: lp:compiz-core/0.9.5
Diff against target: 4435 lines (+2257/-1088) (has conflicts)
70 files modified
CMakeLists.txt (+47/-21)
cmake/CompizCommon.cmake (+379/-5)
cmake/CompizPlugin.cmake (+41/-51)
cmake/EnableCoverageReport.cmake (+153/-0)
cmake/FindLcov.cmake (+29/-0)
cmake/Findgcovr.cmake (+31/-0)
cmake/ParseArguments.cmake (+52/-0)
include/CMakeLists.txt (+0/-1)
include/compiz-common.h.in (+0/-5)
include/compiz.h (+0/-103)
include/core/CMakeLists.txt (+0/-5)
include/core/core.h (+19/-0)
include/core/global.h (+37/-0)
include/core/logmessage.h (+51/-0)
include/core/match.h (+1/-0)
include/core/option.h (+1/-2)
include/core/plugin.h (+1/-1)
include/core/session.h (+1/-0)
include/core/string.h (+39/-0)
metadata/CMakeLists.txt (+2/-2)
plugins/CMakeLists.txt (+10/-0)
plugins/composite/src/screen.cpp (+4/-2)
plugins/opengl/src/matrix.cpp (+0/-1)
plugins/opengl/src/texture.cpp (+0/-2)
po/POTFILES.in (+3/-0)
src/CMakeLists.txt (+77/-30)
src/action.cpp (+0/-2)
src/logmessage/CMakeLists.txt (+37/-0)
src/logmessage/include/core/logmessage.h (+51/-0)
src/logmessage/src/logmessage.cpp (+5/-1)
src/main.cpp (+0/-2)
src/pluginclasshandler/CMakeLists.txt (+50/-0)
src/pluginclasshandler/include/core/pluginclasshandler.h (+1/-1)
src/pluginclasshandler/include/core/valueholder.h (+3/-2)
src/pluginclasshandler/tests/CMakeLists.txt (+81/-6)
src/pluginclasshandler/tests/construct/src/test-pch-construct.cpp (+40/-55)
src/pluginclasshandler/tests/get/src/test-pch-get.cpp (+4/-17)
src/pluginclasshandler/tests/indexes/src/test-pch-indexes.cpp (+30/-33)
src/pluginclasshandler/tests/test-pluginclasshandler.cpp (+3/-31)
src/pluginclasshandler/tests/test-pluginclasshandler.h (+5/-57)
src/pluginclasshandler/tests/typenames/src/test-pch-typenames.cpp (+72/-80)
src/privatescreen.h (+14/-0)
src/screen.cpp (+2/-2)
src/session.cpp (+0/-2)
src/string/CMakeLists.txt (+35/-0)
src/string/src/string.cpp (+2/-2)
src/string/tests/CMakeLists.txt (+20/-0)
src/string/tests/printf/src/test-string-printf.cpp (+161/-0)
src/string/tests/test-string.cpp (+47/-0)
src/string/tests/test-string.h (+52/-0)
src/timer/CMakeLists.txt (+70/-0)
src/timer/include/core/timer.h (+18/-0)
src/timer/tests/CMakeLists.txt (+76/-15)
src/timer/tests/callbacks/src/test-timer-callbacks.cpp (+138/-0)
src/timer/tests/diffs/src/test-timer-diffs.cpp (+117/-0)
src/timer/tests/set-values/src/test-timer-set-values.cpp (+13/-111)
src/timer/tests/test-timer.cpp (+10/-20)
src/timer/tests/test-timer.h (+6/-39)
src/timer/tests/while-calling/src/test-timer-set-times-while-calling.cpp (+114/-96)
src/window.cpp (+2/-4)
tests/CMakeLists.txt (+0/-2)
tests/pluginclasshandler/construct/CMakeLists.txt (+0/-25)
tests/pluginclasshandler/get/CMakeLists.txt (+0/-25)
tests/pluginclasshandler/indexes/CMakeLists.txt (+0/-28)
tests/pluginclasshandler/typenames/CMakeLists.txt (+0/-25)
tests/timer/callbacks/CMakeLists.txt (+0/-23)
tests/timer/diffs/CMakeLists.txt (+0/-23)
tests/timer/diffs/test-timer-diffs.cpp (+0/-82)
tests/timer/set-values/CMakeLists.txt (+0/-23)
tests/timer/while-calling/CMakeLists.txt (+0/-23)
Text conflict in po/POTFILES.in
Text conflict in src/timer/tests/callbacks/src/test-timer-callbacks.cpp
To merge this branch: bzr merge lp:~thomas-voss/compiz-core/GoogleTest
Reviewer Review Type Date Requested Status
Thomas Voß Pending
Tim Penhey Pending
Compiz Maintainers Pending
Review via email: mp+86321@code.launchpad.net

This proposal supersedes a proposal from 2011-10-31.

This proposal has been superseded by a proposal from 2011-12-20.

Description of the change

Fix bug 883102

    Move to a test-driven-development type buildsystem which allows for
    modules to be build interternally and statically linked to plugins and to
    testcases.

    Use compiz_module to add a new module, with the following directory structure:

    module/
     src/
     include/
     tests/
     CMakeLists.txt

    Use compiz_test_base to add a library for all tests for that module to
    link to, and add each test in a separate subdirectory in tests/

    Use compiz_test to add a new test in a name subdirectory for a module and
    prefix.

    prefix: plugin / core
    module: module of functionality
    test: test name

    Removed compiz.h and compiz-common.h . Use core/string.h core/timer.h
    core/logmessage.h core/screen.h for timeval diff functionality, CompString,
    compLogMessage and wraparound modulus.

    Added workaround for core xml file race condition

    Switched to Google Test for unit testing purposes.

To post a comment you must log in.
Revision history for this message
Tim Penhey (thumper) wrote : Posted in a previous version of this proposal

I find the string test remarkably hard to follow. Have you considered using google-test and google-mock for the testing framework?

The CMake stuff is way over my understanding, and I can't comfortably review the code.

A +1 for removing compiz.h, but is this used in unity at all?

Revision history for this message
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

On Wed, Nov 9, 2011 at 6:55 AM, Tim Penhey <email address hidden> wrote:
> I find the string test remarkably hard to follow.  Have you considered using google-test and google-mock for the testing framework?

Yeah, the string test could probably be reworked slightly. I am not
sure about using google-mock or google-test as I am not sure how
available they are on other distributions.

>
> The CMake stuff is way over my understanding, and I can't comfortably review the code.
>
> A +1 for removing compiz.h, but is this used in unity at all?

It is used by some compiz code, but was mostly just a random
assortment of #defines and typedefs that needed to die.

> --
> https://code.launchpad.net/~compiz-team/compiz-core/compiz-core.fix_883102/+merge/80803
> Your team Compiz Maintainers is requested to review the proposed merge of lp:~compiz-team/compiz-core/compiz-core.fix_883102 into lp:compiz-core.
>

--
Sam Spilsbury

Revision history for this message
Tim Penhey (thumper) wrote : Posted in a previous version of this proposal

I don't feel confident about reviewing the CMake changes. We should get someone who knows cmake to look at it.

review: Abstain
Revision history for this message
Jussi Pakkanen (jpakkane) wrote : Posted in a previous version of this proposal

The CMake functions seem to be duplicating a lot of stuff that CMake already does. For example there is a lot of code to build compiler flag prefixes which you really should not need to do. As an example is this line:

list (APPEND ${_prefix}_LIBRARY_LDFLAGS -l${_library})

It seems (not having read all of the build system code thoroughly) that these are then added to a target with set_target_properties. You really should not need to do this. Simply do target_link_libraries(foo library_of_bar). It's the same, but portable and consistency checked by CMake.

In the same vein, why are linker flags set with set_target_properties and not target_link_libraries? The arguments to the latter can be linker flags and they are handled appropriately by CMake. The same applies for include paths and other properties. Why have a function for include expansion (that basically just adds a "-I" to a list of strings) when all you would need to do is include_directories(${foobar})? These definitions do not propagate to parent directories so you can just set them in a test subdirectory and they remain isolated.

On this line the word "library" is misspelt:

list (APPEND ${_full_prefix}_LINK_FLAGS ${${_full_prefix}_LIBARY_FLAGS})

Revision history for this message
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

> The CMake functions seem to be duplicating a lot of stuff that CMake already
> does. For example there is a lot of code to build compiler flag prefixes which
> you really should not need to do. As an example is this line:
>
> list (APPEND ${_prefix}_LIBRARY_LDFLAGS -l${_library})
>
> It seems (not having read all of the build system code thoroughly) that these
> are then added to a target with set_target_properties. You really should not
> need to do this. Simply do target_link_libraries(foo library_of_bar). It's the
> same, but portable and consistency checked by CMake.
>
> In the same vein, why are linker flags set with set_target_properties and not
> target_link_libraries? The arguments to the latter can be linker flags and
> they are handled appropriately by CMake. The same applies for include paths
> and other properties. Why have a function for include expansion (that
> basically just adds a "-I" to a list of strings) when all you would need to do
> is include_directories(${foobar})? These definitions do not propagate to
> parent directories so you can just set them in a test subdirectory and they
> remain isolated.

Yes, that is ugly.

The reason I did it that way was because CMake seems to have a preference for storing the include dirs and link libraries on a per-directory basis rather than a per-target basis. Or at least, I was hitting problems where I would end up with absurdly long linker lines because it was pulling in all the stuff from the directories before it.

I'll need to have another look at whether or not I was just hacking around some problem that I may have fixed later on.

>
> On this line the word "library" is misspelt:
>
> list (APPEND ${_full_prefix}_LINK_FLAGS ${${_full_prefix}_LIBARY_FLAGS})

ack.

Revision history for this message
Thomas Voß (thomas-voss) wrote : Posted in a previous version of this proposal

+1 for Jussi's remarks.

Regarding Google Test: It is recommended in [*] that Google Test is distributed together with the respective project. It provides a simple CMake setup that allows for adding it in by means of add_subdirectory in compiz' CMake setup.

[*] http://code.google.com/p/googletest/wiki/V1_6_Primer#Setting_up_a_New_Test_Project

review: Needs Fixing
Revision history for this message
Jussi Pakkanen (jpakkane) wrote : Posted in a previous version of this proposal

There's nothing wrong with keeping target definitions to a minimum. But you should still set them with the default commands.

You can control which settings propagate to subdirectories quite easily. If you have something like this:

add_definitions(-DTHING1)
add_subdirectory(foo)
add_definitions(-DTHING2)

add_executable(thing thing.c)

then only THING1 is defined in subdirectory foo and both THING1 and THING2 are defined for "thing" executable. Include directories and others work the same way.

And further, if you have multiple targets in one subdirectory that have massively different (and possibly conflicting) build requirements, it's a pretty strong indication that they should be moved further away from each other.

Revision history for this message
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

On Mon, Nov 21, 2011 at 6:18 PM, Thomas Voß <email address hidden>wrote:

>
> Regarding Google Test: It is recommended in [*] that Google Test is
> distributed together with the respective project. It provides a simple
> CMake setup that allows for adding it in by means of add_subdirectory in
> compiz' CMake setup.
>
> [*]
> http://code.google.com/p/googletest/wiki/V1_6_Primer#Setting_up_a_New_Test_Project
>
>
Hmmmm, this seems all kinds of wrong, it shouldn't be necessary to
statically link it in.

> --
>
> https://code.launchpad.net/~compiz-team/compiz-core/compiz-core.fix_883102/+merge/80803<https://code.launchpad.net/%7Ecompiz-team/compiz-core/compiz-core.fix_883102/+merge/80803>
> Your team Compiz Maintainers is requested to review the proposed merge of
> lp:~compiz-team/compiz-core/compiz-core.fix_883102 into lp:compiz-core.
>

--
Sam Spilsbury

Revision history for this message
Thomas Voß (thomas-voss) wrote : Posted in a previous version of this proposal

> On Mon, Nov 21, 2011 at 6:18 PM, Thomas Voß <email address hidden>wrote:
>
> >
> > Regarding Google Test: It is recommended in [*] that Google Test is
> > distributed together with the respective project. It provides a simple
> > CMake setup that allows for adding it in by means of add_subdirectory in
> > compiz' CMake setup.
> >
> > [*]
> > http://code.google.com/p/googletest/wiki/V1_6_Primer#Setting_up_a_New_Test_P
> roject
> >
> >
> Hmmmm, this seems all kinds of wrong, it shouldn't be necessary to
> statically link it in.
>
>

Wouldn't do it by default. How about introducing a cmake option then?

  Thomas

> > --
> >
> > https://code.launchpad.net/~compiz-team/compiz-core/compiz-
> core.fix_883102/+merge/80803<https://code.launchpad.net/%7Ecompiz-team/compiz-
> core/compiz-core.fix_883102/+merge/80803>
> > Your team Compiz Maintainers is requested to review the proposed merge of
> > lp:~compiz-team/compiz-core/compiz-core.fix_883102 into lp:compiz-core.
> >
>
>
>
> --
> Sam Spilsbury

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2011-09-09 09:54:02 +0000
3+++ CMakeLists.txt 2011-12-20 02:49:24 +0000
4@@ -1,19 +1,44 @@
5+#
6+# Main CMakeLists.txt for compiz
7+#
8 project (compiz)
9
10 set (CMAKE_MODULE_PATH_ORIG ${CMAKE_MODULE_PATH})
11 set (COMPIZ_CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
12 set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${COMPIZ_CMAKE_MODULE_PATH})
13+
14+# Common compiz CMake macros & functions.
15 include (CompizCommon)
16+# Packaging-specific CMake macros & functions.
17 include (CompizPackage)
18 include (cmake/base.cmake)
19+# Check if specific function is present in library.
20 include (CheckFunctionExists)
21-include (CTest)
22-
23-
24-set (CMAKE_CONFIGURATION_TYPES "Debug;Release;RelWithDebInfo;MinSizeRe" CACHE INTERNAL "" FORCE)
25-if (NOT CMAKE_BUILD_TYPE)
26- set (CMAKE_BUILD_TYPE "Debug" CACHE STRING "Build type (Debug/Release/RelWithDebInfo/MinSizeRe)" FORCE)
27-endif (NOT CMAKE_BUILD_TYPE)
28+
29+enable_testing()
30+
31+# Import macro for doing coverage reporting
32+include(EnableCoverageReport)
33+
34+#####################################################################
35+# Enable code coverage calculation with gcov/gcovr/lcov
36+# Usage:
37+# * Switch build type to coverage (use ccmake or cmake-gui)
38+# * Invoke make, make test, make coverage
39+# * Find html report in subdir coveragereport
40+# * Find xml report feasible for jenkins in coverage.xml
41+#####################################################################
42+IF(CMAKE_BUILD_TYPE MATCHES [cC][oO][vV][eE][rR][aA][gG][eE])
43+ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftest-coverage -fprofile-arcs" )
44+ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ftest-coverage -fprofile-arcs" )
45+ SET(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -ftest-coverage -fprofile-arcs" )
46+ SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -ftest-coverage -fprofile-arcs" )
47+ENDIF(CMAKE_BUILD_TYPE MATCHES [cC][oO][vV][eE][rR][aA][gG][eE])
48+
49+#set (CMAKE_CONFIGURATION_TYPES "Debug;Release;RelWithDebInfo;MinSizeRe" CACHE INTERNAL "" FORCE)
50+#if (NOT CMAKE_BUILD_TYPE)
51+# set (CMAKE_BUILD_TYPE "Debug" CACHE STRING "Build type (Debug/Release/RelWithDebInfo/MinSizeRe)" FORCE)
52+#endif (NOT CMAKE_BUILD_TYPE)
53
54 file (READ ${CMAKE_SOURCE_DIR}/VERSION COMPIZ_RELEASE_VERSION LIMIT 12 OFFSET 0)
55 string (STRIP ${COMPIZ_RELEASE_VERSION} COMPIZ_RELEASE_VERSION)
56@@ -41,6 +66,7 @@
57 set (compiz_metadatadir ${datadir}/compiz)
58 set (COMPIZ_I18N_DIR ${CMAKE_SOURCE_DIR}/po)
59
60+# Translation
61 set (ALL_LINGUAS af ar bg bn bn_IN bs ca cs cy da de el en_GB en_US es eu et fi fr gl gu he hi hr hu id it ja ka km ko lo lt mk mr nb nl or pa pl pt pt_BR ro ru sk sl sr sv ta tr uk vi xh zh_CN zh_TW zu)
62 set (GETTEXT_PACKAGE compiz)
63
64@@ -82,16 +108,6 @@
65 compiz_configure_file (${compiz_SOURCE_DIR}/config.h.core.in ${compiz_BINARY_DIR}/generated/config.h)
66
67 compiz_configure_file (
68- ${CMAKE_SOURCE_DIR}/include/compiz-common.h.in
69- ${CMAKE_BINARY_DIR}/generated/compiz-common.h
70-)
71-
72-install (
73- FILES ${CMAKE_BINARY_DIR}/generated/compiz-common.h
74- DESTINATION ${COMPIZ_DESTDIR}${includedir}/compiz
75-)
76-
77-compiz_configure_file (
78 ${CMAKE_SOURCE_DIR}/compiz.pc.in
79 ${CMAKE_BINARY_DIR}/compiz.pc
80 COMPIZ_REQUIRES
81@@ -103,6 +119,17 @@
82 DESTINATION ${COMPIZ_DESTDIR}${libdir}/pkgconfig
83 )
84
85+# Build Google Test and make its headers known
86+find_package( GTest REQUIRED )
87+
88+
89+include_directories(
90+ ${GTEST_INCLUDE_DIRS}
91+)
92+
93+find_package( Threads REQUIRED )
94+
95+# Add the rest of compiz
96 add_subdirectory (cmake)
97 add_subdirectory (include)
98 add_subdirectory (images)
99@@ -115,10 +142,6 @@
100 add_subdirectory (xslt)
101 add_subdirectory (plugins)
102
103-if (BUILD_TESTING)
104- add_subdirectory (tests)
105-endif (BUILD_TESTING)
106-
107 compiz_ensure_linkage ()
108 compiz_package_generation ("Compiz")
109 compiz_add_uninstall ()
110@@ -131,4 +154,7 @@
111
112 _check_compiz_cmake_macro (${CMAKE_MODULE_PATH_ORIG})
113
114+# Enable coverage reporting for compiz
115+enable_coverage_report()
116+
117
118
119=== modified file 'cmake/CompizCommon.cmake'
120--- cmake/CompizCommon.cmake 2011-09-19 13:00:51 +0000
121+++ cmake/CompizCommon.cmake 2011-12-20 02:49:24 +0000
122@@ -1,12 +1,12 @@
123 cmake_minimum_required (VERSION 2.6)
124
125-if ("${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}")
126+if ("${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
127 message (SEND_ERROR "Building in the source directory is not supported.")
128 message (FATAL_ERROR "Please remove the created \"CMakeCache.txt\" file, the \"CMakeFiles\" directory and create a build directory and call \"${CMAKE_COMMAND} <path to the sources>\".")
129-endif ("${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}")
130+endif ("${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
131
132 #### CTest
133-include (CTest)
134+enable_testing()
135
136 #### policies
137
138@@ -404,7 +404,7 @@
139 endforeach (_val ${ARGN})
140 endfunction ()
141
142-function (compiz_add_plugins_in_folder folder)
143+macro (compiz_add_plugins_in_folder folder)
144 set (COMPIZ_PLUGIN_PACK_BUILD 1)
145 file (
146 GLOB _plugins_in
147@@ -416,7 +416,7 @@
148 get_filename_component (_plugin_dir ${_plugin} PATH)
149 add_subdirectory (${folder}/${_plugin_dir})
150 endforeach ()
151-endfunction ()
152+endmacro ()
153
154 #### pkg-config handling
155
156@@ -489,6 +489,380 @@
157 endif ()
158 endfunction ()
159
160+#### modules / tests
161+macro (_get_parameters _prefix)
162+ set (_current_var _foo)
163+ set (_supported_var PKGDEPS PLUGINDEPS MODULES LDFLAGSADD CFLAGSADD LIBRARIES LIBDIRS INCDIRS DEFSADD)
164+ foreach (_val ${_supported_var})
165+ set (${_prefix}_${_val})
166+ endforeach (_val)
167+ foreach (_val ${ARGN})
168+ set (_found FALSE)
169+ foreach (_find ${_supported_var})
170+ if ("${_find}" STREQUAL "${_val}")
171+ set (_found TRUE)
172+ endif ("${_find}" STREQUAL "${_val}")
173+ endforeach (_find)
174+
175+ if (_found)
176+ set (_current_var ${_prefix}_${_val})
177+ else (_found)
178+ list (APPEND ${_current_var} ${_val})
179+ endif (_found)
180+ endforeach (_val)
181+endmacro (_get_parameters)
182+
183+macro (_check_pkg_deps _prefix)
184+ set (${_prefix}_HAS_PKG_DEPS TRUE)
185+ foreach (_val ${ARGN})
186+ string (REGEX REPLACE "[<>=\\.]" "_" _name ${_val})
187+ string (TOUPPER ${_name} _name)
188+
189+ compiz_pkg_check_modules (_${_name} ${_val})
190+
191+ if (_${_name}_FOUND)
192+ list (APPEND ${_prefix}_PKG_LIBDIRS "${_${_name}_LIBRARY_DIRS}")
193+ list (APPEND ${_prefix}_PKG_LIBRARIES "${_${_name}_LIBRARIES}")
194+ list (APPEND ${_prefix}_PKG_INCDIRS "${_${_name}_INCLUDE_DIRS}")
195+ else (_${_name}_FOUND)
196+ set (${_prefix}_HAS_PKG_DEPS FALSE)
197+ compiz_set (${_prefix}_MISSING_DEPS "${${_prefix}_MISSING_DEPS} ${_val}")
198+ set(__pkg_config_checked__${_name} 0 CACHE INTERNAL "" FORCE)
199+ endif (_${_name}_FOUND)
200+ endforeach ()
201+endmacro (_check_pkg_deps)
202+
203+macro (_build_include_flags _prefix)
204+ foreach (_include ${ARGN})
205+ if (NOT ${_prefix}_INCLUDE_CFLAGS)
206+ compiz_set (${_prefix}_INCLUDE_CFLAGS "" PARENT_SCOPE)
207+ endif (NOT ${_prefix}_INCLUDE_CFLAGS)
208+ list (APPEND ${_prefix}_INCLUDE_CFLAGS -I${_include})
209+ endforeach (_include)
210+endmacro (_build_include_flags)
211+
212+macro (_build_definitions_flags _prefix)
213+ foreach (_def ${ARGN})
214+ if (NOT ${_prefix}_DEFINITIONS_CFLAGS)
215+ compiz_set (${_prefix}_DEFINITIONS_CFLAGS "")
216+ endif (NOT ${_prefix}_DEFINITIONS_CFLAGS)
217+ list (APPEND ${_prefix}_DEFINITIONS_CFLAGS -D${_def})
218+ endforeach (_def)
219+endmacro (_build_definitions_flags)
220+
221+macro (_build_link_dir_flags _prefix)
222+ foreach (_link_dir ${ARGN})
223+ if (NOT ${_prefix}_LINK_DIR_LDFLAGS)
224+ compiz_set (${_prefix}_LINK_DIR_LDFLAGS "")
225+ endif (NOT ${_prefix}_LINK_DIR_LDFLAGS)
226+ list (APPEND ${_prefix}_LINK_DIR_LDFLAGS -L${_link_dir})
227+ endforeach (_link_dir)
228+endmacro (_build_link_dir_flags)
229+
230+macro (_build_library_flags _prefix)
231+ foreach (_library ${ARGN})
232+ if (NOT ${_prefix}_LIBRARY_LDFLAGS)
233+ compiz_set (${_prefix}_LIBRARY_LDFLAGS "")
234+ endif (NOT ${_prefix}_LIBRARY_LDFLAGS)
235+ list (APPEND ${_prefix}_LIBRARY_LDFLAGS -l${_library})
236+ endforeach (_library)
237+endmacro (_build_library_flags)
238+
239+function (_build_compiz_module _prefix _name _full_prefix)
240+
241+ if (${_full_prefix}_INCLUDE_DIRS)
242+ _build_include_flags (${_full_prefix} ${${_full_prefix}_INCLUDE_DIRS})
243+ endif (${_full_prefix}_INCLUDE_DIRS)
244+ _build_include_flags (${_full_prefix} ${${_full_prefix}_SOURCE_DIR})
245+ _build_include_flags (${_full_prefix} ${${_full_prefix}_INCLUDE_DIR})
246+
247+ if (${_full_prefix}_DEFSADD)
248+ _build_definitions_flags (${_full_prefix} ${${_full_prefix}_DEFSADD})
249+ endif (${_full_prefix}_DEFSADD)
250+
251+ if (${_full_prefix}_LIBRARY_DIRS)
252+ _build_link_dir_flags (${_full_prefix} ${${_full_prefix}_LIBRARY_DIRS})
253+ endif (${_full_prefix}_LIBRARY_DIRS)
254+
255+ if (${_full_prefix}_LIBRARIES)
256+ _build_library_flags (${_full_prefix} ${${_full_prefix}_LIBRARIES})
257+ endif (${_full_prefix}_LIBRARIES)
258+
259+ file (GLOB _cpp_files "${${_full_prefix}_SOURCE_DIR}/*.cpp")
260+
261+ add_library (${_prefix}_${_name}_internal STATIC ${_cpp_files})
262+
263+ target_link_libraries (${_prefix}_${_name}_internal
264+ ${${_full_prefix}_LIBRARIES} m pthread dl)
265+
266+ list (APPEND ${_full_prefix}_COMPILE_FLAGS ${${_full_prefix}_INCLUDE_CFLAGS})
267+ list (APPEND ${_full_prefix}_COMPILE_FLAGS ${${_full_prefix}_DEFINITIONS_CFLAGS})
268+ list (APPEND ${_full_prefix}_COMPILE_FLAGS ${${_full_prefix}_CFLAGSADD})
269+
270+ set (${_full_prefix}_COMPILE_FLAGS_STR " ")
271+ foreach (_flag ${${_full_prefix}_COMPILE_FLAGS})
272+ set (${_full_prefix}_COMPILE_FLAGS_STR "${_flag} ${${_full_prefix}_COMPILE_FLAGS_STR}")
273+ endforeach (_flag)
274+
275+ list (APPEND ${_full_prefix}_LINK_FLAGS ${${_full_prefix}_LINK_LDFLAGS})
276+ list (APPEND ${_full_prefix}_LINK_FLAGS ${${_full_prefix}_LDFLAGSADD})
277+ list (APPEND ${_full_prefix}_LINK_FLAGS ${${_full_prefix}_LIBARY_FLAGS})
278+
279+ set (${_full_prefix}_LINK_FLAGS_STR " ")
280+ foreach (_flag ${${_full_prefix}_LINK_FLAGS})
281+ set (${_full_prefix}_LINK_FLAGS_STR "${_flag} ${${_full_prefix}_LINK_FLAGS_STR}")
282+ endforeach (_flag)
283+
284+ set_target_properties (${_prefix}_${_name}_internal PROPERTIES
285+ COMPILE_FLAGS ${${_full_prefix}_COMPILE_FLAGS_STR}
286+ LINK_FLAGS ${${_full_prefix}_LINK_FLAGS_STR})
287+
288+ file (GLOB _h_files "${_full_prefix}_INCLUDE_DIR/*.h")
289+
290+ foreach (_file ${_h_files})
291+
292+ install (
293+ FILES ${_file}
294+ DESTINATION ${COMPIZ_DESTDIR}${includedir}/compiz/${_prefix}
295+ )
296+
297+ endforeach (_file)
298+
299+endfunction (_build_compiz_module)
300+
301+macro (compiz_module _prefix _name)
302+
303+ string (TOUPPER ${_prefix} _PREFIX)
304+ string (TOUPPER ${_name} _NAME)
305+ set (_FULL_PREFIX ${_PREFIX}_${_NAME})
306+
307+ _get_parameters (${_FULL_PREFIX} ${ARGN})
308+ _check_pkg_deps (${_FULL_PREFIX} ${${_FULL_PREFIX}_PKGDEPS})
309+
310+ if (${_FULL_PREFIX}_HAS_PKG_DEPS)
311+
312+ list (APPEND ${_FULL_PREFIX}_LIBRARIES ${${_FULL_PREFIX}_PKG_LIBRARIES})
313+ list (APPEND ${_FULL_PREFIX}_INCLUDE_DIRS ${${_FULL_PREFIX}_INCDIRS})
314+ list (APPEND ${_FULL_PREFIX}_INCLUDE_DIRS ${${_FULL_PREFIX}_PKG_INCDIRS})
315+ list (APPEND ${_FULL_PREFIX}_LIBRARY_DIRS ${${_FULL_PREFIX}_LIBDIRS})
316+ list (APPEND ${_FULL_PREFIX}_LIBRARY_DIRS ${${_FULL_PREFIX}_PKG_LIBDIRS})
317+
318+ # also add modules
319+ foreach (_module ${${_FULL_PREFIX}_MODULES})
320+ string (TOUPPER ${_module} _MODULE)
321+ list (APPEND ${_FULL_PREFIX}_INCLUDE_DIRS ${${_MODULE}_INCLUDE_DIR})
322+ list (APPEND ${_FULL_PREFIX}_LIBRARY_DIRS ${${_MODULE}_BINARY_DIR})
323+ list (APPEND ${_FULL_PREFIX}_LIBRARIES ${_module}_internal)
324+ endforeach (_module)
325+
326+ compiz_set (${_FULL_PREFIX}_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${_name})
327+ compiz_set (${_FULL_PREFIX}_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/${_name}/src)
328+ compiz_set (${_FULL_PREFIX}_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/${_name}/include)
329+ compiz_set (${_FULL_PREFIX}_TESTS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/${_name}tests)
330+
331+ # Need to abuse set_property here since set () with CACHE INTERNAL will save the
332+ # value to the cache which we will just read right back (but we need to regenerate that)
333+ set_property (GLOBAL APPEND PROPERTY ${_PREFIX}_MOD_LIBRARY_DIRS ${${_FULL_PREFIX}_BINARY_DIR})
334+ set_property (GLOBAL APPEND PROPERTY ${_PREFIX}_MOD_INCLUDE_DIRS ${${_FULL_PREFIX}_INCLUDE_DIR})
335+ set_property (GLOBAL APPEND PROPERTY ${_PREFIX}_MOD_INCLUDE_DIRS ${${_FULL_PREFIX}_SOURCE_DIR})
336+ set_property (GLOBAL APPEND PROPERTY ${_PREFIX}_MOD_LIBRARIES ${_prefix}_${_name}_internal)
337+
338+ _build_compiz_module (${_prefix} ${_name} ${_FULL_PREFIX})
339+
340+ add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR}/${_name}/tests)
341+
342+ else (${_FULL_PREFIX}_HAS_PKG_DEPS)
343+ message (STATUS "[WARNING] One or more dependencies for module ${_name} for ${_prefix} not found. Skipping module.")
344+ message (STATUS "Missing dependencies :${${_FULL_PREFIX}_MISSING_DEPS}")
345+ compiz_set (${_FULL_PREFIX}_BUILD FALSE)
346+ endif (${_FULL_PREFIX}_HAS_PKG_DEPS)
347+
348+
349+endmacro (compiz_module)
350+
351+function (_build_compiz_test_base _prefix _module _full_prefix)
352+
353+ file (GLOB _cpp_files "${${_FULL_TEST_BASE_PREFIX}_SOURCE_DIR}/*.cpp")
354+
355+ if (${_full_prefix}_INCLUDE_DIRS)
356+ _build_include_flags (${_full_prefix} ${${_full_prefix}_INCLUDE_DIRS})
357+ endif (${_full_prefix}_INCLUDE_DIRS)
358+ _build_include_flags (${_full_prefix} ${${_full_prefix}_SOURCE_DIR})
359+ _build_include_flags (${_full_prefix} ${${_full_prefix}_INCLUDE_DIR})
360+
361+ if (${_full_prefix}_DEFSADD)
362+ _build_definitions_flags (${_full_prefix} ${${_full_prefix}_DEFSADD})
363+ endif (${_full_prefix}_DEFSADD)
364+
365+ if (${_full_prefix}_LIBRARY_DIRS)
366+ _build_link_dir_flags (${_full_prefix} ${${_full_prefix}_LIBRARY_DIRS})
367+ endif (${_full_prefix}_LIBRARY_DIRS)
368+
369+ if (${_full_prefix}_LIBRARIES)
370+ _build_library_flags (${_full_prefix} ${${_full_prefix}_LIBRARIES})
371+ endif (${_full_prefix}_LIBRARIES)
372+
373+ add_library (${_prefix}_${_module}_test_internal STATIC
374+ ${_cpp_files})
375+
376+ target_link_libraries (${_prefix}_${_module}_test_internal
377+ ${${_full_prefix}_LIBRARIES}
378+ ${_prefix}_${_module}_internal)
379+
380+
381+ list (APPEND ${_full_prefix}_COMPILE_FLAGS ${${_full_prefix}_INCLUDE_CFLAGS})
382+ list (APPEND ${_full_prefix}_COMPILE_FLAGS ${${_full_prefix}_DEFINITIONS_CFLAGS})
383+ list (APPEND ${_full_prefix}_COMPILE_FLAGS ${${_full_prefix}_CFLAGSADD})
384+
385+ set (${_full_prefix}_COMPILE_FLAGS_STR " ")
386+ foreach (_flag ${${_full_prefix}_COMPILE_FLAGS})
387+ set (${_full_prefix}_COMPILE_FLAGS_STR "${_flag} ${${_full_prefix}_COMPILE_FLAGS_STR}")
388+ endforeach (_flag)
389+
390+ list (APPEND ${_full_prefix}_LINK_FLAGS ${${_full_prefix}_LINK_LDFLAGS})
391+ list (APPEND ${_full_prefix}_LINK_FLAGS ${${_full_prefix}_LDFLAGSADD})
392+ list (APPEND ${_full_prefix}_LINK_FLAGS ${${_full_prefix}_LIBARY_FLAGS})
393+
394+ set (${_full_prefix}_LINK_FLAGS_STR " ")
395+ foreach (_flag ${${_full_prefix}_LINK_FLAGS})
396+ set (${_full_prefix}_LINK_FLAGS_STR "${_flag} ${${_full_prefix}_LINK_FLAGS_STR}")
397+ endforeach (_flag)
398+
399+ set_target_properties (${_prefix}_${_module}_test_internal PROPERTIES
400+ COMPILE_FLAGS "${${_full_prefix}_COMPILE_FLAGS_STR}"
401+ LINK_FLAGS "${${_full_prefix}_LINK_FLAGS_STR}")
402+endfunction (_build_compiz_test_base)
403+
404+macro (compiz_test_base _prefix _module)
405+
406+ string (TOUPPER ${_prefix} _PREFIX)
407+ string (TOUPPER ${_module} _MODULE)
408+
409+ set (_FULL_MODULE_PREFIX ${_PREFIX}_${_NAME})
410+ set (_FULL_TEST_BASE_PREFIX ${_FULL_MODULE_PREFIX}_TEST_BASE)
411+
412+ _get_parameters (${_FULL_TEST_BASE_PREFIX} ${ARGN})
413+ _check_pkg_deps (${_FULL_TEST_BASE_PREFIX} ${${_FULL_TEST_BASE_PREFIX}_PKGDEPS})
414+
415+ if (${_FULL_TEST_BASE_PREFIX}_HAS_PKG_DEPS)
416+
417+ list (APPEND ${_FULL_TEST_BASE_PREFIX}_LIBRARIES ${${_FULL_TEST_BASE_PREFIX}_PKG_LIBDIRS})
418+ list (APPEND ${_FULL_TEST_BASE_PREFIX}_INCLUDE_DIRS ${${_FULL_TEST_BASE_PREFIX}_INCDIRS})
419+ list (APPEND ${_FULL_TEST_BASE_PREFIX}_INCLUDE_DIRS ${${_FULL_TEST_BASE_PREFIX}_PKG_INCDIRS})
420+ list (APPEND ${_FULL_TEST_BASE_PREFIX}_LIBRARY_DIRS ${${_FULL_TEST_BASE_PREFIX}_LIBDIRS})
421+ list (APPEND ${_FULL_TEST_BASE_PREFIX}_LIBRARY_DIRS ${${_FULL_TEST_BASE_PREFIX}_PKG_LIBDIRS})
422+
423+ compiz_set (${_FULL_TEST_BASE_PREFIX}_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
424+ compiz_set (${_FULL_TEST_BASE_PREFIX}_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
425+ compiz_set (${_FULL_TEST_BASE_PREFIX}_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
426+
427+ list (APPEND ${_FULL_TEST_BASE_PREFIX}_INCLUDE_DIRS ${${_FULL_MODULE_PREFIX}_INCLUDE_DIRS})
428+ list (APPEND ${_FULL_TEST_BASE_PREFIX}_INCLUDE_DIRS ${${_FULL_MODULE_PREFIX}_INCLUDE_DIR})
429+ list (APPEND ${_FULL_TEST_BASE_PREFIX}_INCLUDE_DIRS ${${_FULL_MODULE_PREFIX}_SOURCE_DIR})
430+ list (APPEND ${_FULL_TEST_BASE_PREFIX}_LIBRARY_DIRS ${${_FULL_MODULE_PREFIX}_LIBRARY_DIRS})
431+ list (APPEND ${_FULL_TEST_BASE_PREFIX}_LIBRARY_DIRS ${${_FULL_MODULE_PREFIX}_BINARY_DIR})
432+ list (APPEND ${_FULL_TEST_BASE_PREFIX}_LIBRARIES ${${_FULL_MODULE_PREFIX}_LIBRARIES})
433+
434+ _build_compiz_test_base (${_prefix} ${_module} ${_FULL_TEST_BASE_PREFIX})
435+ else (${_FULL_TEST_BASE_PREFIX}_HAS_PKG_DEPS)
436+ message (STATUS "[WARNING] One or more dependencies for test base on module ${_module} for ${_prefix} not found. Skipping test base.")
437+ message (STATUS "Missing dependencies :${${_FULL_TEST_BASE_PREFIX}_MISSING_DEPS}")
438+ compiz_set (${_FULL_TEST_BASE_PREFIX}_BUILD FALSE)
439+ endif (${_FULL_TEST_BASE_PREFIX}_HAS_PKG_DEPS)
440+endmacro (compiz_test_base)
441+
442+function (_build_compiz_test _prefix _module _test _full_prefix)
443+ file (GLOB _cpp_files "${${_FULL_TEST_PREFIX}_SOURCE_DIR}/*.cpp")
444+
445+ if (${_full_prefix}_INCLUDE_DIRS)
446+ _build_include_flags (${_full_prefix} ${${_full_prefix}_INCLUDE_DIRS})
447+ endif (${_full_prefix}_INCLUDE_DIRS)
448+ _build_include_flags (${_full_prefix} ${${_full_prefix}_SOURCE_DIR})
449+ _build_include_flags (${_full_prefix} ${${_full_prefix}_INCLUDE_DIR})
450+
451+ if (${_full_prefix}_DEFSADD)
452+ _build_definitions_flags (${_full_prefix} ${${_full_prefix}_DEFSADD})
453+ endif (${_full_prefix}_DEFSADD)
454+
455+ if (${_full_prefix}_LIBRARY_DIRS)
456+ _build_link_dir_flags (${_full_prefix} ${${_full_prefix}_LIBRARY_DIRS})
457+ endif (${_full_prefix}_LIBRARY_DIRS)
458+
459+ if (${_full_prefix}_LIBRARIES)
460+ _build_library_flags (${_full_prefix} ${${_full_prefix}_LIBRARIES})
461+ endif (${_full_prefix}_LIBRARIES)
462+
463+ add_executable (${_prefix}_${_module}_${_test}_test
464+ ${_cpp_files})
465+
466+ target_link_libraries (${_prefix}_${_module}_${_test}_test
467+ ${${_full_prefix}_LIBRARIES}
468+ ${_prefix}_${_module}_internal
469+ ${_prefix}_${_module}_test_internal)
470+
471+ list (APPEND ${_full_prefix}_COMPILE_FLAGS ${${_full_prefix}_INCLUDE_CFLAGS})
472+ list (APPEND ${_full_prefix}_COMPILE_FLAGS ${${_full_prefix}_DEFINITIONS_CFLAGS})
473+ list (APPEND ${_full_prefix}_COMPILE_FLAGS ${${_full_prefix}_CFLAGSADD})
474+
475+ set (${_full_prefix}_COMPILE_FLAGS_STR " ")
476+ foreach (_flag ${${_full_prefix}_COMPILE_FLAGS})
477+ set (${_full_prefix}_COMPILE_FLAGS_STR "${_flag} ${${_full_prefix}_COMPILE_FLAGS_STR}")
478+ endforeach (_flag)
479+
480+ list (APPEND ${_full_prefix}_LINK_FLAGS ${${_full_prefix}_LINK_LDFLAGS})
481+ list (APPEND ${_full_prefix}_LINK_FLAGS ${${_full_prefix}_LDFLAGSADD})
482+ list (APPEND ${_full_prefix}_LINK_FLAGS ${${_full_prefix}_LIBARY_FLAGS})
483+
484+ set (${_full_prefix}_LINK_FLAGS_STR " ")
485+ foreach (_flag ${${_full_prefix}_LINK_FLAGS})
486+ set (${_full_prefix}_LINK_FLAGS_STR "${_flag} ${${_full_prefix}_LINK_FLAGS_STR}")
487+ endforeach (_flag)
488+
489+ set_target_properties (${_prefix}_${_module}_${_test}_test PROPERTIES
490+ COMPILE_FLAGS "${${_full_prefix}_COMPILE_FLAGS_STR}"
491+ LINK_FLAGS "${${_full_prefix}_LINK_FLAGS_STR}")
492+
493+ add_test (test-${_prefix}-${_module}-${_test}
494+ ${CMAKE_CURRENT_BINARY_DIR}/${_prefix}_${_module}_${_test}_test)
495+endfunction (_build_compiz_test)
496+
497+macro (compiz_test _prefix _module _test)
498+
499+ set (_supported_var PKGDEPS LDFLAGSADD CFLAGSADD LIBRARIES LIBDIRS INCDIRS DEFSADD)
500+
501+ set (_FULL_TEST_PREFIX ${_FULL_MODULE_PREFIX}_TEST)
502+
503+ _get_parameters (${_FULL_TEST_PREFIX} ${ARGN})
504+ _check_pkg_deps (${_FULL_TEST_PREFIX} ${${_FULL_TEST_PREFIX}_PKGDEPS})
505+
506+ if (${_FULL_TEST_PREFIX}_HAS_PKG_DEPS)
507+ list (APPEND ${_FULL_TEST_PREFIX}_LIBRARIES ${${_FULL_TEST_PREFIX}_PKG_LIBDIRS})
508+ list (APPEND ${_FULL_TEST_PREFIX}_INCLUDE_DIRS ${${_FULL_TEST_PREFIX}_INCDIRS})
509+ list (APPEND ${_FULL_TEST_PREFIX}_INCLUDE_DIRS ${${_FULL_TEST_PREFIX}_PKG_INCDIRS})
510+ list (APPEND ${_FULL_TEST_PREFIX}_LIBRARY_DIRS ${${_FULL_TEST_PREFIX}_LIBDIRS})
511+ list (APPEND ${_FULL_TEST_PREFIX}_LIBRARY_DIRS ${${_FULL_TEST_PREFIX}_PKG_LIBDIRS})
512+
513+ compiz_set (${_FULL_TEST_PREFIX}_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
514+ compiz_set (${_FULL_TEST_PREFIX}_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
515+ compiz_set (${_FULL_TEST_PREFIX}_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
516+
517+ list (APPEND ${_FULL_TEST_PREFIX}_INCLUDE_DIRS ${${_FULL_TEST_BASE_PREFIX}_INCLUDE_DIRS})
518+ list (APPEND ${_FULL_TEST_PREFIX}_INCLUDE_DIRS ${${_FULL_TEST_BASE_PREFIX}_INCLUDE_DIR})
519+ list (APPEND ${_FULL_TEST_PREFIX}_INCLUDE_DIRS ${${_FULL_TEST_BASE_PREFIX}_SOURCE_DIR})
520+ list (APPEND ${_FULL_TEST_PREFIX}_LIBRARY_DIRS ${${_FULL_TEST_BASE_PREFIX}_LIBRARY_DIRS})
521+ list (APPEND ${_FULL_TEST_PREFIX}_LIBRARY_DIRS ${${_FULL_TEST_BASE_PREFIX}_BINARY_DIR})
522+ list (APPEND ${_FULL_TEST_PREFIX}_LIBRARIES ${${_FULL_TEST_BASE_PREFIX}_LIBRARIES})
523+
524+ _build_compiz_test (${_prefix} ${_module} ${_test} ${_FULL_TEST_PREFIX})
525+
526+ else (${_FULL_TEST_PREFIX}_HAS_PKG_DEPS)
527+ message (STATUS "[WARNING] One or more dependencies for test ${_test} on module ${_name} for ${_prefix} not found. Skipping test.")
528+ message (STATUS "Missing dependencies :${${_FULL_TEST_PREFIX}_MISSING_DEPS}")
529+ compiz_set (${_FULL_TEST_PREFIX}_BUILD FALSE)
530+ endif (${_FULL_TEST_PREFIX}_HAS_PKG_DEPS)
531+
532+endmacro (compiz_test)
533+
534 #### optional file install
535
536 function (compiz_opt_install_file _src _dst)
537
538=== modified file 'cmake/CompizPlugin.cmake'
539--- cmake/CompizPlugin.cmake 2011-09-01 19:52:58 +0000
540+++ cmake/CompizPlugin.cmake 2011-12-20 02:49:24 +0000
541@@ -136,50 +136,6 @@
542 endif ("${COMPIZ_PLUGIN_INSTALL_TYPE}" STREQUAL "package")
543 endmacro (_prepare_directories)
544
545-# parse plugin macro parameter
546-macro (_get_plugin_parameters _prefix)
547- set (_current_var _foo)
548- set (_supported_var PKGDEPS PLUGINDEPS LDFLAGSADD CFLAGSADD LIBRARIES LIBDIRS INCDIRS)
549- foreach (_val ${_supported_var})
550- set (${_prefix}_${_val})
551- endforeach (_val)
552- foreach (_val ${ARGN})
553- set (_found FALSE)
554- foreach (_find ${_supported_var})
555- if ("${_find}" STREQUAL "${_val}")
556- set (_found TRUE)
557- endif ("${_find}" STREQUAL "${_val}")
558- endforeach (_find)
559-
560- if (_found)
561- set (_current_var ${_prefix}_${_val})
562- else (_found)
563- list (APPEND ${_current_var} ${_val})
564- endif (_found)
565- endforeach (_val)
566-endmacro (_get_plugin_parameters)
567-
568-# check pkgconfig dependencies
569-macro (_check_plugin_pkg_deps _prefix)
570- set (${_prefix}_HAS_PKG_DEPS TRUE)
571- foreach (_val ${ARGN})
572- string (REGEX REPLACE "[<>=\\.]" "_" _name ${_val})
573- string (TOUPPER ${_name} _name)
574-
575- compiz_pkg_check_modules (_${_name} ${_val})
576-
577- if (_${_name}_FOUND)
578- list (APPEND ${_prefix}_PKG_LIBDIRS "${_${_name}_LIBRARY_DIRS}")
579- list (APPEND ${_prefix}_PKG_LIBRARIES "${_${_name}_LIBRARIES}")
580- list (APPEND ${_prefix}_PKG_INCDIRS "${_${_name}_INCLUDE_DIRS}")
581- else ()
582- set (${_prefix}_HAS_PKG_DEPS FALSE)
583- compiz_set (COMPIZ_${_prefix}_MISSING_DEPS "${COMPIZ_${_prefix}_MISSING_DEPS} ${_val}")
584- set(__pkg_config_checked__${_name} 0 CACHE INTERNAL "" FORCE)
585- endif ()
586- endforeach ()
587-endmacro ()
588-
589 # check plugin dependencies
590 macro (_check_plugin_plugin_deps _prefix)
591 set (${_prefix}_HAS_PLUGIN_DEPS TRUE)
592@@ -216,11 +172,8 @@
593 endforeach ()
594 endmacro ()
595
596-
597-
598-
599 # main function
600-function (_build_compiz_plugin plugin)
601+macro (_build_compiz_plugin plugin)
602 string (TOUPPER ${plugin} _PLUGIN)
603
604 if (COMPIZ_PLUGIN_INSTALL_TYPE)
605@@ -235,7 +188,7 @@
606 )
607 endif (COMPIZ_PLUGIN_INSTALL_TYPE)
608
609- _get_plugin_parameters (${_PLUGIN} ${ARGN})
610+ _get_parameters (${_PLUGIN} ${ARGN})
611 _prepare_directories ()
612
613 find_file (
614@@ -259,7 +212,7 @@
615 # check dependencies
616 compiz_unset (COMPIZ_${_PLUGIN}_MISSING_DEPS)
617 _check_plugin_plugin_deps (${_PLUGIN} ${${_PLUGIN}_PLUGINDEPS})
618- _check_plugin_pkg_deps (${_PLUGIN} ${${_PLUGIN}_PKGDEPS})
619+ _check_pkg_deps (${_PLUGIN} ${${_PLUGIN}_PKGDEPS})
620
621 if (${_PLUGIN}_HAS_PKG_DEPS AND ${_PLUGIN}_HAS_PLUGIN_DEPS)
622
623@@ -357,6 +310,30 @@
624 add_definitions (-DPREFIX='\"${PLUGIN_PREFIX}\"'
625 ${COMPIZ_DEFINITIONS_ADD})
626
627+ foreach (_def ${_PLUGIN}_DEFSADD)
628+ add_definitions (-D${_def})
629+ endforeach (_def)
630+
631+ # Need to know the include-dirs for the internal
632+ # modules to this plugin, core (if built with core)
633+ # and any other plugins that we depend on
634+
635+ get_property (${_PLUGIN}_MOD_INCLUDE_DIRS
636+ GLOBAL
637+ PROPERTY ${_PLUGIN}_MOD_INCLUDE_DIRS)
638+
639+ get_property (CORE_MOD_INCLUDE_DIRS
640+ GLOBAL
641+ PROPERTY CORE_MOD_INCLUDE_DIRS)
642+
643+ foreach (_plugindep ${${_PLUGIN}_PLUGINDEPS})
644+ string (TOUPPER ${_plugindep} _PLUGINDEP)
645+ get_property (${_PLUGINDEP}_MOD_INCLUDE_DIRS
646+ GLOBAL
647+ PROPERTY ${_PLUGINDEP}_MOD_INCLUDE_DIRS)
648+ list (APPEND ${_PLUGIN}_PLUGINDEP_MOD_INCLUDE_DIRS ${${_PLUGINDEP}_MOD_INCLUDE_DIRS})
649+ endforeach (_plugindep)
650+
651 include_directories (
652 ${CMAKE_CURRENT_SOURCE_DIR}/src
653 ${CMAKE_CURRENT_SOURCE_DIR}/include
654@@ -367,8 +344,15 @@
655 ${COMPIZ_INCLUDE_DIRS}
656 ${CMAKE_PREFIX_PATH}/include
657 ${CMAKE_INCLUDE_PATH}
658+ ${${_PLUGIN}_MOD_INCLUDE_DIRS}
659+ ${CORE_MOD_INCLUDE_DIRS}
660+ ${${_PLUGIN}_PLUGINDEP_MOD_INCLUDE_DIRS}
661 )
662
663+ get_property (${_PLUGIN}_MOD_LIBRARY_DIRS
664+ GLOBAL
665+ PROPERTY ${_PLUGIN}_MOD_LIBRARY_DIRS)
666+
667 link_directories (
668 ${COMPIZ_LINK_DIRS}
669 ${${_PLUGIN}_PKG_LIBDIRS}
670@@ -378,6 +362,7 @@
671 ${CMAKE_PREFIX_PATH}/lib
672 ${CMAKE_PREFIX_PATH}/lib32
673 ${CMAKE_PREFIX_PATH}/lib64
674+ ${${_PLUGIN}_MOD_LIBRARY_DIRS}
675 )
676
677 add_library (
678@@ -409,11 +394,16 @@
679 )
680 endif (COMPIZ_BUILD_WITH_RPATH)
681
682+ get_property (${_PLUGIN}_MOD_LIBRARIES
683+ GLOBAL
684+ PROPERTY ${_PLUGIN}_MOD_LIBRARIES)
685+
686 target_link_libraries (
687 ${plugin} ${COMPIZ_LIBRARIES}
688 ${${_PLUGIN}_LOCAL_LIBRARIES}
689 ${${_PLUGIN}_PKG_LIBRARIES}
690 ${${_PLUGIN}_LIBRARIES}
691+ ${${_PLUGIN}_MOD_LIBRARIES}
692 )
693
694 install (
695@@ -449,7 +439,7 @@
696 message (STATUS "Missing dependencies :${COMPIZ_${_PLUGIN}_MISSING_DEPS}")
697 compiz_set (COMPIZ_${_PLUGIN}_BUILD FALSE)
698 endif ()
699-endfunction ()
700+endmacro ()
701
702 macro (compiz_plugin plugin)
703 string (TOUPPER ${plugin} _PLUGIN)
704
705=== added file 'cmake/EnableCoverageReport.cmake'
706--- cmake/EnableCoverageReport.cmake 1970-01-01 00:00:00 +0000
707+++ cmake/EnableCoverageReport.cmake 2011-12-20 02:49:24 +0000
708@@ -0,0 +1,153 @@
709+# - Creates a special coverage build type and target on GCC.
710+#
711+# Defines a function ENABLE_COVERAGE_REPORT which generates the coverage target
712+# for selected targets. Optional arguments to this function are used to filter
713+# unwanted results using globbing expressions. Moreover targets with tests for
714+# the source code can be specified to trigger regenerating the report if the
715+# test has changed
716+#
717+# ENABLE_COVERAGE_REPORT(TARGETS target... [FILTER filter...] [TESTS test targets...])
718+#
719+# To generate a coverage report first build the project with
720+# CMAKE_BUILD_TYPE=coverage, then call make test and afterwards make coverage.
721+#
722+# The coverage report is based on gcov. Depending on the availability of lcov
723+# a HTML report will be generated and/or an XML report of gcovr is found.
724+# The generated coverage target executes all found solutions. Special targets
725+# exist to create e.g. only the xml report: coverage-xml.
726+#
727+# Copyright (C) 2010 by Johannes Wienke <jwienke at techfak dot uni-bielefeld dot de>
728+#
729+# This program is free software; you can redistribute it
730+# and/or modify it under the terms of the GNU General
731+# Public License as published by the Free Software Foundation;
732+# either version 2, or (at your option)
733+# any later version.
734+#
735+# This program is distributed in the hope that it will be useful,
736+# but WITHOUT ANY WARRANTY; without even the implied warranty of
737+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
738+# GNU General Public License for more details.
739+#
740+
741+INCLUDE(ParseArguments)
742+
743+FIND_PACKAGE(Lcov)
744+FIND_PACKAGE(gcovr)
745+
746+FUNCTION(ENABLE_COVERAGE_REPORT)
747+
748+ # argument parsing
749+ PARSE_ARGUMENTS(ARG "FILTER;TARGETS;TESTS" "" ${ARGN})
750+
751+ SET(COVERAGE_RAW_FILE "${CMAKE_BINARY_DIR}/coverage.raw.info")
752+ SET(COVERAGE_FILTERED_FILE "${CMAKE_BINARY_DIR}/coverage.info")
753+ SET(COVERAGE_REPORT_DIR "${CMAKE_BINARY_DIR}/coveragereport")
754+ SET(COVERAGE_XML_FILE "${CMAKE_BINARY_DIR}/coverage.xml")
755+ SET(COVERAGE_XML_COMMAND_FILE "${CMAKE_BINARY_DIR}/coverage-xml.cmake")
756+
757+ # decide if there is any tool to create coverage data
758+ SET(TOOL_FOUND FALSE)
759+ IF(LCOV_FOUND OR GCOVR_FOUND)
760+ SET(TOOL_FOUND TRUE)
761+ ENDIF()
762+ IF(NOT TOOL_FOUND)
763+ MESSAGE(STATUS "Cannot enable coverage targets because neither lcov nor gcovr are found.")
764+ ENDIF()
765+
766+ STRING(TOLOWER "${CMAKE_BUILD_TYPE}" COVERAGE_BUILD_TYPE)
767+ IF(CMAKE_COMPILER_IS_GNUCXX AND TOOL_FOUND AND "${COVERAGE_BUILD_TYPE}" MATCHES "coverage")
768+
769+ MESSAGE(STATUS "Coverage support enabled for targets: ${ARG_TARGETS}")
770+
771+ # create coverage build type
772+ SET(CMAKE_CXX_FLAGS_COVERAGE ${CMAKE_CXX_FLAGS_DEBUG} PARENT_SCOPE)
773+ SET(CMAKE_C_FLAGS_COVERAGE ${CMAKE_C_FLAGS_DEBUG} PARENT_SCOPE)
774+ SET(CMAKE_CONFIGURATION_TYPES ${CMAKE_CONFIGURATION_TYPES} coverage PARENT_SCOPE)
775+
776+ # instrument targets
777+ SET_TARGET_PROPERTIES(${ARG_TARGETS} PROPERTIES COMPILE_FLAGS --coverage
778+ LINK_FLAGS --coverage)
779+
780+ # html report
781+ IF (LCOV_FOUND)
782+
783+ MESSAGE(STATUS "Enabling HTML coverage report")
784+
785+ # set up coverage target
786+
787+ ADD_CUSTOM_COMMAND(OUTPUT ${COVERAGE_RAW_FILE}
788+ COMMAND ${LCOV_EXECUTABLE} -c -d ${CMAKE_BINARY_DIR} -o ${COVERAGE_RAW_FILE}
789+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
790+ COMMENT "Collecting coverage data"
791+ DEPENDS ${ARG_TARGETS} ${ARG_TESTS}
792+ VERBATIM)
793+
794+ # filter unwanted stuff
795+ LIST(LENGTH ARG_FILTER FILTER_LENGTH)
796+ IF(${FILTER_LENGTH} GREATER 0)
797+ SET(FILTER COMMAND ${LCOV_EXECUTABLE})
798+ FOREACH(F ${ARG_FILTER})
799+ SET(FILTER ${FILTER} -r ${COVERAGE_FILTERED_FILE} ${F})
800+ ENDFOREACH()
801+ SET(FILTER ${FILTER} -o ${COVERAGE_FILTERED_FILE})
802+ ELSE()
803+ SET(FILTER "")
804+ ENDIF()
805+
806+ ADD_CUSTOM_COMMAND(OUTPUT ${COVERAGE_FILTERED_FILE}
807+ COMMAND ${LCOV_EXECUTABLE} -e ${COVERAGE_RAW_FILE} "${CMAKE_SOURCE_DIR}*" -o ${COVERAGE_FILTERED_FILE}
808+ ${FILTER}
809+ DEPENDS ${COVERAGE_RAW_FILE}
810+ COMMENT "Filtering recorded coverage data for project-relevant entries"
811+ VERBATIM)
812+ ADD_CUSTOM_COMMAND(OUTPUT ${COVERAGE_REPORT_DIR}
813+ COMMAND ${CMAKE_COMMAND} -E make_directory ${COVERAGE_REPORT_DIR}
814+ COMMAND ${GENHTML_EXECUTABLE} --legend --show-details -t "${PROJECT_NAME} test coverage" -o ${COVERAGE_REPORT_DIR} ${COVERAGE_FILTERED_FILE}
815+ DEPENDS ${COVERAGE_FILTERED_FILE}
816+ COMMENT "Generating HTML coverage report in ${COVERAGE_REPORT_DIR}"
817+ VERBATIM)
818+
819+ ADD_CUSTOM_TARGET(coverage-html
820+ DEPENDS ${COVERAGE_REPORT_DIR})
821+
822+ ENDIF()
823+
824+ # xml coverage report
825+ IF(GCOVR_FOUND)
826+
827+ MESSAGE(STATUS "Enabling XML coverage report")
828+
829+ # gcovr cannot write directly to a file so the execution needs to
830+ # be wrapped in a cmake file that generates the file output
831+ FILE(WRITE ${COVERAGE_XML_COMMAND_FILE}
832+ "SET(ENV{LANG} en)\n")
833+ FILE(APPEND ${COVERAGE_XML_COMMAND_FILE}
834+ "EXECUTE_PROCESS(COMMAND \"${GCOVR_EXECUTABLE}\" -x -r \"${CMAKE_SOURCE_DIR}\" OUTPUT_FILE \"${COVERAGE_XML_FILE}\" WORKING_DIRECTORY \"${CMAKE_BINARY_DIR}\")\n")
835+
836+ ADD_CUSTOM_COMMAND(OUTPUT ${COVERAGE_XML_FILE}
837+ COMMAND ${CMAKE_COMMAND} ARGS -P ${COVERAGE_XML_COMMAND_FILE}
838+ COMMENT "Generating coverage XML report"
839+ VERBATIM)
840+
841+ ADD_CUSTOM_TARGET(coverage-xml
842+ DEPENDS ${COVERAGE_XML_FILE})
843+
844+ ENDIF()
845+
846+ # provide a global coverage target executing both steps if available
847+ SET(GLOBAL_DEPENDS "")
848+ IF(LCOV_FOUND)
849+ LIST(APPEND GLOBAL_DEPENDS ${COVERAGE_REPORT_DIR})
850+ ENDIF()
851+ IF(GCOVR_FOUND)
852+ LIST(APPEND GLOBAL_DEPENDS ${COVERAGE_XML_FILE})
853+ ENDIF()
854+ IF(LCOV_FOUND OR GCOVR_FOUND)
855+ ADD_CUSTOM_TARGET(coverage
856+ DEPENDS ${GLOBAL_DEPENDS})
857+ ENDIF()
858+
859+ ENDIF()
860+
861+ENDFUNCTION()
862
863=== added file 'cmake/FindLcov.cmake'
864--- cmake/FindLcov.cmake 1970-01-01 00:00:00 +0000
865+++ cmake/FindLcov.cmake 2011-12-20 02:49:24 +0000
866@@ -0,0 +1,29 @@
867+# - Find lcov
868+# Will define:
869+#
870+# LCOV_EXECUTABLE - the lcov binary
871+# GENHTML_EXECUTABLE - the genhtml executable
872+#
873+# Copyright (C) 2010 by Johannes Wienke <jwienke at techfak dot uni-bielefeld dot de>
874+#
875+# This program is free software; you can redistribute it
876+# and/or modify it under the terms of the GNU General
877+# Public License as published by the Free Software Foundation;
878+# either version 2, or (at your option)
879+# any later version.
880+#
881+# This program is distributed in the hope that it will be useful,
882+# but WITHOUT ANY WARRANTY; without even the implied warranty of
883+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
884+# GNU General Public License for more details.
885+#
886+
887+INCLUDE(FindPackageHandleStandardArgs)
888+
889+FIND_PROGRAM(LCOV_EXECUTABLE lcov)
890+FIND_PROGRAM(GENHTML_EXECUTABLE genhtml)
891+
892+FIND_PACKAGE_HANDLE_STANDARD_ARGS(Lcov DEFAULT_MSG LCOV_EXECUTABLE GENHTML_EXECUTABLE)
893+
894+# only visible in advanced view
895+MARK_AS_ADVANCED(LCOV_EXECUTABLE GENHTML_EXECUTABLE)
896
897=== added file 'cmake/Findgcovr.cmake'
898--- cmake/Findgcovr.cmake 1970-01-01 00:00:00 +0000
899+++ cmake/Findgcovr.cmake 2011-12-20 02:49:24 +0000
900@@ -0,0 +1,31 @@
901+# - Find gcovr scrip
902+# Will define:
903+#
904+# GCOVR_EXECUTABLE - the gcovr script
905+#
906+# Uses:
907+#
908+# GCOVR_ROOT - root to search for the script
909+#
910+# Copyright (C) 2011 by Johannes Wienke <jwienke at techfak dot uni-bielefeld dot de>
911+#
912+# This program is free software; you can redistribute it
913+# and/or modify it under the terms of the GNU General
914+# Public License as published by the Free Software Foundation;
915+# either version 2, or (at your option)
916+# any later version.
917+#
918+# This program is distributed in the hope that it will be useful,
919+# but WITHOUT ANY WARRANTY; without even the implied warranty of
920+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
921+# GNU General Public License for more details.
922+#
923+
924+INCLUDE(FindPackageHandleStandardArgs)
925+
926+FIND_PROGRAM(GCOVR_EXECUTABLE gcovr HINTS ${GCOVR_ROOT} "${GCOVR_ROOT}/bin")
927+
928+FIND_PACKAGE_HANDLE_STANDARD_ARGS(gcovr DEFAULT_MSG GCOVR_EXECUTABLE)
929+
930+# only visible in advanced view
931+MARK_AS_ADVANCED(GCOVR_EXECUTABLE)
932
933=== added file 'cmake/ParseArguments.cmake'
934--- cmake/ParseArguments.cmake 1970-01-01 00:00:00 +0000
935+++ cmake/ParseArguments.cmake 2011-12-20 02:49:24 +0000
936@@ -0,0 +1,52 @@
937+# Parse arguments passed to a function into several lists separated by
938+# upper-case identifiers and options that do not have an associated list e.g.:
939+#
940+# SET(arguments
941+# hello OPTION3 world
942+# LIST3 foo bar
943+# OPTION2
944+# LIST1 fuz baz
945+# )
946+# PARSE_ARGUMENTS(ARG "LIST1;LIST2;LIST3" "OPTION1;OPTION2;OPTION3" ${arguments})
947+#
948+# results in 7 distinct variables:
949+# * ARG_DEFAULT_ARGS: hello;world
950+# * ARG_LIST1: fuz;baz
951+# * ARG_LIST2:
952+# * ARG_LIST3: foo;bar
953+# * ARG_OPTION1: FALSE
954+# * ARG_OPTION2: TRUE
955+# * ARG_OPTION3: TRUE
956+#
957+# taken from http://www.cmake.org/Wiki/CMakeMacroParseArguments
958+
959+MACRO(PARSE_ARGUMENTS prefix arg_names option_names)
960+ SET(DEFAULT_ARGS)
961+ FOREACH(arg_name ${arg_names})
962+ SET(${prefix}_${arg_name})
963+ ENDFOREACH(arg_name)
964+ FOREACH(option ${option_names})
965+ SET(${prefix}_${option} FALSE)
966+ ENDFOREACH(option)
967+
968+ SET(current_arg_name DEFAULT_ARGS)
969+ SET(current_arg_list)
970+ FOREACH(arg ${ARGN})
971+ SET(larg_names ${arg_names})
972+ LIST(FIND larg_names "${arg}" is_arg_name)
973+ IF (is_arg_name GREATER -1)
974+ SET(${prefix}_${current_arg_name} ${current_arg_list})
975+ SET(current_arg_name ${arg})
976+ SET(current_arg_list)
977+ ELSE (is_arg_name GREATER -1)
978+ SET(loption_names ${option_names})
979+ LIST(FIND loption_names "${arg}" is_option)
980+ IF (is_option GREATER -1)
981+ SET(${prefix}_${arg} TRUE)
982+ ELSE (is_option GREATER -1)
983+ SET(current_arg_list ${current_arg_list} ${arg})
984+ ENDIF (is_option GREATER -1)
985+ ENDIF (is_arg_name GREATER -1)
986+ ENDFOREACH(arg)
987+ SET(${prefix}_${current_arg_name} ${current_arg_list})
988+ENDMACRO(PARSE_ARGUMENTS)
989
990=== modified file 'include/CMakeLists.txt'
991--- include/CMakeLists.txt 2010-05-18 11:30:17 +0000
992+++ include/CMakeLists.txt 2011-12-20 02:49:24 +0000
993@@ -1,5 +1,4 @@
994 set (_headers
995- compiz.h
996 decoration.h
997 )
998
999
1000=== removed file 'include/compiz-common.h.in'
1001--- include/compiz-common.h.in 2011-07-06 22:55:10 +0000
1002+++ include/compiz-common.h.in 1970-01-01 00:00:00 +0000
1003@@ -1,5 +0,0 @@
1004-#ifndef COMPIZ_COMMON_H
1005-#define COMPIZ_COMMON_H
1006-
1007-#define COMPIZ_VERSION_STRING "@VERSION@"
1008-#endif
1009
1010=== removed file 'include/compiz.h'
1011--- include/compiz.h 2011-06-25 05:06:53 +0000
1012+++ include/compiz.h 1970-01-01 00:00:00 +0000
1013@@ -1,103 +0,0 @@
1014-/*
1015- * Copyright © 2007 Novell, Inc.
1016- *
1017- * Permission to use, copy, modify, distribute, and sell this software
1018- * and its documentation for any purpose is hereby granted without
1019- * fee, provided that the above copyright notice appear in all copies
1020- * and that both that copyright notice and this permission notice
1021- * appear in supporting documentation, and that the name of
1022- * Novell, Inc. not be used in advertising or publicity pertaining to
1023- * distribution of the software without specific, written prior permission.
1024- * Novell, Inc. makes no representations about the suitability of this
1025- * software for any purpose. It is provided "as is" without express or
1026- * implied warranty.
1027- *
1028- * NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
1029- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
1030- * NO EVENT SHALL NOVELL, INC. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
1031- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
1032- * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
1033- * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
1034- * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1035- *
1036- * Author: David Reveman <davidr@novell.com>
1037- */
1038-
1039-#ifndef _COMPIZ_H
1040-#define _COMPIZ_H
1041-
1042-#include <compiz-common.h>
1043-
1044-#include <string>
1045-#include <list>
1046-#include <cstdarg>
1047-
1048-#define STRINGIFY(x) #x
1049-#define TOSTRING(x) STRINGIFY (x)
1050-
1051-#define RESTRICT_VALUE(value, min, max) \
1052- (((value) < (min)) ? (min): ((value) > (max)) ? (max) : (value))
1053-
1054-#define MOD(a,b) ((a) < 0 ? ((b) - ((-(a) - 1) % (b))) - 1 : (a) % (b))
1055-
1056-#define TIMEVALDIFF(tv1, tv2) \
1057- ((tv1)->tv_sec == (tv2)->tv_sec || (tv1)->tv_usec >= (tv2)->tv_usec) ? \
1058- ((((tv1)->tv_sec - (tv2)->tv_sec) * 1000000) + \
1059- ((tv1)->tv_usec - (tv2)->tv_usec)) / 1000 : \
1060- ((((tv1)->tv_sec - 1 - (tv2)->tv_sec) * 1000000) + \
1061- (1000000 + (tv1)->tv_usec - (tv2)->tv_usec)) / 1000
1062-
1063-#define TIMESPECDIFF(ts1, ts2) \
1064- ((ts1)->tv_sec == (ts2)->tv_sec || (ts1)->tv_nsec >= (ts2)->tv_nsec) ? \
1065- ((((ts1)->tv_sec - (ts2)->tv_sec) * 1000000) + \
1066- ((ts1)->tv_nsec - (ts2)->tv_nsec)) / 1000000 : \
1067- ((((ts1)->tv_sec - 1 - (ts2)->tv_sec) * 1000000) + \
1068- (1000000 + (ts1)->tv_nsec - (ts2)->tv_nsec)) / 1000000
1069-
1070-#define MULTIPLY_USHORT(us1, us2) \
1071- (((GLuint) (us1) * (GLuint) (us2)) / 0xffff)
1072-
1073-#define DEG2RAD (M_PI / 180.0f)
1074-
1075-#if defined(HAVE_SCANDIR_POSIX)
1076- // POSIX (2008) defines the comparison function like this:
1077- #define scandir(a,b,c,d) scandir((a), (b), (c), (int(*)(const dirent **, const dirent **))(d));
1078-#else
1079- #define scandir(a,b,c,d) scandir((a), (b), (c), (int(*)(const void*,const void*))(d));
1080-#endif
1081-
1082-typedef std::string CompString;
1083-typedef std::list<CompString> CompStringList;
1084-
1085-CompString compPrintf (const char *format, ...);
1086-CompString compPrintf (const char *format, va_list ap);
1087-
1088-extern bool debugOutput;
1089-
1090-typedef enum {
1091- CompLogLevelFatal = 0,
1092- CompLogLevelError,
1093- CompLogLevelWarn,
1094- CompLogLevelInfo,
1095- CompLogLevelDebug
1096-} CompLogLevel;
1097-
1098-void
1099-logMessage (const char *componentName,
1100- CompLogLevel level,
1101- const char *message);
1102-
1103-void
1104-compLogMessage (const char *componentName,
1105- CompLogLevel level,
1106- const char *format,
1107- ...);
1108-
1109-const char *
1110-logLevelToString (CompLogLevel level);
1111-
1112-extern char *programName;
1113-extern char **programArgv;
1114-extern int programArgc;
1115-
1116-#endif
1117
1118=== modified file 'include/core/CMakeLists.txt'
1119--- include/core/CMakeLists.txt 2011-07-07 16:59:41 +0000
1120+++ include/core/CMakeLists.txt 2011-12-20 02:49:24 +0000
1121@@ -10,8 +10,6 @@
1122 output.h
1123 plugin.h
1124 point.h
1125- pluginclasshandler.h
1126- pluginclasses.h
1127 propertywriter.h
1128 privateunion.h
1129 rect.h
1130@@ -20,9 +18,6 @@
1131 serialization.h
1132 session.h
1133 size.h
1134- timeouthandler.h
1135- timer.h
1136- valueholder.h
1137 window.h
1138 wrapsystem.h
1139 )
1140
1141=== modified file 'include/core/core.h'
1142--- include/core/core.h 2011-10-13 09:53:38 +0000
1143+++ include/core/core.h 2011-12-20 02:49:24 +0000
1144@@ -32,6 +32,10 @@
1145 #include <stdio.h>
1146 #include <assert.h>
1147
1148+#include <string>
1149+#include <list>
1150+#include <cstdarg>
1151+
1152 #include <X11/Xlib-xcb.h>
1153 #include <X11/Xutil.h>
1154 #include <X11/extensions/Xdamage.h>
1155@@ -69,6 +73,19 @@
1156 # define BITMAP_BIT_ORDER LSBFirst
1157 #endif
1158
1159+#define STRINGIFY(x) #x
1160+#define TOSTRING(x) STRINGIFY (x)
1161+#define DEG2RAD (M_PI / 180.0f)
1162+
1163+#if defined(HAVE_SCANDIR_POSIX)
1164+ // POSIX (2008) defines the comparison function like this:
1165+ #define scandir(a,b,c,d) scandir((a), (b), (c), (int(*)(const dirent **, const dirent **))(d));
1166+#else
1167+ #define scandir(a,b,c,d) scandir((a), (b), (c), (int(*)(const void*,const void*))(d));
1168+#endif
1169+
1170+#include <core/global.h>
1171+
1172 #include <core/pluginclasses.h>
1173 #include <core/screen.h>
1174 #include <core/window.h>
1175@@ -85,5 +102,7 @@
1176 #include <core/region.h>
1177 #include <core/countedlist.h>
1178 #include <core/timeouthandler.h>
1179+#include <core/logmessage.h>
1180+#include <core/string.h>
1181
1182 #endif
1183
1184=== added file 'include/core/global.h'
1185--- include/core/global.h 1970-01-01 00:00:00 +0000
1186+++ include/core/global.h 2011-12-20 02:49:24 +0000
1187@@ -0,0 +1,37 @@
1188+/*
1189+ * Copyright © 2007 Novell, Inc.
1190+ *
1191+ * Permission to use, copy, modify, distribute, and sell this software
1192+ * and its documentation for any purpose is hereby granted without
1193+ * fee, provided that the above copyright notice appear in all copies
1194+ * and that both that copyright notice and this permission notice
1195+ * appear in supporting documentation, and that the name of
1196+ * Novell, Inc. not be used in advertising or publicity pertaining to
1197+ * distribution of the software without specific, written prior permission.
1198+ * Novell, Inc. makes no representations about the suitability of this
1199+ * software for any purpose. It is provided "as is" without express or
1200+ * implied warranty.
1201+ *
1202+ * NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
1203+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
1204+ * NO EVENT SHALL NOVELL, INC. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
1205+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
1206+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
1207+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
1208+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1209+ *
1210+ * Author: David Reveman <davidr@novell.com>
1211+ */
1212+#ifndef _COMPIZ_GLOBAL_H
1213+#define _COMPIZ_GLOBAL_H
1214+
1215+/**
1216+* Flag indicating whether to produce debug output
1217+*/
1218+extern bool debugOutput;
1219+
1220+extern char *programName;
1221+extern char **programArgv;
1222+extern int programArgc;
1223+
1224+#endif // _COMPIZ_GLOBAL_H
1225
1226=== added file 'include/core/logmessage.h'
1227--- include/core/logmessage.h 1970-01-01 00:00:00 +0000
1228+++ include/core/logmessage.h 2011-12-20 02:49:24 +0000
1229@@ -0,0 +1,51 @@
1230+/*
1231+ * Copyright © 2007 Novell, Inc.
1232+ *
1233+ * Permission to use, copy, modify, distribute, and sell this software
1234+ * and its documentation for any purpose is hereby granted without
1235+ * fee, provided that the above copyright notice appear in all copies
1236+ * and that both that copyright notice and this permission notice
1237+ * appear in supporting documentation, and that the name of
1238+ * Novell, Inc. not be used in advertising or publicity pertaining to
1239+ * distribution of the software without specific, written prior permission.
1240+ * Novell, Inc. makes no representations about the suitability of this
1241+ * software for any purpose. It is provided "as is" without express or
1242+ * implied warranty.
1243+ *
1244+ * NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
1245+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
1246+ * NO EVENT SHALL NOVELL, INC. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
1247+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
1248+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
1249+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
1250+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1251+ *
1252+ * Author: David Reveman <davidr@novell.com>
1253+ */
1254+
1255+#ifndef _COMPIZ_LOGMESSAGE_H
1256+#define _COMPIZ_LOGMESSAGE_H
1257+
1258+typedef enum {
1259+ CompLogLevelFatal = 0,
1260+ CompLogLevelError,
1261+ CompLogLevelWarn,
1262+ CompLogLevelInfo,
1263+ CompLogLevelDebug
1264+} CompLogLevel;
1265+
1266+void
1267+logMessage (const char *componentName,
1268+ CompLogLevel level,
1269+ const char *message);
1270+
1271+void
1272+compLogMessage (const char *componentName,
1273+ CompLogLevel level,
1274+ const char *format,
1275+ ...);
1276+
1277+const char *
1278+logLevelToString (CompLogLevel level);
1279+
1280+#endif
1281
1282=== modified file 'include/core/match.h'
1283--- include/core/match.h 2010-03-24 01:31:41 +0000
1284+++ include/core/match.h 2011-12-20 02:49:24 +0000
1285@@ -28,6 +28,7 @@
1286 #ifndef _COMPMATCH_H
1287 #define _COMPMATCH_H
1288
1289+#include <core/string.h>
1290 #include <core/core.h>
1291
1292 class PrivateMatch;
1293
1294=== modified file 'include/core/option.h'
1295--- include/core/option.h 2011-03-16 19:39:25 +0000
1296+++ include/core/option.h 2011-12-20 02:49:24 +0000
1297@@ -28,8 +28,7 @@
1298 #ifndef _COMPOPTION_H
1299 #define _COMPOPTION_H
1300
1301-#include <compiz.h>
1302-
1303+#include <core/string.h>
1304 #include <vector>
1305
1306 class PrivateOption;
1307
1308=== modified file 'include/core/plugin.h'
1309--- include/core/plugin.h 2011-06-25 02:31:02 +0000
1310+++ include/core/plugin.h 2011-12-20 02:49:24 +0000
1311@@ -26,7 +26,7 @@
1312 #ifndef _COMPIZ_PLUGIN_H
1313 #define _COMPIZ_PLUGIN_H
1314
1315-#include <compiz.h>
1316+#include <core/string.h>
1317 #include <core/option.h>
1318 #include <core/privateunion.h>
1319
1320
1321=== modified file 'include/core/session.h'
1322--- include/core/session.h 2009-03-05 19:42:59 +0000
1323+++ include/core/session.h 2011-12-20 02:49:24 +0000
1324@@ -28,6 +28,7 @@
1325
1326 #define SN_API_NOT_YET_FROZEN
1327 #include <libsn/sn.h>
1328+#include <core/string.h>
1329
1330 namespace CompSession {
1331
1332
1333=== added file 'include/core/string.h'
1334--- include/core/string.h 1970-01-01 00:00:00 +0000
1335+++ include/core/string.h 2011-12-20 02:49:24 +0000
1336@@ -0,0 +1,39 @@
1337+/*
1338+ * Copyright © 2007 Novell, Inc.
1339+ *
1340+ * Permission to use, copy, modify, distribute, and sell this software
1341+ * and its documentation for any purpose is hereby granted without
1342+ * fee, provided that the above copyright notice appear in all copies
1343+ * and that both that copyright notice and this permission notice
1344+ * appear in supporting documentation, and that the name of
1345+ * Novell, Inc. not be used in advertising or publicity pertaining to
1346+ * distribution of the software without specific, written prior permission.
1347+ * Novell, Inc. makes no representations about the suitability of this
1348+ * software for any purpose. It is provided "as is" without express or
1349+ * implied warranty.
1350+ *
1351+ * NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
1352+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
1353+ * NO EVENT SHALL NOVELL, INC. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
1354+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
1355+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
1356+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
1357+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1358+ *
1359+ * Author: David Reveman <davidr@novell.com>
1360+ */
1361+
1362+#ifndef _COMPIZ_STRING_H
1363+#define _COMPIZ_STRING_H
1364+
1365+#include <string>
1366+#include <list>
1367+#include <cstdarg>
1368+
1369+typedef std::string CompString;
1370+typedef std::list<CompString> CompStringList;
1371+
1372+CompString compPrintf (const char *format, ...);
1373+CompString compPrintf (const char *format, va_list ap);
1374+
1375+#endif
1376
1377=== modified file 'metadata/CMakeLists.txt'
1378--- metadata/CMakeLists.txt 2011-08-18 18:15:11 +0000
1379+++ metadata/CMakeLists.txt 2011-12-20 02:49:24 +0000
1380@@ -9,9 +9,9 @@
1381 if (XSLTPROC_EXECUTABLE)
1382
1383 add_custom_command (
1384- OUTPUT ${CMAKE_BINARY_DIR}/generated/core.xml.in
1385+ OUTPUT ${compiz_BINARY_DIR}/generated/core.xml.in
1386 COMMAND ${XSLTPROC_EXECUTABLE}
1387- -o ${CMAKE_BINARY_DIR}/generated/core.xml.in
1388+ -o ${compiz_BINARY_DIR}/generated/core.xml.in
1389 --param default_plugins "\"'${COMPIZ_DEFAULT_PLUGINS}'\""
1390 ${CMAKE_SOURCE_DIR}/xslt/default_plugins.xslt
1391 ${CMAKE_CURRENT_SOURCE_DIR}/core.xml.in
1392
1393=== modified file 'plugins/CMakeLists.txt'
1394--- plugins/CMakeLists.txt 2010-11-12 04:35:58 +0000
1395+++ plugins/CMakeLists.txt 2011-12-20 02:49:24 +0000
1396@@ -7,4 +7,14 @@
1397
1398 add_definitions ( -DHAVE_CONFIG_H)
1399
1400+include_directories(
1401+ ${CMAKE_CURRENT_SOURCE_DIR}/../include
1402+
1403+ ${CMAKE_CURRENT_SOURCE_DIR}/../src
1404+ ${CMAKE_CURRENT_SOURCE_DIR}/../src/timer/include
1405+ ${CMAKE_CURRENT_SOURCE_DIR}/../src/string/include
1406+ ${CMAKE_CURRENT_SOURCE_DIR}/../src/pluginclasshandler/include
1407+ ${CMAKE_CURRENT_SOURCE_DIR}/../logmessage/include
1408+)
1409+
1410 compiz_add_plugins_in_folder (${CMAKE_CURRENT_SOURCE_DIR})
1411
1412=== modified file 'plugins/composite/src/screen.cpp'
1413--- plugins/composite/src/screen.cpp 2011-10-15 11:00:51 +0000
1414+++ plugins/composite/src/screen.cpp 2011-12-20 02:49:24 +0000
1415@@ -43,6 +43,8 @@
1416 #include <X11/extensions/shape.h>
1417 #include <X11/extensions/Xrandr.h>
1418
1419+#include <core/timer.h>
1420+
1421 CompWindow *lastDamagedWindow = 0;
1422
1423 void
1424@@ -696,7 +698,7 @@
1425 {
1426 int diff;
1427
1428- diff = TIMEVALDIFF (tv, &lastRedraw);
1429+ diff = compiz::core::timer::timeval_diff (tv, &lastRedraw);
1430
1431 /* handle clock rollback */
1432 if (diff < 0)
1433@@ -791,7 +793,7 @@
1434 if (priv->pHnd)
1435 priv->pHnd->prepareDrawing ();
1436
1437- timeDiff = TIMEVALDIFF (&tv, &priv->lastRedraw);
1438+ timeDiff = compiz::core::timer::timeval_diff (&tv, &priv->lastRedraw);
1439
1440 /* handle clock rollback */
1441 if (timeDiff < 0)
1442
1443=== modified file 'plugins/opengl/src/matrix.cpp'
1444--- plugins/opengl/src/matrix.cpp 2010-10-24 14:42:07 +0000
1445+++ plugins/opengl/src/matrix.cpp 2011-12-20 02:49:24 +0000
1446@@ -46,7 +46,6 @@
1447 * From Mesa 3-D graphics library.
1448 */
1449
1450-#include <compiz.h>
1451 #include <string.h>
1452 #include <math.h>
1453 #include <core/core.h>
1454
1455=== modified file 'plugins/opengl/src/texture.cpp'
1456--- plugins/opengl/src/texture.cpp 2011-02-24 07:52:09 +0000
1457+++ plugins/opengl/src/texture.cpp 2011-12-20 02:49:24 +0000
1458@@ -27,8 +27,6 @@
1459 # include <config.h>
1460 #endif
1461
1462-#include <compiz.h>
1463-
1464 #include <stdio.h>
1465 #include <stdlib.h>
1466 #include <string.h>
1467
1468=== modified file 'po/POTFILES.in'
1469--- po/POTFILES.in 2011-12-20 02:21:19 +0000
1470+++ po/POTFILES.in 2011-12-20 02:49:24 +0000
1471@@ -1,4 +1,7 @@
1472+<<<<<<< TREE
1473 gtk/gnome/compiz.desktop.in
1474+=======
1475+>>>>>>> MERGE-SOURCE
1476 gtk/window-decorator/gwd.schemas.in
1477 gtk/window-decorator/gtk-window-decorator.c
1478 metadata/core.xml.in
1479
1480=== modified file 'src/CMakeLists.txt'
1481--- src/CMakeLists.txt 2011-09-19 12:54:22 +0000
1482+++ src/CMakeLists.txt 2011-12-20 02:49:24 +0000
1483@@ -1,19 +1,45 @@
1484 include (CompizBcop)
1485
1486+
1487+add_subdirectory( string )
1488+add_subdirectory( logmessage )
1489+add_subdirectory( timer )
1490+add_subdirectory( pluginclasshandler )
1491+
1492 compiz_add_bcop_targets (
1493 core
1494 ${compiz_BINARY_DIR}/generated/core.xml.in
1495 _bcop_sources
1496 )
1497
1498+get_property (CORE_MOD_INCLUDE_DIRS
1499+ GLOBAL
1500+ PROPERTY CORE_MOD_INCLUDE_DIRS)
1501+
1502 include_directories (
1503 ${compiz_SOURCE_DIR}/include
1504 ${compiz_BINARY_DIR}
1505 ${compiz_BINARY_DIR}/generated
1506- ${CMAKE_CURRENT_SOURCE_DIR}
1507 ${COMPIZ_INCLUDE_DIRS}
1508 ${CMAKE_PREFIX_PATH}/include
1509 ${CMAKE_INCLUDE_PATH}
1510+ ${CORE_MOD_INCLUDE_DIRS}
1511+
1512+ ${CMAKE_CURRENT_SOURCE_DIR}
1513+
1514+ # Module specific include dirs
1515+ ${CMAKE_CURRENT_SOURCE_DIR}/string/include
1516+ ${CMAKE_CURRENT_SOURCE_DIR}/string/src
1517+
1518+ ${CMAKE_CURRENT_SOURCE_DIR}/logmessage/include
1519+ ${CMAKE_CURRENT_SOURCE_DIR}/logmessage/src
1520+
1521+ ${CMAKE_CURRENT_SOURCE_DIR}/timer/include
1522+ ${CMAKE_CURRENT_SOURCE_DIR}/timer/src
1523+
1524+ ${CMAKE_CURRENT_SOURCE_DIR}/pluginclasshandler/include
1525+ ${CMAKE_CURRENT_SOURCE_DIR}/pluginclasshandler/src
1526+
1527 )
1528
1529 add_definitions (
1530@@ -23,47 +49,68 @@
1531 -DMETADATADIR=\\\"${compiz_metadatadir}\\\"
1532 )
1533
1534+get_property (CORE_MOD_LIBRARY_DIRS
1535+ GLOBAL
1536+ PROPERTY CORE_MOD_LIBRARY_DIRS)
1537+
1538 link_directories (
1539 ${COMPIZ_LINK_DIRS}
1540+ ${CORE_MOD_LIBRARY_DIRS}
1541 )
1542
1543 add_executable (compiz
1544- region.cpp
1545- atoms.cpp
1546- timer.cpp
1547- main.cpp
1548- actions.cpp
1549- screen.cpp
1550- window.cpp
1551- action.cpp
1552- option.cpp
1553- string.cpp
1554- match.cpp
1555- pluginclasses.cpp
1556- event.cpp
1557- plugin.cpp
1558- session.cpp
1559- output.cpp
1560- rect.cpp
1561- size.cpp
1562- point.cpp
1563- windowgeometry.cpp
1564- icon.cpp
1565- modifierhandler.cpp
1566- propertywriter.cpp
1567- eventsource.cpp
1568- timeouthandler.cpp
1569- valueholder.cpp
1570- logmessage.cpp
1571- stackdebugger.cpp
1572+ ${CMAKE_CURRENT_SOURCE_DIR}/region.cpp
1573+ ${CMAKE_CURRENT_SOURCE_DIR}/atoms.cpp
1574+ ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp
1575+ ${CMAKE_CURRENT_SOURCE_DIR}/actions.cpp
1576+ ${CMAKE_CURRENT_SOURCE_DIR}/screen.cpp
1577+ ${CMAKE_CURRENT_SOURCE_DIR}/window.cpp
1578+ ${CMAKE_CURRENT_SOURCE_DIR}/action.cpp
1579+ ${CMAKE_CURRENT_SOURCE_DIR}/option.cpp
1580+ ${CMAKE_CURRENT_SOURCE_DIR}/match.cpp
1581+ ${CMAKE_CURRENT_SOURCE_DIR}/event.cpp
1582+ ${CMAKE_CURRENT_SOURCE_DIR}/plugin.cpp
1583+ ${CMAKE_CURRENT_SOURCE_DIR}/session.cpp
1584+ ${CMAKE_CURRENT_SOURCE_DIR}/output.cpp
1585+ ${CMAKE_CURRENT_SOURCE_DIR}/rect.cpp
1586+ ${CMAKE_CURRENT_SOURCE_DIR}/size.cpp
1587+ ${CMAKE_CURRENT_SOURCE_DIR}/point.cpp
1588+ ${CMAKE_CURRENT_SOURCE_DIR}/windowgeometry.cpp
1589+ ${CMAKE_CURRENT_SOURCE_DIR}/icon.cpp
1590+ ${CMAKE_CURRENT_SOURCE_DIR}/modifierhandler.cpp
1591+ ${CMAKE_CURRENT_SOURCE_DIR}/propertywriter.cpp
1592+ ${CMAKE_CURRENT_SOURCE_DIR}/eventsource.cpp
1593+ ${CMAKE_CURRENT_SOURCE_DIR}/stackdebugger.cpp
1594+
1595 ${_bcop_sources}
1596 )
1597
1598+# workaround for build race
1599+add_dependencies (compiz core-xml-file)
1600+
1601+get_property (CORE_MOD_LIBRARIES
1602+ GLOBAL
1603+ PROPERTY CORE_MOD_LIBRARIES)
1604+
1605 target_link_libraries (
1606- compiz ${COMPIZ_LIBRARIES} m pthread dl
1607+ compiz ${COMPIZ_LIBRARIES}
1608+
1609+ m
1610+ pthread
1611+ dl
1612+
1613+ compiz_string
1614+ compiz_timer
1615+ compiz_logmessage
1616+ compiz_pluginclasshandler
1617+# ${CORE_MOD_LIBRARIES}
1618 )
1619
1620 install (
1621 TARGETS compiz
1622 DESTINATION ${COMPIZ_DESTDIR}${exec_prefix}
1623 )
1624+
1625+add_test( compiz compiz )
1626+
1627+enable_coverage_report( TARGETS compiz )
1628
1629=== modified file 'src/action.cpp'
1630--- src/action.cpp 2010-11-09 14:13:19 +0000
1631+++ src/action.cpp 2011-12-20 02:49:24 +0000
1632@@ -27,8 +27,6 @@
1633 #include <stdlib.h>
1634 #include <string.h>
1635
1636-#include <compiz.h>
1637-
1638 #include <core/option.h>
1639 #include <core/action.h>
1640 #include <core/screen.h>
1641
1642=== added directory 'src/logmessage'
1643=== added file 'src/logmessage/CMakeLists.txt'
1644--- src/logmessage/CMakeLists.txt 1970-01-01 00:00:00 +0000
1645+++ src/logmessage/CMakeLists.txt 2011-12-20 02:49:24 +0000
1646@@ -0,0 +1,37 @@
1647+
1648+INCLUDE_DIRECTORIES(
1649+ ${CMAKE_CURRENT_SOURCE_DIR}/include
1650+
1651+ ${compiz_SOURCE_DIR}/include
1652+
1653+ ${Boost_INCLUDE_DIRS}
1654+)
1655+
1656+SET( PUBLIC_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/include/core/logmessage.h )
1657+SET( PRIVATE_HEADERS )
1658+
1659+SET( SRCS ${CMAKE_CURRENT_SOURCE_DIR}/src/logmessage.cpp )
1660+
1661+ADD_LIBRARY(
1662+ compiz_logmessage STATIC
1663+
1664+ ${SRCS}
1665+
1666+ ${PUBLIC_HEADERS}
1667+ ${PRIVATE_HEADERS}
1668+)
1669+
1670+ADD_SUBDIRECTORY( ${CMAKE_CURRENT_SOURCE_DIR}/tests )
1671+
1672+SET_TARGET_PROPERTIES(
1673+ compiz_logmessage PROPERTIES
1674+ PUBLIC_HEADER "${PUBLIC_HEADERS}"
1675+)
1676+
1677+INSTALL(
1678+ TARGETS compiz_logmessage
1679+ RUNTIME DESTINATION bin
1680+ LIBRARY DESTINATION lib
1681+ ARCHIVE DESTINATION lib
1682+ PUBLIC_HEADER DESTINATION include/compiz
1683+)
1684
1685=== added directory 'src/logmessage/include'
1686=== added directory 'src/logmessage/include/core'
1687=== added file 'src/logmessage/include/core/logmessage.h'
1688--- src/logmessage/include/core/logmessage.h 1970-01-01 00:00:00 +0000
1689+++ src/logmessage/include/core/logmessage.h 2011-12-20 02:49:24 +0000
1690@@ -0,0 +1,51 @@
1691+/*
1692+ * Copyright © 2007 Novell, Inc.
1693+ *
1694+ * Permission to use, copy, modify, distribute, and sell this software
1695+ * and its documentation for any purpose is hereby granted without
1696+ * fee, provided that the above copyright notice appear in all copies
1697+ * and that both that copyright notice and this permission notice
1698+ * appear in supporting documentation, and that the name of
1699+ * Novell, Inc. not be used in advertising or publicity pertaining to
1700+ * distribution of the software without specific, written prior permission.
1701+ * Novell, Inc. makes no representations about the suitability of this
1702+ * software for any purpose. It is provided "as is" without express or
1703+ * implied warranty.
1704+ *
1705+ * NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
1706+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
1707+ * NO EVENT SHALL NOVELL, INC. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
1708+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
1709+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
1710+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
1711+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1712+ *
1713+ * Author: David Reveman <davidr@novell.com>
1714+ */
1715+
1716+#ifndef _COMPIZ_LOGMESSAGE_H
1717+#define _COMPIZ_LOGMESSAGE_H
1718+
1719+typedef enum {
1720+ CompLogLevelFatal = 0,
1721+ CompLogLevelError,
1722+ CompLogLevelWarn,
1723+ CompLogLevelInfo,
1724+ CompLogLevelDebug
1725+} CompLogLevel;
1726+
1727+void
1728+logMessage (const char *componentName,
1729+ CompLogLevel level,
1730+ const char *message);
1731+
1732+void
1733+compLogMessage (const char *componentName,
1734+ CompLogLevel level,
1735+ const char *format,
1736+ ...);
1737+
1738+const char *
1739+logLevelToString (CompLogLevel level);
1740+
1741+#endif
1742
1743=== added directory 'src/logmessage/src'
1744=== renamed file 'src/logmessage.cpp' => 'src/logmessage/src/logmessage.cpp'
1745--- src/logmessage.cpp 2011-07-05 19:49:12 +0000
1746+++ src/logmessage/src/logmessage.cpp 2011-12-20 02:49:24 +0000
1747@@ -23,9 +23,13 @@
1748 * Author: David Reveman <davidr@novell.com>
1749 */
1750
1751-#include <compiz.h>
1752+#include <core/global.h>
1753+#include <core/logmessage.h>
1754+
1755 #include <cstdio>
1756
1757+#include <stdarg.h>
1758+
1759 const char *
1760 logLevelToString (CompLogLevel level)
1761 {
1762
1763=== added directory 'src/logmessage/tests'
1764=== added file 'src/logmessage/tests/CMakeLists.txt'
1765=== added file 'src/logmessage/tests/test-logmessage.cpp'
1766=== modified file 'src/main.cpp'
1767--- src/main.cpp 2011-10-13 14:46:33 +0000
1768+++ src/main.cpp 2011-12-20 02:49:24 +0000
1769@@ -27,8 +27,6 @@
1770 # include <config.h>
1771 #endif
1772
1773-#include <compiz.h>
1774-
1775 #include <stdio.h>
1776 #include <stdlib.h>
1777 #include <signal.h>
1778
1779=== renamed directory 'tests/pluginclasshandler' => 'src/pluginclasshandler'
1780=== added file 'src/pluginclasshandler/CMakeLists.txt'
1781--- src/pluginclasshandler/CMakeLists.txt 1970-01-01 00:00:00 +0000
1782+++ src/pluginclasshandler/CMakeLists.txt 2011-12-20 02:49:24 +0000
1783@@ -0,0 +1,50 @@
1784+
1785+INCLUDE_DIRECTORIES(
1786+ ${CMAKE_CURRENT_SOURCE_DIR}/include
1787+ ${CMAKE_CURRENT_SOURCE_DIR}../logmessage/include
1788+
1789+ ${compiz_SOURCE_DIR}/include
1790+
1791+ ${Boost_INCLUDE_DIRS}
1792+)
1793+
1794+SET(
1795+ PUBLIC_HEADERS
1796+ ${CMAKE_CURRENT_SOURCE_DIR}/include/core/pluginclasses.h
1797+ ${CMAKE_CURRENT_SOURCE_DIR}/include/core/pluginclasshandler.h
1798+)
1799+
1800+SET(
1801+ PRIVATE_HEADERS
1802+ ${CMAKE_CURRENT_SOURCE_DIR}/src/valueholder.h
1803+)
1804+
1805+SET(
1806+ SRCS
1807+ ${CMAKE_CURRENT_SOURCE_DIR}/src/valueholder.cpp
1808+ ${CMAKE_CURRENT_SOURCE_DIR}/src/pluginclasses.cpp
1809+)
1810+
1811+ADD_LIBRARY(
1812+ compiz_pluginclasshandler STATIC
1813+
1814+ ${SRCS}
1815+
1816+ ${PUBLIC_HEADERS}
1817+ ${PRIVATE_HEADERS}
1818+)
1819+
1820+ADD_SUBDIRECTORY( ${CMAKE_CURRENT_SOURCE_DIR}/tests )
1821+
1822+SET_TARGET_PROPERTIES(
1823+ compiz_pluginclasshandler PROPERTIES
1824+ PUBLIC_HEADER "${PUBLIC_HEADERS}"
1825+)
1826+
1827+INSTALL(
1828+ TARGETS compiz_pluginclasshandler
1829+ RUNTIME DESTINATION bin
1830+ LIBRARY DESTINATION lib
1831+ ARCHIVE DESTINATION lib
1832+ PUBLIC_HEADER DESTINATION include/compiz
1833+)
1834
1835=== added directory 'src/pluginclasshandler/include'
1836=== added directory 'src/pluginclasshandler/include/core'
1837=== renamed file 'include/core/pluginclasses.h' => 'src/pluginclasshandler/include/core/pluginclasses.h'
1838=== renamed file 'include/core/pluginclasshandler.h' => 'src/pluginclasshandler/include/core/pluginclasshandler.h'
1839--- include/core/pluginclasshandler.h 2011-09-16 00:51:33 +0000
1840+++ src/pluginclasshandler/include/core/pluginclasshandler.h 2011-12-20 02:49:24 +0000
1841@@ -29,7 +29,7 @@
1842 #include <typeinfo>
1843 #include <boost/preprocessor/cat.hpp>
1844
1845-#include <compiz.h>
1846+#include <core/string.h>
1847 #include <core/valueholder.h>
1848 #include <core/pluginclasses.h>
1849
1850
1851=== renamed file 'include/core/valueholder.h' => 'src/pluginclasshandler/include/core/valueholder.h'
1852--- include/core/valueholder.h 2011-06-25 02:31:02 +0000
1853+++ src/pluginclasshandler/include/core/valueholder.h 2011-12-20 02:49:24 +0000
1854@@ -26,7 +26,8 @@
1855 #ifndef _COMPIZ_VALUEHOLDER_H
1856 #define _COMPIZ_VALUEHOLDER_H
1857
1858-#include <compiz.h>
1859+#include <core/string.h>
1860+#include <core/logmessage.h>
1861 #include <core/privateunion.h>
1862
1863 class PrivateValueHolder;
1864@@ -50,4 +51,4 @@
1865 PrivateValueHolder *priv;
1866 };
1867
1868-#endif
1869\ No newline at end of file
1870+#endif
1871
1872=== added directory 'src/pluginclasshandler/src'
1873=== renamed file 'src/pluginclasses.cpp' => 'src/pluginclasshandler/src/pluginclasses.cpp'
1874=== renamed file 'src/valueholder.cpp' => 'src/pluginclasshandler/src/valueholder.cpp'
1875=== renamed file 'src/valueholder.h' => 'src/pluginclasshandler/src/valueholder.h'
1876=== added directory 'src/pluginclasshandler/tests'
1877=== renamed file 'tests/pluginclasshandler/CMakeLists.txt' => 'src/pluginclasshandler/tests/CMakeLists.txt'
1878--- tests/pluginclasshandler/CMakeLists.txt 2011-07-06 18:53:03 +0000
1879+++ src/pluginclasshandler/tests/CMakeLists.txt 2011-12-20 02:49:24 +0000
1880@@ -1,6 +1,81 @@
1881-set (COMPIZ_TEST_PCH_BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
1882-
1883-add_subdirectory (construct)
1884-add_subdirectory (get)
1885-add_subdirectory (typenames)
1886-add_subdirectory (indexes)
1887+include_directories( ${CMAKE_CURRENT_SOURCE_DIR} )
1888+
1889+add_library( compiz_pch_test STATIC test-pluginclasshandler.cpp )
1890+
1891+add_executable(
1892+ compiz_pch_construct
1893+
1894+ ${CMAKE_CURRENT_SOURCE_DIR}/construct/src/test-pch-construct.cpp
1895+)
1896+
1897+add_executable(
1898+ compiz_pch_get
1899+
1900+ ${CMAKE_CURRENT_SOURCE_DIR}/get/src/test-pch-get.cpp
1901+)
1902+
1903+#add_executable(
1904+# compiz_pch_indexes
1905+#
1906+# ${CMAKE_CURRENT_SOURCE_DIR}/indexes/src/test-pch-indexes.cpp
1907+#)
1908+
1909+add_executable(
1910+ compiz_pch_typenames
1911+
1912+ ${CMAKE_CURRENT_SOURCE_DIR}/typenames/src/test-pch-typenames.cpp
1913+)
1914+
1915+target_link_libraries(
1916+ compiz_pch_construct
1917+ compiz_pch_test
1918+
1919+ compiz_logmessage
1920+ compiz_pluginclasshandler
1921+ compiz_string
1922+
1923+ ${GTEST_BOTH_LIBRARIES}
1924+ ${CMAKE_THREAD_LIBS_INIT} # Link in pthread.
1925+)
1926+
1927+target_link_libraries(
1928+ compiz_pch_get
1929+ compiz_pch_test
1930+
1931+ compiz_logmessage
1932+ compiz_pluginclasshandler
1933+ compiz_string
1934+
1935+ ${GTEST_BOTH_LIBRARIES}
1936+ ${CMAKE_THREAD_LIBS_INIT} # Link in pthread.
1937+)
1938+
1939+target_link_libraries(
1940+ compiz_pch_typenames
1941+ compiz_pch_test
1942+
1943+ compiz_logmessage
1944+ compiz_pluginclasshandler
1945+ compiz_string
1946+
1947+ ${GTEST_BOTH_LIBRARIES}
1948+ ${CMAKE_THREAD_LIBS_INIT} # Link in pthread.
1949+)
1950+
1951+# Not compilable
1952+#target_link_libraries(
1953+# compiz_pch_indexes
1954+# compiz_pch_test
1955+#
1956+# compiz_pluginclasshandler
1957+# compiz_string
1958+#
1959+# gtest
1960+# gtest_main
1961+#)
1962+
1963+add_test( compiz_pch_construct compiz_pch_construct )
1964+add_test( compiz_pch_get compiz_pch_get )
1965+#add_test( compiz_pch_indexes compiz_pch_indexes )
1966+add_test( compiz_pch_typenames compiz_pch_typenames )
1967+
1968
1969=== renamed directory 'tests/pluginclasshandler/construct' => 'src/pluginclasshandler/tests/construct'
1970=== added directory 'src/pluginclasshandler/tests/construct/src'
1971=== renamed file 'tests/pluginclasshandler/construct/test-pch-construct.cpp' => 'src/pluginclasshandler/tests/construct/src/test-pch-construct.cpp'
1972--- tests/pluginclasshandler/construct/test-pch-construct.cpp 2011-07-06 18:53:03 +0000
1973+++ src/pluginclasshandler/tests/construct/src/test-pch-construct.cpp 2011-12-20 02:49:24 +0000
1974@@ -1,64 +1,49 @@
1975 #include <test-pluginclasshandler.h>
1976
1977-class ConstructPlugin :
1978- public Plugin,
1979- public PluginClassHandler <ConstructPlugin, Base>
1980+class ConstructPlugin: public Plugin, public PluginClassHandler<ConstructPlugin,
1981+ Base>
1982 {
1983- public:
1984- ConstructPlugin (Base *);
1985+public:
1986+ ConstructPlugin (Base * base) :
1987+ Plugin(base), PluginClassHandler<ConstructPlugin, Base>(base)
1988+ {
1989+ }
1990 };
1991
1992-ConstructPlugin::ConstructPlugin (Base *base):
1993- Plugin (base),
1994- PluginClassHandler <ConstructPlugin, Base> (base)
1995-{
1996-}
1997-
1998-CompizPCHTestConstruct::CompizPCHTestConstruct (Global *g) :
1999- CompizPCHTest (g)
2000-{
2001-}
2002-
2003-void
2004-CompizPCHTestConstruct::run ()
2005+TEST_F( CompizPCHTest, TestConstruct )
2006 {
2007 Plugin *p;
2008
2009- std::cout << "-= TEST: Basic construction" << std::endl;
2010-
2011- bases.push_back (new Base ());
2012- plugins.push_back (static_cast <Plugin *> (new ConstructPlugin (bases.back ())));
2013- bases.push_back (new Base ());
2014- plugins.push_back (static_cast <Plugin *> (new ConstructPlugin (bases.back ())));
2015-
2016- if (bases.front ()->pluginClasses.size () != globalPluginClassIndices.size ())
2017- {
2018- std::cout << "FAIL: allocated number of plugin classes is not the same as the"\
2019- " global number of allocated plugin classes" << std::endl;
2020- exit (1);
2021- }
2022-
2023- if (!ValueHolder::Default ()->hasValue (compPrintf ("%s_index_%lu", typeid (ConstructPlugin).name (), 0)))
2024- {
2025- std::cout << "FAIL: ValueHolder does not have value " << compPrintf ("%s_index_%lu", typeid (ConstructPlugin).name (), 0) << std::endl;
2026- exit (1);
2027- }
2028-
2029- p = ConstructPlugin::get (bases.front ());
2030-
2031- if (p != plugins.front ())
2032- {
2033- std::cout << "FAIL: Returned Plugin * is not plugins.front ()" << std::endl;
2034- exit (1);
2035- }
2036-
2037- p = ConstructPlugin::get (bases.back ());
2038-
2039- if (p != plugins.back ())
2040- {
2041- std::cout << "FAIL: Returned Plugin * is not plugins.back ()" << std::endl;
2042- exit (1);
2043- }
2044-
2045- std::cout << "PASS: Basic construction" << std::endl;
2046+ bases.push_back(new Base());
2047+ plugins.push_back(static_cast<Plugin *>(new ConstructPlugin(bases.back())));
2048+ bases.push_back(new Base());
2049+ plugins.push_back(static_cast<Plugin *>(new ConstructPlugin(bases.back())));
2050+
2051+ if (bases.front()->pluginClasses.size() != globalPluginClassIndices.size())
2052+ {
2053+ FAIL() << "allocated number of plugin classes is not the same as the"
2054+ " global number of allocated plugin classes";
2055+ }
2056+
2057+ if (!ValueHolder::Default()->hasValue(
2058+ compPrintf("%s_index_%lu", typeid(ConstructPlugin).name(), 0)))
2059+ {
2060+ FAIL() << "ValueHolder does not have value "
2061+ << compPrintf("%s_index_%lu", typeid(ConstructPlugin).name(), 0);
2062+ }
2063+
2064+ p = ConstructPlugin::get(bases.front());
2065+
2066+ if (p != plugins.front())
2067+ {
2068+ FAIL() << "Returned Plugin * is not plugins.front ()";
2069+ }
2070+
2071+ p = ConstructPlugin::get(bases.back());
2072+
2073+ if (p != plugins.back())
2074+ {
2075+ FAIL() << "Returned Plugin * is not plugins.back ()";
2076+ }
2077 }
2078+
2079
2080=== renamed directory 'tests/pluginclasshandler/get' => 'src/pluginclasshandler/tests/get'
2081=== added directory 'src/pluginclasshandler/tests/get/src'
2082=== renamed file 'tests/pluginclasshandler/get/test-pch-get.cpp' => 'src/pluginclasshandler/tests/get/src/test-pch-get.cpp'
2083--- tests/pluginclasshandler/get/test-pch-get.cpp 2011-07-06 18:53:03 +0000
2084+++ src/pluginclasshandler/tests/get/src/test-pch-get.cpp 2011-12-20 02:49:24 +0000
2085@@ -14,18 +14,10 @@
2086 {
2087 }
2088
2089-CompizPCHTestGet::CompizPCHTestGet (Global *g) :
2090- CompizPCHTest (g)
2091-{
2092-}
2093-
2094-void
2095-CompizPCHTestGet::run ()
2096+TEST_F( CompizPCHTest, TestGet)
2097 {
2098 Plugin *p;
2099
2100- std::cout << "-= TEST: Object Retreival" << std::endl;
2101-
2102 bases.push_back (new Base ());
2103 plugins.push_back (new GetPlugin (bases.back ()));
2104 bases.push_back (new Base ());
2105@@ -35,16 +27,14 @@
2106
2107 if (p != plugins.front ())
2108 {
2109- std::cout << "FAIL: Returned Plugin * is not plugins.front ()" << std::endl;
2110- exit (1);
2111+ FAIL() << "Returned Plugin * is not plugins.front ()";
2112 }
2113
2114 p = GetPlugin::get (bases.back ());
2115
2116 if (p != plugins.back ())
2117 {
2118- std::cout << "FAIL: Returned Plugin * is not plugins.back ()" << std::endl;
2119- exit (1);
2120+ FAIL() << "Returned Plugin * is not plugins.back ()";
2121 }
2122
2123 /* Now create a third base and check if plugin is implicitly created */
2124@@ -56,9 +46,6 @@
2125
2126 if (p->b != bases.back ())
2127 {
2128- std::cout << "FAIL: Returned Plugin * is not the plugin for bases.back ()" << std::endl;
2129- exit (1);
2130+ FAIL() << "Returned Plugin * is not the plugin for bases.back ()";
2131 }
2132-
2133- std::cout << "PASS: Object Retreival" << std::endl;
2134 }
2135
2136=== renamed directory 'tests/pluginclasshandler/indexes' => 'src/pluginclasshandler/tests/indexes'
2137=== added directory 'src/pluginclasshandler/tests/indexes/src'
2138=== renamed file 'tests/pluginclasshandler/indexes/test-pch-indexes.cpp' => 'src/pluginclasshandler/tests/indexes/src/test-pch-indexes.cpp'
2139--- tests/pluginclasshandler/indexes/test-pch-indexes.cpp 2011-07-06 18:53:03 +0000
2140+++ src/pluginclasshandler/tests/indexes/src/test-pch-indexes.cpp 2011-12-20 02:49:24 +0000
2141@@ -103,10 +103,26 @@
2142 {
2143 }
2144
2145-CompizPCHTestIndexes::CompizPCHTestIndexes (Global *g) :
2146- CompizPCHTest (g)
2147+class CompizPCHTestIndexes :
2148+ public CompizPCHTest
2149 {
2150-}
2151+ public:
2152+
2153+ void run ();
2154+
2155+ template <typename I>
2156+ void printFailure (I *);
2157+
2158+ public:
2159+ unsigned int ePluginClassHandlerIndex;
2160+ unsigned int eIndex;
2161+ int eRefCount;
2162+ bool eInitiated;
2163+ bool eFailed;
2164+ bool ePcFailed;
2165+ unsigned int ePcIndex;
2166+ bool eLoadFailed;
2167+};
2168
2169 template <typename I>
2170 void
2171@@ -115,7 +131,6 @@
2172 std::cout << "FAIL: index value does not match!" << std::endl;
2173 std::cout << "INFO: Values of " << std::hex << (void *) i << " are " << std::endl;
2174 std::cout << "INFO: pluginClassHandlerIndex is " << pluginClassHandlerIndex << std::endl;
2175- std::cout << "INFO: mIndex.index " << i->mIndex.index << std::endl;
2176 std::cout << "INFO: mIndex.refCount " << i->mIndex.refCount << std::endl;
2177 std::cout << "INFO: mIndex.initiated " << i->mIndex.initiated << std::endl;
2178 std::cout << "INFO: mIndex.failed " << i->mIndex.failed << std::endl;
2179@@ -142,8 +157,7 @@
2180 i->mIndex.pcFailed != ePcFailed || \
2181 i->mIndex.pcIndex != ePcIndex
2182
2183-void
2184-CompizPCHTestIndexes::run ()
2185+TEST_F( CompizPCHTestIndexes, TestIndexes )
2186 {
2187 Plugin *p;
2188 Base *b;
2189@@ -154,16 +168,12 @@
2190 IPB3Handler *ipbhandler_p3;
2191 FIPBHandler *fipbhandler_p;
2192
2193- std::cout << "-= TEST: Index Sanity" << std::endl;
2194-
2195 bases.push_back (new Base ());
2196 plugins.push_back (new IndexesPlugin (bases.back ()));
2197
2198 p = plugins.back ();
2199 ipbhandler_p = (IPBHandler *) p;
2200
2201- std::cout << "STEP: to base #1 plugin #1(1) " << plugins.size () << std::endl;
2202-
2203 ePluginClassHandlerIndex = 1;
2204 eIndex = 0;
2205 eRefCount = 1;
2206@@ -176,7 +186,7 @@
2207 if (INDEX_INCORRECT (ipbhandler_p))
2208 {
2209 printFailure<IPBHandler> (ipbhandler_p);
2210- exit (1);
2211+ FAIL();
2212 }
2213
2214 bases.push_back (new Base ());
2215@@ -185,7 +195,6 @@
2216 p = plugins.back ();
2217 ipbhandler_p = (IPBHandler *) p;
2218
2219- std::cout << "STEP: to base #3 plugin #1(2) " << plugins.size () << std::endl;
2220 ePluginClassHandlerIndex = 1;
2221 eIndex = 0;
2222 eRefCount = 2;
2223@@ -198,7 +207,7 @@
2224 if (INDEX_INCORRECT (ipbhandler_p))
2225 {
2226 printFailure<IPBHandler> (ipbhandler_p);
2227- exit (1);
2228+ FAIL();
2229 }
2230
2231 bases.push_back (new Base ());
2232@@ -207,7 +216,6 @@
2233 p = plugins.back ();
2234 ipbhandler_p2 = (IPB2Handler *) p;
2235
2236- std::cout << "STEP: to base #3 plugin #2(1) " << plugins.size () << std::endl;
2237 ePluginClassHandlerIndex = 2;
2238 eIndex = 1;
2239 eRefCount = 1;
2240@@ -233,7 +241,6 @@
2241 p = plugins.back ();
2242 ipbhandler_p = (IPBHandler *) p;
2243
2244- std::cout << "STEP: back to base #2 plugin #1(2) " << plugins.size () << std::endl;
2245 ePluginClassHandlerIndex = 3;
2246 eIndex = 0;
2247 eRefCount = 2;
2248@@ -246,7 +253,7 @@
2249 if (INDEX_INCORRECT (ipbhandler_p))
2250 {
2251 printFailure<IPBHandler> (ipbhandler_p);
2252- exit (1);
2253+ FAIL();
2254 }
2255
2256 plugins.pop_back ();
2257@@ -259,7 +266,6 @@
2258 p = plugins.back ();
2259 ipbhandler_p = (IPBHandler *) p;
2260
2261- std::cout << "STEP: back to base #1 plugin #1(1) " << plugins.size () << std::endl;
2262 ePluginClassHandlerIndex = 3;
2263 eIndex = 0;
2264 eRefCount = 1;
2265@@ -272,13 +278,12 @@
2266 if (INDEX_INCORRECT (ipbhandler_p))
2267 {
2268 printFailure<IPBHandler> (ipbhandler_p);
2269- exit (1);
2270+ FAIL();
2271 }
2272
2273 p = IndexesPlugin::get (bases.back ());
2274 ipbhandler_p = (IPBHandler *) p;
2275
2276- std::cout << "STEP: back to base #1 plugin #1(1) ::get " << plugins.size () << std::endl;
2277 ePluginClassHandlerIndex = 3;
2278 eIndex = 0;
2279 eRefCount = 1;
2280@@ -291,7 +296,7 @@
2281 if (INDEX_INCORRECT (ipbhandler_p))
2282 {
2283 printFailure<IPBHandler> (ipbhandler_p);
2284- exit (1);
2285+ FAIL();
2286 }
2287
2288 bases.push_back (new Base ());
2289@@ -300,7 +305,6 @@
2290 p = plugins.back ();
2291 ipbhandler_p3 = (IPB3Handler *) p;
2292
2293- std::cout << "STEP: to base #2 plugin #3(1) (load failing plugin) " << plugins.size () << std::endl;
2294 ePluginClassHandlerIndex = 4;
2295 eIndex = 1;
2296 eRefCount = 1;
2297@@ -326,7 +330,6 @@
2298 p = plugins.back ();
2299 ipbhandler_p = (IPBHandler *) p;
2300
2301- std::cout << "STEP: to base #2 plugin #1(2) (failing key) " << plugins.size () << std::endl;
2302 ePluginClassHandlerIndex = 4;
2303 eIndex = 0;
2304 eRefCount = 2;
2305@@ -339,7 +342,7 @@
2306 if (INDEX_INCORRECT (ipbhandler_p))
2307 {
2308 printFailure<IPBHandler> (ipbhandler_p);
2309- exit (1);
2310+ FAIL();
2311 }
2312
2313 plugins.push_back (new IndexesPlugin2 (bases.back ()));
2314@@ -347,7 +350,6 @@
2315 p = plugins.back ();
2316 ipbhandler_p2 = (IPB2Handler *) p;
2317
2318- std::cout << "STEP: to base #1 plugin #2(1) (failing key) " << plugins.size () << std::endl;
2319 ePluginClassHandlerIndex = 5;
2320 eIndex = 2;
2321 eRefCount = 1;
2322@@ -360,14 +362,13 @@
2323 if (INDEX_INCORRECT (ipbhandler_p2))
2324 {
2325 printFailure<IPB2Handler> (ipbhandler_p2);
2326- exit (1);
2327+ FAIL();
2328 }
2329
2330 /* Now call ::get on the first one to reset the pluginClassHandlerIndex */
2331 p = IndexesPlugin::get (bases.back ());
2332 ipbhandler_p = (IPBHandler *) p;
2333
2334- std::cout << "STEP: to base #1 plugin #1(2) (failing key - after get) " << plugins.size () << std::endl;
2335 ePluginClassHandlerIndex = 5;
2336 eIndex = 0;
2337 eRefCount = 2;
2338@@ -380,7 +381,7 @@
2339 if (INDEX_INCORRECT (ipbhandler_p))
2340 {
2341 printFailure<IPBHandler> (ipbhandler_p);
2342- exit (1);
2343+ FAIL();
2344 }
2345
2346 /* Now erase the key that was used by the second plugin so subsequent attempts to ::get
2347@@ -391,7 +392,6 @@
2348 ValueHolder::Default ()->eraseValue (ipbhandler_p2->keyName ());
2349 p = IndexesPlugin2::get (bases.back ());
2350
2351- std::cout << "STEP: to base #1 plugin #2(1) (failing key - after erasure) " << plugins.size () << std::endl;
2352 ePluginClassHandlerIndex = 5;
2353 eIndex = 2;
2354 eRefCount = 1;
2355@@ -404,14 +404,13 @@
2356 if (INDEX_INCORRECT (ipbhandler_p2))
2357 {
2358 printFailure<IPB2Handler> (ipbhandler_p2);
2359- exit (1);
2360+ FAIL();
2361 }
2362
2363 fb = new FailingBase ();
2364 fp = new FailingIndexesPlugin (fb);
2365 fipbhandler_p = (FIPBHandler *) fp;
2366
2367- std::cout << "STEP: to base #3 (failing base) plugin #1(2) " << plugins.size () << std::endl;
2368 ePluginClassHandlerIndex = 5;
2369 eIndex = 0;
2370 eRefCount = 0;
2371@@ -424,11 +423,9 @@
2372 if (INDEX_INCORRECT (fipbhandler_p))
2373 {
2374 printFailure<FIPBHandler> (fipbhandler_p);
2375- exit (1);
2376+ FAIL();
2377 }
2378
2379 delete fp;
2380 delete fb;
2381-
2382- std::cout << "PASS: Index Sanity" << std::endl;
2383 }
2384
2385=== renamed file 'tests/pluginclasshandler/test-pluginclasshandler.cpp' => 'src/pluginclasshandler/tests/test-pluginclasshandler.cpp'
2386--- tests/pluginclasshandler/test-pluginclasshandler.cpp 2011-07-06 18:53:03 +0000
2387+++ src/pluginclasshandler/tests/test-pluginclasshandler.cpp 2011-12-20 02:49:24 +0000
2388@@ -60,42 +60,14 @@
2389 {
2390 }
2391
2392-CompizPCHTest::CompizPCHTest (Global *g) :
2393- global (g)
2394+CompizPCHTest::CompizPCHTest () :
2395+ global (new Global())
2396 {
2397 ValueHolder::SetDefault (static_cast<ValueHolder *> (global));
2398+ gTest = this;
2399 }
2400
2401 CompizPCHTest::~CompizPCHTest ()
2402 {
2403 delete global;
2404 }
2405-
2406-int
2407-main (int argc, char **argv)
2408-{
2409- programName = argv[0];
2410-
2411- gTest = static_cast <CompizPCHTest *> (new OBJECT (new Global ()));
2412- gTest->run ();
2413-
2414- while (gTest->plugins.size ())
2415- {
2416- Plugin *p = gTest->plugins.front ();
2417- gTest->plugins.pop_front ();
2418-
2419- delete p;
2420- }
2421-
2422- while (gTest->bases.size ())
2423- {
2424- Base *b = gTest->bases.front ();
2425- gTest->bases.pop_front ();
2426-
2427- delete b;
2428- }
2429-
2430- delete gTest;
2431-
2432- return 0;
2433-}
2434
2435=== renamed file 'tests/pluginclasshandler/test-pluginclasshandler.h' => 'src/pluginclasshandler/tests/test-pluginclasshandler.h'
2436--- tests/pluginclasshandler/test-pluginclasshandler.h 2011-07-06 18:53:03 +0000
2437+++ src/pluginclasshandler/tests/test-pluginclasshandler.h 2011-12-20 02:49:24 +0000
2438@@ -1,5 +1,8 @@
2439 #include <core/pluginclasshandler.h>
2440 #include <core/pluginclasses.h>
2441+
2442+#include <gtest/gtest.h>
2443+
2444 #include <list>
2445 #include <boost/foreach.hpp>
2446
2447@@ -46,69 +49,14 @@
2448 Base *b;
2449 };
2450
2451-class CompizPCHTest
2452+class CompizPCHTest : public ::testing::Test
2453 {
2454 public:
2455
2456- CompizPCHTest (Global *g);
2457+ CompizPCHTest ();
2458 virtual ~CompizPCHTest ();
2459
2460 Global *global;
2461 std::list <Base *> bases;
2462 std::list <Plugin *> plugins;
2463-
2464- virtual void run () = 0;
2465-};
2466-
2467-class CompizPCHTestConstruct :
2468- public CompizPCHTest
2469-{
2470- public:
2471-
2472- CompizPCHTestConstruct (Global *g);
2473-
2474- void run ();
2475-};
2476-
2477-class CompizPCHTestGet :
2478- public CompizPCHTest
2479-{
2480- public:
2481-
2482- CompizPCHTestGet (Global *g);
2483-
2484- void run ();
2485-};
2486-
2487-class CompizPCHTestTypenames :
2488- public CompizPCHTest
2489-{
2490- public:
2491-
2492- CompizPCHTestTypenames (Global *g);
2493-
2494- void run ();
2495-};
2496-
2497-class CompizPCHTestIndexes :
2498- public CompizPCHTest
2499-{
2500- public:
2501-
2502- CompizPCHTestIndexes (Global *g);
2503-
2504- void run ();
2505-
2506- template <typename I>
2507- void printFailure (I *);
2508-
2509- public:
2510- unsigned int ePluginClassHandlerIndex;
2511- unsigned int eIndex;
2512- int eRefCount;
2513- bool eInitiated;
2514- bool eFailed;
2515- bool ePcFailed;
2516- unsigned int ePcIndex;
2517- bool eLoadFailed;
2518 };
2519
2520=== renamed directory 'tests/pluginclasshandler/typenames' => 'src/pluginclasshandler/tests/typenames'
2521=== added directory 'src/pluginclasshandler/tests/typenames/src'
2522=== renamed file 'tests/pluginclasshandler/typenames/test-pch-typenames.cpp' => 'src/pluginclasshandler/tests/typenames/src/test-pch-typenames.cpp'
2523--- tests/pluginclasshandler/typenames/test-pch-typenames.cpp 2011-07-06 18:53:03 +0000
2524+++ src/pluginclasshandler/tests/typenames/src/test-pch-typenames.cpp 2011-12-20 02:49:24 +0000
2525@@ -1,83 +1,75 @@
2526 #include <test-pluginclasshandler.h>
2527
2528-class TypenamesPlugin :
2529- public Plugin,
2530- public PluginClassHandler <TypenamesPlugin, Base>
2531-{
2532- public:
2533- TypenamesPlugin (Base *);
2534-};
2535-
2536-class TypenamesPluginABI1 :
2537- public Plugin,
2538- public PluginClassHandler <TypenamesPluginABI1, Base, 1>
2539-{
2540- public:
2541- TypenamesPluginABI1 (Base *);
2542-};
2543-
2544-class TypenamesPluginABI2 :
2545- public Plugin,
2546- public PluginClassHandler <TypenamesPluginABI2, Base, 2>
2547-{
2548- public:
2549- TypenamesPluginABI2 (Base *);
2550-};
2551-
2552-TypenamesPlugin::TypenamesPlugin (Base *base):
2553- Plugin (base),
2554- PluginClassHandler <TypenamesPlugin, Base> (base)
2555-{
2556-}
2557-
2558-TypenamesPluginABI1::TypenamesPluginABI1 (Base *base):
2559- Plugin (base),
2560- PluginClassHandler <TypenamesPluginABI1, Base, 1> (base)
2561-{
2562-}
2563-
2564-TypenamesPluginABI2::TypenamesPluginABI2 (Base *base):
2565- Plugin (base),
2566- PluginClassHandler <TypenamesPluginABI2, Base, 2> (base)
2567-{
2568-}
2569-
2570-CompizPCHTestTypenames::CompizPCHTestTypenames (Global *g) :
2571- CompizPCHTest (g)
2572-{
2573-}
2574-
2575-void
2576-CompizPCHTestTypenames::run ()
2577-{
2578- std::list <Plugin *>::iterator it;
2579-
2580- std::cout << "-= TEST: Typenames" << std::endl;
2581-
2582- bases.push_back (new Base ());
2583- plugins.push_back (new TypenamesPlugin (bases.back ()));
2584- bases.push_back (new Base ());
2585- plugins.push_back (new TypenamesPluginABI1 (bases.back ()));
2586- bases.push_back (new Base ());
2587- plugins.push_back (new TypenamesPluginABI2 (bases.back ()));
2588-
2589- if (!ValueHolder::Default ()->hasValue (compPrintf ("%s_index_%lu", typeid (TypenamesPlugin).name (), 0)))
2590- {
2591- std::cout << "FAIL: ValueHolder does not have value " << compPrintf ("%s_index_%lu", typeid (TypenamesPlugin).name (), 0) << std::endl;
2592- exit (1);
2593- }
2594-
2595- if (!ValueHolder::Default ()->hasValue (compPrintf ("%s_index_%lu", typeid (TypenamesPluginABI1).name (), 1)))
2596- {
2597- std::cout << "FAIL: ValueHolder does not have value " << compPrintf ("%s_index_%lu", typeid (TypenamesPluginABI1).name (), 0) << std::endl;
2598- exit (1);
2599- }
2600-
2601- if (!ValueHolder::Default ()->hasValue (compPrintf ("%s_index_%lu", typeid (TypenamesPluginABI2).name (), 2)))
2602- {
2603- std::cout << "FAIL: ValueHolder does not have value " << compPrintf ("%s_index_%lu", typeid (TypenamesPluginABI2).name (), 2) << std::endl;
2604- exit (1);
2605- }
2606-
2607- std::cout << "PASS: Typenames" << std::endl;
2608+class TypenamesPlugin: public Plugin, public PluginClassHandler<TypenamesPlugin,
2609+ Base>
2610+{
2611+public:
2612+ TypenamesPlugin (Base *);
2613+};
2614+
2615+class TypenamesPluginABI1: public Plugin, public PluginClassHandler<
2616+ TypenamesPluginABI1, Base, 1>
2617+{
2618+public:
2619+ TypenamesPluginABI1 (Base *);
2620+};
2621+
2622+class TypenamesPluginABI2: public Plugin, public PluginClassHandler<
2623+ TypenamesPluginABI2, Base, 2>
2624+{
2625+public:
2626+ TypenamesPluginABI2 (Base *);
2627+};
2628+
2629+TypenamesPlugin::TypenamesPlugin (Base *base) :
2630+ Plugin(base), PluginClassHandler<TypenamesPlugin, Base>(base)
2631+{
2632+}
2633+
2634+TypenamesPluginABI1::TypenamesPluginABI1 (Base *base) :
2635+ Plugin(base), PluginClassHandler<TypenamesPluginABI1, Base, 1>(base)
2636+{
2637+}
2638+
2639+TypenamesPluginABI2::TypenamesPluginABI2 (Base *base) :
2640+ Plugin(base), PluginClassHandler<TypenamesPluginABI2, Base, 2>(base)
2641+{
2642+}
2643+
2644+TEST_F( CompizPCHTest, TestTypenames)
2645+{
2646+ std::list<Plugin *>::iterator it;
2647+
2648+ bases.push_back(new Base());
2649+ plugins.push_back(new TypenamesPlugin(bases.back()));
2650+ bases.push_back(new Base());
2651+ plugins.push_back(new TypenamesPluginABI1(bases.back()));
2652+ bases.push_back(new Base());
2653+ plugins.push_back(new TypenamesPluginABI2(bases.back()));
2654+
2655+ if (!ValueHolder::Default()->hasValue(
2656+ compPrintf("%s_index_%lu", typeid(TypenamesPlugin).name(), 0)))
2657+ {
2658+ FAIL() << "ValueHolder does not have value "
2659+ << compPrintf("%s_index_%lu", typeid(TypenamesPlugin).name(), 0);
2660+ }
2661+
2662+ if (!ValueHolder::Default()->hasValue(
2663+ compPrintf("%s_index_%lu", typeid(TypenamesPluginABI1).name(), 1)))
2664+ {
2665+ FAIL()
2666+ << "ValueHolder does not have value "
2667+ << compPrintf("%s_index_%lu",
2668+ typeid(TypenamesPluginABI1).name(), 0);
2669+ }
2670+
2671+ if (!ValueHolder::Default()->hasValue(
2672+ compPrintf("%s_index_%lu", typeid(TypenamesPluginABI2).name(), 2)))
2673+ {
2674+ FAIL()
2675+ << "FAIL: ValueHolder does not have value "
2676+ << compPrintf("%s_index_%lu",
2677+ typeid(TypenamesPluginABI2).name(), 2);
2678+ }
2679+
2680 }
2681
2682=== modified file 'src/privatescreen.h'
2683--- src/privatescreen.h 2011-10-10 14:56:06 +0000
2684+++ src/privatescreen.h 2011-12-20 02:49:24 +0000
2685@@ -103,6 +103,20 @@
2686
2687 namespace compiz
2688 {
2689+namespace core
2690+{
2691+namespace screen
2692+{
2693+ inline int wraparound_mod (int a, int b)
2694+ {
2695+ if (a < 0)
2696+ return (b - ((-a - 1) % (b))) - 1;
2697+ else
2698+ return a % b;
2699+ };
2700+}
2701+}
2702+
2703 namespace X11
2704 {
2705 class PendingEvent {
2706
2707=== modified file 'src/screen.cpp'
2708--- src/screen.cpp 2011-10-13 14:28:30 +0000
2709+++ src/screen.cpp 2011-12-20 02:49:24 +0000
2710@@ -3502,11 +3502,11 @@
2711 CompPoint pnt;
2712
2713 tx = priv->vp.x () - tx;
2714- tx = MOD (tx, priv->vpSize.width ());
2715+ tx = compiz::core::screen::wraparound_mod (tx, priv->vpSize.width ());
2716 tx -= priv->vp.x ();
2717
2718 ty = priv->vp.y () - ty;
2719- ty = MOD (ty, priv->vpSize.height ());
2720+ ty = compiz::core::screen::wraparound_mod (ty, priv->vpSize.height ());
2721 ty -= priv->vp.y ();
2722
2723 if (!tx && !ty)
2724
2725=== modified file 'src/session.cpp'
2726--- src/session.cpp 2011-03-16 20:27:14 +0000
2727+++ src/session.cpp 2011-12-20 02:49:24 +0000
2728@@ -27,8 +27,6 @@
2729 # include <config.h>
2730 #endif
2731
2732-#include <compiz.h>
2733-
2734 #include <stdlib.h>
2735 #include <stdio.h>
2736 #include <poll.h>
2737
2738=== added directory 'src/string'
2739=== added file 'src/string/CMakeLists.txt'
2740--- src/string/CMakeLists.txt 1970-01-01 00:00:00 +0000
2741+++ src/string/CMakeLists.txt 2011-12-20 02:49:24 +0000
2742@@ -0,0 +1,35 @@
2743+INCLUDE_DIRECTORIES(
2744+ ${compiz_SOURCE_DIR}/include
2745+ ${CMAKE_CURRENT_SOURCE_DIR}/include
2746+
2747+ ${Boost_INCLUDE_DIRS}
2748+)
2749+
2750+SET( PUBLIC_HEADERS )
2751+SET( PRIVATE_HEADERS )
2752+
2753+SET( SRCS ${CMAKE_CURRENT_SOURCE_DIR}/src/string.cpp )
2754+
2755+ADD_LIBRARY(
2756+ compiz_string STATIC
2757+
2758+ ${SRCS}
2759+
2760+ ${PUBLIC_HEADERS}
2761+ ${PRIVATE_HEADERS}
2762+)
2763+
2764+ADD_SUBDIRECTORY( ${CMAKE_CURRENT_SOURCE_DIR}/tests )
2765+
2766+SET_TARGET_PROPERTIES(
2767+ compiz_string PROPERTIES
2768+ PUBLIC_HEADER "${PUBLIC_HEADERS}"
2769+)
2770+
2771+INSTALL(
2772+ TARGETS compiz_string
2773+ RUNTIME DESTINATION bin
2774+ LIBRARY DESTINATION lib
2775+ ARCHIVE DESTINATION lib
2776+ PUBLIC_HEADER DESTINATION include/compiz
2777+)
2778
2779=== added directory 'src/string/include'
2780=== added directory 'src/string/src'
2781=== renamed file 'src/string.cpp' => 'src/string/src/string.cpp'
2782--- src/string.cpp 2009-08-08 05:52:48 +0000
2783+++ src/string/src/string.cpp 2011-12-20 02:49:24 +0000
2784@@ -23,12 +23,12 @@
2785 * Authors: Dennis Kasprzyk <onestone@compiz-fusion.org>
2786 */
2787
2788-#include <compiz.h>
2789-
2790 #include <cstring>
2791 #include <cstdarg>
2792 #include <cstdio>
2793
2794+#include <core/string.h>
2795+
2796 CompString compPrintf (const char *format, ...)
2797 {
2798 va_list ap;
2799
2800=== added directory 'src/string/tests'
2801=== added file 'src/string/tests/CMakeLists.txt'
2802--- src/string/tests/CMakeLists.txt 1970-01-01 00:00:00 +0000
2803+++ src/string/tests/CMakeLists.txt 2011-12-20 02:49:24 +0000
2804@@ -0,0 +1,20 @@
2805+include_directories(
2806+ ${CMAKE_CURRENT_SOURCE_DIR}
2807+)
2808+
2809+add_executable(
2810+ compiz_string_test
2811+
2812+ ${CMAKE_CURRENT_SOURCE_DIR}/printf/src/test-string-printf.cpp
2813+)
2814+
2815+target_link_libraries(
2816+ compiz_string_test
2817+
2818+ compiz_string
2819+
2820+ ${GTEST_BOTH_LIBRARIES}
2821+ ${CMAKE_THREAD_LIBS_INIT} # Link in pthread.
2822+)
2823+
2824+add_test( compiz_string_test compiz_string_test )
2825
2826=== added directory 'src/string/tests/printf'
2827=== added directory 'src/string/tests/printf/src'
2828=== added file 'src/string/tests/printf/src/test-string-printf.cpp'
2829--- src/string/tests/printf/src/test-string-printf.cpp 1970-01-01 00:00:00 +0000
2830+++ src/string/tests/printf/src/test-string-printf.cpp 2011-12-20 02:49:24 +0000
2831@@ -0,0 +1,161 @@
2832+/*
2833+ * Copyright © 2011 Canonical Ltd.
2834+ *
2835+ * Permission to use, copy, modify, distribute, and sell this software
2836+ * and its documentation for any purpose is hereby granted without
2837+ * fee, provided that the above copyright notice appear in all copies
2838+ * and that both that copyright notice and this permission notice
2839+ * appear in supporting documentation, and that the name of
2840+ * Canonical Ltd. not be used in advertising or publicity pertaining to
2841+ * distribution of the software without specific, written prior permission.
2842+ * Canonical Ltd. makes no representations about the suitability of this
2843+ * software for any purpose. It is provided "as is" without express or
2844+ * implied warranty.
2845+ *
2846+ * CANONICAL, LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
2847+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
2848+ * NO EVENT SHALL CANONICAL, LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
2849+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
2850+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
2851+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
2852+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
2853+ *
2854+ * Authored by: Sam Spilsbury <sam.spilsbury@canonical.com>
2855+ */
2856+
2857+#include <core/string.h>
2858+
2859+#include <gtest/gtest.h>
2860+
2861+#include <string>
2862+#include <iostream>
2863+#include <map>
2864+#include <boost/shared_ptr.hpp>
2865+#include <boost/pointer_cast.hpp>
2866+#include <typeinfo>
2867+
2868+namespace compiz
2869+{
2870+namespace string
2871+{
2872+namespace printf_test
2873+{
2874+
2875+class Value
2876+{
2877+public:
2878+ virtual ~Value ();
2879+
2880+ typedef boost::shared_ptr<Value> Ptr;
2881+
2882+protected:
2883+
2884+ Value ()
2885+ {
2886+ }
2887+ ;
2888+
2889+ void *v;
2890+};
2891+
2892+template<typename T>
2893+class TValue: public Value
2894+{
2895+public:
2896+ TValue (const T &);
2897+ ~TValue ();
2898+
2899+ const T & value ();
2900+};
2901+
2902+template<typename T>
2903+TValue<T>::TValue (const T &av)
2904+{
2905+ v = new T(av);
2906+}
2907+
2908+template<typename T>
2909+TValue<T>::~TValue ()
2910+{
2911+ delete (reinterpret_cast<T *>(v));
2912+}
2913+
2914+template<typename T>
2915+const T &
2916+TValue<T>::value ()
2917+{
2918+ return *(reinterpret_cast<T *>(v));
2919+}
2920+
2921+Value::~Value ()
2922+{
2923+}
2924+
2925+CompString get_format (const CompString &fmt, Value::Ptr v)
2926+{
2927+ if (fmt == "%i" || fmt == "%d")
2928+ return compPrintf(fmt.c_str(),
2929+ (boost::shared_static_cast<TValue<int> >(v))->value());
2930+ if (fmt == "%f")
2931+ return compPrintf(fmt.c_str(),
2932+ (boost::shared_static_cast<TValue<float> >(v))->value());
2933+ if (fmt == "%s")
2934+ return compPrintf(
2935+ fmt.c_str(),
2936+ (boost::shared_static_cast<TValue<std::string> >(v))->value().c_str());
2937+ if (fmt == "%x")
2938+ return compPrintf(fmt.c_str(),
2939+ (boost::shared_static_cast<TValue<int> >(v))->value());
2940+
2941+ return "not_reached";
2942+}
2943+
2944+}
2945+}
2946+}
2947+
2948+TEST(CompizString,PrintfTest)
2949+{
2950+ CompString s1;
2951+ CompString s2;
2952+ std::map<CompString, compiz::string::printf_test::Value::Ptr> formatValues;
2953+ std::map<CompString, CompString> formatStrings;
2954+
2955+ s1 = "foo";
2956+
2957+ const char *other_foo = "foo";
2958+ s2 = compPrintf ("%s", other_foo);
2959+
2960+ ASSERT_EQ(s1, s2);
2961+
2962+ s1 = "3";
2963+ s2 = compPrintf ("%i", 3, NULL);
2964+
2965+ ASSERT_EQ(s1, s2);
2966+
2967+ s1 = "3.012600";
2968+ s2 = compPrintf ("%f", 3.0126, NULL);
2969+
2970+ ASSERT_EQ(s1, s2);
2971+
2972+ s1 = "0x4f567";
2973+ s2 = compPrintf ("0x%x", 0x4f567, NULL);
2974+
2975+ ASSERT_EQ(s1, s2);
2976+
2977+ formatValues["%i"] = boost::shared_static_cast <compiz::string::printf_test::Value> (compiz::string::printf_test::Value::Ptr (new compiz::string::printf_test::TValue<int> (6)));
2978+ formatStrings["%i"] = CompString ("6");
2979+ formatValues["%f"] = boost::shared_static_cast <compiz::string::printf_test::Value> (compiz::string::printf_test::Value::Ptr (new compiz::string::printf_test::TValue<float> (6.532)));
2980+ formatStrings["%f"] = CompString ("6.532000");
2981+ formatValues["%x"] = boost::shared_static_cast <compiz::string::printf_test::Value> (compiz::string::printf_test::Value::Ptr (new compiz::string::printf_test::TValue<int> (0x34fe5aa)));
2982+ formatStrings["%x"] = CompString ("34fe5aa");
2983+ formatValues["%d"] = boost::shared_static_cast <compiz::string::printf_test::Value> (compiz::string::printf_test::Value::Ptr (new compiz::string::printf_test::TValue<int> (2)));
2984+ formatStrings["%d"] = CompString ("2");
2985+
2986+ for (std::map <CompString, CompString>::iterator it = formatStrings.begin ();
2987+ it != formatStrings.end (); it++)
2988+ {
2989+ CompString str = compiz::string::printf_test::get_format (it->first, formatValues[it->first]);
2990+ ASSERT_EQ(str, it->second);
2991+ }
2992+}
2993
2994=== added file 'src/string/tests/test-string.cpp'
2995--- src/string/tests/test-string.cpp 1970-01-01 00:00:00 +0000
2996+++ src/string/tests/test-string.cpp 2011-12-20 02:49:24 +0000
2997@@ -0,0 +1,47 @@
2998+/*
2999+ * Copyright © 2011 Canonical Ltd.
3000+ *
3001+ * Permission to use, copy, modify, distribute, and sell this software
3002+ * and its documentation for any purpose is hereby granted without
3003+ * fee, provided that the above copyright notice appear in all copies
3004+ * and that both that copyright notice and this permission notice
3005+ * appear in supporting documentation, and that the name of
3006+ * Canonical Ltd. not be used in advertising or publicity pertaining to
3007+ * distribution of the software without specific, written prior permission.
3008+ * Canonical Ltd. makes no representations about the suitability of this
3009+ * software for any purpose. It is provided "as is" without express or
3010+ * implied warranty.
3011+ *
3012+ * CANONICAL, LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
3013+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
3014+ * NO EVENT SHALL CANONICAL, LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
3015+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
3016+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
3017+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
3018+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
3019+ *
3020+ * Authored by: Sam Spilsbury <sam.spilsbury@canonical.com>
3021+ */
3022+
3023+#include "test-string.h"
3024+
3025+CompStringTest::CompStringTest ()
3026+{
3027+}
3028+
3029+CompStringTest::~CompStringTest ()
3030+{
3031+}
3032+
3033+int
3034+main (int argc, char **argv)
3035+{
3036+ CompStringTest *cst = static_cast <CompStringTest *> (getTestObject ());
3037+ bool ret = false;
3038+
3039+ ret = cst->test ();
3040+
3041+ delete cst;
3042+
3043+ return ret ? 0 : 1;
3044+}
3045
3046=== added file 'src/string/tests/test-string.h'
3047--- src/string/tests/test-string.h 1970-01-01 00:00:00 +0000
3048+++ src/string/tests/test-string.h 2011-12-20 02:49:24 +0000
3049@@ -0,0 +1,52 @@
3050+/*
3051+ * Copyright © 2011 Canonical Ltd.
3052+ *
3053+ * Permission to use, copy, modify, distribute, and sell this software
3054+ * and its documentation for any purpose is hereby granted without
3055+ * fee, provided that the above copyright notice appear in all copies
3056+ * and that both that copyright notice and this permission notice
3057+ * appear in supporting documentation, and that the name of
3058+ * Canonical Ltd. not be used in advertising or publicity pertaining to
3059+ * distribution of the software without specific, written prior permission.
3060+ * Canonical Ltd. makes no representations about the suitability of this
3061+ * software for any purpose. It is provided "as is" without express or
3062+ * implied warranty.
3063+ *
3064+ * CANONICAL, LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
3065+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
3066+ * NO EVENT SHALL CANONICAL, LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
3067+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
3068+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
3069+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
3070+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
3071+ *
3072+ * Authored by: Sam Spilsbury <sam.spilsbury@canonical.com>
3073+ */
3074+
3075+#ifndef _COMPIZ_TEST_STRING_H
3076+#define _COMPIZ_TEST_STRING_H
3077+
3078+#include <core/string.h>
3079+
3080+class CompStringTest
3081+{
3082+public:
3083+
3084+ CompStringTest ();
3085+ virtual ~CompStringTest ();
3086+
3087+ virtual bool test () = 0;
3088+};
3089+
3090+class CompStringTestPrintf :
3091+ public CompStringTest
3092+{
3093+public:
3094+
3095+ bool test ();
3096+};
3097+
3098+CompStringTest *
3099+getTestObject ();
3100+
3101+#endif
3102
3103=== added directory 'src/timer'
3104=== added file 'src/timer/CMakeLists.txt'
3105--- src/timer/CMakeLists.txt 1970-01-01 00:00:00 +0000
3106+++ src/timer/CMakeLists.txt 2011-12-20 02:49:24 +0000
3107@@ -0,0 +1,70 @@
3108+pkg_check_modules(
3109+ GLIBMM
3110+ REQUIRED
3111+ glibmm-2.4
3112+)
3113+
3114+INCLUDE_DIRECTORIES(
3115+ ${CMAKE_CURRENT_SOURCE_DIR}/include
3116+ ${CMAKE_CURRENT_SOURCE_DIR}/src
3117+
3118+ ${compiz_SOURCE_DIR}/include
3119+
3120+ ${Boost_INCLUDE_DIRS}
3121+
3122+ ${GLIBMM_INCLUDE_DIRS}
3123+)
3124+
3125+LINK_DIRECTORIES( ${GLIBMM_LIBRARY_DIRS} )
3126+
3127+SET(
3128+ PUBLIC_HEADERS
3129+ ${CMAKE_CURRENT_SOURCE_DIR}/include/core/timer.h
3130+ ${CMAKE_CURRENT_SOURCE_DIR}/include/core/timeouthandler.h
3131+)
3132+
3133+SET(
3134+ PRIVATE_HEADERS
3135+ ${CMAKE_CURRENT_SOURCE_DIR}/src/privatetimeouthandler.h
3136+ ${CMAKE_CURRENT_SOURCE_DIR}/src/privatetimeoutsource.h
3137+ ${CMAKE_CURRENT_SOURCE_DIR}/src/privatetimer.h
3138+
3139+)
3140+
3141+SET(
3142+ SRCS
3143+ ${CMAKE_CURRENT_SOURCE_DIR}/src/timeouthandler.cpp
3144+ ${CMAKE_CURRENT_SOURCE_DIR}/src/timer.cpp
3145+)
3146+
3147+ADD_LIBRARY(
3148+ compiz_timer STATIC
3149+
3150+ ${SRCS}
3151+
3152+ ${PUBLIC_HEADERS}
3153+ ${PRIVATE_HEADERS}
3154+)
3155+
3156+ADD_SUBDIRECTORY( ${CMAKE_CURRENT_SOURCE_DIR}/tests )
3157+
3158+SET_TARGET_PROPERTIES(
3159+ compiz_timer PROPERTIES
3160+ PUBLIC_HEADER "${PUBLIC_HEADERS}"
3161+)
3162+
3163+INSTALL(
3164+ TARGETS compiz_timer
3165+ RUNTIME DESTINATION bin
3166+ LIBRARY DESTINATION lib
3167+ ARCHIVE DESTINATION lib
3168+ PUBLIC_HEADER DESTINATION include/compiz
3169+)
3170+
3171+
3172+
3173+TARGET_LINK_LIBRARIES(
3174+ compiz_timer
3175+
3176+ ${GLIBMM_LIBRARIES}
3177+)
3178
3179=== added directory 'src/timer/include'
3180=== added directory 'src/timer/include/core'
3181=== renamed file 'include/core/timeouthandler.h' => 'src/timer/include/core/timeouthandler.h'
3182=== renamed file 'include/core/timer.h' => 'src/timer/include/core/timer.h'
3183--- include/core/timer.h 2011-07-04 18:17:44 +0000
3184+++ src/timer/include/core/timer.h 2011-12-20 02:49:24 +0000
3185@@ -32,6 +32,24 @@
3186
3187 class CompTimeoutSource;
3188 class PrivateTimer;
3189+
3190+namespace compiz {
3191+namespace core {
3192+namespace timer {
3193+
3194+ inline int timeval_diff (struct timeval *tv1, struct timeval *tv2)
3195+ {
3196+ if (tv1->tv_sec == tv2->tv_sec || tv1->tv_usec >= tv2->tv_usec)
3197+ return (((tv1->tv_sec - tv2->tv_sec) * 1000000) +
3198+ (tv1->tv_usec - tv2->tv_usec)) / 1000;
3199+ else
3200+ return (((tv1->tv_sec - 1 - tv2->tv_sec) * 1000000) +
3201+ (1000000 + tv1->tv_usec - tv2->tv_usec)) / 1000;
3202+ }
3203+}
3204+}
3205+}
3206+
3207 /**
3208 * A simple timer for use with invoking a CallBack during a timed duration.
3209 */
3210
3211=== added directory 'src/timer/src'
3212=== renamed file 'src/privatetimeouthandler.h' => 'src/timer/src/privatetimeouthandler.h'
3213=== renamed file 'src/privatetimeoutsource.h' => 'src/timer/src/privatetimeoutsource.h'
3214=== renamed file 'src/privatetimer.h' => 'src/timer/src/privatetimer.h'
3215=== renamed file 'src/timeouthandler.cpp' => 'src/timer/src/timeouthandler.cpp'
3216=== renamed file 'src/timer.cpp' => 'src/timer/src/timer.cpp'
3217=== added directory 'src/timer/tests'
3218=== renamed file 'tests/timer/CMakeLists.txt' => 'src/timer/tests/CMakeLists.txt'
3219--- tests/timer/CMakeLists.txt 2011-07-06 18:58:47 +0000
3220+++ src/timer/tests/CMakeLists.txt 2011-12-20 02:49:24 +0000
3221@@ -1,15 +1,76 @@
3222-include (CompizCommon)
3223-include (FindPkgConfig)
3224-
3225-pkg_check_modules (COMPIZ_TEST_TIMER glibmm-2.4)
3226-
3227-if (COMPIZ_TEST_TIMER_FOUND)
3228-
3229- set (COMPIZ_TIMER_TEST_BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
3230-
3231- add_subdirectory (callbacks)
3232- add_subdirectory (diffs)
3233- add_subdirectory (set-values)
3234- add_subdirectory (while-calling)
3235-
3236-endif (COMPIZ_TEST_TIMER_FOUND)
3237+include_directories( ${CMAKE_CURRENT_SOURCE_DIR} )
3238+
3239+add_library(
3240+ compiz_timer_test
3241+
3242+ ${CMAKE_CURRENT_SOURCE_DIR}/test-timer.cpp
3243+)
3244+
3245+add_executable(
3246+ compiz_timer_callbacks
3247+
3248+ ${CMAKE_CURRENT_SOURCE_DIR}/callbacks/src/test-timer-callbacks.cpp
3249+)
3250+
3251+add_executable(
3252+ compiz_timer_diffs
3253+
3254+ ${CMAKE_CURRENT_SOURCE_DIR}/diffs/src/test-timer-diffs.cpp
3255+)
3256+
3257+add_executable(
3258+ compiz_timer_set-values
3259+
3260+ ${CMAKE_CURRENT_SOURCE_DIR}/set-values/src/test-timer-set-values.cpp
3261+)
3262+
3263+add_executable(
3264+ compiz_timer_while-calling
3265+
3266+ ${CMAKE_CURRENT_SOURCE_DIR}/while-calling/src/test-timer-set-times-while-calling.cpp
3267+)
3268+
3269+target_link_libraries(
3270+ compiz_timer_callbacks
3271+ compiz_timer_test
3272+
3273+ compiz_timer
3274+
3275+ ${GTEST_BOTH_LIBRARIES}
3276+ ${CMAKE_THREAD_LIBS_INIT} # Link in pthread.
3277+)
3278+
3279+target_link_libraries(
3280+ compiz_timer_diffs
3281+ compiz_timer_test
3282+
3283+ compiz_timer
3284+
3285+ ${GTEST_BOTH_LIBRARIES}
3286+ ${CMAKE_THREAD_LIBS_INIT} # Link in pthread.
3287+)
3288+
3289+target_link_libraries(
3290+ compiz_timer_set-values
3291+ compiz_timer_test
3292+
3293+ compiz_timer
3294+
3295+ ${GTEST_BOTH_LIBRARIES}
3296+ ${CMAKE_THREAD_LIBS_INIT} # Link in pthread.
3297+)
3298+
3299+target_link_libraries(
3300+ compiz_timer_while-calling
3301+ compiz_timer_test
3302+
3303+ compiz_timer
3304+
3305+ ${GTEST_BOTH_LIBRARIES}
3306+ ${CMAKE_THREAD_LIBS_INIT} # Link in pthread.
3307+)
3308+
3309+add_test( compiz_timer_callbacks compiz_timer_callbacks )
3310+add_test( compiz_timer_diffs compiz_timer_diffs )
3311+add_test( compiz_timer_set-values compiz_timer_set-values )
3312+add_test( compiz_timer_while-calling compiz_timer_while-calling )
3313
3314=== renamed directory 'tests/timer/callbacks' => 'src/timer/tests/callbacks'
3315=== added directory 'src/timer/tests/callbacks/src'
3316=== renamed file 'tests/timer/callbacks/test-timer-callbacks.cpp' => 'src/timer/tests/callbacks/src/test-timer-callbacks.cpp'
3317--- tests/timer/callbacks/test-timer-callbacks.cpp 2011-11-20 08:50:20 +0000
3318+++ src/timer/tests/callbacks/src/test-timer-callbacks.cpp 2011-12-20 02:49:24 +0000
3319@@ -28,6 +28,7 @@
3320
3321 static time_t starttime = 0;
3322
3323+<<<<<<< TREE
3324 bool
3325 CompTimerTestCallbacks::cb (int timernum)
3326 {
3327@@ -153,4 +154,141 @@
3328 std::cout << "FAIL: timer with the most time is not at the back" << std::endl;
3329 exit (1);
3330 }
3331+=======
3332+#include <pthread.h>
3333+
3334+class CompTimerTestCallback: public CompTimerTest
3335+{
3336+public:
3337+ CompTimerTestCallback () :
3338+ mlistGuard(PTHREAD_MUTEX_INITIALIZER)
3339+ {
3340+
3341+ }
3342+protected:
3343+
3344+ pthread_mutex_t mlistGuard;
3345+
3346+ static void* run (void* cb)
3347+ {
3348+ if (cb == NULL)
3349+ {
3350+ return NULL;
3351+ }
3352+ static_cast<CompTimerTestCallback*>(cb)->ml->run();
3353+ return NULL;
3354+ }
3355+
3356+ pthread_t mmainLoopThread;
3357+ std::list<int> mtriggeredTimers;
3358+
3359+ bool cb (int num)
3360+ {
3361+ std::cout << "cb: " << num << std::endl;
3362+ pthread_mutex_lock( &mlistGuard );
3363+ mtriggeredTimers.push_back(num);
3364+ pthread_mutex_unlock( &mlistGuard );
3365+ return (true);
3366+ }
3367+
3368+ void SetUp ()
3369+ {
3370+ CompTimerTest::SetUp();
3371+ mtriggeredTimers.clear();
3372+
3373+ /* Test 2: Adding timers */
3374+ timers.push_back(new CompTimer());
3375+ timers.front()->setTimes(100, 110);
3376+ timers.front()->setCallback(
3377+ boost::bind(&CompTimerTestCallback::cb, this, 1));
3378+
3379+ /* TimeoutHandler::timers should be empty */
3380+ if (!TimeoutHandler::Default()->timers().empty())
3381+ {
3382+ FAIL() << "timers list is not empty";
3383+ }
3384+
3385+ timers.push_back(new CompTimer());
3386+ timers.back()->setTimes(50, 90);
3387+ timers.back()->setCallback(
3388+ boost::bind(&CompTimerTestCallback::cb, this, 2));
3389+
3390+ /* Start both timers */
3391+ timers.front()->start();
3392+ timers.back()->start();
3393+
3394+ /* TimeoutHandler::timers should have the timer that
3395+ * is going to trigger first at the front of the
3396+ * list and the last timer at the back */
3397+ if (TimeoutHandler::Default()->timers().front() != timers.back())
3398+ {
3399+ RecordProperty("TimeoutHandler::Default ().size",
3400+ TimeoutHandler::Default()->timers().size());
3401+ RecordProperty("TimeoutHandler::Default ().front->minLeft",
3402+ TimeoutHandler::Default()->timers().front()->minLeft());
3403+ RecordProperty("TimeoutHandler::Default ().front->maxLeft",
3404+ TimeoutHandler::Default()->timers().front()->maxLeft());
3405+ RecordProperty("TimeoutHandler::Default ().front->minTime",
3406+ TimeoutHandler::Default()->timers().front()->minTime());
3407+ RecordProperty("TimeoutHandler::Default ().front->maxTime",
3408+ TimeoutHandler::Default()->timers().front()->maxTime());
3409+ RecordProperty("TimeoutHandler::Default ().back->minLeft",
3410+ TimeoutHandler::Default()->timers().back()->minLeft());
3411+ RecordProperty("TimeoutHandler::Default ().back->maxLeft",
3412+ TimeoutHandler::Default()->timers().back()->maxLeft());
3413+ RecordProperty("TimeoutHandler::Default ().back->minTime",
3414+ TimeoutHandler::Default()->timers().back()->minTime());
3415+ RecordProperty("TimeoutHandler::Default ().back->maxTime",
3416+ TimeoutHandler::Default()->timers().back()->maxTime());
3417+ FAIL() << "timer with the least time is not at the front";
3418+ }
3419+
3420+ if (TimeoutHandler::Default()->timers().back() != timers.front())
3421+ {
3422+ FAIL() << "timer with the most time is not at the back";
3423+ }
3424+
3425+ ASSERT_EQ(
3426+ 0,
3427+ pthread_create(&mmainLoopThread, NULL, CompTimerTestCallback::run, this));
3428+
3429+ ::sleep(1);
3430+ }
3431+
3432+ void TearDown ()
3433+ {
3434+ ml->quit();
3435+ pthread_join(mmainLoopThread, NULL);
3436+
3437+ CompTimerTest::TearDown();
3438+ }
3439+};
3440+
3441+TEST_F( CompTimerTestCallback, TimerOrder )
3442+{
3443+ RecordProperty("mtriggeredTimers.front()", mtriggeredTimers.front());
3444+ RecordProperty("mtriggeredTimers.back()", mtriggeredTimers.back());
3445+
3446+ std::list<int>::iterator it = mtriggeredTimers.begin();
3447+ ++it;
3448+
3449+ int lastTimer = mtriggeredTimers.front();
3450+
3451+ while (it != mtriggeredTimers.end())
3452+ {
3453+ std::cout << *it;
3454+ switch (lastTimer)
3455+ {
3456+ case 1:
3457+ ASSERT_EQ(2, *it);
3458+ break;
3459+ case 2:
3460+ ASSERT_EQ(1, *it);
3461+ break;
3462+ }
3463+ lastTimer = *it;
3464+ ++it;
3465+ }
3466+ ASSERT_EQ(mtriggeredTimers.front(), 2);
3467+>>>>>>> MERGE-SOURCE
3468 }
3469
3470=== renamed directory 'tests/timer/diffs' => 'src/timer/tests/diffs'
3471=== added directory 'src/timer/tests/diffs/src'
3472=== added file 'src/timer/tests/diffs/src/test-timer-diffs.cpp'
3473--- src/timer/tests/diffs/src/test-timer-diffs.cpp 1970-01-01 00:00:00 +0000
3474+++ src/timer/tests/diffs/src/test-timer-diffs.cpp 2011-12-20 02:49:24 +0000
3475@@ -0,0 +1,117 @@
3476+/*
3477+ * Copyright © 2011 Canonical Ltd.
3478+ *
3479+ * Permission to use, copy, modify, distribute, and sell this software
3480+ * and its documentation for any purpose is hereby granted without
3481+ * fee, provided that the above copyright notice appear in all copies
3482+ * and that both that copyright notice and this permission notice
3483+ * appear in supporting documentation, and that the name of
3484+ * Canonical Ltd. not be used in advertising or publicity pertaining to
3485+ * distribution of the software without specific, written prior permission.
3486+ * Canonical Ltd. makes no representations about the suitability of this
3487+ * software for any purpose. It is provided "as is" without express or
3488+ * implied warranty.
3489+ *
3490+ * CANONICAL, LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
3491+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
3492+ * NO EVENT SHALL CANONICAL, LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
3493+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
3494+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
3495+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
3496+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
3497+ *
3498+ * Authored by: Sam Spilsbury <sam.spilsbury@canonical.com>
3499+ */
3500+
3501+#include "test-timer.h"
3502+
3503+#include <pthread.h>
3504+
3505+class CompTimerTestDiffs: public CompTimerTest
3506+{
3507+protected:
3508+
3509+ static void* run (void* cb)
3510+ {
3511+ if (cb == NULL)
3512+ {
3513+ return NULL;
3514+ }
3515+ static_cast<CompTimerTestDiffs*>(cb)->ml->run();
3516+ return NULL;
3517+ }
3518+
3519+ pthread_t mmainLoopThread;
3520+ std::list<int> mtriggeredTimers;
3521+
3522+ bool cb (int timernum, CompTimer* t1, CompTimer* t2, CompTimer* t3)
3523+ {
3524+ if (timernum == 1 || timernum == 2 || timernum == 3)
3525+ {
3526+ RecordProperty("executing timer", timernum);
3527+ RecordProperty("t1->minLeft", t1->minLeft());
3528+ RecordProperty("t1->maxLeft", t1->maxLeft());
3529+ RecordProperty("t1->minTime", t1->minTime());
3530+ RecordProperty("t1->maxTime", t1->maxTime());
3531+
3532+ RecordProperty("t3->minLeft", t3->minLeft());
3533+ RecordProperty("t3->maxLeft", t3->maxLeft());
3534+ RecordProperty("t3->minTime", t3->minTime());
3535+ RecordProperty("t3->maxTime", t3->maxTime());
3536+
3537+ RecordProperty("t3->minLeft", t3->minLeft());
3538+ RecordProperty("t3->maxLeft", t3->maxLeft());
3539+ RecordProperty("t3->minTime", t3->minTime());
3540+ RecordProperty("t3->maxTime", t3->maxTime());
3541+
3542+ }
3543+
3544+ return false;
3545+ }
3546+
3547+ void SetUp ()
3548+ {
3549+ CompTimerTest::SetUp();
3550+ mtriggeredTimers.clear();
3551+
3552+ CompTimer *t1, *t2, *t3;
3553+
3554+ t1 = new CompTimer();
3555+ t2 = new CompTimer();
3556+ t3 = new CompTimer();
3557+
3558+ timers.push_back(t1);
3559+ timers.push_back(t2);
3560+ timers.push_back(t3);
3561+
3562+ t1->setCallback(
3563+ boost::bind(&CompTimerTestDiffs::cb, this, 1, t1, t2, t3));
3564+ t1->setTimes(1000, 1100);
3565+ t1->start();
3566+ t2->setCallback(
3567+ boost::bind(&CompTimerTestDiffs::cb, this, 2, t1, t2, t3));
3568+ t2->setTimes(2000, 2100);
3569+ t2->start();
3570+ t3->setCallback(
3571+ boost::bind(&CompTimerTestDiffs::cb, this, 3, t1, t2, t3));
3572+ t3->setTimes(3000, 3100);
3573+ t3->start();
3574+
3575+ ASSERT_EQ(
3576+ 0,
3577+ pthread_create(&mmainLoopThread, NULL, CompTimerTestDiffs::run, this));
3578+
3579+ ::sleep(4);
3580+ }
3581+
3582+ void TearDown ()
3583+ {
3584+ ml->quit();
3585+ pthread_join(mmainLoopThread, NULL);
3586+
3587+ CompTimerTest::TearDown();
3588+ }
3589+};
3590+
3591+TEST_F(CompTimerTestDiffs,TimerDiffs) {}
3592+
3593
3594=== renamed directory 'tests/timer/set-values' => 'src/timer/tests/set-values'
3595=== added directory 'src/timer/tests/set-values/src'
3596=== renamed file 'tests/timer/set-values/test-timer-set-values.cpp' => 'src/timer/tests/set-values/src/test-timer-set-values.cpp'
3597--- tests/timer/set-values/test-timer-set-values.cpp 2011-07-06 18:58:47 +0000
3598+++ src/timer/tests/set-values/src/test-timer-set-values.cpp 2011-12-20 02:49:24 +0000
3599@@ -25,115 +25,17 @@
3600
3601 #include "test-timer.h"
3602
3603-bool
3604-CompTimerTestSetValues::cb (int timernum)
3605-{
3606- if (timernum == 3)
3607- {
3608- ml->quit ();
3609- std::cout << "PASS: testing values" << std::endl;
3610- }
3611- return false;
3612-}
3613-
3614-void
3615-CompTimerTestSetValues::precallback ()
3616-{
3617- CompTimer *t1, *t2, *t3;
3618-
3619- std::cout << "-= TEST: testing values" << std::endl;
3620-
3621- t1 = new CompTimer ();
3622-
3623- t1->setTimes (100, 90);
3624- t1->setCallback (boost::bind (&CompTimerTestSetValues::cb, this, 1));
3625- t1->start ();
3626-
3627- if (t1->minTime () != 100)
3628- {
3629- std::cout << "FAIL: min time was not the min value passed" << std::endl;
3630- exit (1);
3631- }
3632-
3633- if (t1->maxTime () != 100)
3634- {
3635- std::cout << "FAIL: max time was not the min value passed" << std::endl;
3636- exit (1);
3637- }
3638-
3639- if (t1->minLeft () != 100)
3640- {
3641- std::cout << "FAIL: min left was not the min value passed " << std::endl;
3642- exit (1);
3643- }
3644-
3645- if (t1->maxLeft () != 100)
3646- {
3647- std::cout << "FAIL: max left was not the min value passed" << std::endl;
3648- exit (1);
3649- }
3650-
3651- t2 = new CompTimer ();
3652-
3653- t2->setTimes (100, 110);
3654- t2->setCallback (boost::bind (&CompTimerTestSetValues::cb, this, 2));
3655- t2->start ();
3656-
3657- if (t2->minTime () != 100)
3658- {
3659- std::cout << "FAIL: min time was not the min value passed" << std::endl;
3660- exit (1);
3661- }
3662-
3663- if (t2->maxTime () != 110)
3664- {
3665- std::cout << "FAIL: max time was not the max value passed" << std::endl;
3666- exit (1);
3667- }
3668-
3669- if (t2->minLeft () != 100)
3670- {
3671- std::cout << "FAIL: min left was not the min value passed " << std::endl;
3672- exit (1);
3673- }
3674-
3675- if (t2->maxLeft () != 110)
3676- {
3677- std::cout << "FAIL: max left was not the max value passed" << std::endl;
3678- exit (1);
3679- }
3680-
3681- t3 = new CompTimer ();
3682-
3683- t3->setTimes (100);
3684- t3->setCallback (boost::bind (&CompTimerTestSetValues::cb, this, 3));
3685- t3->start ();
3686-
3687- if (t3->minTime () != 100)
3688- {
3689- std::cout << "FAIL: min time was not the value passed" << std::endl;
3690- exit (1);
3691- }
3692-
3693- if (t3->maxTime () != 100)
3694- {
3695- std::cout << "FAIL: max time was not the value passed" << std::endl;
3696- exit (1);
3697- }
3698-
3699- if (t3->minLeft () != 100)
3700- {
3701- std::cout << "FAIL: min left was not the value passed" << t3->minLeft () << std::endl;
3702- exit (1);
3703- }
3704-
3705- if (t3->maxLeft () != 100)
3706- {
3707- std::cout << "FAIL: max left was not the value passed" << std::endl;
3708- exit (1);
3709- }
3710-
3711- timers.push_back (t1);
3712- timers.push_back (t2);
3713- timers.push_back (t3);
3714+TEST_F(CompTimerTest, TimerSetValues)
3715+{
3716+ CompTimer* t1 = new CompTimer();
3717+
3718+ t1->setTimes(100, 90);
3719+ t1->start();
3720+
3721+ ASSERT_EQ( t1->minTime(), 100 );
3722+ ASSERT_EQ( t1->maxTime(), 100 );
3723+ ASSERT_EQ( t1->minLeft(), 100 );
3724+ ASSERT_EQ( t1->maxLeft(), 100 );
3725+
3726+ delete t1;
3727 }
3728
3729=== renamed file 'tests/timer/test-timer.cpp' => 'src/timer/tests/test-timer.cpp'
3730--- tests/timer/test-timer.cpp 2011-07-06 18:58:47 +0000
3731+++ src/timer/tests/test-timer.cpp 2011-12-20 02:49:24 +0000
3732@@ -26,36 +26,26 @@
3733 #include "test-timer.h"
3734
3735 CompTimerTest::CompTimerTest () :
3736- mc (Glib::MainContext::get_default ()),
3737- ml (Glib::MainLoop::create (mc, false)),
3738- ts (CompTimeoutSource::create (mc)),
3739- lastTimerTriggered (0)
3740+ mc(Glib::MainContext::get_default()),
3741+ ml(Glib::MainLoop::create(mc, false)),
3742+ ts(CompTimeoutSource::create(mc)),
3743+ lastTimerTriggered(0)
3744 {
3745 }
3746
3747 CompTimerTest::~CompTimerTest ()
3748 {
3749- while (timers.size ())
3750+ while (timers.size())
3751 {
3752- CompTimer *t = timers.front ();
3753+ CompTimer *t = timers.front();
3754
3755- timers.pop_front ();
3756+ timers.pop_front();
3757 delete t;
3758 }
3759 }
3760
3761-int
3762-main (int argc, char **argv)
3763+void CompTimerTest::SetUp ()
3764 {
3765- CompTimerTest *ctt = static_cast <CompTimerTest *> (new OBJECT ());
3766- TimeoutHandler *th = new TimeoutHandler ();
3767- TimeoutHandler::SetDefault (th);
3768-
3769- ctt->precallback ();
3770- ctt->ml->run ();
3771-
3772- delete ctt;
3773- delete th;
3774-
3775- return 0;
3776+ TimeoutHandler *th = new TimeoutHandler();
3777+ TimeoutHandler::SetDefault(th);
3778 }
3779
3780=== renamed file 'tests/timer/test-timer.h' => 'src/timer/tests/test-timer.h'
3781--- tests/timer/test-timer.h 2011-07-06 18:58:47 +0000
3782+++ src/timer/tests/test-timer.h 2011-12-20 02:49:24 +0000
3783@@ -26,64 +26,31 @@
3784 #ifndef _COMPIZ_TEST_TIMER_H
3785 #define _COMPIZ_TEST_TIMER_H
3786
3787+#include <gtest/gtest.h>
3788+
3789 #include <glibmm/main.h>
3790 #include <core/timer.h>
3791 #include <privatetimeouthandler.h>
3792 #include <privatetimeoutsource.h>
3793 #include <iostream>
3794 #include <boost/bind.hpp>
3795+#include <boost/shared_ptr.hpp>
3796
3797-class CompTimerTest
3798+class CompTimerTest : public ::testing::Test
3799 {
3800 public:
3801
3802 CompTimerTest ();
3803 virtual ~CompTimerTest ();
3804
3805+ virtual void SetUp();
3806+
3807 Glib::RefPtr <Glib::MainContext> mc;
3808 Glib::RefPtr <Glib::MainLoop> ml;
3809 Glib::RefPtr <CompTimeoutSource> ts;
3810 std::list <CompTimer *> timers;
3811
3812- virtual void precallback () = 0;
3813-
3814 int lastTimerTriggered;
3815 };
3816
3817-class CompTimerTestCallbacks :
3818- public CompTimerTest
3819-{
3820-public:
3821-
3822- void precallback ();
3823- bool cb (int timernum);
3824-};
3825-
3826-class CompTimerTestDiffs :
3827- public CompTimerTest
3828-{
3829-public:
3830-
3831- void precallback ();
3832- bool cb (int timernum, CompTimer *t1, CompTimer *t2, CompTimer *t3);
3833-};
3834-
3835-class CompTimerTestSetValues :
3836- public CompTimerTest
3837-{
3838-public:
3839-
3840- void precallback ();
3841- bool cb (int timernum);
3842-};
3843-
3844-class CompTimerTestSetCalling :
3845- public CompTimerTest
3846-{
3847-public:
3848-
3849- void precallback ();
3850- bool cb (int timernum, CompTimer *t1, CompTimer *t2, CompTimer *t3);
3851-};
3852-
3853 #endif
3854
3855=== renamed directory 'tests/timer/while-calling' => 'src/timer/tests/while-calling'
3856=== added directory 'src/timer/tests/while-calling/src'
3857=== renamed file 'tests/timer/while-calling/test-timer-set-times-while-calling.cpp' => 'src/timer/tests/while-calling/src/test-timer-set-times-while-calling.cpp'
3858--- tests/timer/while-calling/test-timer-set-times-while-calling.cpp 2011-07-06 18:58:47 +0000
3859+++ src/timer/tests/while-calling/src/test-timer-set-times-while-calling.cpp 2011-12-20 02:49:24 +0000
3860@@ -25,100 +25,118 @@
3861
3862 #include "test-timer.h"
3863
3864-bool
3865-CompTimerTestSetCalling::cb (int timernum, CompTimer *t1, CompTimer *t2, CompTimer *t3)
3866-{
3867- std::cout << "INFO: triggering timer " << timernum << std::endl;
3868-
3869- if (lastTimerTriggered == 0 && timernum == 1)
3870- {
3871- /* Change the timeout time of the second timer to be after the third */
3872- t2->setTimes (4000, 4100);
3873-
3874- /* Check if it is now at the back of the timeout list */
3875- if (TimeoutHandler::Default ()->timers ().back () != t2)
3876- {
3877- std::cout << "FAIL: timer with higher timeout time is not at the back of the list" << std::endl;
3878-
3879- for (std::list <CompTimer *>::iterator it = TimeoutHandler::Default ()->timers ().begin ();
3880- it != TimeoutHandler::Default ()->timers ().end (); it++)
3881- {
3882- CompTimer *t = (*it);
3883- std::cout << "INFO: t->minLeft " << t->minLeft () << std::endl << \
3884- "INFO: t->maxLeft " << t->maxLeft () << std::endl << \
3885- "INFO: t->minTime " << t->minTime () << std::endl << \
3886- "INFO: t->maxTime " << t->maxTime () << std::endl;
3887- }
3888-
3889- exit (1);
3890- }
3891- }
3892- else if (lastTimerTriggered == 1 && timernum == 2)
3893- {
3894- std::cout << "FAIL: timer with a higher timeout time got triggered before a timer with a lower timeout time" << std::endl;
3895-
3896- for (std::list <CompTimer *>::iterator it = TimeoutHandler::Default ()->timers ().begin ();
3897- it != TimeoutHandler::Default ()->timers ().end (); it++)
3898- {
3899- CompTimer *t = (*it);
3900- std::cout << "INFO: t->minLeft " << t->minLeft () << std::endl << \
3901- "INFO: t->maxLeft " << t->maxLeft () << std::endl << \
3902- "INFO: t->minTime " << t->minTime () << std::endl << \
3903- "INFO: t->maxTime " << t->maxTime () << std::endl;
3904- }
3905-
3906- exit (1);
3907- }
3908- else if (lastTimerTriggered == 2 && timernum != 1)
3909- {
3910- std::cout << "FAIL: timer with higher timeout time didn't get triggered after a lower timeout time" << std::endl;
3911-
3912- for (std::list <CompTimer *>::iterator it = TimeoutHandler::Default ()->timers ().begin ();
3913- it != TimeoutHandler::Default ()->timers ().end (); it++)
3914- {
3915- CompTimer *t = (*it);
3916- std::cout << "INFO: t->minLeft " << t->minLeft () << std::endl << \
3917- "INFO: t->maxLeft " << t->maxLeft () << std::endl << \
3918- "INFO: t->minTime " << t->minTime () << std::endl << \
3919- "INFO: t->maxTime " << t->maxTime () << std::endl;
3920- }
3921-
3922- exit (1);
3923- }
3924-
3925- lastTimerTriggered = timernum;
3926-
3927- if (timernum == 2)
3928- {
3929- std::cout << "PASS: retiming" << std::endl;
3930- ml->quit ();
3931- }
3932-
3933- return false;
3934-}
3935-
3936-void
3937-CompTimerTestSetCalling::precallback ()
3938-{
3939- CompTimer *t1, *t2, *t3;
3940-
3941- std::cout << "-= TEST: changing timeout time" << std::endl;
3942-
3943- t1 = new CompTimer ();
3944- t2 = new CompTimer ();
3945- t3 = new CompTimer ();
3946-
3947- timers.push_back (t1);
3948- timers.push_back (t2);
3949- timers.push_back (t3);
3950-
3951- t1->setCallback (boost::bind (&CompTimerTestSetCalling::cb, this, 1, t1, t2, t3));
3952- t1->setTimes (1000, 1100);
3953- t1->start ();
3954- t2->setCallback (boost::bind (&CompTimerTestSetCalling::cb, this, 2, t1, t2, t3));
3955- t2->setTimes (2000, 2100);
3956- t2->start ();
3957- t3->setCallback (boost::bind (&CompTimerTestSetCalling::cb, this, 3, t1, t2, t3));
3958- t3->setTimes (3000, 3100);
3959- t3->start ();
3960+#include <pthread.h>
3961+
3962+class CompTimerTestSetTimes: public CompTimerTest
3963+{
3964+protected:
3965+
3966+ int mlastTimerTriggered;
3967+
3968+ static void* run (void* cb)
3969+ {
3970+ if (cb == NULL)
3971+ {
3972+ return NULL;
3973+ }
3974+ static_cast<CompTimerTestSetTimes*>(cb)->ml->run();
3975+ return NULL;
3976+ }
3977+
3978+ pthread_t mmainLoopThread;
3979+ std::list<int> mtriggeredTimers;
3980+
3981+ void recordTimers ()
3982+ {
3983+ for (std::list<CompTimer *>::iterator it =
3984+ TimeoutHandler::Default()->timers().begin();
3985+ it != TimeoutHandler::Default()->timers().end(); it++)
3986+ {
3987+ CompTimer *t = (*it);
3988+ RecordProperty("t->minLeft", t->minLeft());
3989+ RecordProperty("t->maxLeft", t->maxLeft());
3990+ RecordProperty("t->minTime", t->minTime());
3991+ RecordProperty("t->maxTime", t->maxTime());
3992+ }
3993+ }
3994+
3995+ bool cb (int timernum, CompTimer* t1, CompTimer* t2, CompTimer* t3) {
3996+ cb_(timernum,t1,t2,t3);
3997+ return(true);
3998+ }
3999+ void cb_ (int timernum, CompTimer* t1, CompTimer* t2, CompTimer* t3)
4000+ {
4001+ recordTimers();
4002+ if (mlastTimerTriggered == 0 && timernum == 1)
4003+ {
4004+ /* Change the timeout time of the second timer to be after the third */
4005+ t2->setTimes(4000, 4100);
4006+
4007+ recordTimers();
4008+
4009+ /* Check if it is now at the back of the timeout list */
4010+ ASSERT_EQ( TimeoutHandler::Default()->timers().back(), t2 );
4011+ }
4012+ else if (mlastTimerTriggered == 1 && timernum == 2)
4013+ {
4014+ recordTimers();
4015+ FAIL() << "timer with a higher timeout time got triggered "
4016+ "before a timer with a lower timeout time";
4017+ }
4018+ else if (mlastTimerTriggered == 2 && timernum != 1)
4019+ {
4020+
4021+ recordTimers();
4022+ FAIL() << "timer with higher timeout time didn't get "
4023+ "triggered after a lower timeout time";
4024+ }
4025+
4026+ mlastTimerTriggered = timernum;
4027+ }
4028+
4029+ void SetUp ()
4030+ {
4031+ CompTimerTest::SetUp();
4032+ mlastTimerTriggered = 0;
4033+ CompTimer *t1, *t2, *t3;
4034+
4035+ t1 = new CompTimer();
4036+ t2 = new CompTimer();
4037+ t3 = new CompTimer();
4038+
4039+ timers.push_back(t1);
4040+ timers.push_back(t2);
4041+ timers.push_back(t3);
4042+
4043+ t1->setCallback(
4044+ boost::bind(&CompTimerTestSetTimes::cb, this, 1, t1, t2, t3));
4045+ t1->setTimes(1000, 1100);
4046+ t1->start();
4047+ t2->setCallback(
4048+ boost::bind(&CompTimerTestSetTimes::cb, this, 2, t1, t2, t3));
4049+ t2->setTimes(2000, 2100);
4050+ t2->start();
4051+ t3->setCallback(
4052+ boost::bind(&CompTimerTestSetTimes::cb, this, 3, t1, t2, t3));
4053+ t3->setTimes(3000, 3100);
4054+ t3->start();
4055+
4056+ ASSERT_EQ(
4057+ 0,
4058+ pthread_create(&mmainLoopThread, NULL, CompTimerTestSetTimes::run, this));
4059+ }
4060+
4061+ void TearDown ()
4062+ {
4063+ ml->quit();
4064+ pthread_join(mmainLoopThread, NULL);
4065+
4066+ CompTimerTest::TearDown();
4067+ }
4068+};
4069+
4070+TEST_F(CompTimerTestSetTimes, SetTimesWhileCalling)
4071+{
4072+ ::sleep(4);
4073+ // Just a dummy forcing instantiation of fixture.
4074 }
4075
4076=== modified file 'src/window.cpp'
4077--- src/window.cpp 2011-12-15 07:40:03 +0000
4078+++ src/window.cpp 2011-12-20 02:49:24 +0000
4079@@ -23,8 +23,6 @@
4080 * Author: David Reveman <davidr@novell.com>
4081 */
4082
4083-#include <compiz.h>
4084-
4085 #include <X11/Xlib.h>
4086 #include <X11/Xatom.h>
4087 #include <X11/Xproto.h>
4088@@ -6149,14 +6147,14 @@
4089 if (screen->vpSize ().width () != 1)
4090 {
4091 x += screen->vp ().x () * screen->width ();
4092- x = MOD (x, vWidth);
4093+ x = compiz::core::screen::wraparound_mod (x, vWidth);
4094 x -= screen->vp ().x () * screen->width ();
4095 }
4096
4097 if (screen->vpSize ().height () != 1)
4098 {
4099 y += screen->vp ().y () * screen->height ();
4100- y = MOD (y, vHeight);
4101+ y = compiz::core::screen::wraparound_mod (y, vHeight);
4102 y -= screen->vp ().y () * screen->height ();
4103 }
4104
4105
4106=== removed directory 'tests'
4107=== removed file 'tests/CMakeLists.txt'
4108--- tests/CMakeLists.txt 2011-07-06 19:52:01 +0000
4109+++ tests/CMakeLists.txt 1970-01-01 00:00:00 +0000
4110@@ -1,2 +0,0 @@
4111-add_subdirectory (pluginclasshandler)
4112-add_subdirectory (timer)
4113
4114=== removed file 'tests/pluginclasshandler/construct/CMakeLists.txt'
4115--- tests/pluginclasshandler/construct/CMakeLists.txt 2011-07-06 19:52:01 +0000
4116+++ tests/pluginclasshandler/construct/CMakeLists.txt 1970-01-01 00:00:00 +0000
4117@@ -1,25 +0,0 @@
4118-link_directories (${COMPIZ_TEST_PCH_LINK_DIRS})
4119-
4120-include_directories (${COMPIZ_TEST_PCH_INCLUDE_DIRS}
4121- ${compiz_SOURCE_DIR}/include
4122- ${compiz_BINARY_DIR}
4123- ${compiz_BINARY_DIR}/generated
4124- ${compiz_SOURCE_DIR}/src
4125- ${COMPIZ_TEST_PCH_BASE_DIR})
4126-
4127-set (OBJECT CompizPCHTestConstruct)
4128-add_definitions (-DOBJECT=${OBJECT})
4129-
4130-add_executable (test-pch-construct
4131- test-pch-construct.cpp
4132- ../test-pluginclasshandler.cpp
4133- ${compiz_SOURCE_DIR}/src/valueholder.cpp
4134- ${compiz_SOURCE_DIR}/src/pluginclasses.cpp
4135- ${compiz_SOURCE_DIR}/src/string.cpp
4136- ${compiz_SOURCE_DIR}/src/logmessage.cpp)
4137-
4138-target_link_libraries (test-pch-construct
4139- ${COMPIZ_TEST_PCH_LIBRARIES})
4140-
4141-add_test (test-pch-construct
4142- ${CMAKE_CURRENT_BINARY_DIR}/test-pch-construct)
4143
4144=== removed file 'tests/pluginclasshandler/get/CMakeLists.txt'
4145--- tests/pluginclasshandler/get/CMakeLists.txt 2011-07-06 19:52:01 +0000
4146+++ tests/pluginclasshandler/get/CMakeLists.txt 1970-01-01 00:00:00 +0000
4147@@ -1,25 +0,0 @@
4148-link_directories (${COMPIZ_TEST_PCH_LINK_DIRS})
4149-
4150-include_directories (${COMPIZ_TEST_PCH_INCLUDE_DIRS}
4151- ${compiz_SOURCE_DIR}/include
4152- ${compiz_BINARY_DIR}
4153- ${compiz_BINARY_DIR}/generated
4154- ${compiz_SOURCE_DIR}/src
4155- ${COMPIZ_TEST_PCH_BASE_DIR})
4156-
4157-set (OBJECT CompizPCHTestGet)
4158-add_definitions (-DOBJECT=${OBJECT})
4159-
4160-add_executable (test-pch-get
4161- test-pch-get.cpp
4162- ../test-pluginclasshandler.cpp
4163- ${compiz_SOURCE_DIR}/src/valueholder.cpp
4164- ${compiz_SOURCE_DIR}/src/pluginclasses.cpp
4165- ${compiz_SOURCE_DIR}/src/string.cpp
4166- ${compiz_SOURCE_DIR}/src/logmessage.cpp)
4167-
4168-target_link_libraries (test-pch-get
4169- ${COMPIZ_TEST_PCH_LIBRARIES})
4170-
4171-add_test (test-pch-get
4172- ${CMAKE_CURRENT_BINARY_DIR}/test-pch-get)
4173
4174=== removed file 'tests/pluginclasshandler/indexes/CMakeLists.txt'
4175--- tests/pluginclasshandler/indexes/CMakeLists.txt 2011-07-06 19:52:01 +0000
4176+++ tests/pluginclasshandler/indexes/CMakeLists.txt 1970-01-01 00:00:00 +0000
4177@@ -1,28 +0,0 @@
4178-link_directories (${COMPIZ_TEST_PCH_LINK_DIRS})
4179-
4180-include_directories (${COMPIZ_TEST_PCH_INCLUDE_DIRS}
4181- ${compiz_SOURCE_DIR}/include
4182- ${compiz_BINARY_DIR}
4183- ${compiz_BINARY_DIR}/generated
4184- ${compiz_SOURCE_DIR}/src
4185- ${COMPIZ_TEST_PCH_BASE_DIR})
4186-
4187-set (OBJECT CompizPCHTestIndexes)
4188-add_definitions (-DOBJECT=${OBJECT})
4189-# hack
4190-add_definitions (-Dprivate=public)
4191-add_definitions (-Dprotected=public)
4192-
4193-add_executable (test-pch-indexes
4194- test-pch-indexes.cpp
4195- ../test-pluginclasshandler.cpp
4196- ${compiz_SOURCE_DIR}/src/valueholder.cpp
4197- ${compiz_SOURCE_DIR}/src/pluginclasses.cpp
4198- ${compiz_SOURCE_DIR}/src/string.cpp
4199- ${compiz_SOURCE_DIR}/src/logmessage.cpp)
4200-
4201-target_link_libraries (test-pch-indexes
4202- ${COMPIZ_TEST_PCH_LIBRARIES})
4203-
4204-add_test (test-pch-indexes
4205- ${CMAKE_CURRENT_BINARY_DIR}/test-pch-indexes)
4206
4207=== removed file 'tests/pluginclasshandler/typenames/CMakeLists.txt'
4208--- tests/pluginclasshandler/typenames/CMakeLists.txt 2011-07-06 19:52:01 +0000
4209+++ tests/pluginclasshandler/typenames/CMakeLists.txt 1970-01-01 00:00:00 +0000
4210@@ -1,25 +0,0 @@
4211-link_directories (${COMPIZ_TEST_PCH_LINK_DIRS})
4212-
4213-include_directories (${COMPIZ_TEST_PCH_INCLUDE_DIRS}
4214- ${compiz_SOURCE_DIR}/include
4215- ${compiz_BINARY_DIR}
4216- ${compiz_BINARY_DIR}/generated
4217- ${compiz_SOURCE_DIR}/src
4218- ${COMPIZ_TEST_PCH_BASE_DIR})
4219-
4220-set (OBJECT CompizPCHTestTypenames)
4221-add_definitions (-DOBJECT=${OBJECT})
4222-
4223-add_executable (test-pch-typenames
4224- test-pch-typenames.cpp
4225- ../test-pluginclasshandler.cpp
4226- ${compiz_SOURCE_DIR}/src/valueholder.cpp
4227- ${compiz_SOURCE_DIR}/src/pluginclasses.cpp
4228- ${compiz_SOURCE_DIR}/src/string.cpp
4229- ${compiz_SOURCE_DIR}/src/logmessage.cpp)
4230-
4231-target_link_libraries (test-pch-typenames
4232- ${COMPIZ_TEST_PCH_LIBRARIES})
4233-
4234-add_test (test-pch-typenames
4235- ${CMAKE_CURRENT_BINARY_DIR}/test-pch-typenames)
4236
4237=== removed directory 'tests/timer'
4238=== removed file 'tests/timer/callbacks/CMakeLists.txt'
4239--- tests/timer/callbacks/CMakeLists.txt 2011-07-06 18:58:47 +0000
4240+++ tests/timer/callbacks/CMakeLists.txt 1970-01-01 00:00:00 +0000
4241@@ -1,23 +0,0 @@
4242-link_directories (${COMPIZ_TEST_TIMER_LINK_DIRS})
4243-
4244-include_directories (${COMPIZ_TEST_TIMER_INCLUDE_DIRS}
4245- ${compiz_SOURCE_DIR}/include
4246- ${compiz_BINARY_DIR}
4247- ${compiz_BINARY_DIR}/generated
4248- ${compiz_SOURCE_DIR}/src
4249- ${COMPIZ_TIMER_TEST_BASE_DIR})
4250-
4251-set (OBJECT CompTimerTestCallbacks)
4252-add_definitions (-DOBJECT=${OBJECT})
4253-
4254-add_executable (test-timer-callbacks
4255- test-timer-callbacks.cpp
4256- ../test-timer.cpp
4257- ${compiz_SOURCE_DIR}/src/timer.cpp
4258- ${compiz_SOURCE_DIR}/src/timeouthandler.cpp)
4259-
4260-target_link_libraries (test-timer-callbacks
4261- ${COMPIZ_TEST_TIMER_LIBRARIES})
4262-
4263-add_test (test-timer-callbacks
4264- ${CMAKE_CURRENT_BINARY_DIR}/test-timer-callbacks)
4265
4266=== removed file 'tests/timer/diffs/CMakeLists.txt'
4267--- tests/timer/diffs/CMakeLists.txt 2011-07-06 18:58:47 +0000
4268+++ tests/timer/diffs/CMakeLists.txt 1970-01-01 00:00:00 +0000
4269@@ -1,23 +0,0 @@
4270-link_directories (${COMPIZ_TEST_TIMER_LINK_DIRS})
4271-
4272-include_directories (${COMPIZ_TEST_TIMER_INCLUDE_DIRS}
4273- ${compiz_SOURCE_DIR}/include
4274- ${compiz_BINARY_DIR}
4275- ${compiz_BINARY_DIR}/generated
4276- ${compiz_SOURCE_DIR}/src
4277- ${COMPIZ_TIMER_TEST_BASE_DIR})
4278-
4279-set (OBJECT CompTimerTestDiffs)
4280-add_definitions (-DOBJECT=${OBJECT})
4281-
4282-add_executable (test-timer-diffs
4283- test-timer-diffs.cpp
4284- ../test-timer.cpp
4285- ${compiz_SOURCE_DIR}/src/timer.cpp
4286- ${compiz_SOURCE_DIR}/src/timeouthandler.cpp)
4287-
4288-target_link_libraries (test-timer-diffs
4289- ${COMPIZ_TEST_TIMER_LIBRARIES})
4290-
4291-add_test (test-timer-diffs
4292- ${CMAKE_CURRENT_BINARY_DIR}/test-timer-diffs)
4293
4294=== removed file 'tests/timer/diffs/test-timer-diffs.cpp'
4295--- tests/timer/diffs/test-timer-diffs.cpp 2011-07-06 18:58:47 +0000
4296+++ tests/timer/diffs/test-timer-diffs.cpp 1970-01-01 00:00:00 +0000
4297@@ -1,82 +0,0 @@
4298-/*
4299- * Copyright © 2011 Canonical Ltd.
4300- *
4301- * Permission to use, copy, modify, distribute, and sell this software
4302- * and its documentation for any purpose is hereby granted without
4303- * fee, provided that the above copyright notice appear in all copies
4304- * and that both that copyright notice and this permission notice
4305- * appear in supporting documentation, and that the name of
4306- * Canonical Ltd. not be used in advertising or publicity pertaining to
4307- * distribution of the software without specific, written prior permission.
4308- * Canonical Ltd. makes no representations about the suitability of this
4309- * software for any purpose. It is provided "as is" without express or
4310- * implied warranty.
4311- *
4312- * CANONICAL, LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
4313- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
4314- * NO EVENT SHALL CANONICAL, LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
4315- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
4316- * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
4317- * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
4318- * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
4319- *
4320- * Authored by: Sam Spilsbury <sam.spilsbury@canonical.com>
4321- */
4322-
4323-#include "test-timer.h"
4324-
4325-bool
4326-CompTimerTestDiffs::cb (int timernum, CompTimer *t1, CompTimer *t2, CompTimer *t3)
4327-{
4328- if (timernum == 1 || timernum == 2 || timernum == 3)
4329- {
4330- std::cout << "INFO: executing timer " << timernum << std::endl;
4331-
4332- std::cout << "INFO: t1->minLeft " << t1->minLeft () << std::endl << \
4333- "INFO: t1->maxLeft " << t1->maxLeft () << std::endl << \
4334- "INFO: t1->minTime " << t1->minTime () << std::endl << \
4335- "INFO: t1->maxTime " << t1->maxTime () << std::endl;
4336-
4337- std::cout << "INFO: t2->minLeft " << t2->minLeft () << std::endl << \
4338- "INFO: t2->maxLeft " << t2->maxLeft () << std::endl << \
4339- "INFO: t2->minTime " << t2->minTime () << std::endl << \
4340- "INFO: t2->maxTime " << t2->maxTime () << std::endl;
4341-
4342- std::cout << "INFO: t3->minLeft " << t3->minLeft () << std::endl << \
4343- "INFO: t3->maxLeft " << t3->maxLeft () << std::endl << \
4344- "INFO: t3->minTime " << t3->minTime () << std::endl << \
4345- "INFO: t3->maxTime " << t3->maxTime () << std::endl;
4346- }
4347-
4348- if (timernum == 3)
4349- ml->quit ();
4350-
4351- std::cout << "return false" << std::endl;
4352- return false;
4353-}
4354-
4355-void
4356-CompTimerTestDiffs::precallback ()
4357-{
4358- CompTimer *t1, *t2, *t3;
4359-
4360- std::cout << "-= TEST: checking timeout diff" << std::endl;
4361-
4362- t1 = new CompTimer ();
4363- t2 = new CompTimer ();
4364- t3 = new CompTimer ();
4365-
4366- timers.push_back (t1);
4367- timers.push_back (t2);
4368- timers.push_back (t3);
4369-
4370- t1->setCallback (boost::bind (&CompTimerTestDiffs::cb, this, 1, t1, t2, t3));
4371- t1->setTimes (1000, 1100);
4372- t1->start ();
4373- t2->setCallback (boost::bind (&CompTimerTestDiffs::cb, this, 2, t1, t2, t3));
4374- t2->setTimes (2000, 2100);
4375- t2->start ();
4376- t3->setCallback (boost::bind (&CompTimerTestDiffs::cb, this, 3, t1, t2, t3));
4377- t3->setTimes (3000, 3100);
4378- t3->start ();
4379-}
4380
4381=== removed file 'tests/timer/set-values/CMakeLists.txt'
4382--- tests/timer/set-values/CMakeLists.txt 2011-07-06 18:58:47 +0000
4383+++ tests/timer/set-values/CMakeLists.txt 1970-01-01 00:00:00 +0000
4384@@ -1,23 +0,0 @@
4385-link_directories (${COMPIZ_TEST_TIMER_LINK_DIRS})
4386-
4387-include_directories (${COMPIZ_TEST_TIMER_INCLUDE_DIRS}
4388- ${compiz_SOURCE_DIR}/include
4389- ${compiz_BINARY_DIR}
4390- ${compiz_BINARY_DIR}/generated
4391- ${compiz_SOURCE_DIR}/src
4392- ${COMPIZ_TIMER_TEST_BASE_DIR})
4393-
4394-set (OBJECT CompTimerTestSetValues)
4395-add_definitions (-DOBJECT=${OBJECT})
4396-
4397-add_executable (test-timer-set-values
4398- test-timer-set-values.cpp
4399- ../test-timer.cpp
4400- ${compiz_SOURCE_DIR}/src/timer.cpp
4401- ${compiz_SOURCE_DIR}/src/timeouthandler.cpp)
4402-
4403-target_link_libraries (test-timer-set-values
4404- ${COMPIZ_TEST_TIMER_LIBRARIES})
4405-
4406-add_test (test-timer-set-values
4407- ${CMAKE_CURRENT_BINARY_DIR}/test-timer-set-values)
4408
4409=== removed file 'tests/timer/while-calling/CMakeLists.txt'
4410--- tests/timer/while-calling/CMakeLists.txt 2011-07-06 18:58:47 +0000
4411+++ tests/timer/while-calling/CMakeLists.txt 1970-01-01 00:00:00 +0000
4412@@ -1,23 +0,0 @@
4413-link_directories (${COMPIZ_TEST_TIMER_LINK_DIRS})
4414-
4415-include_directories (${COMPIZ_TEST_TIMER_INCLUDE_DIRS}
4416- ${compiz_SOURCE_DIR}/include
4417- ${compiz_BINARY_DIR}
4418- ${compiz_BINARY_DIR}/generated
4419- ${compiz_SOURCE_DIR}/src
4420- ${COMPIZ_TIMER_TEST_BASE_DIR})
4421-
4422-set (OBJECT CompTimerTestSetCalling)
4423-add_definitions (-DOBJECT=${OBJECT})
4424-
4425-add_executable (test-timer-set-times-while-calling
4426- test-timer-set-times-while-calling.cpp
4427- ../test-timer.cpp
4428- ${compiz_SOURCE_DIR}/src/timer.cpp
4429- ${compiz_SOURCE_DIR}/src/timeouthandler.cpp)
4430-
4431-target_link_libraries (test-timer-set-times-while-calling
4432- ${COMPIZ_TEST_TIMER_LIBRARIES})
4433-
4434-add_test (test-timer-set-times-while-calling
4435- ${CMAKE_CURRENT_BINARY_DIR}/test-timer-set-times-while-calling)

Subscribers

People subscribed via source and target branches