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