Merge lp:~compiz-team/compiz/compiz.tests_1041535 into lp:compiz/0.9.8
- compiz.tests_1041535
- Merge into 0.9.8
Status: | Superseded |
---|---|
Proposed branch: | lp:~compiz-team/compiz/compiz.tests_1041535 |
Merge into: | lp:compiz/0.9.8 |
Prerequisite: | lp:~compiz-team/compiz/compiz.tests_1042537.3 |
Diff against target: |
7931 lines (+5072/-1295) 76 files modified
compizconfig/CMakeLists.txt (+1/-0) compizconfig/gsettings/CMakeLists.txt (+2/-0) compizconfig/gsettings/gsettings_backend_shared/CMakeLists.txt (+0/-1) compizconfig/gsettings/gsettings_backend_shared/ccs_gsettings_backend.c (+0/-23) compizconfig/gsettings/gsettings_backend_shared/ccs_gsettings_backend_interface.c (+23/-0) compizconfig/gsettings/mocks/CMakeLists.txt (+21/-0) compizconfig/gsettings/tests/CMakeLists.txt (+19/-10) compizconfig/gsettings/tests/compizconfig_ccs_gsettings_settings_env_test.cpp (+364/-0) compizconfig/gsettings/tests/compizconfig_ccs_gsettings_settings_env_test.h (+134/-0) compizconfig/gsettings/tests/gsettings-mock-schemas-config.h.in (+2/-0) compizconfig/gsettings/tests/gsettings_settings_test_fixture.h (+29/-0) compizconfig/gsettings/tests/test_gsettings_conformance.cpp (+25/-430) compizconfig/gsettings/tests/test_gsettings_tests.h (+57/-14) compizconfig/integration/gnome/CMakeLists.txt (+2/-0) compizconfig/integration/gnome/gconf/src/ccs_gnome_integration_gconf_integrated_setting.c (+18/-3) compizconfig/integration/gnome/gsettings/CMakeLists.txt (+2/-0) compizconfig/integration/gnome/gsettings/src/ccs_gnome_integration_gsettings_integrated_setting.c (+62/-22) compizconfig/integration/gnome/gsettings/tests/CMakeLists.txt (+31/-0) compizconfig/integration/gnome/gsettings/tests/compizconfig_test_ccs_gnome_gsettings_integrated_setting.cpp (+388/-0) compizconfig/integration/gnome/include/ccs_gnome_integrated_setting.h (+9/-1) compizconfig/integration/gnome/include/ccs_gnome_integration_constants.h (+1/-0) compizconfig/integration/gnome/include/ccs_gnome_integration_types.h (+2/-0) compizconfig/integration/gnome/include/ccs_gnome_integration_types.h~ (+0/-26) compizconfig/integration/gnome/src/ccs_gnome_integrated_setting.c (+18/-3) compizconfig/integration/gnome/src/ccs_gnome_integration.c (+13/-10) compizconfig/integration/gnome/tests/CMakeLists.txt (+47/-0) compizconfig/integration/gnome/tests/compizconfig_ccs_mock_gnome_integrated_setting_composition.c (+222/-0) compizconfig/integration/gnome/tests/compizconfig_ccs_mock_gnome_integrated_setting_composition.h (+42/-0) compizconfig/integration/gnome/tests/compizconfig_test_ccs_gnome_integration.cpp (+813/-0) compizconfig/libcompizconfig/src/main.c (+2/-2) compizconfig/libcompizconfig/tests/CMakeLists.txt (+9/-1) compizconfig/libcompizconfig/tests/compizconfig_test_ccs_mock_backend_conformance.cpp (+22/-10) compizconfig/libcompizconfig/tests/compizconfig_test_ccs_settings_upgrade_internal.cpp (+13/-65) compizconfig/mocks/libcompizconfig/CMakeLists.txt (+40/-0) compizconfig/mocks/libcompizconfig/compizconfig_ccs_integrated_setting_factory_mock.cpp (+70/-0) compizconfig/mocks/libcompizconfig/compizconfig_ccs_integrated_setting_factory_mock.h (+99/-0) compizconfig/mocks/libcompizconfig/compizconfig_ccs_integrated_setting_mock.cpp (+71/-0) compizconfig/mocks/libcompizconfig/compizconfig_ccs_integrated_setting_mock.h (+97/-0) compizconfig/mocks/libcompizconfig/compizconfig_ccs_integrated_setting_storage_mock.cpp (+73/-0) compizconfig/mocks/libcompizconfig/compizconfig_ccs_integrated_setting_storage_mock.h (+119/-0) compizconfig/mocks/libcompizconfig/compizconfig_ccs_integration_mock.cpp (+70/-0) compizconfig/mocks/libcompizconfig/compizconfig_ccs_integration_mock.h (+129/-0) compizconfig/tests/CMakeLists.txt (+71/-0) compizconfig/tests/compizconfig_backend_concept_test.cpp (+381/-0) compizconfig/tests/compizconfig_backend_concept_test.h (+144/-189) compizconfig/tests/compizconfig_backend_concept_test_environment_interface.h (+101/-0) compizconfig/tests/compizconfig_backend_concept_test_internal.h (+146/-0) compizconfig/tests/compizconfig_ccs_item_in_list_matcher.cpp (+36/-0) compizconfig/tests/compizconfig_ccs_item_in_list_matcher.h (+8/-13) compizconfig/tests/compizconfig_ccs_list_equality.cpp (+74/-0) compizconfig/tests/compizconfig_ccs_list_equality.h (+15/-29) compizconfig/tests/compizconfig_ccs_list_wrapper.cpp (+109/-0) compizconfig/tests/compizconfig_ccs_list_wrapper.h (+0/-199) compizconfig/tests/compizconfig_ccs_setting_value_matcher.cpp (+69/-0) compizconfig/tests/compizconfig_ccs_setting_value_matcher.h (+64/-0) compizconfig/tests/compizconfig_ccs_setting_value_operators.cpp (+103/-0) compizconfig/tests/compizconfig_ccs_setting_value_operators.h (+17/-52) compizconfig/tests/compizconfig_ccs_settings_test_fixture.h (+106/-0) compizconfig/tests/compizconfig_ccs_variant_types.h (+40/-0) compizconfig/tests/compizconfig_test_value_combiners.cpp (+147/-0) compizconfig/tests/compizconfig_test_value_combiners.h (+17/-82) gtk/window-decorator/tests/CMakeLists.txt (+3/-1) gtk/window-decorator/tests/test_gwd_metacity_decorations.cpp (+2/-3) gtk/window-decorator/tests/test_gwd_settings.cpp (+65/-83) plugins/composite/CMakeLists.txt (+5/-4) plugins/decor/CMakeLists.txt (+4/-2) plugins/expo/CMakeLists.txt (+4/-3) plugins/grid/CMakeLists.txt (+5/-4) plugins/place/CMakeLists.txt (+8/-6) plugins/resize/CMakeLists.txt (+4/-2) plugins/wall/CMakeLists.txt (+4/-2) tests/shared/glib/glib_gsettings_memory_backend_env.h (+45/-0) tests/shared/glib/glib_gslice_off_env.h (+43/-0) tests/shared/gtest_shared_autodestroy.h (+20/-0) tests/shared/gtest_shared_characterwrapper.h (+21/-0) tests/shared/gtest_unspecified_bool_type_matcher.h (+30/-0) |
To merge this branch: | bzr merge lp:~compiz-team/compiz/compiz.tests_1041535 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Daniel van Vugt | Needs Fixing | ||
jenkins (community) | continuous-integration | Needs Fixing | |
Review via email: mp+125886@code.launchpad.net |
This proposal has been superseded by a proposal from 2012-09-24.
Commit message
Increased test coverage on CCSGSettingsInt
Description of the change
Increased test coverage on CCSGSettingsInt
Start 238: CCSGSettingsInt
238/582 Test #238: CCSGSettingsInt
Start 239: CCSGSettingsInt
239/582 Test #239: CCSGSettingsInt
Start 240: CCSGSettingsInt
240/582 Test #240: CCSGSettingsInt
Start 241: CCSGSettingsInt
241/582 Test #241: CCSGSettingsInt
Start 242: CCSGSettingsInt
242/582 Test #242: CCSGSettingsInt
Start 243: CCSGSettingsInt
243/582 Test #243: CCSGSettingsInt
Start 244: CCSGSettingsInt
244/582 Test #244: CCSGSettingsInt
Start 245: CCSGSettingsInt
245/582 Test #245: CCSGSettingsInt
Start 246: CCSGSettingsInt
246/582 Test #246: CCSGSettingsInt
Start 247: CCSGSettingsInt
247/582 Test #247: CCSGSettingsInt
Start 248: CCSGSettingsInt
248/582 Test #248: CCSGSettingsInt
Start 249: CCSGSettingsInt
249/582 Test #249: CCSGSettingsInt
Start 250: CCSGSettingsInt
250/582 Test #250: CCSGSettingsInt
Start 251: CCSGSettingsInt
251/582 Test #251: CCSGSettingsInt
Start 252: CCSGSettingsInt
252/582 Test #252: CCSGSettingsInt
Start 253: CCSGSettingsInt
253/582 Test #253: CCSGSettingsInt
Start 254: CCSGSettingsInt
254/582 Test #254: CCSGSettingsInt
Start 255: CCSGSettingsInt
255/582 Test #255: CCSGSettingsInt
Start 256: CCSGSettingsInt
256/582 Test #256: CCSGSettingsInt
Start 257: CCSGSettingsInt
257/582 Test #257: CCSGSettingsInt
Start 258: CCSGSettingsInt
258/582 Test #258: CCSGSettingsInt
Start 259: CCSGSettingsInt
259/582 Test #259: CCSGSettingsInt
Start 260: CCSGSettingsInt
260/582 Test #260: CCSGSettingsInt
Start 261: CCSGSettingsInt
261/582 Test #261: CCSGSettingsInt
Start 262: CCSGSettingsInt
262/582 Test #262: CCSGSettingsInt
Start 263: CCSGSettingsInt
263/582 Test #263: CCSGSettingsInt
Start 264: CCSGSettingsInt
264/582 Test #264: CCSGSettingsInt
Start 265: CCSGSettingsInt
265/582 Test #265: CCSGSettingsInt
Start 266: CCSGSettingsInt
266/582 Test #266: CCSGSettingsInt
Start 267: CCSGSettingsInt
267/582 Test #267: CCSGSettingsInt
Start 268: CCSGSettingsInt
268/582 Test #268: CCSGSettingsInt
Start 269: CCSGSettingsInt
269/582 Test #269: CCSGSettingsInt
Start 270: CCSGNOMEIntegra
270/582 Test #270: CCSGNOMEIntegra
Start 271: CCSGNOMEIntegra
271/582 Test #271: CCSGNOMEIntegra
Start 272: CCSGNOMEIntegra
272/582 Test #272: CCSGNOMEIntegra
Start 273: CCSGNOMEIntegra
273/582 Test #273: CCSGNOMEIntegra
Start 274: CCSGNOMEIntegra
274/582 Test #274: CCSGNOMEIntegra
Start 275: CCSGNOMEIntegra
275/582 Test #275: CCSGNOMEIntegra
Start 276: CCSGNOMEIntegra
276/582 Test #276: CCSGNOMEIntegra
Start 277: CCSGNOMEIntegra
277/582 Test #277: CCSGNOMEIntegra
Start 278: CCSGNOMEIntegra
278/582 Test #278: CCSGNOMEIntegra
Start 279: CCSGNOMEIntegra
279/582 Test #279: CCSGNOMEIntegra
Start 280: CCSGNOMEIntegra
280/582 Test #280: CCSGNOMEIntegra
In order to make this work bug 1049169 was mostly fixed too (there are other memleaks so lets leave it open).
jenkins (martin-mrazik+qa) wrote : | # |
- 3390. By Sam Spilsbury
-
Also free and return null for the gconf integrated settings
- 3391. By Sam Spilsbury
-
Failing test: 277 - CCSGNOMEIntegra
tionTestWithMoc ksReadIntegrate dMouseButtonMod ifiers. TestReadInSpeci alOptionWhereIn tegratedOptionR eturnsNull (SEGFAULT) - 3392. By Sam Spilsbury
-
Make CCSGNOMEIntegra
tionTestWithMoc ksReadIntegrate dMouseButtonMod ifiers. TestReadInSpeci alOptionWhereIn tegratedOptionR eturnsNull
pass
jenkins (martin-mrazik+qa) wrote : | # |
FAILED: Continuous integration, rev:3392
http://
Executed test runs:
FAILURE: http://
Daniel van Vugt (vanvugt) wrote : | # |
There's no explicit mention of fixing bug 1041535. Does it?
If so, please claim bug 1041535 and mark it in progress.
Martin Mrazik (mrazik) wrote : | # |
This is the jenkins error:
patching file plugins/
patching file plugins/
Hunk #1 FAILED at 1.
1 out of 1 hunk FAILED -- rejects in file plugins/
patching file plugins/
patching file plugins/
patching file plugins/
patching file plugins/
patching file plugins/
patching file plugins/
patching file plugins/
Patch 100_expo_
dh_quilt_patch: quilt --quiltrc /dev/null push -a || test $? = 2 returned exit code 1
make[1]: *** [override_
make[1]: Leaving directory `/tmp/buildd/
make: *** [build] Error 2
dpkg-buildpackage: error: debian/rules build gave erro
Daniel van Vugt (vanvugt) wrote : | # |
Please add a check for NULL inside ccsStringToModi
Sam Spilsbury (smspillaz) wrote : | # |
> This is the jenkins error:
> patching file plugins/
> patching file plugins/
> Hunk #1 FAILED at 1.
> 1 out of 1 hunk FAILED -- rejects in file plugins/
> patching file plugins/
> patching file plugins/
> viewport.h
> patching file plugins/
> patching file plugins/
> patching file plugins/
> viewport.cpp
> patching file plugins/
> patching file plugins/
> Patch 100_expo_
> dh_quilt_patch: quilt --quiltrc /dev/null push -a || test $? = 2 returned exit
> code 1
> make[1]: *** [override_
> make[1]: Leaving directory `/tmp/buildd/
> make: *** [build] Error 2
> dpkg-buildpackage: error: debian/rules build gave erro
Hmm, this branch doesn't touch the expo plugin, so that error is suprising. However, maybe trunk has broken CI. I'll look into it.
Unmerged revisions
Preview Diff
1 | === modified file 'compizconfig/CMakeLists.txt' | |||
2 | --- compizconfig/CMakeLists.txt 2012-08-22 06:15:40 +0000 | |||
3 | +++ compizconfig/CMakeLists.txt 2012-09-24 03:58:20 +0000 | |||
4 | @@ -21,6 +21,7 @@ | |||
5 | 21 | 21 | ||
6 | 22 | if (COMPIZ_BUILD_TESTING) | 22 | if (COMPIZ_BUILD_TESTING) |
7 | 23 | add_subdirectory (mocks) | 23 | add_subdirectory (mocks) |
8 | 24 | add_subdirectory (tests) | ||
9 | 24 | endif (COMPIZ_BUILD_TESTING) | 25 | endif (COMPIZ_BUILD_TESTING) |
10 | 25 | 26 | ||
11 | 26 | add_custom_target (pyclean) | 27 | add_custom_target (pyclean) |
12 | 27 | 28 | ||
13 | === modified file 'compizconfig/gsettings/CMakeLists.txt' | |||
14 | --- compizconfig/gsettings/CMakeLists.txt 2012-08-15 06:45:13 +0000 | |||
15 | +++ compizconfig/gsettings/CMakeLists.txt 2012-09-24 03:58:20 +0000 | |||
16 | @@ -14,6 +14,8 @@ | |||
17 | 14 | add_definitions (-DUSE_GCONF) | 14 | add_definitions (-DUSE_GCONF) |
18 | 15 | endif (USE_GCONF) | 15 | endif (USE_GCONF) |
19 | 16 | 16 | ||
20 | 17 | add_subdirectory (mocks) | ||
21 | 18 | add_subdirectory (testenvironments) | ||
22 | 17 | add_subdirectory (gsettings_backend_shared) | 19 | add_subdirectory (gsettings_backend_shared) |
23 | 18 | 20 | ||
24 | 19 | include_directories (${CMAKE_CURRENT_SOURCE_DIR}/gsettings_backend_shared | 21 | include_directories (${CMAKE_CURRENT_SOURCE_DIR}/gsettings_backend_shared |
25 | 20 | 22 | ||
26 | === modified file 'compizconfig/gsettings/gsettings_backend_shared/CMakeLists.txt' | |||
27 | --- compizconfig/gsettings/gsettings_backend_shared/CMakeLists.txt 2012-08-19 10:02:23 +0000 | |||
28 | +++ compizconfig/gsettings/gsettings_backend_shared/CMakeLists.txt 2012-09-24 03:58:20 +0000 | |||
29 | @@ -41,7 +41,6 @@ | |||
30 | 41 | compizconfig_gsettings_backend_interface | 41 | compizconfig_gsettings_backend_interface |
31 | 42 | compizconfig_gsettings_wrapper_interface | 42 | compizconfig_gsettings_wrapper_interface |
32 | 43 | compizconfig | 43 | compizconfig |
33 | 44 | compizconfig | ||
34 | 45 | ${GSETTINGS_UTIL_LIBRARIES}) | 44 | ${GSETTINGS_UTIL_LIBRARIES}) |
35 | 46 | 45 | ||
36 | 47 | add_library (compizconfig_gsettings_backend SHARED | 46 | add_library (compizconfig_gsettings_backend SHARED |
37 | 48 | 47 | ||
38 | === modified file 'compizconfig/gsettings/gsettings_backend_shared/ccs_gsettings_backend.c' | |||
39 | --- compizconfig/gsettings/gsettings_backend_shared/ccs_gsettings_backend.c 2012-08-17 23:50:08 +0000 | |||
40 | +++ compizconfig/gsettings/gsettings_backend_shared/ccs_gsettings_backend.c 2012-09-24 03:58:20 +0000 | |||
41 | @@ -223,29 +223,6 @@ | |||
42 | 223 | } | 223 | } |
43 | 224 | } | 224 | } |
44 | 225 | 225 | ||
45 | 226 | CCSContext * | ||
46 | 227 | ccsGSettingsBackendGetContext (CCSBackend *backend) | ||
47 | 228 | { | ||
48 | 229 | return (*(GET_INTERFACE (CCSGSettingsBackendInterface, backend))->gsettingsBackendGetContext) (backend); | ||
49 | 230 | } | ||
50 | 231 | |||
51 | 232 | |||
52 | 233 | void | ||
53 | 234 | ccsGSettingsBackendConnectToChangedSignal (CCSBackend *backend, | ||
54 | 235 | CCSGSettingsWrapper *object) | ||
55 | 236 | { | ||
56 | 237 | (*(GET_INTERFACE (CCSGSettingsBackendInterface, backend))->gsettingsBackendConnectToChangedSignal) (backend, object); | ||
57 | 238 | } | ||
58 | 239 | |||
59 | 240 | CCSGSettingsWrapper * | ||
60 | 241 | ccsGSettingsGetSettingsObjectForPluginWithPath (CCSBackend *backend, | ||
61 | 242 | const char *plugin, | ||
62 | 243 | const char *path, | ||
63 | 244 | CCSContext *context) | ||
64 | 245 | { | ||
65 | 246 | return (*(GET_INTERFACE (CCSGSettingsBackendInterface, backend))->gsettingsBackendGetSettingsObjectForPluginWithPath) (backend, plugin, path, context); | ||
66 | 247 | } | ||
67 | 248 | |||
68 | 249 | static CCSContext * | 226 | static CCSContext * |
69 | 250 | ccsGSettingsBackendGetContextDefault (CCSBackend *backend) | 227 | ccsGSettingsBackendGetContextDefault (CCSBackend *backend) |
70 | 251 | { | 228 | { |
71 | 252 | 229 | ||
72 | === modified file 'compizconfig/gsettings/gsettings_backend_shared/ccs_gsettings_backend_interface.c' | |||
73 | --- compizconfig/gsettings/gsettings_backend_shared/ccs_gsettings_backend_interface.c 2012-08-13 14:41:20 +0000 | |||
74 | +++ compizconfig/gsettings/gsettings_backend_shared/ccs_gsettings_backend_interface.c 2012-09-24 03:58:20 +0000 | |||
75 | @@ -3,6 +3,29 @@ | |||
76 | 3 | 3 | ||
77 | 4 | INTERFACE_TYPE (CCSGSettingsBackendInterface); | 4 | INTERFACE_TYPE (CCSGSettingsBackendInterface); |
78 | 5 | 5 | ||
79 | 6 | CCSContext * | ||
80 | 7 | ccsGSettingsBackendGetContext (CCSBackend *backend) | ||
81 | 8 | { | ||
82 | 9 | return (*(GET_INTERFACE (CCSGSettingsBackendInterface, backend))->gsettingsBackendGetContext) (backend); | ||
83 | 10 | } | ||
84 | 11 | |||
85 | 12 | |||
86 | 13 | void | ||
87 | 14 | ccsGSettingsBackendConnectToChangedSignal (CCSBackend *backend, | ||
88 | 15 | CCSGSettingsWrapper *object) | ||
89 | 16 | { | ||
90 | 17 | (*(GET_INTERFACE (CCSGSettingsBackendInterface, backend))->gsettingsBackendConnectToChangedSignal) (backend, object); | ||
91 | 18 | } | ||
92 | 19 | |||
93 | 20 | CCSGSettingsWrapper * | ||
94 | 21 | ccsGSettingsGetSettingsObjectForPluginWithPath (CCSBackend *backend, | ||
95 | 22 | const char *plugin, | ||
96 | 23 | const char *path, | ||
97 | 24 | CCSContext *context) | ||
98 | 25 | { | ||
99 | 26 | return (*(GET_INTERFACE (CCSGSettingsBackendInterface, backend))->gsettingsBackendGetSettingsObjectForPluginWithPath) (backend, plugin, path, context); | ||
100 | 27 | } | ||
101 | 28 | |||
102 | 6 | const char * | 29 | const char * |
103 | 7 | ccsGSettingsBackendGetCurrentProfile (CCSBackend *backend) | 30 | ccsGSettingsBackendGetCurrentProfile (CCSBackend *backend) |
104 | 8 | { | 31 | { |
105 | 9 | 32 | ||
106 | === added directory 'compizconfig/gsettings/mocks' | |||
107 | === added file 'compizconfig/gsettings/mocks/CMakeLists.txt' | |||
108 | --- compizconfig/gsettings/mocks/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
109 | +++ compizconfig/gsettings/mocks/CMakeLists.txt 2012-09-24 03:58:20 +0000 | |||
110 | @@ -0,0 +1,21 @@ | |||
111 | 1 | pkg_check_modules (GLIB glib-2.0) | ||
112 | 2 | |||
113 | 3 | if (GLIB_FOUND) | ||
114 | 4 | |||
115 | 5 | include_directories (${CMAKE_CURRENT_SOURCE_DIR} | ||
116 | 6 | ${CMAKE_CURRENT_BINARY_DIR} | ||
117 | 7 | ${CMAKE_CURRENT_SOURCE_DIR}/../../libcompizconfig/include | ||
118 | 8 | ${CMAKE_CURRENT_SOURCE_DIR}/../gsettings_backend_shared | ||
119 | 9 | ${GLIB_INCLUDE_DIRS}) | ||
120 | 10 | |||
121 | 11 | set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") | ||
122 | 12 | |||
123 | 13 | add_library (compizconfig_ccs_gsettings_wrapper_mock STATIC | ||
124 | 14 | ${CMAKE_CURRENT_SOURCE_DIR}/ccs_gsettings_wrapper_mock.cpp | ||
125 | 15 | ${CMAKE_CURRENT_SOURCE_DIR}/ccs_gsettings_wrapper_mock.h) | ||
126 | 16 | |||
127 | 17 | add_library (compizconfig_ccs_gsettings_backend_mock STATIC | ||
128 | 18 | ${CMAKE_CURRENT_SOURCE_DIR}/ccs_gsettings_backend_mock.cpp | ||
129 | 19 | ${CMAKE_CURRENT_SOURCE_DIR}/ccs_gsettings_backend_mock.h) | ||
130 | 20 | |||
131 | 21 | endif (GLIB_FOUND) | ||
132 | 0 | 22 | ||
133 | === renamed file 'compizconfig/gsettings/tests/ccs_gsettings_backend_mock.cpp' => 'compizconfig/gsettings/mocks/ccs_gsettings_backend_mock.cpp' | |||
134 | === renamed file 'compizconfig/gsettings/tests/ccs_gsettings_backend_mock.h' => 'compizconfig/gsettings/mocks/ccs_gsettings_backend_mock.h' | |||
135 | === renamed file 'compizconfig/gsettings/tests/ccs_gsettings_wrapper_mock.cpp' => 'compizconfig/gsettings/mocks/ccs_gsettings_wrapper_mock.cpp' | |||
136 | === renamed file 'compizconfig/gsettings/tests/ccs_gsettings_wrapper_mock.h' => 'compizconfig/gsettings/mocks/ccs_gsettings_wrapper_mock.h' | |||
137 | === added directory 'compizconfig/gsettings/testenvironments' | |||
138 | === added file 'compizconfig/gsettings/testenvironments/CMakeLists.txt' | |||
139 | === modified file 'compizconfig/gsettings/tests/CMakeLists.txt' | |||
140 | --- compizconfig/gsettings/tests/CMakeLists.txt 2012-08-16 10:22:05 +0000 | |||
141 | +++ compizconfig/gsettings/tests/CMakeLists.txt 2012-09-24 03:58:20 +0000 | |||
142 | @@ -2,25 +2,25 @@ | |||
143 | 2 | 2 | ||
144 | 3 | include_directories (${CMAKE_CURRENT_SOURCE_DIR} | 3 | include_directories (${CMAKE_CURRENT_SOURCE_DIR} |
145 | 4 | ${CMAKE_CURRENT_BINARY_DIR} | 4 | ${CMAKE_CURRENT_BINARY_DIR} |
146 | 5 | ${CMAKE_CURRENT_SOURCE_DIR}/../mocks | ||
147 | 6 | ${CMAKE_CURRENT_SOURCE_DIR}/../testenvironments | ||
148 | 5 | ${CMAKE_CURRENT_SOURCE_DIR}/../src | 7 | ${CMAKE_CURRENT_SOURCE_DIR}/../src |
149 | 6 | ${CMAKE_CURRENT_SOURCE_DIR}/../../libcompizconfig/tests | 8 | ${CMAKE_CURRENT_SOURCE_DIR}/../../libcompizconfig/tests |
150 | 7 | ${CMAKE_CURRENT_SOURCE_DIR}/../../mocks/libcompizconfig | 9 | ${CMAKE_CURRENT_SOURCE_DIR}/../../mocks/libcompizconfig |
151 | 8 | ${CMAKE_CURRENT_SOURCE_DIR}/../../tests | 10 | ${CMAKE_CURRENT_SOURCE_DIR}/../../tests |
153 | 9 | ${CMAKE_SOURCE_DIR}/tests/shared) | 11 | ${CMAKE_SOURCE_DIR}/tests/shared |
154 | 12 | ${CMAKE_SOURCE_DIR}/tests/shared/glib) | ||
155 | 10 | 13 | ||
157 | 11 | pkg_check_modules (COMPIZCONFIG_TEST_GSETTINGS libcompizconfig) | 14 | pkg_check_modules (COMPIZCONFIG_TEST_GSETTINGS libcompizconfig_internal) |
158 | 12 | 15 | ||
159 | 13 | set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") | 16 | set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") |
160 | 14 | 17 | ||
161 | 15 | link_directories (${CMAKE_CURRENT_BINARY_DIR}/../../libcompizconfig/tests) | 18 | link_directories (${CMAKE_CURRENT_BINARY_DIR}/../../libcompizconfig/tests) |
170 | 16 | 19 | link_directories (${CMAKE_CURRENT_BINARY_DIR}/../testenvironments) | |
171 | 17 | add_library (compizconfig_ccs_gsettings_wrapper_mock STATIC | 20 | link_directories (${CMAKE_CURRENT_BINARY_DIR}/../mocks) |
172 | 18 | ${CMAKE_CURRENT_SOURCE_DIR}/ccs_gsettings_wrapper_mock.cpp | 21 | |
173 | 19 | ${CMAKE_CURRENT_SOURCE_DIR}/ccs_gsettings_wrapper_mock.h) | 22 | add_library (compizconfig_gsettings_settings_test_env STATIC |
174 | 20 | 23 | ${CMAKE_CURRENT_SOURCE_DIR}/compizconfig_ccs_gsettings_settings_env_test.cpp) | |
167 | 21 | add_library (compizconfig_ccs_gsettings_backend_mock STATIC | ||
168 | 22 | ${CMAKE_CURRENT_SOURCE_DIR}/ccs_gsettings_backend_mock.cpp | ||
169 | 23 | ${CMAKE_CURRENT_SOURCE_DIR}/ccs_gsettings_backend_mock.h) | ||
175 | 24 | 24 | ||
176 | 25 | add_executable (compizconfig_test_gsettings | 25 | add_executable (compizconfig_test_gsettings |
177 | 26 | ${CMAKE_CURRENT_SOURCE_DIR}/test_gsettings_tests.cpp | 26 | ${CMAKE_CURRENT_SOURCE_DIR}/test_gsettings_tests.cpp |
178 | @@ -38,6 +38,7 @@ | |||
179 | 38 | compizconfig_ccs_context_mock | 38 | compizconfig_ccs_context_mock |
180 | 39 | compizconfig_ccs_gsettings_backend_mock | 39 | compizconfig_ccs_gsettings_backend_mock |
181 | 40 | compizconfig_ccs_gsettings_wrapper_mock | 40 | compizconfig_ccs_gsettings_wrapper_mock |
182 | 41 | compizconfig_ccs_test_value_combinations | ||
183 | 41 | ${COMPIZCONFIG_TEST_GSETTINGS_LIBRARIES} | 42 | ${COMPIZCONFIG_TEST_GSETTINGS_LIBRARIES} |
184 | 42 | ${GTEST_BOTH_LIBRARIES} | 43 | ${GTEST_BOTH_LIBRARIES} |
185 | 43 | ${GMOCK_MAIN_LIBRARY}) | 44 | ${GMOCK_MAIN_LIBRARY}) |
186 | @@ -59,10 +60,18 @@ | |||
187 | 59 | ${CMAKE_CURRENT_BINARY_DIR}/backend-conformance-config.h) | 60 | ${CMAKE_CURRENT_BINARY_DIR}/backend-conformance-config.h) |
188 | 60 | 61 | ||
189 | 61 | target_link_libraries (compizconfig_test_gsettings_conformance | 62 | target_link_libraries (compizconfig_test_gsettings_conformance |
190 | 63 | compizconfig_gsettings_settings_test_env | ||
191 | 62 | compizconfig_gsettings_backend | 64 | compizconfig_gsettings_backend |
192 | 63 | compizconfig_ccs_setting_mock | 65 | compizconfig_ccs_setting_mock |
193 | 64 | compizconfig_ccs_plugin_mock | 66 | compizconfig_ccs_plugin_mock |
194 | 65 | compizconfig_ccs_context_mock | 67 | compizconfig_ccs_context_mock |
195 | 68 | compizconfig_ccs_item_in_list_matcher | ||
196 | 69 | compizconfig_ccs_list_equality | ||
197 | 70 | compizconfig_ccs_list_wrapper | ||
198 | 71 | compizconfig_ccs_backend_conformance_test | ||
199 | 72 | compizconfig_ccs_setting_value_operators | ||
200 | 73 | compizconfig_ccs_test_value_combinations | ||
201 | 74 | compizconfig_ccs_integration_mock | ||
202 | 66 | ${COMPIZCONFIG_TEST_GSETTINGS_LIBRARIES} | 75 | ${COMPIZCONFIG_TEST_GSETTINGS_LIBRARIES} |
203 | 67 | ${GTEST_BOTH_LIBRARIES} | 76 | ${GTEST_BOTH_LIBRARIES} |
204 | 68 | ${GMOCK_MAIN_LIBRARY}) | 77 | ${GMOCK_MAIN_LIBRARY}) |
205 | 69 | 78 | ||
206 | === added file 'compizconfig/gsettings/tests/compizconfig_ccs_gsettings_settings_env_test.cpp' | |||
207 | --- compizconfig/gsettings/tests/compizconfig_ccs_gsettings_settings_env_test.cpp 1970-01-01 00:00:00 +0000 | |||
208 | +++ compizconfig/gsettings/tests/compizconfig_ccs_gsettings_settings_env_test.cpp 2012-09-24 03:58:20 +0000 | |||
209 | @@ -0,0 +1,364 @@ | |||
210 | 1 | /* | ||
211 | 2 | * Compiz configuration system library | ||
212 | 3 | * | ||
213 | 4 | * Copyright (C) 2012 Canonical Ltd. | ||
214 | 5 | * | ||
215 | 6 | * This library is free software; you can redistribute it and/or | ||
216 | 7 | * modify it under the terms of the GNU Lesser General Public | ||
217 | 8 | * License as published by the Free Software Foundation; either | ||
218 | 9 | * version 2.1 of the License, or (at your option) any later version. | ||
219 | 10 | |||
220 | 11 | * This library is distributed in the hope that it will be useful, | ||
221 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
222 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
223 | 14 | * Lesser General Public License for more details. | ||
224 | 15 | |||
225 | 16 | * You should have received a copy of the GNU Lesser General Public | ||
226 | 17 | * License along with this library; if not, write to the Free Software | ||
227 | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
228 | 19 | * | ||
229 | 20 | * Authored By: | ||
230 | 21 | * Sam Spilsbury <sam.spilsbury@canonical.com> | ||
231 | 22 | */ | ||
232 | 23 | |||
233 | 24 | #include <gtest/gtest.h> | ||
234 | 25 | #include <gmock/gmock.h> | ||
235 | 26 | |||
236 | 27 | #include <gio/gio.h> | ||
237 | 28 | #include <gsettings_util.h> | ||
238 | 29 | #include <ccs_gsettings_backend_interface.h> | ||
239 | 30 | |||
240 | 31 | #include <gtest_shared_autodestroy.h> | ||
241 | 32 | #include <gtest_shared_characterwrapper.h> | ||
242 | 33 | #include "test_gsettings_tests.h" | ||
243 | 34 | |||
244 | 35 | #include <glib_gslice_off_env.h> | ||
245 | 36 | #include <glib_gsettings_memory_backend_env.h> | ||
246 | 37 | |||
247 | 38 | #include "compizconfig_ccs_gsettings_settings_env_test.h" | ||
248 | 39 | |||
249 | 40 | #include "backend-conformance-config.h" | ||
250 | 41 | #include "gsettings-mock-schemas-config.h" | ||
251 | 42 | |||
252 | 43 | namespace cci = compiz::config::impl; | ||
253 | 44 | namespace cct = compizconfig::test; | ||
254 | 45 | |||
255 | 46 | class PrivateCCSGSettingsStorageEnv | ||
256 | 47 | { | ||
257 | 48 | public: | ||
258 | 49 | |||
259 | 50 | PrivateCCSGSettingsStorageEnv (CCSGSettingsWrapper *settings, | ||
260 | 51 | const std::string &profileName); | ||
261 | 52 | |||
262 | 53 | CCSGSettingsWrapper *mSettings; | ||
263 | 54 | std::string profileName; | ||
264 | 55 | CompizGLibGSettingsMemoryBackendTestingEnv gsettingsEnv; | ||
265 | 56 | CompizGLibGSliceOffEnv gsliceEnv; | ||
266 | 57 | }; | ||
267 | 58 | |||
268 | 59 | void | ||
269 | 60 | CCSGSettingsStorageEnv::WriteBoolAtKey (const std::string &plugin, | ||
270 | 61 | const std::string &key, | ||
271 | 62 | const VariantTypes &value) | ||
272 | 63 | { | ||
273 | 64 | GVariant *variant = NULL; | ||
274 | 65 | if (writeBoolToVariant (cct::boolToBool (boost::get <bool> (value)), &variant)) | ||
275 | 66 | writeVariantToKey (priv->mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant); | ||
276 | 67 | else | ||
277 | 68 | throw std::exception (); | ||
278 | 69 | } | ||
279 | 70 | |||
280 | 71 | void | ||
281 | 72 | CCSGSettingsStorageEnv::WriteIntegerAtKey (const std::string &plugin, | ||
282 | 73 | const std::string &key, | ||
283 | 74 | const VariantTypes &value) | ||
284 | 75 | { | ||
285 | 76 | GVariant *variant = NULL; | ||
286 | 77 | if (writeIntToVariant (boost::get <int> (value), &variant)) | ||
287 | 78 | writeVariantToKey (priv->mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant); | ||
288 | 79 | else | ||
289 | 80 | throw std::exception (); | ||
290 | 81 | } | ||
291 | 82 | |||
292 | 83 | void | ||
293 | 84 | CCSGSettingsStorageEnv::WriteFloatAtKey (const std::string &plugin, | ||
294 | 85 | const std::string &key, | ||
295 | 86 | const VariantTypes &value) | ||
296 | 87 | { | ||
297 | 88 | GVariant *variant = NULL; | ||
298 | 89 | if (writeFloatToVariant (boost::get <float> (value), &variant)) | ||
299 | 90 | writeVariantToKey (priv->mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant); | ||
300 | 91 | else | ||
301 | 92 | throw std::exception (); | ||
302 | 93 | } | ||
303 | 94 | |||
304 | 95 | void | ||
305 | 96 | CCSGSettingsStorageEnv::WriteStringAtKey (const std::string &plugin, | ||
306 | 97 | const std::string &key, | ||
307 | 98 | const VariantTypes &value) | ||
308 | 99 | { | ||
309 | 100 | GVariant *variant = NULL; | ||
310 | 101 | if (writeStringToVariant (boost::get <const char *> (value), &variant)) | ||
311 | 102 | writeVariantToKey (priv->mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant); | ||
312 | 103 | else | ||
313 | 104 | throw std::exception (); | ||
314 | 105 | } | ||
315 | 106 | |||
316 | 107 | void | ||
317 | 108 | CCSGSettingsStorageEnv::WriteColorAtKey (const std::string &plugin, | ||
318 | 109 | const std::string &key, | ||
319 | 110 | const VariantTypes &value) | ||
320 | 111 | { | ||
321 | 112 | GVariant *variant = NULL; | ||
322 | 113 | if (writeColorToVariant (boost::get <CCSSettingColorValue> (value), &variant)) | ||
323 | 114 | writeVariantToKey (priv->mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant); | ||
324 | 115 | else | ||
325 | 116 | throw std::exception (); | ||
326 | 117 | } | ||
327 | 118 | |||
328 | 119 | void | ||
329 | 120 | CCSGSettingsStorageEnv::WriteKeyAtKey (const std::string &plugin, | ||
330 | 121 | const std::string &key, | ||
331 | 122 | const VariantTypes &value) | ||
332 | 123 | { | ||
333 | 124 | GVariant *variant = NULL; | ||
334 | 125 | if (writeKeyToVariant (boost::get <CCSSettingKeyValue> (value), &variant)) | ||
335 | 126 | writeVariantToKey (priv->mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant); | ||
336 | 127 | else | ||
337 | 128 | throw std::exception (); | ||
338 | 129 | } | ||
339 | 130 | |||
340 | 131 | void | ||
341 | 132 | CCSGSettingsStorageEnv::WriteButtonAtKey (const std::string &plugin, | ||
342 | 133 | const std::string &key, | ||
343 | 134 | const VariantTypes &value) | ||
344 | 135 | { | ||
345 | 136 | GVariant *variant = NULL; | ||
346 | 137 | if (writeButtonToVariant (boost::get <CCSSettingButtonValue> (value), &variant)) | ||
347 | 138 | writeVariantToKey (priv->mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant); | ||
348 | 139 | else | ||
349 | 140 | throw std::exception (); | ||
350 | 141 | } | ||
351 | 142 | |||
352 | 143 | void | ||
353 | 144 | CCSGSettingsStorageEnv::WriteEdgeAtKey (const std::string &plugin, | ||
354 | 145 | const std::string &key, | ||
355 | 146 | const VariantTypes &value) | ||
356 | 147 | { | ||
357 | 148 | GVariant *variant = NULL; | ||
358 | 149 | if (writeEdgeToVariant (boost::get <unsigned int> (value), &variant)) | ||
359 | 150 | writeVariantToKey (priv->mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant); | ||
360 | 151 | else | ||
361 | 152 | throw std::exception (); | ||
362 | 153 | } | ||
363 | 154 | |||
364 | 155 | void | ||
365 | 156 | CCSGSettingsStorageEnv::WriteMatchAtKey (const std::string &plugin, | ||
366 | 157 | const std::string &key, | ||
367 | 158 | const VariantTypes &value) | ||
368 | 159 | { | ||
369 | 160 | GVariant *variant = NULL; | ||
370 | 161 | if (writeStringToVariant (boost::get <const char *> (value), &variant)) | ||
371 | 162 | writeVariantToKey (priv->mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant); | ||
372 | 163 | else | ||
373 | 164 | throw std::exception (); | ||
374 | 165 | } | ||
375 | 166 | |||
376 | 167 | void | ||
377 | 168 | CCSGSettingsStorageEnv::WriteBellAtKey (const std::string &plugin, | ||
378 | 169 | const std::string &key, | ||
379 | 170 | const VariantTypes &value) | ||
380 | 171 | { | ||
381 | 172 | GVariant *variant = NULL; | ||
382 | 173 | if (writeBoolToVariant (cct::boolToBool (boost::get <bool> (value)), &variant)) | ||
383 | 174 | writeVariantToKey (priv->mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant); | ||
384 | 175 | else | ||
385 | 176 | throw std::exception (); | ||
386 | 177 | } | ||
387 | 178 | |||
388 | 179 | void | ||
389 | 180 | CCSGSettingsStorageEnv::WriteListAtKey (const std::string &plugin, | ||
390 | 181 | const std::string &key, | ||
391 | 182 | const VariantTypes &value) | ||
392 | 183 | { | ||
393 | 184 | GVariant *variant = NULL; | ||
394 | 185 | |||
395 | 186 | const cci::SettingValueListWrapper::Ptr &lw (boost::get <cci::SettingValueListWrapper::Ptr> (value)); | ||
396 | 187 | |||
397 | 188 | if (writeListValue (*lw, lw->type (), &variant)) | ||
398 | 189 | writeVariantToKey (priv->mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant); | ||
399 | 190 | else | ||
400 | 191 | throw std::exception (); | ||
401 | 192 | } | ||
402 | 193 | |||
403 | 194 | Bool | ||
404 | 195 | CCSGSettingsStorageEnv::ReadBoolAtKey (const std::string &plugin, | ||
405 | 196 | const std::string &key) | ||
406 | 197 | { | ||
407 | 198 | GVariantShared variant (ReadVariantAtKeyToShared (plugin, | ||
408 | 199 | key, | ||
409 | 200 | TypeBool)); | ||
410 | 201 | return readBoolFromVariant (variant.get ()); | ||
411 | 202 | } | ||
412 | 203 | |||
413 | 204 | |||
414 | 205 | int | ||
415 | 206 | CCSGSettingsStorageEnv::ReadIntegerAtKey (const std::string &plugin, | ||
416 | 207 | const std::string &key) | ||
417 | 208 | { | ||
418 | 209 | GVariantShared variant (ReadVariantAtKeyToShared (plugin, | ||
419 | 210 | key, | ||
420 | 211 | TypeInt)); | ||
421 | 212 | return readIntFromVariant (variant.get ()); | ||
422 | 213 | } | ||
423 | 214 | |||
424 | 215 | float | ||
425 | 216 | CCSGSettingsStorageEnv::ReadFloatAtKey (const std::string &plugin, | ||
426 | 217 | const std::string &key) | ||
427 | 218 | { | ||
428 | 219 | GVariantShared variant (ReadVariantAtKeyToShared (plugin, | ||
429 | 220 | key, | ||
430 | 221 | TypeFloat)); | ||
431 | 222 | return readFloatFromVariant (variant.get ()); | ||
432 | 223 | } | ||
433 | 224 | |||
434 | 225 | const char * | ||
435 | 226 | CCSGSettingsStorageEnv::ReadStringAtKey (const std::string &plugin, | ||
436 | 227 | const std::string &key) | ||
437 | 228 | { | ||
438 | 229 | GVariantShared variant (ReadVariantAtKeyToShared (plugin, | ||
439 | 230 | key, | ||
440 | 231 | TypeString)); | ||
441 | 232 | return readStringFromVariant (variant.get ()); | ||
442 | 233 | } | ||
443 | 234 | |||
444 | 235 | CCSSettingColorValue | ||
445 | 236 | CCSGSettingsStorageEnv::ReadColorAtKey (const std::string &plugin, | ||
446 | 237 | const std::string &key) | ||
447 | 238 | { | ||
448 | 239 | Bool success = FALSE; | ||
449 | 240 | GVariantShared variant (ReadVariantAtKeyToShared (plugin, | ||
450 | 241 | key, | ||
451 | 242 | TypeColor)); | ||
452 | 243 | CCSSettingColorValue value = readColorFromVariant (variant.get (), &success); | ||
453 | 244 | EXPECT_TRUE (success); | ||
454 | 245 | return value; | ||
455 | 246 | } | ||
456 | 247 | |||
457 | 248 | CCSSettingKeyValue | ||
458 | 249 | CCSGSettingsStorageEnv::ReadKeyAtKey (const std::string &plugin, | ||
459 | 250 | const std::string &key) | ||
460 | 251 | { | ||
461 | 252 | Bool success = FALSE; | ||
462 | 253 | GVariantShared variant (ReadVariantAtKeyToShared (plugin, | ||
463 | 254 | key, | ||
464 | 255 | TypeKey)); | ||
465 | 256 | CCSSettingKeyValue value = readKeyFromVariant (variant.get (), &success); | ||
466 | 257 | EXPECT_TRUE (success); | ||
467 | 258 | return value; | ||
468 | 259 | } | ||
469 | 260 | |||
470 | 261 | CCSSettingButtonValue | ||
471 | 262 | CCSGSettingsStorageEnv::ReadButtonAtKey (const std::string &plugin, | ||
472 | 263 | const std::string &key) | ||
473 | 264 | { | ||
474 | 265 | Bool success = FALSE; | ||
475 | 266 | GVariantShared variant (ReadVariantAtKeyToShared (plugin, | ||
476 | 267 | key, | ||
477 | 268 | TypeButton)); | ||
478 | 269 | CCSSettingButtonValue value = readButtonFromVariant (variant.get (), &success); | ||
479 | 270 | EXPECT_TRUE (success); | ||
480 | 271 | return value; | ||
481 | 272 | } | ||
482 | 273 | |||
483 | 274 | unsigned int | ||
484 | 275 | CCSGSettingsStorageEnv::ReadEdgeAtKey (const std::string &plugin, | ||
485 | 276 | const std::string &key) | ||
486 | 277 | { | ||
487 | 278 | GVariantShared variant (ReadVariantAtKeyToShared (plugin, | ||
488 | 279 | key, | ||
489 | 280 | TypeEdge)); | ||
490 | 281 | return readEdgeFromVariant (variant.get ()); | ||
491 | 282 | } | ||
492 | 283 | |||
493 | 284 | const char * | ||
494 | 285 | CCSGSettingsStorageEnv::ReadMatchAtKey (const std::string &plugin, | ||
495 | 286 | const std::string &key) | ||
496 | 287 | { | ||
497 | 288 | GVariantShared variant (ReadVariantAtKeyToShared (plugin, | ||
498 | 289 | key, | ||
499 | 290 | TypeMatch)); | ||
500 | 291 | return readStringFromVariant (variant.get ()); | ||
501 | 292 | } | ||
502 | 293 | |||
503 | 294 | Bool | ||
504 | 295 | CCSGSettingsStorageEnv::ReadBellAtKey (const std::string &plugin, | ||
505 | 296 | const std::string &key) | ||
506 | 297 | { | ||
507 | 298 | GVariantShared variant (ReadVariantAtKeyToShared (plugin, | ||
508 | 299 | key, | ||
509 | 300 | TypeBell)); | ||
510 | 301 | return readBoolFromVariant (variant.get ()); | ||
511 | 302 | } | ||
512 | 303 | |||
513 | 304 | CCSSettingValueList | ||
514 | 305 | CCSGSettingsStorageEnv::ReadListAtKey (const std::string &plugin, | ||
515 | 306 | const std::string &key, | ||
516 | 307 | CCSSetting *setting) | ||
517 | 308 | { | ||
518 | 309 | GVariantShared variant (ReadVariantAtKeyToShared (plugin, | ||
519 | 310 | key, | ||
520 | 311 | TypeList)); | ||
521 | 312 | return readListValue (variant.get (), setting, &ccsDefaultObjectAllocator); | ||
522 | 313 | } | ||
523 | 314 | |||
524 | 315 | GVariantShared | ||
525 | 316 | CCSGSettingsStorageEnv::ReadVariantAtKeyToShared (const std::string &plugin, | ||
526 | 317 | const std::string &key, | ||
527 | 318 | CCSSettingType type) | ||
528 | 319 | { | ||
529 | 320 | CharacterWrapper translatedKey (translateKeyForGSettings (key.c_str ())); | ||
530 | 321 | CharacterWrapper pluginPath (makeCompizPluginPath (priv->profileName.c_str (), | ||
531 | 322 | plugin.c_str ())); | ||
532 | 323 | |||
533 | 324 | GVariant *rawVariant = getVariantAtKey (priv->mSettings, | ||
534 | 325 | translatedKey, | ||
535 | 326 | pluginPath, | ||
536 | 327 | type); | ||
537 | 328 | |||
538 | 329 | GVariantShared shared (AutoDestroy (rawVariant, g_variant_unref)); | ||
539 | 330 | |||
540 | 331 | |||
541 | 332 | |||
542 | 333 | return shared; | ||
543 | 334 | } | ||
544 | 335 | |||
545 | 336 | void | ||
546 | 337 | CCSGSettingsStorageEnv::SetUp () | ||
547 | 338 | { | ||
548 | 339 | g_type_init (); | ||
549 | 340 | priv->gsliceEnv.SetUpEnv (); | ||
550 | 341 | priv->gsettingsEnv.SetUpEnv (MOCK_PATH); | ||
551 | 342 | } | ||
552 | 343 | |||
553 | 344 | void | ||
554 | 345 | CCSGSettingsStorageEnv::TearDown () | ||
555 | 346 | { | ||
556 | 347 | priv->gsettingsEnv.TearDownEnv (); | ||
557 | 348 | priv->gsliceEnv.TearDownEnv (); | ||
558 | 349 | } | ||
559 | 350 | |||
560 | 351 | PrivateCCSGSettingsStorageEnv::PrivateCCSGSettingsStorageEnv (CCSGSettingsWrapper *settings, | ||
561 | 352 | const std::string &profileName) : | ||
562 | 353 | mSettings (settings), | ||
563 | 354 | profileName (profileName) | ||
564 | 355 | |||
565 | 356 | { | ||
566 | 357 | } | ||
567 | 358 | |||
568 | 359 | CCSGSettingsStorageEnv::CCSGSettingsStorageEnv (CCSGSettingsWrapper *settings, | ||
569 | 360 | const std::string &profileName) : | ||
570 | 361 | priv (new PrivateCCSGSettingsStorageEnv (settings, | ||
571 | 362 | profileName)) | ||
572 | 363 | { | ||
573 | 364 | } | ||
574 | 0 | 365 | ||
575 | === added file 'compizconfig/gsettings/tests/compizconfig_ccs_gsettings_settings_env_test.h' | |||
576 | --- compizconfig/gsettings/tests/compizconfig_ccs_gsettings_settings_env_test.h 1970-01-01 00:00:00 +0000 | |||
577 | +++ compizconfig/gsettings/tests/compizconfig_ccs_gsettings_settings_env_test.h 2012-09-24 03:58:20 +0000 | |||
578 | @@ -0,0 +1,134 @@ | |||
579 | 1 | /* | ||
580 | 2 | * Compiz configuration system library | ||
581 | 3 | * | ||
582 | 4 | * Copyright (C) 2012 Canonical Ltd. | ||
583 | 5 | * | ||
584 | 6 | * This library is free software; you can redistribute it and/or | ||
585 | 7 | * modify it under the terms of the GNU Lesser General Public | ||
586 | 8 | * License as published by the Free Software Foundation; either | ||
587 | 9 | * version 2.1 of the License, or (at your option) any later version. | ||
588 | 10 | |||
589 | 11 | * This library is distributed in the hope that it will be useful, | ||
590 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
591 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
592 | 14 | * Lesser General Public License for more details. | ||
593 | 15 | |||
594 | 16 | * You should have received a copy of the GNU Lesser General Public | ||
595 | 17 | * License along with this library; if not, write to the Free Software | ||
596 | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
597 | 19 | * | ||
598 | 20 | * Authored By: | ||
599 | 21 | * Sam Spilsbury <sam.spilsbury@canonical.com> | ||
600 | 22 | */ | ||
601 | 23 | #ifndef _COMPIZCONFIG_CCS_GSETTINGS_SETTINGS_ENV_TEST_H | ||
602 | 24 | #define _COMPIZCONFIG_CCS_GSETTINGS_SETTINGS_ENV_TEST_H | ||
603 | 25 | |||
604 | 26 | #include <memory> | ||
605 | 27 | #include <boost/shared_ptr.hpp> | ||
606 | 28 | |||
607 | 29 | #include "compizconfig_ccs_settings_test_fixture.h" | ||
608 | 30 | |||
609 | 31 | typedef boost::shared_ptr <GVariant> GVariantShared; | ||
610 | 32 | typedef struct _CCSSetting CCSSetting; | ||
611 | 33 | typedef struct _CCSGSettingsWrapper CCSGSettingsWrapper; | ||
612 | 34 | typedef enum _CCSSettingType CCSSettingType; | ||
613 | 35 | |||
614 | 36 | class PrivateCCSGSettingsStorageEnv; | ||
615 | 37 | |||
616 | 38 | class CCSGSettingsStorageEnv : | ||
617 | 39 | public CCSSettingsConceptTestEnvironmentInterface | ||
618 | 40 | { | ||
619 | 41 | public: | ||
620 | 42 | |||
621 | 43 | virtual void SetUp (); | ||
622 | 44 | virtual void TearDown (); | ||
623 | 45 | |||
624 | 46 | CCSGSettingsStorageEnv (CCSGSettingsWrapper *settings, | ||
625 | 47 | const std::string &profileName); | ||
626 | 48 | |||
627 | 49 | void WriteBoolAtKey (const std::string &plugin, | ||
628 | 50 | const std::string &key, | ||
629 | 51 | const VariantTypes &value); | ||
630 | 52 | void WriteIntegerAtKey (const std::string &plugin, | ||
631 | 53 | const std::string &key, | ||
632 | 54 | const VariantTypes &value); | ||
633 | 55 | |||
634 | 56 | void WriteFloatAtKey (const std::string &plugin, | ||
635 | 57 | const std::string &key, | ||
636 | 58 | const VariantTypes &value); | ||
637 | 59 | |||
638 | 60 | void WriteStringAtKey (const std::string &plugin, | ||
639 | 61 | const std::string &key, | ||
640 | 62 | const VariantTypes &value); | ||
641 | 63 | |||
642 | 64 | void WriteColorAtKey (const std::string &plugin, | ||
643 | 65 | const std::string &key, | ||
644 | 66 | const VariantTypes &value); | ||
645 | 67 | |||
646 | 68 | void WriteKeyAtKey (const std::string &plugin, | ||
647 | 69 | const std::string &key, | ||
648 | 70 | const VariantTypes &value); | ||
649 | 71 | |||
650 | 72 | void WriteButtonAtKey (const std::string &plugin, | ||
651 | 73 | const std::string &key, | ||
652 | 74 | const VariantTypes &value); | ||
653 | 75 | |||
654 | 76 | void WriteEdgeAtKey (const std::string &plugin, | ||
655 | 77 | const std::string &key, | ||
656 | 78 | const VariantTypes &value); | ||
657 | 79 | |||
658 | 80 | void WriteMatchAtKey (const std::string &plugin, | ||
659 | 81 | const std::string &key, | ||
660 | 82 | const VariantTypes &value); | ||
661 | 83 | |||
662 | 84 | void WriteBellAtKey (const std::string &plugin, | ||
663 | 85 | const std::string &key, | ||
664 | 86 | const VariantTypes &value); | ||
665 | 87 | |||
666 | 88 | void WriteListAtKey (const std::string &plugin, | ||
667 | 89 | const std::string &key, | ||
668 | 90 | const VariantTypes &value); | ||
669 | 91 | |||
670 | 92 | Bool ReadBoolAtKey (const std::string &plugin, | ||
671 | 93 | const std::string &key); | ||
672 | 94 | |||
673 | 95 | int ReadIntegerAtKey (const std::string &plugin, | ||
674 | 96 | const std::string &key); | ||
675 | 97 | |||
676 | 98 | float ReadFloatAtKey (const std::string &plugin, | ||
677 | 99 | const std::string &key); | ||
678 | 100 | |||
679 | 101 | const char * ReadStringAtKey (const std::string &plugin, | ||
680 | 102 | const std::string &key); | ||
681 | 103 | |||
682 | 104 | CCSSettingColorValue ReadColorAtKey (const std::string &plugin, | ||
683 | 105 | const std::string &key); | ||
684 | 106 | |||
685 | 107 | CCSSettingKeyValue ReadKeyAtKey (const std::string &plugin, | ||
686 | 108 | const std::string &key); | ||
687 | 109 | CCSSettingButtonValue ReadButtonAtKey (const std::string &plugin, | ||
688 | 110 | const std::string &key); | ||
689 | 111 | |||
690 | 112 | unsigned int ReadEdgeAtKey (const std::string &plugin, | ||
691 | 113 | const std::string &key); | ||
692 | 114 | |||
693 | 115 | const char * ReadMatchAtKey (const std::string &plugin, | ||
694 | 116 | const std::string &key); | ||
695 | 117 | Bool ReadBellAtKey (const std::string &plugin, | ||
696 | 118 | const std::string &key); | ||
697 | 119 | |||
698 | 120 | CCSSettingValueList ReadListAtKey (const std::string &plugin, | ||
699 | 121 | const std::string &key, | ||
700 | 122 | CCSSetting *setting); | ||
701 | 123 | |||
702 | 124 | private: | ||
703 | 125 | |||
704 | 126 | GVariantShared | ||
705 | 127 | ReadVariantAtKeyToShared (const std::string &plugin, | ||
706 | 128 | const std::string &key, | ||
707 | 129 | CCSSettingType type); | ||
708 | 130 | |||
709 | 131 | std::auto_ptr <PrivateCCSGSettingsStorageEnv> priv; | ||
710 | 132 | }; | ||
711 | 133 | |||
712 | 134 | #endif | ||
713 | 0 | 135 | ||
714 | === modified file 'compizconfig/gsettings/tests/gsettings-mock-schemas-config.h.in' | |||
715 | --- compizconfig/gsettings/tests/gsettings-mock-schemas-config.h.in 2012-08-11 11:05:13 +0000 | |||
716 | +++ compizconfig/gsettings/tests/gsettings-mock-schemas-config.h.in 2012-09-24 03:58:20 +0000 | |||
717 | @@ -3,6 +3,8 @@ | |||
718 | 3 | 3 | ||
719 | 4 | #define MOCK_SCHEMA_PATH "@CMAKE_BINARY_DIR@/generated/glib-2.0/schemas" | 4 | #define MOCK_SCHEMA_PATH "@CMAKE_BINARY_DIR@/generated/glib-2.0/schemas" |
720 | 5 | 5 | ||
721 | 6 | #include <string> | ||
722 | 7 | |||
723 | 6 | namespace | 8 | namespace |
724 | 7 | { | 9 | { |
725 | 8 | const std::string MOCK_SCHEMA ("org.compiz.mock"); | 10 | const std::string MOCK_SCHEMA ("org.compiz.mock"); |
726 | 9 | 11 | ||
727 | === added file 'compizconfig/gsettings/tests/gsettings_settings_test_fixture.h' | |||
728 | --- compizconfig/gsettings/tests/gsettings_settings_test_fixture.h 1970-01-01 00:00:00 +0000 | |||
729 | +++ compizconfig/gsettings/tests/gsettings_settings_test_fixture.h 2012-09-24 03:58:20 +0000 | |||
730 | @@ -0,0 +1,29 @@ | |||
731 | 1 | /* | ||
732 | 2 | * Compiz configuration system library | ||
733 | 3 | * | ||
734 | 4 | * Copyright (C) 2012 Canonical Ltd. | ||
735 | 5 | * | ||
736 | 6 | * This library is free software; you can redistribute it and/or | ||
737 | 7 | * modify it under the terms of the GNU Lesser General Public | ||
738 | 8 | * License as published by the Free Software Foundation; either | ||
739 | 9 | * version 2.1 of the License, or (at your option) any later version. | ||
740 | 10 | |||
741 | 11 | * This library is distributed in the hope that it will be useful, | ||
742 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
743 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
744 | 14 | * Lesser General Public License for more details. | ||
745 | 15 | |||
746 | 16 | * You should have received a copy of the GNU Lesser General Public | ||
747 | 17 | * License along with this library; if not, write to the Free Software | ||
748 | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
749 | 19 | * | ||
750 | 20 | * Authored By: | ||
751 | 21 | * Sam Spilsbury <sam.spilsbury@canonical.com> | ||
752 | 22 | */ | ||
753 | 23 | #ifndef _COMPIZCONFIG_GSETTINGS_SETTINGS_TEST_FIXTURE_H | ||
754 | 24 | #define _COMPIZCONFIG_GSETTINGS_SETTINGS_TEST_FIXTURE_H | ||
755 | 25 | |||
756 | 26 | #include <gtest/gtest.h> | ||
757 | 27 | #include <glib_gsettings_memory_backend_env.h> | ||
758 | 28 | |||
759 | 29 | #endif | ||
760 | 0 | 30 | ||
761 | === modified file 'compizconfig/gsettings/tests/test_gsettings_conformance.cpp' | |||
762 | --- compizconfig/gsettings/tests/test_gsettings_conformance.cpp 2012-09-24 03:58:20 +0000 | |||
763 | +++ compizconfig/gsettings/tests/test_gsettings_conformance.cpp 2012-09-24 03:58:20 +0000 | |||
764 | @@ -1,3 +1,25 @@ | |||
765 | 1 | /* | ||
766 | 2 | * Compiz configuration system library | ||
767 | 3 | * | ||
768 | 4 | * Copyright (C) 2012 Canonical Ltd. | ||
769 | 5 | * | ||
770 | 6 | * This library is free software; you can redistribute it and/or | ||
771 | 7 | * modify it under the terms of the GNU Lesser General Public | ||
772 | 8 | * License as published by the Free Software Foundation; either | ||
773 | 9 | * version 2.1 of the License, or (at your option) any later version. | ||
774 | 10 | |||
775 | 11 | * This library is distributed in the hope that it will be useful, | ||
776 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
777 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
778 | 14 | * Lesser General Public License for more details. | ||
779 | 15 | |||
780 | 16 | * You should have received a copy of the GNU Lesser General Public | ||
781 | 17 | * License along with this library; if not, write to the Free Software | ||
782 | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
783 | 19 | * | ||
784 | 20 | * Authored By: | ||
785 | 21 | * Sam Spilsbury <sam.spilsbury@canonical.com> | ||
786 | 22 | */ | ||
787 | 1 | #include <gtest/gtest.h> | 23 | #include <gtest/gtest.h> |
788 | 2 | #include <gmock/gmock.h> | 24 | #include <gmock/gmock.h> |
789 | 3 | 25 | ||
790 | @@ -15,441 +37,15 @@ | |||
791 | 15 | #include "gtest_shared_autodestroy.h" | 37 | #include "gtest_shared_autodestroy.h" |
792 | 16 | #include "test_gsettings_tests.h" | 38 | #include "test_gsettings_tests.h" |
793 | 17 | 39 | ||
794 | 40 | #include "compizconfig_ccs_gsettings_settings_env_test.h" | ||
795 | 41 | #include "compizconfig_ccs_integration_mock.h" | ||
796 | 42 | |||
797 | 18 | using ::testing::AtLeast; | 43 | using ::testing::AtLeast; |
798 | 19 | using ::testing::Pointee; | 44 | using ::testing::Pointee; |
799 | 20 | using ::testing::ReturnNull; | 45 | using ::testing::ReturnNull; |
800 | 21 | 46 | ||
801 | 22 | namespace cci = compiz::config::impl; | 47 | namespace cci = compiz::config::impl; |
802 | 23 | 48 | ||
803 | 24 | CCSIntegration * | ||
804 | 25 | ccsMockIntegrationBackendNew (CCSObjectAllocationInterface *ai); | ||
805 | 26 | |||
806 | 27 | void | ||
807 | 28 | ccsMockIntegrationBackendFree (CCSIntegration *integration); | ||
808 | 29 | |||
809 | 30 | class CCSIntegrationGMockInterface | ||
810 | 31 | { | ||
811 | 32 | public: | ||
812 | 33 | |||
813 | 34 | virtual ~CCSIntegrationGMockInterface () {} | ||
814 | 35 | |||
815 | 36 | virtual CCSIntegratedSetting * getIntegratedOptionIndex (const char *pluginName, const char *settingName) = 0; | ||
816 | 37 | virtual Bool readOptionIntoSetting (CCSContext *context, CCSSetting *setting, CCSIntegratedSetting *) = 0; | ||
817 | 38 | virtual void writeOptionFromSetting (CCSContext *context, CCSSetting *setting, CCSIntegratedSetting *) = 0; | ||
818 | 39 | virtual void updateIntegratedSettings (CCSContext *context, CCSIntegratedSettingList settingList) = 0; | ||
819 | 40 | virtual void disallowIntegratedWrites () = 0; | ||
820 | 41 | virtual void allowIntegratedWrites () = 0; | ||
821 | 42 | }; | ||
822 | 43 | |||
823 | 44 | class CCSIntegrationGMock : | ||
824 | 45 | public CCSIntegrationGMockInterface | ||
825 | 46 | { | ||
826 | 47 | public: | ||
827 | 48 | |||
828 | 49 | MOCK_METHOD2 (getIntegratedOptionIndex, CCSIntegratedSetting * (const char *, const char *)); | ||
829 | 50 | MOCK_METHOD3 (readOptionIntoSetting, Bool (CCSContext *, CCSSetting *, CCSIntegratedSetting *)); | ||
830 | 51 | MOCK_METHOD3 (writeOptionFromSetting, void (CCSContext *, CCSSetting *, CCSIntegratedSetting *)); | ||
831 | 52 | MOCK_METHOD2 (updateIntegratedSettings, void (CCSContext *, CCSIntegratedSettingList)); | ||
832 | 53 | MOCK_METHOD0 (disallowIntegratedWrites, void ()); | ||
833 | 54 | MOCK_METHOD0 (allowIntegratedWrites, void ()); | ||
834 | 55 | |||
835 | 56 | |||
836 | 57 | CCSIntegrationGMock (CCSIntegration *integration) : | ||
837 | 58 | mIntegration (integration) | ||
838 | 59 | { | ||
839 | 60 | } | ||
840 | 61 | |||
841 | 62 | CCSIntegration * | ||
842 | 63 | getIntegrationBackend () | ||
843 | 64 | { | ||
844 | 65 | return mIntegration; | ||
845 | 66 | } | ||
846 | 67 | |||
847 | 68 | public: | ||
848 | 69 | |||
849 | 70 | static | ||
850 | 71 | CCSIntegratedSetting * CCSIntegrationGetIntegratedOptionIndex (CCSIntegration *integration, | ||
851 | 72 | const char *pluginName, | ||
852 | 73 | const char *settingName) | ||
853 | 74 | { | ||
854 | 75 | return reinterpret_cast <CCSIntegrationGMockInterface *> (ccsObjectGetPrivate (integration))->getIntegratedOptionIndex (pluginName, settingName); | ||
855 | 76 | } | ||
856 | 77 | |||
857 | 78 | static | ||
858 | 79 | Bool CCSIntegrationReadOptionIntoSetting (CCSIntegration *integration, | ||
859 | 80 | CCSContext *context, | ||
860 | 81 | CCSSetting *setting, | ||
861 | 82 | CCSIntegratedSetting *integrated) | ||
862 | 83 | { | ||
863 | 84 | return reinterpret_cast <CCSIntegrationGMockInterface *> (ccsObjectGetPrivate (integration))->readOptionIntoSetting (context, setting, integrated); | ||
864 | 85 | } | ||
865 | 86 | |||
866 | 87 | static | ||
867 | 88 | void CCSIntegrationWriteSettingIntoOption (CCSIntegration *integration, | ||
868 | 89 | CCSContext *context, | ||
869 | 90 | CCSSetting *setting, | ||
870 | 91 | CCSIntegratedSetting *integrated) | ||
871 | 92 | { | ||
872 | 93 | return reinterpret_cast <CCSIntegrationGMockInterface *> (ccsObjectGetPrivate (integration))->writeOptionFromSetting (context, setting, integrated); | ||
873 | 94 | } | ||
874 | 95 | |||
875 | 96 | static void CCSIntegrationUpdateIntegratedSettings (CCSIntegration *integration, | ||
876 | 97 | CCSContext *context, | ||
877 | 98 | CCSIntegratedSettingList settingList) | ||
878 | 99 | { | ||
879 | 100 | return reinterpret_cast <CCSIntegrationGMockInterface *> (ccsObjectGetPrivate (integration))->updateIntegratedSettings (context, settingList); | ||
880 | 101 | } | ||
881 | 102 | |||
882 | 103 | static | ||
883 | 104 | void ccsFreeIntegration (CCSIntegration *integration) | ||
884 | 105 | { | ||
885 | 106 | ccsMockIntegrationBackendFree (integration); | ||
886 | 107 | } | ||
887 | 108 | |||
888 | 109 | static void ccsIntegrationDisallowIntegratedWrites (CCSIntegration *integration) | ||
889 | 110 | { | ||
890 | 111 | reinterpret_cast <CCSIntegrationGMockInterface *> (ccsObjectGetPrivate (integration))->disallowIntegratedWrites (); | ||
891 | 112 | } | ||
892 | 113 | |||
893 | 114 | static void ccsIntegrationAllowIntegratedWrites (CCSIntegration *integration) | ||
894 | 115 | { | ||
895 | 116 | reinterpret_cast <CCSIntegrationGMockInterface *> (ccsObjectGetPrivate (integration))->allowIntegratedWrites (); | ||
896 | 117 | } | ||
897 | 118 | |||
898 | 119 | private: | ||
899 | 120 | |||
900 | 121 | CCSIntegration *mIntegration; | ||
901 | 122 | }; | ||
902 | 123 | |||
903 | 124 | const CCSIntegrationInterface mockIntegrationBackendInterface = | ||
904 | 125 | { | ||
905 | 126 | CCSIntegrationGMock::CCSIntegrationGetIntegratedOptionIndex, | ||
906 | 127 | CCSIntegrationGMock::CCSIntegrationReadOptionIntoSetting, | ||
907 | 128 | CCSIntegrationGMock::CCSIntegrationWriteSettingIntoOption, | ||
908 | 129 | CCSIntegrationGMock::CCSIntegrationUpdateIntegratedSettings, | ||
909 | 130 | CCSIntegrationGMock::ccsIntegrationDisallowIntegratedWrites, | ||
910 | 131 | CCSIntegrationGMock::ccsIntegrationAllowIntegratedWrites, | ||
911 | 132 | CCSIntegrationGMock::ccsFreeIntegration | ||
912 | 133 | }; | ||
913 | 134 | |||
914 | 135 | CCSIntegration * | ||
915 | 136 | ccsMockIntegrationBackendNew (CCSObjectAllocationInterface *ai) | ||
916 | 137 | { | ||
917 | 138 | CCSIntegration *integration = reinterpret_cast <CCSIntegration *> ((*ai->calloc_) (ai->allocator, 1, sizeof (CCSIntegration))); | ||
918 | 139 | |||
919 | 140 | if (!integration) | ||
920 | 141 | return NULL; | ||
921 | 142 | |||
922 | 143 | CCSIntegrationGMock *gmockBackend = new CCSIntegrationGMock (integration); | ||
923 | 144 | |||
924 | 145 | ccsObjectInit (integration, ai); | ||
925 | 146 | ccsObjectSetPrivate (integration, (CCSPrivate *) gmockBackend); | ||
926 | 147 | ccsObjectAddInterface (integration, (const CCSInterface *) &mockIntegrationBackendInterface, GET_INTERFACE_TYPE (CCSIntegrationInterface)); | ||
927 | 148 | |||
928 | 149 | ccsObjectRef (integration); | ||
929 | 150 | |||
930 | 151 | return integration; | ||
931 | 152 | } | ||
932 | 153 | |||
933 | 154 | void | ||
934 | 155 | ccsMockIntegrationBackendFree (CCSIntegration *integration) | ||
935 | 156 | { | ||
936 | 157 | CCSIntegrationGMock *gmockBackend = reinterpret_cast <CCSIntegrationGMock *> (ccsObjectGetPrivate (integration)); | ||
937 | 158 | |||
938 | 159 | delete gmockBackend; | ||
939 | 160 | |||
940 | 161 | ccsObjectSetPrivate (integration, NULL); | ||
941 | 162 | ccsObjectFinalize (integration); | ||
942 | 163 | (*integration->object.object_allocation->free_) (integration->object.object_allocation->allocator, integration); | ||
943 | 164 | } | ||
944 | 165 | |||
945 | 166 | class CCSGSettingsStorageEnv : | ||
946 | 167 | public CCSSettingsConceptTestEnvironmentInterface, | ||
947 | 168 | public CCSGSettingsMemoryBackendTestingEnv | ||
948 | 169 | { | ||
949 | 170 | public: | ||
950 | 171 | |||
951 | 172 | typedef boost::shared_ptr <GVariant> GVariantShared; | ||
952 | 173 | |||
953 | 174 | virtual void SetUp () | ||
954 | 175 | { | ||
955 | 176 | SetUpEnv (); | ||
956 | 177 | } | ||
957 | 178 | |||
958 | 179 | virtual void TearDown () | ||
959 | 180 | { | ||
960 | 181 | TearDownEnv (); | ||
961 | 182 | } | ||
962 | 183 | |||
963 | 184 | CCSGSettingsStorageEnv (CCSGSettingsWrapper *settings, | ||
964 | 185 | const std::string &profileName) : | ||
965 | 186 | mSettings (settings), | ||
966 | 187 | profileName (profileName) | ||
967 | 188 | { | ||
968 | 189 | } | ||
969 | 190 | |||
970 | 191 | void WriteBoolAtKey (const std::string &plugin, | ||
971 | 192 | const std::string &key, | ||
972 | 193 | const VariantTypes &value) | ||
973 | 194 | { | ||
974 | 195 | GVariant *variant = NULL; | ||
975 | 196 | if (writeBoolToVariant (boolToBool (boost::get <bool> (value)), &variant)) | ||
976 | 197 | writeVariantToKey (mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant); | ||
977 | 198 | else | ||
978 | 199 | throw std::exception (); | ||
979 | 200 | } | ||
980 | 201 | |||
981 | 202 | void WriteIntegerAtKey (const std::string &plugin, | ||
982 | 203 | const std::string &key, | ||
983 | 204 | const VariantTypes &value) | ||
984 | 205 | { | ||
985 | 206 | GVariant *variant = NULL; | ||
986 | 207 | if (writeIntToVariant (boost::get <int> (value), &variant)) | ||
987 | 208 | writeVariantToKey (mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant); | ||
988 | 209 | else | ||
989 | 210 | throw std::exception (); | ||
990 | 211 | } | ||
991 | 212 | |||
992 | 213 | void WriteFloatAtKey (const std::string &plugin, | ||
993 | 214 | const std::string &key, | ||
994 | 215 | const VariantTypes &value) | ||
995 | 216 | { | ||
996 | 217 | GVariant *variant = NULL; | ||
997 | 218 | if (writeFloatToVariant (boost::get <float> (value), &variant)) | ||
998 | 219 | writeVariantToKey (mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant); | ||
999 | 220 | else | ||
1000 | 221 | throw std::exception (); | ||
1001 | 222 | } | ||
1002 | 223 | |||
1003 | 224 | void WriteStringAtKey (const std::string &plugin, | ||
1004 | 225 | const std::string &key, | ||
1005 | 226 | const VariantTypes &value) | ||
1006 | 227 | { | ||
1007 | 228 | GVariant *variant = NULL; | ||
1008 | 229 | if (writeStringToVariant (boost::get <const char *> (value), &variant)) | ||
1009 | 230 | writeVariantToKey (mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant); | ||
1010 | 231 | else | ||
1011 | 232 | throw std::exception (); | ||
1012 | 233 | } | ||
1013 | 234 | |||
1014 | 235 | void WriteColorAtKey (const std::string &plugin, | ||
1015 | 236 | const std::string &key, | ||
1016 | 237 | const VariantTypes &value) | ||
1017 | 238 | { | ||
1018 | 239 | GVariant *variant = NULL; | ||
1019 | 240 | if (writeColorToVariant (boost::get <CCSSettingColorValue> (value), &variant)) | ||
1020 | 241 | writeVariantToKey (mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant); | ||
1021 | 242 | else | ||
1022 | 243 | throw std::exception (); | ||
1023 | 244 | } | ||
1024 | 245 | |||
1025 | 246 | void WriteKeyAtKey (const std::string &plugin, | ||
1026 | 247 | const std::string &key, | ||
1027 | 248 | const VariantTypes &value) | ||
1028 | 249 | { | ||
1029 | 250 | GVariant *variant = NULL; | ||
1030 | 251 | if (writeKeyToVariant (boost::get <CCSSettingKeyValue> (value), &variant)) | ||
1031 | 252 | writeVariantToKey (mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant); | ||
1032 | 253 | else | ||
1033 | 254 | throw std::exception (); | ||
1034 | 255 | } | ||
1035 | 256 | |||
1036 | 257 | void WriteButtonAtKey (const std::string &plugin, | ||
1037 | 258 | const std::string &key, | ||
1038 | 259 | const VariantTypes &value) | ||
1039 | 260 | { | ||
1040 | 261 | GVariant *variant = NULL; | ||
1041 | 262 | if (writeButtonToVariant (boost::get <CCSSettingButtonValue> (value), &variant)) | ||
1042 | 263 | writeVariantToKey (mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant); | ||
1043 | 264 | else | ||
1044 | 265 | throw std::exception (); | ||
1045 | 266 | } | ||
1046 | 267 | |||
1047 | 268 | void WriteEdgeAtKey (const std::string &plugin, | ||
1048 | 269 | const std::string &key, | ||
1049 | 270 | const VariantTypes &value) | ||
1050 | 271 | { | ||
1051 | 272 | GVariant *variant = NULL; | ||
1052 | 273 | if (writeEdgeToVariant (boost::get <unsigned int> (value), &variant)) | ||
1053 | 274 | writeVariantToKey (mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant); | ||
1054 | 275 | else | ||
1055 | 276 | throw std::exception (); | ||
1056 | 277 | } | ||
1057 | 278 | |||
1058 | 279 | void WriteMatchAtKey (const std::string &plugin, | ||
1059 | 280 | const std::string &key, | ||
1060 | 281 | const VariantTypes &value) | ||
1061 | 282 | { | ||
1062 | 283 | GVariant *variant = NULL; | ||
1063 | 284 | if (writeStringToVariant (boost::get <const char *> (value), &variant)) | ||
1064 | 285 | writeVariantToKey (mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant); | ||
1065 | 286 | else | ||
1066 | 287 | throw std::exception (); | ||
1067 | 288 | } | ||
1068 | 289 | |||
1069 | 290 | void WriteBellAtKey (const std::string &plugin, | ||
1070 | 291 | const std::string &key, | ||
1071 | 292 | const VariantTypes &value) | ||
1072 | 293 | { | ||
1073 | 294 | GVariant *variant = NULL; | ||
1074 | 295 | if (writeBoolToVariant (boolToBool (boost::get <bool> (value)), &variant)) | ||
1075 | 296 | writeVariantToKey (mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant); | ||
1076 | 297 | else | ||
1077 | 298 | throw std::exception (); | ||
1078 | 299 | } | ||
1079 | 300 | |||
1080 | 301 | void WriteListAtKey (const std::string &plugin, | ||
1081 | 302 | const std::string &key, | ||
1082 | 303 | const VariantTypes &value) | ||
1083 | 304 | { | ||
1084 | 305 | GVariant *variant = NULL; | ||
1085 | 306 | |||
1086 | 307 | const cci::SettingValueListWrapper::Ptr &lw (boost::get <cci::SettingValueListWrapper::Ptr> (value)); | ||
1087 | 308 | |||
1088 | 309 | if (writeListValue (*lw, lw->type (), &variant)) | ||
1089 | 310 | writeVariantToKey (mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant); | ||
1090 | 311 | else | ||
1091 | 312 | throw std::exception (); | ||
1092 | 313 | } | ||
1093 | 314 | |||
1094 | 315 | Bool ReadBoolAtKey (const std::string &plugin, | ||
1095 | 316 | const std::string &key) | ||
1096 | 317 | { | ||
1097 | 318 | GVariantShared variant (ReadVariantAtKeyToShared (plugin, | ||
1098 | 319 | key, | ||
1099 | 320 | TypeBool)); | ||
1100 | 321 | return readBoolFromVariant (variant.get ()); | ||
1101 | 322 | } | ||
1102 | 323 | |||
1103 | 324 | int ReadIntegerAtKey (const std::string &plugin, | ||
1104 | 325 | const std::string &key) | ||
1105 | 326 | { | ||
1106 | 327 | GVariantShared variant (ReadVariantAtKeyToShared (plugin, | ||
1107 | 328 | key, | ||
1108 | 329 | TypeInt)); | ||
1109 | 330 | return readIntFromVariant (variant.get ()); | ||
1110 | 331 | } | ||
1111 | 332 | |||
1112 | 333 | float ReadFloatAtKey (const std::string &plugin, | ||
1113 | 334 | const std::string &key) | ||
1114 | 335 | { | ||
1115 | 336 | GVariantShared variant (ReadVariantAtKeyToShared (plugin, | ||
1116 | 337 | key, | ||
1117 | 338 | TypeFloat)); | ||
1118 | 339 | return readFloatFromVariant (variant.get ()); | ||
1119 | 340 | } | ||
1120 | 341 | |||
1121 | 342 | const char * ReadStringAtKey (const std::string &plugin, | ||
1122 | 343 | const std::string &key) | ||
1123 | 344 | { | ||
1124 | 345 | GVariantShared variant (ReadVariantAtKeyToShared (plugin, | ||
1125 | 346 | key, | ||
1126 | 347 | TypeString)); | ||
1127 | 348 | return readStringFromVariant (variant.get ()); | ||
1128 | 349 | } | ||
1129 | 350 | |||
1130 | 351 | CCSSettingColorValue ReadColorAtKey (const std::string &plugin, | ||
1131 | 352 | const std::string &key) | ||
1132 | 353 | { | ||
1133 | 354 | Bool success = FALSE; | ||
1134 | 355 | GVariantShared variant (ReadVariantAtKeyToShared (plugin, | ||
1135 | 356 | key, | ||
1136 | 357 | TypeColor)); | ||
1137 | 358 | CCSSettingColorValue value = readColorFromVariant (variant.get (), &success); | ||
1138 | 359 | EXPECT_TRUE (success); | ||
1139 | 360 | return value; | ||
1140 | 361 | } | ||
1141 | 362 | |||
1142 | 363 | CCSSettingKeyValue ReadKeyAtKey (const std::string &plugin, | ||
1143 | 364 | const std::string &key) | ||
1144 | 365 | { | ||
1145 | 366 | Bool success = FALSE; | ||
1146 | 367 | GVariantShared variant (ReadVariantAtKeyToShared (plugin, | ||
1147 | 368 | key, | ||
1148 | 369 | TypeKey)); | ||
1149 | 370 | CCSSettingKeyValue value = readKeyFromVariant (variant.get (), &success); | ||
1150 | 371 | EXPECT_TRUE (success); | ||
1151 | 372 | return value; | ||
1152 | 373 | } | ||
1153 | 374 | |||
1154 | 375 | CCSSettingButtonValue ReadButtonAtKey (const std::string &plugin, | ||
1155 | 376 | const std::string &key) | ||
1156 | 377 | { | ||
1157 | 378 | Bool success = FALSE; | ||
1158 | 379 | GVariantShared variant (ReadVariantAtKeyToShared (plugin, | ||
1159 | 380 | key, | ||
1160 | 381 | TypeButton)); | ||
1161 | 382 | CCSSettingButtonValue value = readButtonFromVariant (variant.get (), &success); | ||
1162 | 383 | EXPECT_TRUE (success); | ||
1163 | 384 | return value; | ||
1164 | 385 | } | ||
1165 | 386 | |||
1166 | 387 | unsigned int ReadEdgeAtKey (const std::string &plugin, | ||
1167 | 388 | const std::string &key) | ||
1168 | 389 | { | ||
1169 | 390 | GVariantShared variant (ReadVariantAtKeyToShared (plugin, | ||
1170 | 391 | key, | ||
1171 | 392 | TypeEdge)); | ||
1172 | 393 | return readEdgeFromVariant (variant.get ()); | ||
1173 | 394 | } | ||
1174 | 395 | |||
1175 | 396 | const char * ReadMatchAtKey (const std::string &plugin, | ||
1176 | 397 | const std::string &key) | ||
1177 | 398 | { | ||
1178 | 399 | GVariantShared variant (ReadVariantAtKeyToShared (plugin, | ||
1179 | 400 | key, | ||
1180 | 401 | TypeMatch)); | ||
1181 | 402 | return readStringFromVariant (variant.get ()); | ||
1182 | 403 | } | ||
1183 | 404 | |||
1184 | 405 | Bool ReadBellAtKey (const std::string &plugin, | ||
1185 | 406 | const std::string &key) | ||
1186 | 407 | { | ||
1187 | 408 | GVariantShared variant (ReadVariantAtKeyToShared (plugin, | ||
1188 | 409 | key, | ||
1189 | 410 | TypeBell)); | ||
1190 | 411 | return readBoolFromVariant (variant.get ()); | ||
1191 | 412 | } | ||
1192 | 413 | |||
1193 | 414 | CCSSettingValueList ReadListAtKey (const std::string &plugin, | ||
1194 | 415 | const std::string &key, | ||
1195 | 416 | CCSSetting *setting) | ||
1196 | 417 | { | ||
1197 | 418 | GVariantShared variant (ReadVariantAtKeyToShared (plugin, | ||
1198 | 419 | key, | ||
1199 | 420 | TypeList)); | ||
1200 | 421 | return readListValue (variant.get (), setting, &ccsDefaultObjectAllocator); | ||
1201 | 422 | } | ||
1202 | 423 | |||
1203 | 424 | private: | ||
1204 | 425 | |||
1205 | 426 | GVariantShared | ||
1206 | 427 | ReadVariantAtKeyToShared (const std::string &plugin, | ||
1207 | 428 | const std::string &key, | ||
1208 | 429 | CCSSettingType type) | ||
1209 | 430 | { | ||
1210 | 431 | CharacterWrapper translatedKey (translateKeyForGSettings (key.c_str ())); | ||
1211 | 432 | CharacterWrapper pluginPath (makeCompizPluginPath (profileName.c_str (), | ||
1212 | 433 | plugin.c_str ())); | ||
1213 | 434 | |||
1214 | 435 | GVariant *rawVariant = getVariantAtKey (mSettings, | ||
1215 | 436 | translatedKey, | ||
1216 | 437 | pluginPath, | ||
1217 | 438 | type); | ||
1218 | 439 | |||
1219 | 440 | GVariantShared shared (AutoDestroy (rawVariant, g_variant_unref)); | ||
1220 | 441 | |||
1221 | 442 | |||
1222 | 443 | |||
1223 | 444 | return shared; | ||
1224 | 445 | } | ||
1225 | 446 | |||
1226 | 447 | CCSGSettingsWrapper *mSettings; | ||
1227 | 448 | std::string profileName; | ||
1228 | 449 | |||
1229 | 450 | |||
1230 | 451 | }; | ||
1231 | 452 | |||
1232 | 453 | class CCSGSettingsBackendEnv : | 49 | class CCSGSettingsBackendEnv : |
1233 | 454 | public CCSBackendConceptTestEnvironmentInterface, | 50 | public CCSBackendConceptTestEnvironmentInterface, |
1234 | 455 | public CCSGSettingsMemoryBackendTestingEnv | 51 | public CCSGSettingsMemoryBackendTestingEnv |
1235 | @@ -551,7 +147,6 @@ | |||
1236 | 551 | 147 | ||
1237 | 552 | ccsFreeDynamicBackend (mBackend); | 148 | ccsFreeDynamicBackend (mBackend); |
1238 | 553 | 149 | ||
1239 | 554 | ccsGSettingsWrapperUnref (mSettings); | ||
1240 | 555 | mStorage.reset (); | 150 | mStorage.reset (); |
1241 | 556 | 151 | ||
1242 | 557 | g_variant_unref (pluginKeys); | 152 | g_variant_unref (pluginKeys); |
1243 | 558 | 153 | ||
1244 | === modified file 'compizconfig/gsettings/tests/test_gsettings_tests.h' | |||
1245 | --- compizconfig/gsettings/tests/test_gsettings_tests.h 2012-08-17 14:59:52 +0000 | |||
1246 | +++ compizconfig/gsettings/tests/test_gsettings_tests.h 2012-09-24 03:58:20 +0000 | |||
1247 | @@ -1,9 +1,33 @@ | |||
1248 | 1 | /* | ||
1249 | 2 | * Compiz configuration system library | ||
1250 | 3 | * | ||
1251 | 4 | * Copyright (C) 2012 Canonical Ltd. | ||
1252 | 5 | * | ||
1253 | 6 | * This library is free software; you can redistribute it and/or | ||
1254 | 7 | * modify it under the terms of the GNU Lesser General Public | ||
1255 | 8 | * License as published by the Free Software Foundation; either | ||
1256 | 9 | * version 2.1 of the License, or (at your option) any later version. | ||
1257 | 10 | |||
1258 | 11 | * This library is distributed in the hope that it will be useful, | ||
1259 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1260 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
1261 | 14 | * Lesser General Public License for more details. | ||
1262 | 15 | |||
1263 | 16 | * You should have received a copy of the GNU Lesser General Public | ||
1264 | 17 | * License along with this library; if not, write to the Free Software | ||
1265 | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
1266 | 19 | * | ||
1267 | 20 | * Authored By: | ||
1268 | 21 | * Sam Spilsbury <sam.spilsbury@canonical.com> | ||
1269 | 22 | */ | ||
1270 | 1 | #ifndef _COMPIZCONFIG_TEST_GSETTINGS_TESTS_H | 23 | #ifndef _COMPIZCONFIG_TEST_GSETTINGS_TESTS_H |
1271 | 2 | #define _COMPIZCONFIG_TEST_GSETTINGS_TESTS_H | 24 | #define _COMPIZCONFIG_TEST_GSETTINGS_TESTS_H |
1272 | 3 | 25 | ||
1273 | 4 | #include <gtest/gtest.h> | 26 | #include <gtest/gtest.h> |
1274 | 5 | #include <glib.h> | 27 | #include <glib.h> |
1275 | 6 | #include <glib-object.h> | 28 | #include <glib-object.h> |
1276 | 29 | #include <glib_gslice_off_env.h> | ||
1277 | 30 | #include <glib_gsettings_memory_backend_env.h> | ||
1278 | 7 | #include <gsettings-mock-schemas-config.h> | 31 | #include <gsettings-mock-schemas-config.h> |
1279 | 8 | 32 | ||
1280 | 9 | using ::testing::TestWithParam; | 33 | using ::testing::TestWithParam; |
1281 | @@ -52,9 +76,29 @@ | |||
1282 | 52 | } | 76 | } |
1283 | 53 | }; | 77 | }; |
1284 | 54 | 78 | ||
1285 | 79 | class CCSGSettingsTestCommon : | ||
1286 | 80 | public ::testing::Test | ||
1287 | 81 | { | ||
1288 | 82 | public: | ||
1289 | 83 | |||
1290 | 84 | virtual void SetUp () | ||
1291 | 85 | { | ||
1292 | 86 | env.SetUpEnv (); | ||
1293 | 87 | } | ||
1294 | 88 | |||
1295 | 89 | virtual void TearDown () | ||
1296 | 90 | { | ||
1297 | 91 | env.TearDownEnv (); | ||
1298 | 92 | } | ||
1299 | 93 | |||
1300 | 94 | private: | ||
1301 | 95 | |||
1302 | 96 | CompizGLibGSliceOffEnv env; | ||
1303 | 97 | }; | ||
1304 | 98 | |||
1305 | 55 | class CCSGSettingsTest : | 99 | class CCSGSettingsTest : |
1308 | 56 | public CCSGSettingsTestingEnv, | 100 | public CCSGSettingsTestCommon, |
1309 | 57 | public ::testing::TestWithParam <CCSGSettingsTeardownSetupInterface *> | 101 | public ::testing::WithParamInterface <CCSGSettingsTeardownSetupInterface *> |
1310 | 58 | { | 102 | { |
1311 | 59 | public: | 103 | public: |
1312 | 60 | 104 | ||
1313 | @@ -65,13 +109,13 @@ | |||
1314 | 65 | 109 | ||
1315 | 66 | virtual void SetUp () | 110 | virtual void SetUp () |
1316 | 67 | { | 111 | { |
1318 | 68 | CCSGSettingsTestingEnv::SetUpEnv (); | 112 | CCSGSettingsTestCommon::SetUp (); |
1319 | 69 | mFuncs->SetUp (); | 113 | mFuncs->SetUp (); |
1320 | 70 | } | 114 | } |
1321 | 71 | 115 | ||
1322 | 72 | virtual void TearDown () | 116 | virtual void TearDown () |
1323 | 73 | { | 117 | { |
1325 | 74 | CCSGSettingsTestingEnv::TearDownEnv (); | 118 | CCSGSettingsTestCommon::TearDown (); |
1326 | 75 | mFuncs->TearDown (); | 119 | mFuncs->TearDown (); |
1327 | 76 | } | 120 | } |
1328 | 77 | 121 | ||
1329 | @@ -81,41 +125,40 @@ | |||
1330 | 81 | }; | 125 | }; |
1331 | 82 | 126 | ||
1332 | 83 | class CCSGSettingsTestIndependent : | 127 | class CCSGSettingsTestIndependent : |
1335 | 84 | public CCSGSettingsTestingEnv, | 128 | public CCSGSettingsTestCommon |
1334 | 85 | public ::testing::Test | ||
1336 | 86 | { | 129 | { |
1337 | 87 | public: | 130 | public: |
1338 | 88 | 131 | ||
1339 | 89 | virtual void SetUp () | 132 | virtual void SetUp () |
1340 | 90 | { | 133 | { |
1341 | 134 | CCSGSettingsTestCommon::SetUp (); | ||
1342 | 91 | g_type_init (); | 135 | g_type_init (); |
1343 | 92 | |||
1344 | 93 | CCSGSettingsTestingEnv::SetUpEnv (); | ||
1345 | 94 | } | 136 | } |
1346 | 95 | 137 | ||
1347 | 96 | virtual void TearDown () | 138 | virtual void TearDown () |
1348 | 97 | { | 139 | { |
1350 | 98 | CCSGSettingsTestingEnv::TearDownEnv (); | 140 | CCSGSettingsTestCommon::TearDown (); |
1351 | 99 | } | 141 | } |
1352 | 100 | }; | 142 | }; |
1353 | 101 | 143 | ||
1354 | 102 | class CCSGSettingsTestWithMemoryBackend : | 144 | class CCSGSettingsTestWithMemoryBackend : |
1357 | 103 | public CCSGSettingsTestIndependent, | 145 | public CCSGSettingsTestIndependent |
1356 | 104 | public CCSGSettingsMemoryBackendTestingEnv | ||
1358 | 105 | { | 146 | { |
1359 | 106 | public: | 147 | public: |
1360 | 107 | 148 | ||
1361 | 108 | virtual void SetUp () | 149 | virtual void SetUp () |
1362 | 109 | { | 150 | { |
1363 | 110 | CCSGSettingsTestIndependent::SetUp (); | 151 | CCSGSettingsTestIndependent::SetUp (); |
1365 | 111 | CCSGSettingsMemoryBackendTestingEnv::SetUpEnv (); | 152 | env.SetUpEnv (MOCK_PATH); |
1366 | 112 | } | 153 | } |
1367 | 113 | 154 | ||
1368 | 114 | virtual void TearDown () | 155 | virtual void TearDown () |
1369 | 115 | { | 156 | { |
1372 | 116 | CCSGSettingsMemoryBackendTestingEnv::TearDownEnv (); | 157 | env.TearDownEnv (); |
1371 | 117 | CCSGSettingsTestIndependent::TearDown (); | ||
1373 | 118 | } | 158 | } |
1374 | 159 | private: | ||
1375 | 160 | |||
1376 | 161 | CompizGLibGSettingsMemoryBackendTestingEnv env; | ||
1377 | 119 | }; | 162 | }; |
1378 | 120 | 163 | ||
1379 | 121 | #endif | 164 | #endif |
1380 | 122 | 165 | ||
1381 | === modified file 'compizconfig/integration/gnome/CMakeLists.txt' | |||
1382 | --- compizconfig/integration/gnome/CMakeLists.txt 2012-08-18 13:15:30 +0000 | |||
1383 | +++ compizconfig/integration/gnome/CMakeLists.txt 2012-09-24 03:58:20 +0000 | |||
1384 | @@ -38,4 +38,6 @@ | |||
1385 | 38 | compizconfig | 38 | compizconfig |
1386 | 39 | ${COMPIZCONFIG_GNOME_INTEGRATION_LIBRARIES}) | 39 | ${COMPIZCONFIG_GNOME_INTEGRATION_LIBRARIES}) |
1387 | 40 | 40 | ||
1388 | 41 | add_subdirectory (tests) | ||
1389 | 42 | |||
1390 | 41 | endif (COMPIZCONFIG_GNOME_INTEGRATION_FOUND) | 43 | endif (COMPIZCONFIG_GNOME_INTEGRATION_FOUND) |
1391 | 42 | 44 | ||
1392 | === modified file 'compizconfig/integration/gnome/gconf/src/ccs_gnome_integration_gconf_integrated_setting.c' | |||
1393 | --- compizconfig/integration/gnome/gconf/src/ccs_gnome_integration_gconf_integrated_setting.c 2012-08-17 07:33:02 +0000 | |||
1394 | +++ compizconfig/integration/gnome/gconf/src/ccs_gnome_integration_gconf_integrated_setting.c 2012-09-24 03:58:20 +0000 | |||
1395 | @@ -63,7 +63,8 @@ | |||
1396 | 63 | { | 63 | { |
1397 | 64 | ccsError ("NULL encountered while reading GConf setting"); | 64 | ccsError ("NULL encountered while reading GConf setting"); |
1398 | 65 | free (gnomeKeyPath); | 65 | free (gnomeKeyPath); |
1400 | 66 | return v; | 66 | free (v); |
1401 | 67 | return NULL; | ||
1402 | 67 | } | 68 | } |
1403 | 68 | 69 | ||
1404 | 69 | if (err) | 70 | if (err) |
1405 | @@ -71,7 +72,8 @@ | |||
1406 | 71 | ccsError ("%s", err->message); | 72 | ccsError ("%s", err->message); |
1407 | 72 | g_error_free (err); | 73 | g_error_free (err); |
1408 | 73 | free (gnomeKeyPath); | 74 | free (gnomeKeyPath); |
1410 | 74 | return v; | 75 | free (v); |
1411 | 76 | return NULL; | ||
1412 | 75 | } | 77 | } |
1413 | 76 | 78 | ||
1414 | 77 | switch (type) | 79 | switch (type) |
1415 | @@ -80,6 +82,8 @@ | |||
1416 | 80 | if (gconfValue->type != GCONF_VALUE_INT) | 82 | if (gconfValue->type != GCONF_VALUE_INT) |
1417 | 81 | { | 83 | { |
1418 | 82 | ccsError ("Expected integer value"); | 84 | ccsError ("Expected integer value"); |
1419 | 85 | free (v); | ||
1420 | 86 | v = NULL; | ||
1421 | 83 | break; | 87 | break; |
1422 | 84 | } | 88 | } |
1423 | 85 | 89 | ||
1424 | @@ -89,6 +93,8 @@ | |||
1425 | 89 | if (gconfValue->type != GCONF_VALUE_BOOL) | 93 | if (gconfValue->type != GCONF_VALUE_BOOL) |
1426 | 90 | { | 94 | { |
1427 | 91 | ccsError ("Expected boolean value"); | 95 | ccsError ("Expected boolean value"); |
1428 | 96 | free (v); | ||
1429 | 97 | v = NULL; | ||
1430 | 92 | break; | 98 | break; |
1431 | 93 | } | 99 | } |
1432 | 94 | 100 | ||
1433 | @@ -99,6 +105,8 @@ | |||
1434 | 99 | if (gconfValue->type != GCONF_VALUE_STRING) | 105 | if (gconfValue->type != GCONF_VALUE_STRING) |
1435 | 100 | { | 106 | { |
1436 | 101 | ccsError ("Expected string value"); | 107 | ccsError ("Expected string value"); |
1437 | 108 | free (v); | ||
1438 | 109 | v = NULL; | ||
1439 | 102 | break; | 110 | break; |
1440 | 103 | } | 111 | } |
1441 | 104 | 112 | ||
1442 | @@ -220,10 +228,17 @@ | |||
1443 | 220 | ccsGConfIntegratedSettingFree ((CCSIntegratedSetting *) info); | 228 | ccsGConfIntegratedSettingFree ((CCSIntegratedSetting *) info); |
1444 | 221 | } | 229 | } |
1445 | 222 | 230 | ||
1446 | 231 | void | ||
1447 | 232 | ccsGConfGNOMEIntegratedSettingInfoFree (CCSGNOMEIntegratedSettingInfo *info) | ||
1448 | 233 | { | ||
1449 | 234 | ccsGConfIntegratedSettingFree ((CCSIntegratedSetting *) info); | ||
1450 | 235 | } | ||
1451 | 236 | |||
1452 | 223 | const CCSGNOMEIntegratedSettingInfoInterface ccsGConfGNOMEIntegratedSettingInfoInterface = | 237 | const CCSGNOMEIntegratedSettingInfoInterface ccsGConfGNOMEIntegratedSettingInfoInterface = |
1453 | 224 | { | 238 | { |
1454 | 225 | ccsGConfIntegratedSettingGetSpecialOptionType, | 239 | ccsGConfIntegratedSettingGetSpecialOptionType, |
1456 | 226 | ccsGConfIntegratedSettingGetGNOMEName | 240 | ccsGConfIntegratedSettingGetGNOMEName, |
1457 | 241 | ccsGConfGNOMEIntegratedSettingInfoFree | ||
1458 | 227 | }; | 242 | }; |
1459 | 228 | 243 | ||
1460 | 229 | const CCSIntegratedSettingInterface ccsGConfIntegratedSettingInterface = | 244 | const CCSIntegratedSettingInterface ccsGConfIntegratedSettingInterface = |
1461 | 230 | 245 | ||
1462 | === modified file 'compizconfig/integration/gnome/gsettings/CMakeLists.txt' | |||
1463 | --- compizconfig/integration/gnome/gsettings/CMakeLists.txt 2012-08-18 13:15:30 +0000 | |||
1464 | +++ compizconfig/integration/gnome/gsettings/CMakeLists.txt 2012-09-24 03:58:20 +0000 | |||
1465 | @@ -71,6 +71,8 @@ | |||
1466 | 71 | 71 | ||
1467 | 72 | endif (GLIB_COMPILE_SCHEMAS) | 72 | endif (GLIB_COMPILE_SCHEMAS) |
1468 | 73 | 73 | ||
1469 | 74 | add_subdirectory (tests) | ||
1470 | 75 | |||
1471 | 74 | endif (COMPIZCONFIG_GNOME_GSETTINGS_INTEGRATION_FOUND) | 76 | endif (COMPIZCONFIG_GNOME_GSETTINGS_INTEGRATION_FOUND) |
1472 | 75 | 77 | ||
1473 | 76 | endif (USE_GSETTINGS) | 78 | endif (USE_GSETTINGS) |
1474 | 77 | 79 | ||
1475 | === modified file 'compizconfig/integration/gnome/gsettings/src/ccs_gnome_integration_gsettings_integrated_setting.c' | |||
1476 | --- compizconfig/integration/gnome/gsettings/src/ccs_gnome_integration_gsettings_integrated_setting.c 2012-08-17 07:33:02 +0000 | |||
1477 | +++ compizconfig/integration/gnome/gsettings/src/ccs_gnome_integration_gsettings_integrated_setting.c 2012-09-24 03:58:20 +0000 | |||
1478 | @@ -55,7 +55,11 @@ | |||
1479 | 55 | GVariant *variant = ccsGSettingsWrapperGetValue (priv->wrapper, gsettingsTranslatedName); | 55 | GVariant *variant = ccsGSettingsWrapperGetValue (priv->wrapper, gsettingsTranslatedName); |
1480 | 56 | 56 | ||
1481 | 57 | if (!variant) | 57 | if (!variant) |
1482 | 58 | { | ||
1483 | 58 | free (gsettingsTranslatedName); | 59 | free (gsettingsTranslatedName); |
1484 | 60 | free (v); | ||
1485 | 61 | return NULL; | ||
1486 | 62 | } | ||
1487 | 59 | 63 | ||
1488 | 60 | const GVariantType *variantType = G_VARIANT_TYPE (g_variant_get_type_string (variant)); | 64 | const GVariantType *variantType = G_VARIANT_TYPE (g_variant_get_type_string (variant)); |
1489 | 61 | 65 | ||
1490 | @@ -65,6 +69,8 @@ | |||
1491 | 65 | if (!g_variant_type_equal (variantType, G_VARIANT_TYPE_INT32)) | 69 | if (!g_variant_type_equal (variantType, G_VARIANT_TYPE_INT32)) |
1492 | 66 | { | 70 | { |
1493 | 67 | ccsError ("Expected integer value"); | 71 | ccsError ("Expected integer value"); |
1494 | 72 | free (v); | ||
1495 | 73 | v = NULL; | ||
1496 | 68 | break; | 74 | break; |
1497 | 69 | } | 75 | } |
1498 | 70 | 76 | ||
1499 | @@ -74,6 +80,8 @@ | |||
1500 | 74 | if (!g_variant_type_equal (variantType, G_VARIANT_TYPE_BOOLEAN)) | 80 | if (!g_variant_type_equal (variantType, G_VARIANT_TYPE_BOOLEAN)) |
1501 | 75 | { | 81 | { |
1502 | 76 | ccsError ("Expected boolean value"); | 82 | ccsError ("Expected boolean value"); |
1503 | 83 | free (v); | ||
1504 | 84 | v = NULL; | ||
1505 | 77 | break; | 85 | break; |
1506 | 78 | } | 86 | } |
1507 | 79 | 87 | ||
1508 | @@ -84,6 +92,8 @@ | |||
1509 | 84 | if (!g_variant_type_equal (variantType, G_VARIANT_TYPE_STRING)) | 92 | if (!g_variant_type_equal (variantType, G_VARIANT_TYPE_STRING)) |
1510 | 85 | { | 93 | { |
1511 | 86 | ccsError ("Expected string value"); | 94 | ccsError ("Expected string value"); |
1512 | 95 | free (v); | ||
1513 | 96 | v = NULL; | ||
1514 | 87 | break; | 97 | break; |
1515 | 88 | } | 98 | } |
1516 | 89 | 99 | ||
1517 | @@ -96,6 +106,8 @@ | |||
1518 | 96 | if (!g_variant_type_equal (variantType, G_VARIANT_TYPE ("as"))) | 106 | if (!g_variant_type_equal (variantType, G_VARIANT_TYPE ("as"))) |
1519 | 97 | { | 107 | { |
1520 | 98 | ccsError ("Expected array-of-string value"); | 108 | ccsError ("Expected array-of-string value"); |
1521 | 109 | free (v); | ||
1522 | 110 | v = NULL; | ||
1523 | 99 | break; | 111 | break; |
1524 | 100 | } | 112 | } |
1525 | 101 | 113 | ||
1526 | @@ -127,8 +139,9 @@ | |||
1527 | 127 | const char *gnomeKeyName = ccsGNOMEIntegratedSettingInfoGetGNOMEName ((CCSGNOMEIntegratedSettingInfo *) setting); | 139 | const char *gnomeKeyName = ccsGNOMEIntegratedSettingInfoGetGNOMEName ((CCSGNOMEIntegratedSettingInfo *) setting); |
1528 | 128 | char *gsettingsTranslatedName = translateKeyForGSettings (gnomeKeyName); | 140 | char *gsettingsTranslatedName = translateKeyForGSettings (gnomeKeyName); |
1529 | 129 | 141 | ||
1532 | 130 | GVariant *variant = ccsGSettingsWrapperGetValue (priv->wrapper, gsettingsTranslatedName); | 142 | GVariant *variant = ccsGSettingsWrapperGetValue (priv->wrapper, gsettingsTranslatedName); |
1533 | 131 | GVariant *newVariant = NULL; | 143 | const GVariantType *variantType = g_variant_get_type (variant); |
1534 | 144 | GVariant *newVariant = NULL; | ||
1535 | 132 | 145 | ||
1536 | 133 | if (!variant) | 146 | if (!variant) |
1537 | 134 | { | 147 | { |
1538 | @@ -141,42 +154,62 @@ | |||
1539 | 141 | { | 154 | { |
1540 | 142 | case TypeInt: | 155 | case TypeInt: |
1541 | 143 | { | 156 | { |
1543 | 144 | int currentValue = readIntFromVariant (variant); | 157 | if (!g_variant_type_equal (variantType, G_VARIANT_TYPE_INT32)) |
1544 | 158 | ccsError ("Expected integer value"); | ||
1545 | 159 | else | ||
1546 | 160 | { | ||
1547 | 161 | int currentValue = readIntFromVariant (variant); | ||
1548 | 145 | 162 | ||
1551 | 146 | if ((currentValue != v->value.asInt)) | 163 | if ((currentValue != v->value.asInt)) |
1552 | 147 | writeIntToVariant (v->value.asInt, &newVariant); | 164 | writeIntToVariant (v->value.asInt, &newVariant); |
1553 | 165 | } | ||
1554 | 148 | } | 166 | } |
1555 | 149 | break; | 167 | break; |
1556 | 150 | case TypeBool: | 168 | case TypeBool: |
1557 | 151 | { | 169 | { |
1559 | 152 | gboolean currentValue = readBoolFromVariant (variant); | 170 | if (!g_variant_type_equal (variantType, G_VARIANT_TYPE_BOOLEAN)) |
1560 | 171 | ccsError ("Expected boolean value"); | ||
1561 | 172 | else | ||
1562 | 173 | { | ||
1563 | 174 | gboolean currentValue = readBoolFromVariant (variant); | ||
1564 | 153 | 175 | ||
1567 | 154 | if ((currentValue != v->value.asBool)) | 176 | if ((currentValue != v->value.asBool)) |
1568 | 155 | writeBoolToVariant (v->value.asBool, &newVariant); | 177 | writeBoolToVariant (v->value.asBool, &newVariant); |
1569 | 178 | } | ||
1570 | 156 | } | 179 | } |
1571 | 157 | break; | 180 | break; |
1572 | 158 | case TypeString: | 181 | case TypeString: |
1573 | 159 | { | 182 | { |
1578 | 160 | const char *defaultValue = ""; | 183 | if (!g_variant_type_equal (variantType, G_VARIANT_TYPE_STRING)) |
1579 | 161 | const char *newValue = v->value.asString ? v->value.asString : defaultValue; | 184 | ccsError ("Expected string value"); |
1580 | 162 | gsize len = 0; | 185 | else |
1581 | 163 | const gchar *currentValue = g_variant_get_string (variant, &len); | 186 | { |
1582 | 187 | const char *defaultValue = ""; | ||
1583 | 188 | const char *newValue = v->value.asString ? v->value.asString : defaultValue; | ||
1584 | 189 | gsize len = 0; | ||
1585 | 190 | const gchar *currentValue = g_variant_get_string (variant, &len); | ||
1586 | 164 | 191 | ||
1591 | 165 | if (currentValue) | 192 | if (currentValue) |
1592 | 166 | { | 193 | { |
1593 | 167 | if (strcmp (currentValue, newValue) != 0) | 194 | if (strcmp (currentValue, newValue) != 0) |
1594 | 168 | writeStringToVariant (currentValue, &newVariant); | 195 | writeStringToVariant (currentValue, &newVariant); |
1595 | 196 | } | ||
1596 | 169 | } | 197 | } |
1597 | 170 | } | 198 | } |
1598 | 171 | break; | 199 | break; |
1599 | 172 | case TypeKey: | 200 | case TypeKey: |
1600 | 173 | { | 201 | { |
1603 | 174 | const char *defaultValue = ""; | 202 | if (!g_variant_type_equal (variantType, G_VARIANT_TYPE ("as"))) |
1604 | 175 | GVariantBuilder strvBuilder; | 203 | ccsError ("Expected array-of-string value"); |
1605 | 204 | else | ||
1606 | 205 | { | ||
1607 | 206 | const char *defaultValue = ""; | ||
1608 | 207 | GVariantBuilder strvBuilder; | ||
1609 | 176 | 208 | ||
1613 | 177 | g_variant_builder_init (&strvBuilder, G_VARIANT_TYPE ("as")); | 209 | g_variant_builder_init (&strvBuilder, G_VARIANT_TYPE ("as")); |
1614 | 178 | g_variant_builder_add (&strvBuilder, "s", v->value.asString ? v->value.asString : defaultValue); | 210 | g_variant_builder_add (&strvBuilder, "s", v->value.asString ? v->value.asString : defaultValue); |
1615 | 179 | newVariant = g_variant_builder_end (&strvBuilder); | 211 | newVariant = g_variant_builder_end (&strvBuilder); |
1616 | 212 | } | ||
1617 | 180 | } | 213 | } |
1618 | 181 | break; | 214 | break; |
1619 | 182 | default: | 215 | default: |
1620 | @@ -238,10 +271,17 @@ | |||
1621 | 238 | return ccsGSettingsIntegratedSettingFree ((CCSIntegratedSetting *) info); | 271 | return ccsGSettingsIntegratedSettingFree ((CCSIntegratedSetting *) info); |
1622 | 239 | } | 272 | } |
1623 | 240 | 273 | ||
1624 | 274 | void | ||
1625 | 275 | ccsGSettingsGNOMEIntegratedSettingInfoFree (CCSGNOMEIntegratedSettingInfo *info) | ||
1626 | 276 | { | ||
1627 | 277 | return ccsGSettingsIntegratedSettingFree ((CCSIntegratedSetting *) info); | ||
1628 | 278 | } | ||
1629 | 279 | |||
1630 | 241 | const CCSGNOMEIntegratedSettingInfoInterface ccsGSettingsGNOMEIntegratedSettingInterface = | 280 | const CCSGNOMEIntegratedSettingInfoInterface ccsGSettingsGNOMEIntegratedSettingInterface = |
1631 | 242 | { | 281 | { |
1632 | 243 | ccsGSettingsIntegratedSettingGetSpecialOptionType, | 282 | ccsGSettingsIntegratedSettingGetSpecialOptionType, |
1634 | 244 | ccsGSettingsIntegratedSettingGetGNOMEName | 283 | ccsGSettingsIntegratedSettingGetGNOMEName, |
1635 | 284 | ccsGSettingsGNOMEIntegratedSettingInfoFree | ||
1636 | 245 | }; | 285 | }; |
1637 | 246 | 286 | ||
1638 | 247 | const CCSIntegratedSettingInterface ccsGSettingsIntegratedSettingInterface = | 287 | const CCSIntegratedSettingInterface ccsGSettingsIntegratedSettingInterface = |
1639 | 248 | 288 | ||
1640 | === added directory 'compizconfig/integration/gnome/gsettings/tests' | |||
1641 | === added file 'compizconfig/integration/gnome/gsettings/tests/CMakeLists.txt' | |||
1642 | --- compizconfig/integration/gnome/gsettings/tests/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
1643 | +++ compizconfig/integration/gnome/gsettings/tests/CMakeLists.txt 2012-09-24 03:58:20 +0000 | |||
1644 | @@ -0,0 +1,31 @@ | |||
1645 | 1 | include_directories (${GTEST_INCLUDE_DIRS}) | ||
1646 | 2 | include_directories (${CMAKE_SOURCE_DIR}/include) | ||
1647 | 3 | include_directories (${CMAKE_SOURCE_DIR}/tests/shared) | ||
1648 | 4 | include_directories (${CMAKE_SOURCE_DIR}/tests/shared/glib) | ||
1649 | 5 | include_directories (${CMAKE_CURRENT_SOURCE_DIR}/../../../../mocks/libcompizconfig) | ||
1650 | 6 | include_directories (${CMAKE_CURRENT_SOURCE_DIR}/../../../../gsettings/tests) | ||
1651 | 7 | include_directories (${CMAKE_CURRENT_SOURCE_DIR}/../../../../gsettings/mocks) | ||
1652 | 8 | include_directories (${CMAKE_SOURCE_DIR}/compizconfig/tests) | ||
1653 | 9 | link_directories (${CMAKE_INSTALL_PREFIX}/lib) | ||
1654 | 10 | link_directories (${CMAKE_CURRENT_BINARY_DIR}/../../mocks/libcompizconfig) | ||
1655 | 11 | link_directories (${CMAKE_CURRENT_BINARY_DIR}/../../tests/) | ||
1656 | 12 | link_directories (${CMAKE_CURRENT_BINARY_DIR}/../src/) | ||
1657 | 13 | |||
1658 | 14 | set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") | ||
1659 | 15 | |||
1660 | 16 | add_executable (compizconfig_test_ccs_gnome_gsettings_integrated_setting | ||
1661 | 17 | ${CMAKE_CURRENT_SOURCE_DIR}/compizconfig_test_ccs_gnome_gsettings_integrated_setting.cpp) | ||
1662 | 18 | |||
1663 | 19 | target_link_libraries (compizconfig_test_ccs_gnome_gsettings_integrated_setting | ||
1664 | 20 | ${GTEST_BOTH_LIBRARIES} | ||
1665 | 21 | ${GMOCK_LIBRARY} | ||
1666 | 22 | ${GMOCK_MAIN_LIBRARY} | ||
1667 | 23 | ${CMAKE_THREAD_LIBS_INIT} | ||
1668 | 24 | ${LIBCOMPIZCONFIG_LIBRARIES} | ||
1669 | 25 | compizconfig | ||
1670 | 26 | compizconfig_gsettings_settings_test_env | ||
1671 | 27 | compizconfig_ccs_gsettings_wrapper_mock | ||
1672 | 28 | compizconfig_gnome_integration_gsettings_integrated_setting | ||
1673 | 29 | compizconfig_gsettings_backend_interface) | ||
1674 | 30 | |||
1675 | 31 | compiz_discover_tests (compizconfig_test_ccs_gnome_gsettings_integrated_setting COVERAGE compizconfig_gnome_gsettings_integrated_setting) | ||
1676 | 0 | 32 | ||
1677 | === added file 'compizconfig/integration/gnome/gsettings/tests/compizconfig_test_ccs_gnome_gsettings_integrated_setting.cpp' | |||
1678 | --- compizconfig/integration/gnome/gsettings/tests/compizconfig_test_ccs_gnome_gsettings_integrated_setting.cpp 1970-01-01 00:00:00 +0000 | |||
1679 | +++ compizconfig/integration/gnome/gsettings/tests/compizconfig_test_ccs_gnome_gsettings_integrated_setting.cpp 2012-09-24 03:58:20 +0000 | |||
1680 | @@ -0,0 +1,388 @@ | |||
1681 | 1 | /* | ||
1682 | 2 | * Compiz configuration system library | ||
1683 | 3 | * | ||
1684 | 4 | * Copyright (C) 2012 Canonical Ltd. | ||
1685 | 5 | * | ||
1686 | 6 | * This library is free software; you can redistribute it and/or | ||
1687 | 7 | * modify it under the terms of the GNU Lesser General Public | ||
1688 | 8 | * License as published by the Free Software Foundation; either | ||
1689 | 9 | * version 2.1 of the License, or (at your option) any later version. | ||
1690 | 10 | |||
1691 | 11 | * This library is distributed in the hope that it will be useful, | ||
1692 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1693 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
1694 | 14 | * Lesser General Public License for more details. | ||
1695 | 15 | |||
1696 | 16 | * You should have received a copy of the GNU Lesser General Public | ||
1697 | 17 | * License along with this library; if not, write to the Free Software | ||
1698 | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
1699 | 19 | * | ||
1700 | 20 | * Authored By: | ||
1701 | 21 | * Sam Spilsbury <sam.spilsbury@canonical.com> | ||
1702 | 22 | */ | ||
1703 | 23 | #include <gtest/gtest.h> | ||
1704 | 24 | #include <gmock/gmock.h> | ||
1705 | 25 | |||
1706 | 26 | #include <map> | ||
1707 | 27 | #include <memory> | ||
1708 | 28 | #include <tr1/tuple> | ||
1709 | 29 | #include <boost/shared_ptr.hpp> | ||
1710 | 30 | |||
1711 | 31 | #include <glib_gslice_off_env.h> | ||
1712 | 32 | #include <gtest_shared_autodestroy.h> | ||
1713 | 33 | |||
1714 | 34 | #include <ccs.h> | ||
1715 | 35 | #include <ccs-backend.h> | ||
1716 | 36 | #include <ccs_gnome_integrated_setting.h> | ||
1717 | 37 | #include <ccs_gnome_integration_gsettings_integrated_setting.h> | ||
1718 | 38 | #include <ccs_gsettings_wrapper_mock.h> | ||
1719 | 39 | |||
1720 | 40 | using ::testing::Combine; | ||
1721 | 41 | using ::testing::Return; | ||
1722 | 42 | using ::testing::IsNull; | ||
1723 | 43 | using ::testing::ValuesIn; | ||
1724 | 44 | using ::testing::Values; | ||
1725 | 45 | using ::testing::Eq; | ||
1726 | 46 | using ::testing::_; | ||
1727 | 47 | |||
1728 | 48 | namespace compiz | ||
1729 | 49 | { | ||
1730 | 50 | namespace config | ||
1731 | 51 | { | ||
1732 | 52 | namespace integration | ||
1733 | 53 | { | ||
1734 | 54 | namespace test | ||
1735 | 55 | { | ||
1736 | 56 | const std::string KEYBINDING_ONE = "keybinding_one"; | ||
1737 | 57 | const std::string KEYBINDING_TWO = "keybinding_two"; | ||
1738 | 58 | const std::string STRING = "string"; | ||
1739 | 59 | const Bool BOOLEAN = TRUE; | ||
1740 | 60 | const int INTEGER = 2; | ||
1741 | 61 | |||
1742 | 62 | const std::string STRING_ALT = "string_alt"; | ||
1743 | 63 | const Bool BOOLEAN_ALT = FALSE; | ||
1744 | 64 | const int INTEGER_ALT = 1; | ||
1745 | 65 | |||
1746 | 66 | namespace variant_generators | ||
1747 | 67 | { | ||
1748 | 68 | GVariant * i (); | ||
1749 | 69 | GVariant * s (); | ||
1750 | 70 | GVariant * b (); | ||
1751 | 71 | GVariant * as (); | ||
1752 | 72 | } | ||
1753 | 73 | |||
1754 | 74 | namespace value_generators | ||
1755 | 75 | { | ||
1756 | 76 | CCSSettingValue * integer (); | ||
1757 | 77 | CCSSettingValue * string (); | ||
1758 | 78 | CCSSettingValue * key (); | ||
1759 | 79 | CCSSettingValue * boolean (); | ||
1760 | 80 | } | ||
1761 | 81 | |||
1762 | 82 | namespace expectations | ||
1763 | 83 | { | ||
1764 | 84 | void integer (CCSSettingValue *); | ||
1765 | 85 | void string (CCSSettingValue *); | ||
1766 | 86 | void boolean (CCSSettingValue *); | ||
1767 | 87 | void key (CCSSettingValue *); | ||
1768 | 88 | |||
1769 | 89 | void integerVariant (GVariant *, int); | ||
1770 | 90 | void stringVariant (GVariant *, const std::string &); | ||
1771 | 91 | void booleanVariant (GVariant *, bool); | ||
1772 | 92 | void keyVariant (GVariant *, const std::string &); | ||
1773 | 93 | } | ||
1774 | 94 | |||
1775 | 95 | typedef GVariant * (*VariantGenerator) (); | ||
1776 | 96 | typedef CCSSettingValue * (*ValueGenerator) (); | ||
1777 | 97 | typedef void (*Expectation) (CCSSettingValue *); | ||
1778 | 98 | |||
1779 | 99 | struct GSettingsIntegratedSettingInfo | ||
1780 | 100 | { | ||
1781 | 101 | VariantGenerator variantGenerator; | ||
1782 | 102 | ValueGenerator valueGenerator; | ||
1783 | 103 | Expectation expectation; | ||
1784 | 104 | CCSSettingType settingType; | ||
1785 | 105 | }; | ||
1786 | 106 | |||
1787 | 107 | namespace impl | ||
1788 | 108 | { | ||
1789 | 109 | namespace ccit = compiz::config::integration::test; | ||
1790 | 110 | namespace vg = compiz::config::integration::test::variant_generators; | ||
1791 | 111 | namespace cvg = compiz::config::integration::test::value_generators; | ||
1792 | 112 | namespace ex = compiz::config::integration::test::expectations; | ||
1793 | 113 | |||
1794 | 114 | ccit::GSettingsIntegratedSettingInfo settingsInfo[] = | ||
1795 | 115 | { | ||
1796 | 116 | { vg::i, cvg::integer, ex::integer, TypeInt }, | ||
1797 | 117 | { vg::b, cvg::boolean, ex::boolean, TypeBool }, | ||
1798 | 118 | { vg::s, cvg::string, ex::string, TypeString }, | ||
1799 | 119 | { vg::as, cvg::key, ex::key, TypeKey } | ||
1800 | 120 | }; | ||
1801 | 121 | } | ||
1802 | 122 | } | ||
1803 | 123 | } | ||
1804 | 124 | } | ||
1805 | 125 | } | ||
1806 | 126 | |||
1807 | 127 | namespace | ||
1808 | 128 | { | ||
1809 | 129 | std::map <CCSSettingType, SpecialOptionType> & | ||
1810 | 130 | ccsTypeToSpecialType () | ||
1811 | 131 | { | ||
1812 | 132 | static std::map <CCSSettingType, SpecialOptionType> types; | ||
1813 | 133 | static bool initialized = false; | ||
1814 | 134 | |||
1815 | 135 | if (!initialized) | ||
1816 | 136 | { | ||
1817 | 137 | types[TypeInt] = OptionInt; | ||
1818 | 138 | types[TypeBool] = OptionBool; | ||
1819 | 139 | types[TypeString] = OptionString; | ||
1820 | 140 | types[TypeKey] = OptionKey; | ||
1821 | 141 | } | ||
1822 | 142 | |||
1823 | 143 | return types; | ||
1824 | 144 | } | ||
1825 | 145 | } | ||
1826 | 146 | |||
1827 | 147 | namespace ccit = compiz::config::integration::test; | ||
1828 | 148 | namespace cciti = compiz::config::integration::test::impl; | ||
1829 | 149 | namespace ccvg = compiz::config::integration::test::variant_generators; | ||
1830 | 150 | namespace ccvalg = compiz::config::integration::test::value_generators; | ||
1831 | 151 | namespace ccex = compiz::config::integration::test::expectations; | ||
1832 | 152 | |||
1833 | 153 | typedef std::tr1::tuple <CCSSettingType, | ||
1834 | 154 | ccit::GSettingsIntegratedSettingInfo> CCSGSettingsIntegratedSettingTestInfo; | ||
1835 | 155 | |||
1836 | 156 | class CCSGSettingsIntegratedSettingTest : | ||
1837 | 157 | public ::testing::TestWithParam <CCSGSettingsIntegratedSettingTestInfo> | ||
1838 | 158 | { | ||
1839 | 159 | public: | ||
1840 | 160 | |||
1841 | 161 | virtual void SetUp (); | ||
1842 | 162 | virtual void TearDown (); | ||
1843 | 163 | |||
1844 | 164 | protected: | ||
1845 | 165 | |||
1846 | 166 | CompizGLibGSliceOffEnv env; | ||
1847 | 167 | boost::shared_ptr <CCSGSettingsWrapper> mWrapper; | ||
1848 | 168 | CCSGSettingsWrapperGMock *mWrapperMock; | ||
1849 | 169 | }; | ||
1850 | 170 | |||
1851 | 171 | GVariant * | ||
1852 | 172 | ccvg::as () | ||
1853 | 173 | { | ||
1854 | 174 | GVariantBuilder builder; | ||
1855 | 175 | g_variant_builder_init (&builder, G_VARIANT_TYPE ("as")); | ||
1856 | 176 | g_variant_builder_add (&builder, "s", ccit::KEYBINDING_ONE.c_str ()); | ||
1857 | 177 | g_variant_builder_add (&builder, "s", ccit::KEYBINDING_TWO.c_str ()); | ||
1858 | 178 | |||
1859 | 179 | return g_variant_builder_end (&builder); | ||
1860 | 180 | } | ||
1861 | 181 | |||
1862 | 182 | GVariant * | ||
1863 | 183 | ccvg::i () | ||
1864 | 184 | { | ||
1865 | 185 | return g_variant_new ("i", ccit::INTEGER); | ||
1866 | 186 | } | ||
1867 | 187 | |||
1868 | 188 | GVariant * | ||
1869 | 189 | ccvg::b () | ||
1870 | 190 | { | ||
1871 | 191 | return g_variant_new ("b", ccit::BOOLEAN); | ||
1872 | 192 | } | ||
1873 | 193 | |||
1874 | 194 | GVariant * | ||
1875 | 195 | ccvg::s () | ||
1876 | 196 | { | ||
1877 | 197 | return g_variant_new ("s", ccit::STRING.c_str ()); | ||
1878 | 198 | } | ||
1879 | 199 | |||
1880 | 200 | namespace | ||
1881 | 201 | { | ||
1882 | 202 | CCSSettingValue * createSettingValue () | ||
1883 | 203 | { | ||
1884 | 204 | CCSSettingValue *v = reinterpret_cast <CCSSettingValue *> (calloc (1, sizeof (CCSSettingValue))); | ||
1885 | 205 | |||
1886 | 206 | v->isListChild = FALSE; | ||
1887 | 207 | v->parent = NULL; | ||
1888 | 208 | v->refCount = 1; | ||
1889 | 209 | |||
1890 | 210 | return v; | ||
1891 | 211 | } | ||
1892 | 212 | } | ||
1893 | 213 | |||
1894 | 214 | CCSSettingValue * | ||
1895 | 215 | ccvalg::integer () | ||
1896 | 216 | { | ||
1897 | 217 | CCSSettingValue *v = createSettingValue (); | ||
1898 | 218 | v->value.asInt = ccit::INTEGER_ALT; | ||
1899 | 219 | return v; | ||
1900 | 220 | } | ||
1901 | 221 | |||
1902 | 222 | CCSSettingValue * | ||
1903 | 223 | ccvalg::string () | ||
1904 | 224 | { | ||
1905 | 225 | CCSSettingValue *v = createSettingValue (); | ||
1906 | 226 | v->value.asString = strdup (ccit::STRING_ALT.c_str ()); | ||
1907 | 227 | return v; | ||
1908 | 228 | } | ||
1909 | 229 | |||
1910 | 230 | CCSSettingValue * | ||
1911 | 231 | ccvalg::key () | ||
1912 | 232 | { | ||
1913 | 233 | CCSSettingValue *v = createSettingValue (); | ||
1914 | 234 | v->value.asString = strdup (ccit::KEYBINDING_TWO.c_str ()); | ||
1915 | 235 | return v; | ||
1916 | 236 | } | ||
1917 | 237 | |||
1918 | 238 | CCSSettingValue * | ||
1919 | 239 | ccvalg::boolean () | ||
1920 | 240 | { | ||
1921 | 241 | CCSSettingValue *v = createSettingValue (); | ||
1922 | 242 | v->value.asBool = ccit::BOOLEAN_ALT; | ||
1923 | 243 | return v; | ||
1924 | 244 | } | ||
1925 | 245 | |||
1926 | 246 | void | ||
1927 | 247 | ccex::boolean (CCSSettingValue *v) | ||
1928 | 248 | { | ||
1929 | 249 | EXPECT_EQ (v->value.asBool, ccit::BOOLEAN); | ||
1930 | 250 | } | ||
1931 | 251 | |||
1932 | 252 | void | ||
1933 | 253 | ccex::integer (CCSSettingValue *v) | ||
1934 | 254 | { | ||
1935 | 255 | EXPECT_EQ (v->value.asInt, ccit::INTEGER); | ||
1936 | 256 | } | ||
1937 | 257 | |||
1938 | 258 | void | ||
1939 | 259 | ccex::string (CCSSettingValue *v) | ||
1940 | 260 | { | ||
1941 | 261 | EXPECT_EQ (v->value.asString, ccit::STRING); | ||
1942 | 262 | } | ||
1943 | 263 | |||
1944 | 264 | void | ||
1945 | 265 | ccex::key (CCSSettingValue *v) | ||
1946 | 266 | { | ||
1947 | 267 | EXPECT_EQ (v->value.asString, ccit::KEYBINDING_ONE); | ||
1948 | 268 | } | ||
1949 | 269 | |||
1950 | 270 | void | ||
1951 | 271 | ccex::integerVariant (GVariant *v , int i) | ||
1952 | 272 | { | ||
1953 | 273 | EXPECT_EQ (g_variant_get_int32 (v), i); | ||
1954 | 274 | } | ||
1955 | 275 | |||
1956 | 276 | void | ||
1957 | 277 | ccex::stringVariant (GVariant *v, const std::string &s) | ||
1958 | 278 | { | ||
1959 | 279 | gsize len; | ||
1960 | 280 | EXPECT_EQ (g_variant_get_string (v, &len), s); | ||
1961 | 281 | } | ||
1962 | 282 | |||
1963 | 283 | void | ||
1964 | 284 | ccex::booleanVariant (GVariant *v, bool b) | ||
1965 | 285 | { | ||
1966 | 286 | EXPECT_EQ (g_variant_get_boolean (v), b); | ||
1967 | 287 | } | ||
1968 | 288 | |||
1969 | 289 | void | ||
1970 | 290 | ccex::keyVariant (GVariant *v, const std::string &s) | ||
1971 | 291 | { | ||
1972 | 292 | gsize len; | ||
1973 | 293 | const gchar * const *strv = g_variant_get_strv (v, &len); | ||
1974 | 294 | EXPECT_EQ (strv[0], s); | ||
1975 | 295 | } | ||
1976 | 296 | |||
1977 | 297 | void | ||
1978 | 298 | CCSGSettingsIntegratedSettingTest::SetUp () | ||
1979 | 299 | { | ||
1980 | 300 | env.SetUpEnv (); | ||
1981 | 301 | mWrapper.reset (ccsMockGSettingsWrapperNew (), | ||
1982 | 302 | boost::bind (ccsMockGSettingsWrapperFree, _1)); | ||
1983 | 303 | mWrapperMock = reinterpret_cast <CCSGSettingsWrapperGMock *> ( | ||
1984 | 304 | ccsObjectGetPrivate (mWrapper.get ())); | ||
1985 | 305 | } | ||
1986 | 306 | |||
1987 | 307 | void | ||
1988 | 308 | CCSGSettingsIntegratedSettingTest::TearDown () | ||
1989 | 309 | { | ||
1990 | 310 | mWrapper.reset (); | ||
1991 | 311 | mWrapperMock = NULL; | ||
1992 | 312 | env.TearDownEnv (); | ||
1993 | 313 | } | ||
1994 | 314 | |||
1995 | 315 | TEST_P (CCSGSettingsIntegratedSettingTest, MatchedTypesReturnValueMismatchedTypesReturnNull) | ||
1996 | 316 | { | ||
1997 | 317 | const std::string keyName ("mock"); | ||
1998 | 318 | const ccit::GSettingsIntegratedSettingInfo &integratedSettingInfo = | ||
1999 | 319 | std::tr1::get <1> (GetParam ()); | ||
2000 | 320 | const CCSSettingType createSettingType = | ||
2001 | 321 | std::tr1::get <0> (GetParam ()); | ||
2002 | 322 | |||
2003 | 323 | CCSIntegratedSettingInfo *integratedSetting = ccsSharedIntegratedSettingInfoNew (keyName.c_str (), | ||
2004 | 324 | keyName.c_str (), | ||
2005 | 325 | integratedSettingInfo.settingType, | ||
2006 | 326 | &ccsDefaultObjectAllocator); | ||
2007 | 327 | SpecialOptionType specialType = ccsTypeToSpecialType ()[integratedSettingInfo.settingType]; | ||
2008 | 328 | CCSGNOMEIntegratedSettingInfo *gnomeIntegratedSetting = ccsGNOMEIntegratedSettingInfoNew (integratedSetting, | ||
2009 | 329 | specialType, | ||
2010 | 330 | keyName.c_str (), | ||
2011 | 331 | &ccsDefaultObjectAllocator); | ||
2012 | 332 | CCSIntegratedSetting *gsettingsIntegrated = ccsGSettingsIntegratedSettingNew (gnomeIntegratedSetting, | ||
2013 | 333 | mWrapper.get (), | ||
2014 | 334 | &ccsDefaultObjectAllocator); | ||
2015 | 335 | |||
2016 | 336 | GVariant *variant = (*integratedSettingInfo.variantGenerator) (); | ||
2017 | 337 | EXPECT_CALL (*mWrapperMock, getValue (Eq (keyName))).WillOnce (Return (variant)); | ||
2018 | 338 | |||
2019 | 339 | CCSSettingValue *value = ccsIntegratedSettingReadValue (gsettingsIntegrated, createSettingType); | ||
2020 | 340 | |||
2021 | 341 | if (createSettingType == integratedSettingInfo.settingType) | ||
2022 | 342 | (*integratedSettingInfo.expectation) (value); | ||
2023 | 343 | else | ||
2024 | 344 | EXPECT_THAT (value, IsNull ()); | ||
2025 | 345 | |||
2026 | 346 | if (value) | ||
2027 | 347 | ccsFreeSettingValueWithType (value, integratedSettingInfo.settingType); | ||
2028 | 348 | } | ||
2029 | 349 | |||
2030 | 350 | TEST_P (CCSGSettingsIntegratedSettingTest, MatchedTypesReturnValueMismatchedTypesResetOrWrite) | ||
2031 | 351 | { | ||
2032 | 352 | const std::string keyName ("mock"); | ||
2033 | 353 | const ccit::GSettingsIntegratedSettingInfo &integratedSettingInfo = | ||
2034 | 354 | std::tr1::get <1> (GetParam ()); | ||
2035 | 355 | const CCSSettingType createSettingType = | ||
2036 | 356 | std::tr1::get <0> (GetParam ()); | ||
2037 | 357 | |||
2038 | 358 | CCSIntegratedSettingInfo *integratedSetting = ccsSharedIntegratedSettingInfoNew (keyName.c_str (), | ||
2039 | 359 | keyName.c_str (), | ||
2040 | 360 | integratedSettingInfo.settingType, | ||
2041 | 361 | &ccsDefaultObjectAllocator); | ||
2042 | 362 | SpecialOptionType specialType = ccsTypeToSpecialType ()[integratedSettingInfo.settingType]; | ||
2043 | 363 | CCSGNOMEIntegratedSettingInfo *gnomeIntegratedSetting = ccsGNOMEIntegratedSettingInfoNew (integratedSetting, | ||
2044 | 364 | specialType, | ||
2045 | 365 | keyName.c_str (), | ||
2046 | 366 | &ccsDefaultObjectAllocator); | ||
2047 | 367 | CCSIntegratedSetting *gsettingsIntegrated = ccsGSettingsIntegratedSettingNew (gnomeIntegratedSetting, | ||
2048 | 368 | mWrapper.get (), | ||
2049 | 369 | &ccsDefaultObjectAllocator); | ||
2050 | 370 | |||
2051 | 371 | CCSSettingValue *value = (*integratedSettingInfo.valueGenerator) (); | ||
2052 | 372 | GVariant *variant = (*integratedSettingInfo.variantGenerator) (); | ||
2053 | 373 | EXPECT_CALL (*mWrapperMock, getValue (Eq (keyName))).WillOnce (Return (variant)); | ||
2054 | 374 | |||
2055 | 375 | if (createSettingType == integratedSettingInfo.settingType) | ||
2056 | 376 | EXPECT_CALL (*mWrapperMock, setValue (Eq (keyName), _)); // can't verify this right yet | ||
2057 | 377 | else | ||
2058 | 378 | EXPECT_CALL (*mWrapperMock, resetKey (Eq (keyName))); | ||
2059 | 379 | |||
2060 | 380 | ccsIntegratedSettingWriteValue (gsettingsIntegrated, value, createSettingType); | ||
2061 | 381 | |||
2062 | 382 | if (value) | ||
2063 | 383 | ccsFreeSettingValueWithType (value, integratedSettingInfo.settingType); | ||
2064 | 384 | } | ||
2065 | 385 | |||
2066 | 386 | INSTANTIATE_TEST_CASE_P (CCSGSettingsIntegratedSettingTestMismatchedValues, CCSGSettingsIntegratedSettingTest, | ||
2067 | 387 | Combine (Values (TypeInt, TypeString, TypeBool, TypeKey), | ||
2068 | 388 | ValuesIn (cciti::settingsInfo))); | ||
2069 | 0 | 389 | ||
2070 | === modified file 'compizconfig/integration/gnome/include/ccs_gnome_integrated_setting.h' | |||
2071 | --- compizconfig/integration/gnome/include/ccs_gnome_integrated_setting.h 2012-08-17 07:33:02 +0000 | |||
2072 | +++ compizconfig/integration/gnome/include/ccs_gnome_integrated_setting.h 2012-09-24 03:58:20 +0000 | |||
2073 | @@ -15,11 +15,13 @@ | |||
2074 | 15 | 15 | ||
2075 | 16 | typedef SpecialOptionType (*CCSGNOMEIntegratedSettingInfoGetSpecialOptionType) (CCSGNOMEIntegratedSettingInfo *); | 16 | typedef SpecialOptionType (*CCSGNOMEIntegratedSettingInfoGetSpecialOptionType) (CCSGNOMEIntegratedSettingInfo *); |
2076 | 17 | typedef const char * (*CCSGNOMEIntegratedSettingInfoGetGNOMEName) (CCSGNOMEIntegratedSettingInfo *); | 17 | typedef const char * (*CCSGNOMEIntegratedSettingInfoGetGNOMEName) (CCSGNOMEIntegratedSettingInfo *); |
2077 | 18 | typedef void (*CCSGNOMEIntegratedSettingInfoFree) (CCSGNOMEIntegratedSettingInfo *); | ||
2078 | 18 | 19 | ||
2079 | 19 | struct _CCSGNOMEIntegratedSettingInfoInterface | 20 | struct _CCSGNOMEIntegratedSettingInfoInterface |
2080 | 20 | { | 21 | { |
2081 | 21 | CCSGNOMEIntegratedSettingInfoGetSpecialOptionType getSpecialOptionType; | 22 | CCSGNOMEIntegratedSettingInfoGetSpecialOptionType getSpecialOptionType; |
2083 | 22 | CCSGNOMEIntegratedSettingInfoGetGNOMEName getGNOMEName; | 23 | CCSGNOMEIntegratedSettingInfoGetGNOMEName getGNOMEName; |
2084 | 24 | CCSGNOMEIntegratedSettingInfoFree free; | ||
2085 | 23 | }; | 25 | }; |
2086 | 24 | 26 | ||
2087 | 25 | /** | 27 | /** |
2088 | @@ -53,6 +55,12 @@ | |||
2089 | 53 | const char *gnomeName, | 55 | const char *gnomeName, |
2090 | 54 | CCSObjectAllocationInterface *ai); | 56 | CCSObjectAllocationInterface *ai); |
2091 | 55 | 57 | ||
2092 | 58 | void | ||
2093 | 59 | ccsFreeGNOMEIntegratedSettingInfo (CCSGNOMEIntegratedSettingInfo *); | ||
2094 | 60 | |||
2095 | 61 | CCSREF_HDR (GNOMEIntegratedSettingInfo, CCSGNOMEIntegratedSettingInfo); | ||
2096 | 62 | CCSLIST_HDR (GNOMEIntegratedSettingInfo, CCSGNOMEIntegratedSettingInfo); | ||
2097 | 63 | |||
2098 | 56 | COMPIZCONFIG_END_DECLS | 64 | COMPIZCONFIG_END_DECLS |
2099 | 57 | 65 | ||
2100 | 58 | #endif | 66 | #endif |
2101 | 59 | 67 | ||
2102 | === modified file 'compizconfig/integration/gnome/include/ccs_gnome_integration_constants.h' | |||
2103 | --- compizconfig/integration/gnome/include/ccs_gnome_integration_constants.h 2012-09-05 09:02:56 +0000 | |||
2104 | +++ compizconfig/integration/gnome/include/ccs_gnome_integration_constants.h 2012-09-24 03:58:20 +0000 | |||
2105 | @@ -2,6 +2,7 @@ | |||
2106 | 2 | #define _CCS_GNOME_INTEGRATION_CONSTANTS_H | 2 | #define _CCS_GNOME_INTEGRATION_CONSTANTS_H |
2107 | 3 | 3 | ||
2108 | 4 | #include <ccs-defs.h> | 4 | #include <ccs-defs.h> |
2109 | 5 | #include <glib.h> | ||
2110 | 5 | 6 | ||
2111 | 6 | COMPIZCONFIG_BEGIN_DECLS | 7 | COMPIZCONFIG_BEGIN_DECLS |
2112 | 7 | 8 | ||
2113 | 8 | 9 | ||
2114 | === modified file 'compizconfig/integration/gnome/include/ccs_gnome_integration_types.h' | |||
2115 | --- compizconfig/integration/gnome/include/ccs_gnome_integration_types.h 2012-08-14 04:46:41 +0000 | |||
2116 | +++ compizconfig/integration/gnome/include/ccs_gnome_integration_types.h 2012-09-24 03:58:20 +0000 | |||
2117 | @@ -22,5 +22,7 @@ | |||
2118 | 22 | OptionSpecial, | 22 | OptionSpecial, |
2119 | 23 | } SpecialOptionType; | 23 | } SpecialOptionType; |
2120 | 24 | 24 | ||
2121 | 25 | COMPIZCONFIG_END_DECLS | ||
2122 | 26 | |||
2123 | 25 | #endif | 27 | #endif |
2124 | 26 | 28 | ||
2125 | 27 | 29 | ||
2126 | === removed file 'compizconfig/integration/gnome/include/ccs_gnome_integration_types.h~' | |||
2127 | --- compizconfig/integration/gnome/include/ccs_gnome_integration_types.h~ 2012-08-14 06:42:11 +0000 | |||
2128 | +++ compizconfig/integration/gnome/include/ccs_gnome_integration_types.h~ 1970-01-01 00:00:00 +0000 | |||
2129 | @@ -1,26 +0,0 @@ | |||
2130 | 1 | #ifndef _CCS_GNOME_INTEGRATION_TYPES_H | ||
2131 | 2 | #define _CCS_GNOME_INTEGRATION_TYPES_H | ||
2132 | 3 | |||
2133 | 4 | #include <ccs-defs.h> | ||
2134 | 5 | |||
2135 | 6 | COMPIZCONFIG_BEGIN_DECLS | ||
2136 | 7 | |||
2137 | 8 | typedef struct _CCSBackend CCSBackend; | ||
2138 | 9 | typedef struct _CCSContext CCSContext; | ||
2139 | 10 | typedef struct _CCSObjectAllocationInterface CCSObjectAllocationInterface; | ||
2140 | 11 | typedef struct _CCSIntegration CCSIntegration; | ||
2141 | 12 | typedef struct _CCSIntegratedSetting CCSIntegratedSetting; | ||
2142 | 13 | typedef struct _CCSIntegratedSettingFactory CCSIntegratedSettingFactory; | ||
2143 | 14 | typedef struct _CCSIntegratedSettingsStorage CCSIntegratedSettingsStorage; | ||
2144 | 15 | typedef struct _GConfClient GConfClient; | ||
2145 | 16 | |||
2146 | 17 | typedef enum { | ||
2147 | 18 | OptionInt, | ||
2148 | 19 | OptionBool, | ||
2149 | 20 | OptionKey, | ||
2150 | 21 | OptionString, | ||
2151 | 22 | OptionSpecial, | ||
2152 | 23 | } SpecialOptionType; | ||
2153 | 24 | |||
2154 | 25 | #endif | ||
2155 | 26 | |||
2156 | 27 | 0 | ||
2157 | === modified file 'compizconfig/integration/gnome/src/ccs_gnome_integrated_setting.c' | |||
2158 | --- compizconfig/integration/gnome/src/ccs_gnome_integrated_setting.c 2012-08-18 13:15:30 +0000 | |||
2159 | +++ compizconfig/integration/gnome/src/ccs_gnome_integrated_setting.c 2012-09-24 03:58:20 +0000 | |||
2160 | @@ -12,6 +12,8 @@ | |||
2161 | 12 | 12 | ||
2162 | 13 | INTERFACE_TYPE (CCSGNOMEIntegratedSettingInfoInterface); | 13 | INTERFACE_TYPE (CCSGNOMEIntegratedSettingInfoInterface); |
2163 | 14 | 14 | ||
2164 | 15 | CCSREF_OBJ (GNOMEIntegratedSettingInfo, CCSGNOMEIntegratedSettingInfo); | ||
2165 | 16 | |||
2166 | 15 | SpecialOptionType | 17 | SpecialOptionType |
2167 | 16 | ccsGNOMEIntegratedSettingInfoGetSpecialOptionType (CCSGNOMEIntegratedSettingInfo *info) | 18 | ccsGNOMEIntegratedSettingInfoGetSpecialOptionType (CCSGNOMEIntegratedSettingInfo *info) |
2168 | 17 | { | 19 | { |
2169 | @@ -89,7 +91,7 @@ | |||
2170 | 89 | } | 91 | } |
2171 | 90 | 92 | ||
2172 | 91 | void | 93 | void |
2174 | 92 | ccsGNOMEIntegratedSettingInfoFree (CCSIntegratedSettingInfo *info) | 94 | ccsGNOMESharedIntegratedSettingInfoFree (CCSIntegratedSettingInfo *info) |
2175 | 93 | { | 95 | { |
2176 | 94 | CCSGNOMEIntegratedSettingInfoDefaultImplPrivate *priv = (CCSGNOMEIntegratedSettingInfoDefaultImplPrivate *) ccsObjectGetPrivate (info); | 96 | CCSGNOMEIntegratedSettingInfoDefaultImplPrivate *priv = (CCSGNOMEIntegratedSettingInfoDefaultImplPrivate *) ccsObjectGetPrivate (info); |
2177 | 95 | 97 | ||
2178 | @@ -99,10 +101,17 @@ | |||
2179 | 99 | (*info->object.object_allocation->free_) (info->object.object_allocation->allocator, info); | 101 | (*info->object.object_allocation->free_) (info->object.object_allocation->allocator, info); |
2180 | 100 | } | 102 | } |
2181 | 101 | 103 | ||
2182 | 104 | static void | ||
2183 | 105 | ccsGNOMEIntegratedSettingInfoFree (CCSGNOMEIntegratedSettingInfo *info) | ||
2184 | 106 | { | ||
2185 | 107 | ccsGNOMESharedIntegratedSettingInfoFree ((CCSIntegratedSettingInfo *) info); | ||
2186 | 108 | } | ||
2187 | 109 | |||
2188 | 102 | CCSGNOMEIntegratedSettingInfoInterface ccsGNOMEIntegratedSettingInfoDefaultImplInterface = | 110 | CCSGNOMEIntegratedSettingInfoInterface ccsGNOMEIntegratedSettingInfoDefaultImplInterface = |
2189 | 103 | { | 111 | { |
2190 | 104 | ccsGNOMEIntegratedSettingGetSpecialOptionDefault, | 112 | ccsGNOMEIntegratedSettingGetSpecialOptionDefault, |
2192 | 105 | ccsGNOMEIntegratedSettingGetGNOMENameDefault | 113 | ccsGNOMEIntegratedSettingGetGNOMENameDefault, |
2193 | 114 | ccsGNOMEIntegratedSettingInfoFree | ||
2194 | 106 | }; | 115 | }; |
2195 | 107 | 116 | ||
2196 | 108 | const CCSIntegratedSettingInfoInterface ccsGNOMEIntegratedSettingInfoInterface = | 117 | const CCSIntegratedSettingInfoInterface ccsGNOMEIntegratedSettingInfoInterface = |
2197 | @@ -110,9 +119,15 @@ | |||
2198 | 110 | ccsGNOMEIntegratedSettingInfoPluginName, | 119 | ccsGNOMEIntegratedSettingInfoPluginName, |
2199 | 111 | ccsGNOMEIntegratedSettingInfoSettingName, | 120 | ccsGNOMEIntegratedSettingInfoSettingName, |
2200 | 112 | ccsGNOMEIntegratedSettingInfoGetType, | 121 | ccsGNOMEIntegratedSettingInfoGetType, |
2202 | 113 | ccsGNOMEIntegratedSettingInfoFree | 122 | ccsGNOMESharedIntegratedSettingInfoFree |
2203 | 114 | }; | 123 | }; |
2204 | 115 | 124 | ||
2205 | 125 | void | ||
2206 | 126 | ccsFreeGNOMEIntegratedSettingInfo (CCSGNOMEIntegratedSettingInfo *info) | ||
2207 | 127 | { | ||
2208 | 128 | (*(GET_INTERFACE (CCSGNOMEIntegratedSettingInfoInterface, info))->free) (info); | ||
2209 | 129 | } | ||
2210 | 130 | |||
2211 | 116 | CCSGNOMEIntegratedSettingInfo * | 131 | CCSGNOMEIntegratedSettingInfo * |
2212 | 117 | ccsGNOMEIntegratedSettingInfoNew (CCSIntegratedSettingInfo *base, | 132 | ccsGNOMEIntegratedSettingInfoNew (CCSIntegratedSettingInfo *base, |
2213 | 118 | SpecialOptionType type, | 133 | SpecialOptionType type, |
2214 | 119 | 134 | ||
2215 | === modified file 'compizconfig/integration/gnome/src/ccs_gnome_integration.c' | |||
2216 | --- compizconfig/integration/gnome/src/ccs_gnome_integration.c 2012-08-17 07:33:02 +0000 | |||
2217 | +++ compizconfig/integration/gnome/src/ccs_gnome_integration.c 2012-09-24 03:58:20 +0000 | |||
2218 | @@ -132,9 +132,12 @@ | |||
2219 | 132 | CCSSettingType type = TypeString; | 132 | CCSSettingType type = TypeString; |
2220 | 133 | CCSSettingValue *v = ccsIntegratedSettingReadValue (mouseButtonModifierSetting, type); | 133 | CCSSettingValue *v = ccsIntegratedSettingReadValue (mouseButtonModifierSetting, type); |
2221 | 134 | 134 | ||
2223 | 135 | modMask = ccsStringToModifiers (v->value.asString); | 135 | if (v) |
2224 | 136 | { | ||
2225 | 137 | modMask = ccsStringToModifiers (v->value.asString); | ||
2226 | 136 | 138 | ||
2228 | 137 | ccsFreeSettingValueWithType (v, type); | 139 | ccsFreeSettingValueWithType (v, type); |
2229 | 140 | } | ||
2230 | 138 | 141 | ||
2231 | 139 | return modMask; | 142 | return modMask; |
2232 | 140 | } | 143 | } |
2233 | @@ -445,7 +448,7 @@ | |||
2234 | 445 | } | 448 | } |
2235 | 446 | else if (strcmp (settingName, "fullscreen_visual_bell") == 0) | 449 | else if (strcmp (settingName, "fullscreen_visual_bell") == 0) |
2236 | 447 | { | 450 | { |
2238 | 448 | const char *newValueString = v->value.asString ? "fullscreen" : "frame_flash"; | 451 | const char *newValueString = v->value.asBool ? "fullscreen" : "frame_flash"; |
2239 | 449 | newValue->value.asString = strdup (newValueString); | 452 | newValue->value.asString = strdup (newValueString); |
2240 | 450 | type = TypeString; | 453 | type = TypeString; |
2241 | 451 | 454 | ||
2242 | @@ -453,7 +456,7 @@ | |||
2243 | 453 | } | 456 | } |
2244 | 454 | else if (strcmp (settingName, "click_to_focus") == 0) | 457 | else if (strcmp (settingName, "click_to_focus") == 0) |
2245 | 455 | { | 458 | { |
2247 | 456 | const char *newValueString = v->value.asString ? "click" : "sloppy"; | 459 | const char *newValueString = v->value.asBool ? "click" : "sloppy"; |
2248 | 457 | newValue->value.asString = strdup (newValueString); | 460 | newValue->value.asString = strdup (newValueString); |
2249 | 458 | type = TypeString; | 461 | type = TypeString; |
2250 | 459 | 462 | ||
2251 | @@ -468,9 +471,9 @@ | |||
2252 | 468 | unsigned int modMask; | 471 | unsigned int modMask; |
2253 | 469 | Bool resizeWithRightButton = FALSE; | 472 | Bool resizeWithRightButton = FALSE; |
2254 | 470 | 473 | ||
2256 | 471 | if ((getButtonBindingForSetting (context, "resize", | 474 | if ((getButtonBindingForSetting (priv->context, "resize", |
2257 | 472 | "initiate_button") == 3) || | 475 | "initiate_button") == 3) || |
2259 | 473 | (getButtonBindingForSetting (context, "core", | 476 | (getButtonBindingForSetting (priv->context, "core", |
2260 | 474 | "window_menu_button") == 2)) | 477 | "window_menu_button") == 2)) |
2261 | 475 | { | 478 | { |
2262 | 476 | resizeWithRightButton = TRUE; | 479 | resizeWithRightButton = TRUE; |
2263 | @@ -489,16 +492,16 @@ | |||
2264 | 489 | ccsGNOMEIntegratedPluginNames.SPECIAL, | 492 | ccsGNOMEIntegratedPluginNames.SPECIAL, |
2265 | 490 | ccsGNOMEIntegratedSettingNames.NULL_MOUSE_BUTTON_MODIFIER.compizName); | 493 | ccsGNOMEIntegratedSettingNames.NULL_MOUSE_BUTTON_MODIFIER.compizName); |
2266 | 491 | 494 | ||
2268 | 492 | modMask = ccsSettingGetValue (setting)->value.asButton.buttonModMask; | 495 | modMask = v->value.asButton.buttonModMask; |
2269 | 493 | if (setGnomeMouseButtonModifier (integratedSettingsMBM->data, modMask)) | 496 | if (setGnomeMouseButtonModifier (integratedSettingsMBM->data, modMask)) |
2270 | 494 | { | 497 | { |
2272 | 495 | setButtonBindingForSetting (context, "move", | 498 | setButtonBindingForSetting (priv->context, "move", |
2273 | 496 | "initiate_button", 1, modMask); | 499 | "initiate_button", 1, modMask); |
2275 | 497 | setButtonBindingForSetting (context, "resize", | 500 | setButtonBindingForSetting (priv->context, "resize", |
2276 | 498 | "initiate_button", | 501 | "initiate_button", |
2277 | 499 | resizeWithRightButton ? 3 : 2, | 502 | resizeWithRightButton ? 3 : 2, |
2278 | 500 | modMask); | 503 | modMask); |
2280 | 501 | setButtonBindingForSetting (context, "core", | 504 | setButtonBindingForSetting (priv->context, "core", |
2281 | 502 | "window_menu_button", | 505 | "window_menu_button", |
2282 | 503 | resizeWithRightButton ? 2 : 3, | 506 | resizeWithRightButton ? 2 : 3, |
2283 | 504 | modMask); | 507 | modMask); |
2284 | 505 | 508 | ||
2285 | === added directory 'compizconfig/integration/gnome/tests' | |||
2286 | === added file 'compizconfig/integration/gnome/tests/CMakeLists.txt' | |||
2287 | --- compizconfig/integration/gnome/tests/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
2288 | +++ compizconfig/integration/gnome/tests/CMakeLists.txt 2012-09-24 03:58:20 +0000 | |||
2289 | @@ -0,0 +1,47 @@ | |||
2290 | 1 | include_directories (${GTEST_INCLUDE_DIRS}) | ||
2291 | 2 | include_directories (${CMAKE_SOURCE_DIR}/include) | ||
2292 | 3 | include_directories (${CMAKE_SOURCE_DIR}/tests/shared) | ||
2293 | 4 | include_directories (${CMAKE_SOURCE_DIR}/tests/shared/glib) | ||
2294 | 5 | include_directories (${CMAKE_CURRENT_SOURCE_DIR}/../../../mocks/libcompizconfig) | ||
2295 | 6 | include_directories (${CMAKE_CURRENT_SOURCE_DIR}/../../../gsettings/tests) | ||
2296 | 7 | include_directories (${CMAKE_CURRENT_SOURCE_DIR}/../../../gsettings/mocks) | ||
2297 | 8 | include_directories (${CMAKE_SOURCE_DIR}/compizconfig/tests) | ||
2298 | 9 | link_directories (${CMAKE_INSTALL_PREFIX}/lib) | ||
2299 | 10 | |||
2300 | 11 | set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") | ||
2301 | 12 | |||
2302 | 13 | add_library (compizconfig_ccs_mock_gnome_integrated_setting_composition | ||
2303 | 14 | ${CMAKE_CURRENT_SOURCE_DIR}/compizconfig_ccs_mock_gnome_integrated_setting_composition.c) | ||
2304 | 15 | |||
2305 | 16 | target_link_libraries (compizconfig_ccs_mock_gnome_integrated_setting_composition | ||
2306 | 17 | compizconfig_ccs_integrated_setting_mock | ||
2307 | 18 | compizconfig_gnome_integrated_setting | ||
2308 | 19 | compizconfig) | ||
2309 | 20 | |||
2310 | 21 | add_executable (compizconfig_test_ccs_gnome_integration | ||
2311 | 22 | ${CMAKE_CURRENT_SOURCE_DIR}/compizconfig_test_ccs_gnome_integration.cpp) | ||
2312 | 23 | |||
2313 | 24 | target_link_libraries (compizconfig_test_ccs_gnome_integration | ||
2314 | 25 | ${GTEST_BOTH_LIBRARIES} | ||
2315 | 26 | ${GMOCK_LIBRARY} | ||
2316 | 27 | ${GMOCK_MAIN_LIBRARY} | ||
2317 | 28 | ${CMAKE_THREAD_LIBS_INIT} | ||
2318 | 29 | ${LIBCOMPIZCONFIG_LIBRARIES} | ||
2319 | 30 | compizconfig | ||
2320 | 31 | compizconfig_ccs_context_mock | ||
2321 | 32 | compizconfig_ccs_backend_mock | ||
2322 | 33 | compizconfig_ccs_setting_mock | ||
2323 | 34 | compizconfig_ccs_plugin_mock | ||
2324 | 35 | compizconfig_ccs_list_wrapper | ||
2325 | 36 | compizconfig_ccs_setting_value_operators | ||
2326 | 37 | compizconfig_ccs_setting_value_matcher | ||
2327 | 38 | compizconfig_ccs_integrated_setting_mock | ||
2328 | 39 | compizconfig_ccs_integrated_setting_factory_mock | ||
2329 | 40 | compizconfig_ccs_integrated_setting_storage_mock | ||
2330 | 41 | compizconfig_ccs_mock_gnome_integrated_setting_composition | ||
2331 | 42 | compizconfig_gnome_integration) | ||
2332 | 43 | |||
2333 | 44 | compiz_discover_tests (compizconfig_test_ccs_gnome_integration | ||
2334 | 45 | COVERAGE | ||
2335 | 46 | compizconfig_gnome_integration | ||
2336 | 47 | compizconfig_gnome_integration_constants) | ||
2337 | 0 | 48 | ||
2338 | === added file 'compizconfig/integration/gnome/tests/compizconfig_ccs_mock_gnome_integrated_setting_composition.c' | |||
2339 | --- compizconfig/integration/gnome/tests/compizconfig_ccs_mock_gnome_integrated_setting_composition.c 1970-01-01 00:00:00 +0000 | |||
2340 | +++ compizconfig/integration/gnome/tests/compizconfig_ccs_mock_gnome_integrated_setting_composition.c 2012-09-24 03:58:20 +0000 | |||
2341 | @@ -0,0 +1,222 @@ | |||
2342 | 1 | /* | ||
2343 | 2 | * Compiz configuration system library | ||
2344 | 3 | * | ||
2345 | 4 | * Copyright (C) 2012 Canonical Ltd. | ||
2346 | 5 | * | ||
2347 | 6 | * This library is free software; you can redistribute it and/or | ||
2348 | 7 | * modify it under the terms of the GNU Lesser General Public | ||
2349 | 8 | * License as published by the Free Software Foundation; either | ||
2350 | 9 | * version 2.1 of the License, or (at your option) any later version. | ||
2351 | 10 | |||
2352 | 11 | * This library is distributed in the hope that it will be useful, | ||
2353 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2354 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
2355 | 14 | * Lesser General Public License for more details. | ||
2356 | 15 | |||
2357 | 16 | * You should have received a copy of the GNU Lesser General Public | ||
2358 | 17 | * License along with this library; if not, write to the Free Software | ||
2359 | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
2360 | 19 | * | ||
2361 | 20 | * Authored By: | ||
2362 | 21 | * Sam Spilsbury <sam.spilsbury@canonical.com> | ||
2363 | 22 | */ | ||
2364 | 23 | |||
2365 | 24 | #include <ccs.h> | ||
2366 | 25 | #include <ccs-backend.h> | ||
2367 | 26 | #include <ccs_gnome_integrated_setting.h> | ||
2368 | 27 | #include "compizconfig_ccs_mock_gnome_integrated_setting_composition.h" | ||
2369 | 28 | |||
2370 | 29 | typedef struct _CCSMockGNOMEIntegratedSettingCompositionPrivate | ||
2371 | 30 | { | ||
2372 | 31 | CCSIntegratedSetting *integratedSetting; | ||
2373 | 32 | CCSGNOMEIntegratedSettingInfo *gnomeIntegratedSettingInfo; | ||
2374 | 33 | CCSIntegratedSettingInfo *integratedSettingInfo; | ||
2375 | 34 | } CCSMockGNOMEIntegratedSettingCompositionPrivate; | ||
2376 | 35 | |||
2377 | 36 | static CCSIntegratedSetting * | ||
2378 | 37 | allocateCCSIntegratedSetting (CCSObjectAllocationInterface *allocator) | ||
2379 | 38 | { | ||
2380 | 39 | CCSIntegratedSetting *setting = | ||
2381 | 40 | (*allocator->calloc_) (allocator->allocator, | ||
2382 | 41 | 1, | ||
2383 | 42 | sizeof (CCSIntegratedSetting)); | ||
2384 | 43 | |||
2385 | 44 | ccsObjectInit (setting, allocator); | ||
2386 | 45 | |||
2387 | 46 | return setting; | ||
2388 | 47 | } | ||
2389 | 48 | |||
2390 | 49 | static CCSMockGNOMEIntegratedSettingCompositionPrivate * | ||
2391 | 50 | allocatePrivate (CCSIntegratedSetting *integratedSetting, | ||
2392 | 51 | CCSObjectAllocationInterface *allocator) | ||
2393 | 52 | { | ||
2394 | 53 | CCSMockGNOMEIntegratedSettingCompositionPrivate *priv = | ||
2395 | 54 | (*allocator->calloc_) (allocator->allocator, | ||
2396 | 55 | 1, | ||
2397 | 56 | sizeof (CCSMockGNOMEIntegratedSettingCompositionPrivate)); | ||
2398 | 57 | |||
2399 | 58 | if (!priv) | ||
2400 | 59 | { | ||
2401 | 60 | ccsObjectFinalize (integratedSetting); | ||
2402 | 61 | (*allocator->free_) (allocator->allocator, integratedSetting); | ||
2403 | 62 | return NULL; | ||
2404 | 63 | } | ||
2405 | 64 | |||
2406 | 65 | return priv; | ||
2407 | 66 | } | ||
2408 | 67 | |||
2409 | 68 | static SpecialOptionType | ||
2410 | 69 | ccsMockCompositionIntegratedSettingGetSpecialOptionType (CCSGNOMEIntegratedSettingInfo *setting) | ||
2411 | 70 | { | ||
2412 | 71 | CCSMockGNOMEIntegratedSettingCompositionPrivate *priv = GET_PRIVATE (CCSMockGNOMEIntegratedSettingCompositionPrivate, setting); | ||
2413 | 72 | |||
2414 | 73 | return ccsGNOMEIntegratedSettingInfoGetSpecialOptionType (priv->gnomeIntegratedSettingInfo); | ||
2415 | 74 | } | ||
2416 | 75 | |||
2417 | 76 | static const char * | ||
2418 | 77 | ccsMockCompositionIntegratedSettingGetGNOMEName (CCSGNOMEIntegratedSettingInfo *setting) | ||
2419 | 78 | { | ||
2420 | 79 | CCSMockGNOMEIntegratedSettingCompositionPrivate *priv = GET_PRIVATE (CCSMockGNOMEIntegratedSettingCompositionPrivate, setting); | ||
2421 | 80 | |||
2422 | 81 | return ccsGNOMEIntegratedSettingInfoGetGNOMEName (priv->gnomeIntegratedSettingInfo); | ||
2423 | 82 | } | ||
2424 | 83 | |||
2425 | 84 | static CCSSettingValue * | ||
2426 | 85 | ccsMockCompositionIntegratedSettingReadValue (CCSIntegratedSetting *setting, CCSSettingType type) | ||
2427 | 86 | { | ||
2428 | 87 | CCSMockGNOMEIntegratedSettingCompositionPrivate *priv = | ||
2429 | 88 | GET_PRIVATE (CCSMockGNOMEIntegratedSettingCompositionPrivate, setting); | ||
2430 | 89 | |||
2431 | 90 | return ccsIntegratedSettingReadValue (priv->integratedSetting, type); | ||
2432 | 91 | } | ||
2433 | 92 | |||
2434 | 93 | static void | ||
2435 | 94 | ccsMockCompositionIntegratedSettingWriteValue (CCSIntegratedSetting *setting, CCSSettingValue *v, CCSSettingType type) | ||
2436 | 95 | { | ||
2437 | 96 | CCSMockGNOMEIntegratedSettingCompositionPrivate *priv = | ||
2438 | 97 | GET_PRIVATE (CCSMockGNOMEIntegratedSettingCompositionPrivate, setting); | ||
2439 | 98 | |||
2440 | 99 | ccsIntegratedSettingWriteValue (priv->integratedSetting, v, type); | ||
2441 | 100 | } | ||
2442 | 101 | |||
2443 | 102 | static const char * | ||
2444 | 103 | ccsMockCompositionIntegratedSettingInfoPluginName (CCSIntegratedSettingInfo *setting) | ||
2445 | 104 | { | ||
2446 | 105 | CCSMockGNOMEIntegratedSettingCompositionPrivate *priv = GET_PRIVATE (CCSMockGNOMEIntegratedSettingCompositionPrivate, setting); | ||
2447 | 106 | |||
2448 | 107 | return ccsIntegratedSettingInfoPluginName (priv->integratedSettingInfo); | ||
2449 | 108 | } | ||
2450 | 109 | |||
2451 | 110 | static const char * | ||
2452 | 111 | ccsMockCompositionIntegratedSettingInfoSettingName (CCSIntegratedSettingInfo *setting) | ||
2453 | 112 | { | ||
2454 | 113 | CCSMockGNOMEIntegratedSettingCompositionPrivate *priv = GET_PRIVATE (CCSMockGNOMEIntegratedSettingCompositionPrivate, setting); | ||
2455 | 114 | |||
2456 | 115 | return ccsIntegratedSettingInfoSettingName (priv->integratedSettingInfo); | ||
2457 | 116 | } | ||
2458 | 117 | |||
2459 | 118 | static CCSSettingType | ||
2460 | 119 | ccsMockCompositionIntegratedSettingInfoGetType (CCSIntegratedSettingInfo *setting) | ||
2461 | 120 | { | ||
2462 | 121 | CCSMockGNOMEIntegratedSettingCompositionPrivate *priv = GET_PRIVATE (CCSMockGNOMEIntegratedSettingCompositionPrivate, setting); | ||
2463 | 122 | |||
2464 | 123 | return ccsIntegratedSettingInfoGetType (priv->integratedSettingInfo); | ||
2465 | 124 | } | ||
2466 | 125 | |||
2467 | 126 | static void | ||
2468 | 127 | ccsMockCompositionIntegratedSettingFree (CCSIntegratedSetting *integratedSetting) | ||
2469 | 128 | { | ||
2470 | 129 | CCSMockGNOMEIntegratedSettingCompositionPrivate *priv = | ||
2471 | 130 | GET_PRIVATE (CCSMockGNOMEIntegratedSettingCompositionPrivate, integratedSetting); | ||
2472 | 131 | |||
2473 | 132 | ccsIntegratedSettingUnref (priv->integratedSetting); | ||
2474 | 133 | ccsGNOMEIntegratedSettingInfoUnref (priv->gnomeIntegratedSettingInfo); | ||
2475 | 134 | ccsIntegratedSettingInfoUnref (priv->integratedSettingInfo); | ||
2476 | 135 | |||
2477 | 136 | ccsObjectFinalize (integratedSetting); | ||
2478 | 137 | (*integratedSetting->object.object_allocation->free_) | ||
2479 | 138 | (integratedSetting->object.object_allocation->allocator, integratedSetting); | ||
2480 | 139 | } | ||
2481 | 140 | |||
2482 | 141 | static void | ||
2483 | 142 | ccsMockCompositionIntegratedSettingInfoFree (CCSIntegratedSettingInfo *info) | ||
2484 | 143 | { | ||
2485 | 144 | return ccsMockCompositionIntegratedSettingFree ((CCSIntegratedSetting *) info); | ||
2486 | 145 | } | ||
2487 | 146 | |||
2488 | 147 | static void | ||
2489 | 148 | ccsMockCompositionGNOMEIntegratedSettingInfoFree (CCSGNOMEIntegratedSettingInfo *info) | ||
2490 | 149 | { | ||
2491 | 150 | return ccsMockCompositionIntegratedSettingFree ((CCSIntegratedSetting *) info); | ||
2492 | 151 | } | ||
2493 | 152 | |||
2494 | 153 | const CCSGNOMEIntegratedSettingInfoInterface ccsMockCompositionGNOMEIntegratedSettingInfo = | ||
2495 | 154 | { | ||
2496 | 155 | ccsMockCompositionIntegratedSettingGetSpecialOptionType, | ||
2497 | 156 | ccsMockCompositionIntegratedSettingGetGNOMEName, | ||
2498 | 157 | ccsMockCompositionGNOMEIntegratedSettingInfoFree | ||
2499 | 158 | }; | ||
2500 | 159 | |||
2501 | 160 | const CCSIntegratedSettingInterface ccsMockCompositionIntegratedSetting = | ||
2502 | 161 | { | ||
2503 | 162 | ccsMockCompositionIntegratedSettingReadValue, | ||
2504 | 163 | ccsMockCompositionIntegratedSettingWriteValue, | ||
2505 | 164 | ccsMockCompositionIntegratedSettingFree | ||
2506 | 165 | }; | ||
2507 | 166 | |||
2508 | 167 | const CCSIntegratedSettingInfoInterface ccsMockCompositionIntegratedSettingInfo = | ||
2509 | 168 | { | ||
2510 | 169 | ccsMockCompositionIntegratedSettingInfoPluginName, | ||
2511 | 170 | ccsMockCompositionIntegratedSettingInfoSettingName, | ||
2512 | 171 | ccsMockCompositionIntegratedSettingInfoGetType, | ||
2513 | 172 | ccsMockCompositionIntegratedSettingInfoFree | ||
2514 | 173 | }; | ||
2515 | 174 | |||
2516 | 175 | CCSIntegratedSetting * | ||
2517 | 176 | ccsMockCompositionIntegratedSettingNew (CCSIntegratedSetting *integratedSetting, | ||
2518 | 177 | CCSGNOMEIntegratedSettingInfo *gnomeInfo, | ||
2519 | 178 | CCSIntegratedSettingInfo *settingInfo, | ||
2520 | 179 | CCSObjectAllocationInterface *allocator) | ||
2521 | 180 | { | ||
2522 | 181 | CCSIntegratedSetting *composition = allocateCCSIntegratedSetting (allocator); | ||
2523 | 182 | |||
2524 | 183 | if (!composition) | ||
2525 | 184 | return NULL; | ||
2526 | 185 | |||
2527 | 186 | CCSMockGNOMEIntegratedSettingCompositionPrivate *priv = allocatePrivate (composition, | ||
2528 | 187 | allocator); | ||
2529 | 188 | |||
2530 | 189 | if (!priv) | ||
2531 | 190 | return NULL; | ||
2532 | 191 | |||
2533 | 192 | const CCSInterface *integratedSettingImpl = | ||
2534 | 193 | (const CCSInterface *) (&ccsMockCompositionIntegratedSetting); | ||
2535 | 194 | const CCSInterface *integratedSettingInfoImpl = | ||
2536 | 195 | (const CCSInterface *) (&ccsMockCompositionIntegratedSettingInfo); | ||
2537 | 196 | const CCSInterface *gnomeSettingImpl = | ||
2538 | 197 | (const CCSInterface *) (&ccsMockCompositionGNOMEIntegratedSettingInfo); | ||
2539 | 198 | |||
2540 | 199 | priv->integratedSetting = integratedSetting; | ||
2541 | 200 | priv->gnomeIntegratedSettingInfo = gnomeInfo; | ||
2542 | 201 | priv->integratedSettingInfo = settingInfo; | ||
2543 | 202 | |||
2544 | 203 | ccsIntegratedSettingRef (priv->integratedSetting); | ||
2545 | 204 | ccsGNOMEIntegratedSettingInfoRef (priv->gnomeIntegratedSettingInfo); | ||
2546 | 205 | ccsIntegratedSettingInfoRef (priv->integratedSettingInfo); | ||
2547 | 206 | |||
2548 | 207 | ccsObjectSetPrivate (composition, (CCSPrivate *) (priv)); | ||
2549 | 208 | ccsObjectAddInterface (composition, | ||
2550 | 209 | integratedSettingImpl, | ||
2551 | 210 | GET_INTERFACE_TYPE (CCSIntegratedSettingInterface)); | ||
2552 | 211 | ccsObjectAddInterface (composition, | ||
2553 | 212 | integratedSettingInfoImpl, | ||
2554 | 213 | GET_INTERFACE_TYPE (CCSIntegratedSettingInfoInterface)); | ||
2555 | 214 | ccsObjectAddInterface (composition, | ||
2556 | 215 | gnomeSettingImpl, | ||
2557 | 216 | GET_INTERFACE_TYPE (CCSGNOMEIntegratedSettingInfoInterface)); | ||
2558 | 217 | |||
2559 | 218 | ccsObjectRef (composition); | ||
2560 | 219 | |||
2561 | 220 | return composition; | ||
2562 | 221 | } | ||
2563 | 222 | |||
2564 | 0 | 223 | ||
2565 | === added file 'compizconfig/integration/gnome/tests/compizconfig_ccs_mock_gnome_integrated_setting_composition.h' | |||
2566 | --- compizconfig/integration/gnome/tests/compizconfig_ccs_mock_gnome_integrated_setting_composition.h 1970-01-01 00:00:00 +0000 | |||
2567 | +++ compizconfig/integration/gnome/tests/compizconfig_ccs_mock_gnome_integrated_setting_composition.h 2012-09-24 03:58:20 +0000 | |||
2568 | @@ -0,0 +1,42 @@ | |||
2569 | 1 | /* | ||
2570 | 2 | * Compiz configuration system library | ||
2571 | 3 | * | ||
2572 | 4 | * Copyright (C) 2012 Canonical Ltd. | ||
2573 | 5 | * | ||
2574 | 6 | * This library is free software; you can redistribute it and/or | ||
2575 | 7 | * modify it under the terms of the GNU Lesser General Public | ||
2576 | 8 | * License as published by the Free Software Foundation; either | ||
2577 | 9 | * version 2.1 of the License, or (at your option) any later version. | ||
2578 | 10 | |||
2579 | 11 | * This library is distributed in the hope that it will be useful, | ||
2580 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2581 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
2582 | 14 | * Lesser General Public License for more details. | ||
2583 | 15 | |||
2584 | 16 | * You should have received a copy of the GNU Lesser General Public | ||
2585 | 17 | * License along with this library; if not, write to the Free Software | ||
2586 | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
2587 | 19 | * | ||
2588 | 20 | * Authored By: | ||
2589 | 21 | * Sam Spilsbury <sam.spilsbury@canonical.com> | ||
2590 | 22 | */ | ||
2591 | 23 | #ifndef _COMPIZCONFIG_CCS_MOCK_GNOME_INTEGRATED_SETTING_COMPOSITION_H | ||
2592 | 24 | #define _COMPIZCONFIG_CCS_MOCK_GNOME_INTEGRATED_SETTING_COMPOSITION_H | ||
2593 | 25 | |||
2594 | 26 | COMPIZCONFIG_BEGIN_DECLS | ||
2595 | 27 | |||
2596 | 28 | typedef struct _CCSIntegratedSetting CCSIntegratedSetting; | ||
2597 | 29 | typedef struct _CCSGNOMEIntegratedSettingInfo CCSGNOMEIntegratedSettingInfo; | ||
2598 | 30 | typedef struct _CCSIntegratedSettingInfo CCSIntegratedSettingInfo; | ||
2599 | 31 | typedef struct _CCSObjectAllocationInterface CCSObjectAllocationInterface; | ||
2600 | 32 | |||
2601 | 33 | CCSIntegratedSetting * | ||
2602 | 34 | ccsMockCompositionIntegratedSettingNew (CCSIntegratedSetting *integratedSetting, | ||
2603 | 35 | CCSGNOMEIntegratedSettingInfo *gnomeInfo, | ||
2604 | 36 | CCSIntegratedSettingInfo *settingInfo, | ||
2605 | 37 | CCSObjectAllocationInterface *allocator); | ||
2606 | 38 | |||
2607 | 39 | COMPIZCONFIG_END_DECLS | ||
2608 | 40 | |||
2609 | 41 | #endif | ||
2610 | 42 | |||
2611 | 0 | 43 | ||
2612 | === added file 'compizconfig/integration/gnome/tests/compizconfig_test_ccs_gnome_integration.cpp' | |||
2613 | --- compizconfig/integration/gnome/tests/compizconfig_test_ccs_gnome_integration.cpp 1970-01-01 00:00:00 +0000 | |||
2614 | +++ compizconfig/integration/gnome/tests/compizconfig_test_ccs_gnome_integration.cpp 2012-09-24 03:58:20 +0000 | |||
2615 | @@ -0,0 +1,813 @@ | |||
2616 | 1 | /* | ||
2617 | 2 | * Compiz configuration system library | ||
2618 | 3 | * | ||
2619 | 4 | * Copyright (C) 2012 Canonical Ltd. | ||
2620 | 5 | * | ||
2621 | 6 | * This library is free software; you can redistribute it and/or | ||
2622 | 7 | * modify it under the terms of the GNU Lesser General Public | ||
2623 | 8 | * License as published by the Free Software Foundation; either | ||
2624 | 9 | * version 2.1 of the License, or (at your option) any later version. | ||
2625 | 10 | |||
2626 | 11 | * This library is distributed in the hope that it will be useful, | ||
2627 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2628 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
2629 | 14 | * Lesser General Public License for more details. | ||
2630 | 15 | |||
2631 | 16 | * You should have received a copy of the GNU Lesser General Public | ||
2632 | 17 | * License along with this library; if not, write to the Free Software | ||
2633 | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
2634 | 19 | * | ||
2635 | 20 | * Authored By: | ||
2636 | 21 | * Sam Spilsbury <sam.spilsbury@canonical.com> | ||
2637 | 22 | */ | ||
2638 | 23 | #include <tr1/tuple> | ||
2639 | 24 | |||
2640 | 25 | #include <gtest/gtest.h> | ||
2641 | 26 | #include <gmock/gmock.h> | ||
2642 | 27 | |||
2643 | 28 | #include <boost/shared_ptr.hpp> | ||
2644 | 29 | #include <boost/make_shared.hpp> | ||
2645 | 30 | |||
2646 | 31 | #include <gtest_shared_autodestroy.h> | ||
2647 | 32 | #include <gtest_unspecified_bool_type_matcher.h> | ||
2648 | 33 | |||
2649 | 34 | #include <compizconfig_ccs_list_wrapper.h> | ||
2650 | 35 | #include <compizconfig_ccs_setting_value_operators.h> | ||
2651 | 36 | |||
2652 | 37 | #include <ccs.h> | ||
2653 | 38 | #include <ccs-backend.h> | ||
2654 | 39 | #include <ccs_gnome_integrated_setting.h> | ||
2655 | 40 | #include <ccs_gnome_integration.h> | ||
2656 | 41 | #include <ccs_gnome_integration_constants.h> | ||
2657 | 42 | #include <compizconfig_ccs_context_mock.h> | ||
2658 | 43 | #include <compizconfig_ccs_setting_mock.h> | ||
2659 | 44 | #include <compizconfig_ccs_plugin_mock.h> | ||
2660 | 45 | #include <compizconfig_ccs_backend_mock.h> | ||
2661 | 46 | #include <compizconfig_ccs_integrated_setting_factory_mock.h> | ||
2662 | 47 | #include <compizconfig_ccs_integrated_setting_storage_mock.h> | ||
2663 | 48 | #include <compizconfig_ccs_integrated_setting_mock.h> | ||
2664 | 49 | #include "compizconfig_ccs_mock_gnome_integrated_setting_composition.h" | ||
2665 | 50 | #include "compizconfig_ccs_setting_value_matcher.h" | ||
2666 | 51 | |||
2667 | 52 | namespace cc = compiz::config; | ||
2668 | 53 | namespace cci = compiz::config::impl; | ||
2669 | 54 | |||
2670 | 55 | using ::testing::Pointee; | ||
2671 | 56 | using ::testing::Eq; | ||
2672 | 57 | using ::testing::Return; | ||
2673 | 58 | using ::testing::ReturnNull; | ||
2674 | 59 | using ::testing::SetArgPointee; | ||
2675 | 60 | using ::testing::DoAll; | ||
2676 | 61 | using ::testing::_; | ||
2677 | 62 | |||
2678 | 63 | namespace | ||
2679 | 64 | { | ||
2680 | 65 | typedef std::tr1::tuple <CCSIntegratedSettingGMock &, | ||
2681 | 66 | boost::shared_ptr <CCSIntegratedSetting> > IntegratedSettingWithMock; | ||
2682 | 67 | |||
2683 | 68 | typedef boost::shared_ptr <IntegratedSettingWithMock> IntegratedSettingWithMockPtr; | ||
2684 | 69 | |||
2685 | 70 | IntegratedSettingWithMockPtr | ||
2686 | 71 | createIntegratedSettingCompositionFromMock (const std::string &plugin, | ||
2687 | 72 | const std::string &setting, | ||
2688 | 73 | CCSSettingType type, | ||
2689 | 74 | SpecialOptionType gnomeType, | ||
2690 | 75 | const std::string &gnomeName, | ||
2691 | 76 | CCSObjectAllocationInterface *allocator) | ||
2692 | 77 | { | ||
2693 | 78 | CCSIntegratedSettingInfo *integratedSettingInfo = | ||
2694 | 79 | ccsSharedIntegratedSettingInfoNew (plugin.c_str (), | ||
2695 | 80 | setting.c_str (), | ||
2696 | 81 | type, | ||
2697 | 82 | allocator); | ||
2698 | 83 | CCSGNOMEIntegratedSettingInfo *gnomeIntegratedSettingInfo = | ||
2699 | 84 | ccsGNOMEIntegratedSettingInfoNew (integratedSettingInfo, | ||
2700 | 85 | gnomeType, | ||
2701 | 86 | gnomeName.c_str (), | ||
2702 | 87 | allocator); | ||
2703 | 88 | CCSIntegratedSetting *integratedSetting = | ||
2704 | 89 | ccsMockIntegratedSettingNew (allocator); | ||
2705 | 90 | |||
2706 | 91 | CCSIntegratedSettingGMock *mockPtr = GET_PRIVATE (CCSIntegratedSettingGMock, integratedSetting) | ||
2707 | 92 | CCSIntegratedSettingGMock &mock (*mockPtr); | ||
2708 | 93 | |||
2709 | 94 | boost::shared_ptr <CCSIntegratedSetting> composition = | ||
2710 | 95 | AutoDestroy (ccsMockCompositionIntegratedSettingNew (integratedSetting, | ||
2711 | 96 | gnomeIntegratedSettingInfo, | ||
2712 | 97 | integratedSettingInfo, | ||
2713 | 98 | allocator), | ||
2714 | 99 | ccsIntegratedSettingUnref); | ||
2715 | 100 | |||
2716 | 101 | /* We want the composition to take ownership here, so unref the | ||
2717 | 102 | * original members of the composition */ | ||
2718 | 103 | ccsIntegratedSettingInfoUnref (integratedSettingInfo); | ||
2719 | 104 | ccsGNOMEIntegratedSettingInfoUnref (gnomeIntegratedSettingInfo); | ||
2720 | 105 | ccsIntegratedSettingUnref (integratedSetting); | ||
2721 | 106 | |||
2722 | 107 | return boost::make_shared <IntegratedSettingWithMock> (mock, composition); | ||
2723 | 108 | } | ||
2724 | 109 | |||
2725 | 110 | CCSIntegratedSettingGMock & | ||
2726 | 111 | Mock (IntegratedSettingWithMock &integratedSettingWithMocks) | ||
2727 | 112 | { | ||
2728 | 113 | return std::tr1::get <0> (integratedSettingWithMocks); | ||
2729 | 114 | } | ||
2730 | 115 | |||
2731 | 116 | CCSIntegratedSetting * | ||
2732 | 117 | Real (IntegratedSettingWithMock &integratedSettingWithMocks) | ||
2733 | 118 | { | ||
2734 | 119 | return std::tr1::get <1> (integratedSettingWithMocks).get (); | ||
2735 | 120 | } | ||
2736 | 121 | |||
2737 | 122 | typedef std::tr1::tuple <CCSContextGMock &, | ||
2738 | 123 | CCSBackendGMock &, | ||
2739 | 124 | CCSIntegratedSettingsStorageGMock &, | ||
2740 | 125 | CCSIntegratedSettingFactoryGMock &, | ||
2741 | 126 | boost::shared_ptr <CCSContext> , | ||
2742 | 127 | boost::shared_ptr <CCSBackend> , | ||
2743 | 128 | boost::shared_ptr <CCSIntegratedSettingsStorage> , | ||
2744 | 129 | boost::shared_ptr <CCSIntegratedSettingFactory> , | ||
2745 | 130 | boost::shared_ptr <CCSIntegration> > CCSGNOMEIntegrationWithMocks; | ||
2746 | 131 | |||
2747 | 132 | CCSGNOMEIntegrationWithMocks | ||
2748 | 133 | createIntegrationWithMocks (CCSObjectAllocationInterface *ai) | ||
2749 | 134 | { | ||
2750 | 135 | boost::shared_ptr <CCSContext> context (AutoDestroy (ccsMockContextNew (), | ||
2751 | 136 | ccsFreeContext)); | ||
2752 | 137 | boost::shared_ptr <CCSBackend> backend (AutoDestroy (ccsMockBackendNew (), | ||
2753 | 138 | ccsBackendUnref)); | ||
2754 | 139 | boost::shared_ptr <CCSIntegratedSettingsStorage> storage (AutoDestroy (ccsMockIntegratedSettingsStorageNew (ai), | ||
2755 | 140 | ccsIntegratedSettingsStorageUnref)); | ||
2756 | 141 | boost::shared_ptr <CCSIntegratedSettingFactory> factory (AutoDestroy (ccsMockIntegratedSettingFactoryNew (ai), | ||
2757 | 142 | ccsIntegratedSettingFactoryUnref)); | ||
2758 | 143 | boost::shared_ptr <CCSIntegration> integration (AutoDestroy (ccsGNOMEIntegrationBackendNew (backend.get (), | ||
2759 | 144 | context.get (), | ||
2760 | 145 | factory.get (), | ||
2761 | 146 | storage.get (), | ||
2762 | 147 | ai), | ||
2763 | 148 | ccsIntegrationUnref)); | ||
2764 | 149 | |||
2765 | 150 | CCSContextGMock &gmockContext = *(reinterpret_cast <CCSContextGMock *> (ccsObjectGetPrivate (context.get ()))); | ||
2766 | 151 | CCSBackendGMock &gmockBackend = *(reinterpret_cast <CCSBackendGMock *> (ccsObjectGetPrivate (backend.get ()))); | ||
2767 | 152 | CCSIntegratedSettingsStorageGMock &gmockStorage = *(reinterpret_cast <CCSIntegratedSettingsStorageGMock *> (ccsObjectGetPrivate (storage.get ()))); | ||
2768 | 153 | CCSIntegratedSettingFactoryGMock &gmockFactory = *(reinterpret_cast <CCSIntegratedSettingFactoryGMock *> (ccsObjectGetPrivate (factory.get ()))); | ||
2769 | 154 | |||
2770 | 155 | return CCSGNOMEIntegrationWithMocks (gmockContext, | ||
2771 | 156 | gmockBackend, | ||
2772 | 157 | gmockStorage, | ||
2773 | 158 | gmockFactory, | ||
2774 | 159 | context, | ||
2775 | 160 | backend, | ||
2776 | 161 | storage, | ||
2777 | 162 | factory, | ||
2778 | 163 | integration); | ||
2779 | 164 | } | ||
2780 | 165 | |||
2781 | 166 | CCSIntegration * | ||
2782 | 167 | Real (CCSGNOMEIntegrationWithMocks &integrationWithMocks) | ||
2783 | 168 | { | ||
2784 | 169 | return std::tr1::get <8> (integrationWithMocks).get (); | ||
2785 | 170 | } | ||
2786 | 171 | |||
2787 | 172 | CCSContextGMock & | ||
2788 | 173 | MockContext (CCSGNOMEIntegrationWithMocks &integrationWithMocks) | ||
2789 | 174 | { | ||
2790 | 175 | return std::tr1::get <0> (integrationWithMocks); | ||
2791 | 176 | } | ||
2792 | 177 | |||
2793 | 178 | CCSBackendGMock & | ||
2794 | 179 | MockBackend (CCSGNOMEIntegrationWithMocks &integrationWithMocks) | ||
2795 | 180 | { | ||
2796 | 181 | return std::tr1::get <1> (integrationWithMocks); | ||
2797 | 182 | } | ||
2798 | 183 | |||
2799 | 184 | CCSIntegratedSettingsStorageGMock & | ||
2800 | 185 | MockStorage (CCSGNOMEIntegrationWithMocks &integrationWithMocks) | ||
2801 | 186 | { | ||
2802 | 187 | return std::tr1::get <2> (integrationWithMocks); | ||
2803 | 188 | } | ||
2804 | 189 | |||
2805 | 190 | CCSIntegratedSettingFactoryGMock & | ||
2806 | 191 | MockFactory (CCSGNOMEIntegrationWithMocks &integrationWithMocks) | ||
2807 | 192 | { | ||
2808 | 193 | return std::tr1::get <3> (integrationWithMocks); | ||
2809 | 194 | } | ||
2810 | 195 | |||
2811 | 196 | void | ||
2812 | 197 | IgnoreRegistration (CCSIntegratedSettingsStorageGMock &storage) | ||
2813 | 198 | { | ||
2814 | 199 | EXPECT_CALL (storage, empty ()).WillOnce (Return (FALSE)); | ||
2815 | 200 | } | ||
2816 | 201 | |||
2817 | 202 | void | ||
2818 | 203 | AllowReadability (CCSSettingGMock &setting) | ||
2819 | 204 | { | ||
2820 | 205 | EXPECT_CALL (setting, isReadableByBackend ()).WillOnce (Return (TRUE)); | ||
2821 | 206 | } | ||
2822 | 207 | |||
2823 | 208 | void | ||
2824 | 209 | ExpectWriteSettings (CCSContextGMock &context) | ||
2825 | 210 | { | ||
2826 | 211 | EXPECT_CALL (context, writeChangedSettings ()); | ||
2827 | 212 | } | ||
2828 | 213 | |||
2829 | 214 | void | ||
2830 | 215 | SetNames (CCSSettingGMock &setting, | ||
2831 | 216 | CCSPluginGMock &plugin, | ||
2832 | 217 | const std::string &settingName, | ||
2833 | 218 | const std::string &pluginName) | ||
2834 | 219 | { | ||
2835 | 220 | EXPECT_CALL (setting, getName ()).WillOnce (Return (settingName.c_str ())); | ||
2836 | 221 | EXPECT_CALL (setting, getParent ()); | ||
2837 | 222 | EXPECT_CALL (plugin, getName ()).WillOnce (Return (pluginName.c_str ())); | ||
2838 | 223 | } | ||
2839 | 224 | |||
2840 | 225 | CCSSettingValue * | ||
2841 | 226 | MakeSettingValue () | ||
2842 | 227 | { | ||
2843 | 228 | CCSSettingValue *v = new CCSSettingValue; | ||
2844 | 229 | v->parent = NULL; | ||
2845 | 230 | v->isListChild = FALSE; | ||
2846 | 231 | v->refCount = 1; | ||
2847 | 232 | |||
2848 | 233 | return v; | ||
2849 | 234 | } | ||
2850 | 235 | |||
2851 | 236 | boost::shared_ptr <CCSSettingValue> | ||
2852 | 237 | MakeAutoDestroySettingValue (CCSSettingType type) | ||
2853 | 238 | { | ||
2854 | 239 | CCSSettingValue *v = new CCSSettingValue; | ||
2855 | 240 | v->parent = NULL; | ||
2856 | 241 | v->isListChild = FALSE; | ||
2857 | 242 | v->refCount = 1; | ||
2858 | 243 | |||
2859 | 244 | return boost::shared_ptr <CCSSettingValue> (v, | ||
2860 | 245 | boost::bind (ccsFreeSettingValueWithType, _1, type)); | ||
2861 | 246 | } | ||
2862 | 247 | |||
2863 | 248 | const std::string MOCK_PLUGIN ("mock"); | ||
2864 | 249 | const std::string MOCK_SETTING ("mock"); | ||
2865 | 250 | const std::string MOCK_GNOME_NAME ("mock"); | ||
2866 | 251 | const CCSSettingType MOCK_SETTING_TYPE = TypeInt; | ||
2867 | 252 | const SpecialOptionType MOCK_GNOME_SETTING_TYPE = OptionInt; | ||
2868 | 253 | } | ||
2869 | 254 | |||
2870 | 255 | TEST (CCSGNOMEIntegrationTest, TestConstructComposition) | ||
2871 | 256 | { | ||
2872 | 257 | IntegratedSettingWithMockPtr settingWithMock ( | ||
2873 | 258 | createIntegratedSettingCompositionFromMock (MOCK_PLUGIN, | ||
2874 | 259 | MOCK_SETTING, | ||
2875 | 260 | MOCK_SETTING_TYPE, | ||
2876 | 261 | MOCK_GNOME_SETTING_TYPE, | ||
2877 | 262 | MOCK_GNOME_NAME, | ||
2878 | 263 | &ccsDefaultObjectAllocator)); | ||
2879 | 264 | } | ||
2880 | 265 | |||
2881 | 266 | class CCSGNOMEIntegrationTestWithMocks : | ||
2882 | 267 | public ::testing::Test | ||
2883 | 268 | { | ||
2884 | 269 | public: | ||
2885 | 270 | |||
2886 | 271 | CCSGNOMEIntegrationTestWithMocks () : | ||
2887 | 272 | mIntegration (createIntegrationWithMocks (&ccsDefaultObjectAllocator)), | ||
2888 | 273 | mSetting (AutoDestroy (ccsMockSettingNew (), | ||
2889 | 274 | ccsSettingUnref)), | ||
2890 | 275 | mSettingMock ((*(reinterpret_cast <CCSSettingGMock *> (ccsObjectGetPrivate (mSetting.get ()))))), | ||
2891 | 276 | mIntegratedSetting (), | ||
2892 | 277 | mPlugin (AutoDestroy (ccsMockPluginNew (), | ||
2893 | 278 | ccsPluginUnref)), | ||
2894 | 279 | mPluginMock ((*(reinterpret_cast <CCSPluginGMock *> (ccsObjectGetPrivate (mPlugin.get ()))))) | ||
2895 | 280 | { | ||
2896 | 281 | ON_CALL (mSettingMock, getParent ()).WillByDefault (Return (mPlugin.get ())); | ||
2897 | 282 | } | ||
2898 | 283 | |||
2899 | 284 | protected: | ||
2900 | 285 | |||
2901 | 286 | CCSGNOMEIntegrationWithMocks mIntegration; | ||
2902 | 287 | boost::shared_ptr <CCSSetting> mSetting; | ||
2903 | 288 | CCSSettingGMock &mSettingMock; | ||
2904 | 289 | IntegratedSettingWithMockPtr mIntegratedSetting; | ||
2905 | 290 | boost::shared_ptr <CCSPlugin> mPlugin; | ||
2906 | 291 | CCSPluginGMock &mPluginMock; | ||
2907 | 292 | }; | ||
2908 | 293 | |||
2909 | 294 | class CCSGNOMEIntegrationTestReadIntegrated : | ||
2910 | 295 | public CCSGNOMEIntegrationTestWithMocks | ||
2911 | 296 | { | ||
2912 | 297 | public: | ||
2913 | 298 | |||
2914 | 299 | virtual void SetUp () | ||
2915 | 300 | { | ||
2916 | 301 | IgnoreRegistration (MockStorage (mIntegration)); | ||
2917 | 302 | AllowReadability (mSettingMock); | ||
2918 | 303 | } | ||
2919 | 304 | }; | ||
2920 | 305 | |||
2921 | 306 | class CCSGNOMEIntegrationTestWriteIntegrated : | ||
2922 | 307 | public CCSGNOMEIntegrationTestWithMocks | ||
2923 | 308 | { | ||
2924 | 309 | public: | ||
2925 | 310 | |||
2926 | 311 | virtual void SetUp () | ||
2927 | 312 | { | ||
2928 | 313 | IgnoreRegistration (MockStorage (mIntegration)); | ||
2929 | 314 | ExpectWriteSettings (MockContext (mIntegration)); | ||
2930 | 315 | } | ||
2931 | 316 | }; | ||
2932 | 317 | |||
2933 | 318 | TEST_F (CCSGNOMEIntegrationTestWithMocks, TestConstructGNOMEIntegration) | ||
2934 | 319 | { | ||
2935 | 320 | } | ||
2936 | 321 | |||
2937 | 322 | TEST_F (CCSGNOMEIntegrationTestReadIntegrated, TestReadInSpecialOptionCurrentViewport) | ||
2938 | 323 | { | ||
2939 | 324 | const std::string settingName ("current_viewport"); | ||
2940 | 325 | CCSSettingValue *v = MakeSettingValue (); | ||
2941 | 326 | v->value.asBool = FALSE; | ||
2942 | 327 | |||
2943 | 328 | mIntegratedSetting = createIntegratedSettingCompositionFromMock (MOCK_PLUGIN, | ||
2944 | 329 | settingName, | ||
2945 | 330 | TypeBool, | ||
2946 | 331 | OptionSpecial, | ||
2947 | 332 | MOCK_GNOME_NAME, | ||
2948 | 333 | &ccsDefaultObjectAllocator); | ||
2949 | 334 | SetNames (mSettingMock, mPluginMock, settingName, MOCK_PLUGIN); | ||
2950 | 335 | EXPECT_CALL (Mock (*mIntegratedSetting), readValue (TypeBool)).WillOnce (Return (v)); | ||
2951 | 336 | EXPECT_CALL (mSettingMock, setBool (IsTrue (), IsTrue ())); | ||
2952 | 337 | |||
2953 | 338 | EXPECT_THAT (ccsIntegrationReadOptionIntoSetting (Real (mIntegration), | ||
2954 | 339 | NULL, | ||
2955 | 340 | mSetting.get (), | ||
2956 | 341 | Real (*mIntegratedSetting)), IsTrue ()); | ||
2957 | 342 | } | ||
2958 | 343 | |||
2959 | 344 | TEST_F (CCSGNOMEIntegrationTestReadIntegrated, TestReadInSpecialOptionFullscreenVisualBell) | ||
2960 | 345 | { | ||
2961 | 346 | const std::string settingName ("fullscreen_visual_bell"); | ||
2962 | 347 | CCSSettingValue *v = MakeSettingValue (); | ||
2963 | 348 | v->value.asString = strdup ("fullscreen"); | ||
2964 | 349 | |||
2965 | 350 | mIntegratedSetting = createIntegratedSettingCompositionFromMock (MOCK_PLUGIN, | ||
2966 | 351 | settingName, | ||
2967 | 352 | TypeString, | ||
2968 | 353 | OptionSpecial, | ||
2969 | 354 | MOCK_GNOME_NAME, | ||
2970 | 355 | &ccsDefaultObjectAllocator); | ||
2971 | 356 | SetNames (mSettingMock, mPluginMock, settingName, MOCK_PLUGIN); | ||
2972 | 357 | EXPECT_CALL (Mock (*mIntegratedSetting), readValue (TypeString)).WillOnce (Return (v)); | ||
2973 | 358 | EXPECT_CALL (mSettingMock, setBool (IsTrue (), IsTrue ())); | ||
2974 | 359 | |||
2975 | 360 | EXPECT_THAT (ccsIntegrationReadOptionIntoSetting (Real (mIntegration), | ||
2976 | 361 | NULL, | ||
2977 | 362 | mSetting.get (), | ||
2978 | 363 | Real (*mIntegratedSetting)), IsTrue ()); | ||
2979 | 364 | } | ||
2980 | 365 | |||
2981 | 366 | TEST_F (CCSGNOMEIntegrationTestReadIntegrated, TestReadInSpecialOptionClickToFocus) | ||
2982 | 367 | { | ||
2983 | 368 | const std::string settingName ("click_to_focus"); | ||
2984 | 369 | CCSSettingValue *v = MakeSettingValue (); | ||
2985 | 370 | v->value.asString = strdup ("click"); | ||
2986 | 371 | |||
2987 | 372 | mIntegratedSetting = createIntegratedSettingCompositionFromMock (MOCK_PLUGIN, | ||
2988 | 373 | settingName, | ||
2989 | 374 | TypeString, | ||
2990 | 375 | OptionSpecial, | ||
2991 | 376 | MOCK_GNOME_NAME, | ||
2992 | 377 | &ccsDefaultObjectAllocator); | ||
2993 | 378 | SetNames (mSettingMock, mPluginMock, settingName, MOCK_PLUGIN); | ||
2994 | 379 | EXPECT_CALL (Mock (*mIntegratedSetting), readValue (TypeString)).WillOnce (Return (v)); | ||
2995 | 380 | EXPECT_CALL (mSettingMock, setBool (IsTrue (), IsTrue ())); | ||
2996 | 381 | |||
2997 | 382 | EXPECT_THAT (ccsIntegrationReadOptionIntoSetting (Real (mIntegration), | ||
2998 | 383 | NULL, | ||
2999 | 384 | mSetting.get (), | ||
3000 | 385 | Real (*mIntegratedSetting)), IsTrue ()); | ||
3001 | 386 | } | ||
3002 | 387 | |||
3003 | 388 | namespace | ||
3004 | 389 | { | ||
3005 | 390 | const std::string DEFAULT_MOUSE_BUTTON_MODIFIERS_STRING ("<Alt>"); | ||
3006 | 391 | const std::string GNOME_MOUSE_BUTTON_MODIFIERS_STRING ("<Super>"); | ||
3007 | 392 | const unsigned int DEFAULT_MOUSE_BUTTON_MODIFIERS = | ||
3008 | 393 | ccsStringToModifiers (DEFAULT_MOUSE_BUTTON_MODIFIERS_STRING.c_str ()); | ||
3009 | 394 | const unsigned int GNOME_MOUSE_BUTTON_MODIFIERS = | ||
3010 | 395 | ccsStringToModifiers (GNOME_MOUSE_BUTTON_MODIFIERS_STRING.c_str ()); | ||
3011 | 396 | |||
3012 | 397 | const unsigned int LEFT_BUTTON = 1; | ||
3013 | 398 | const unsigned int MIDDLE_BUTTON = 2; | ||
3014 | 399 | const unsigned int RIGHT_BUTTON = 3; | ||
3015 | 400 | |||
3016 | 401 | typedef cci::ListWrapper <CCSIntegratedSettingList, CCSIntegratedSetting *> CCSIntegratedSettingListWrapper; | ||
3017 | 402 | typedef boost::shared_ptr <CCSIntegratedSettingListWrapper> CCSIntegratedSettingListWrapperPtr; | ||
3018 | 403 | |||
3019 | 404 | CCSIntegratedSettingListWrapperPtr | ||
3020 | 405 | constructCCSIntegratedSettingListWrapper (CCSIntegratedSetting *setting) | ||
3021 | 406 | { | ||
3022 | 407 | return boost::make_shared <CCSIntegratedSettingListWrapper> (ccsIntegratedSettingListAppend (NULL, setting), | ||
3023 | 408 | ccsIntegratedSettingListFree, | ||
3024 | 409 | ccsIntegratedSettingListAppend, | ||
3025 | 410 | ccsIntegratedSettingListRemove, | ||
3026 | 411 | cci::Shallow); | ||
3027 | 412 | } | ||
3028 | 413 | } | ||
3029 | 414 | |||
3030 | 415 | class CCSGNOMEIntegrationTestWithMocksIntegratedMouseButtonModifiers | ||
3031 | 416 | { | ||
3032 | 417 | public: | ||
3033 | 418 | |||
3034 | 419 | CCSGNOMEIntegrationTestWithMocksIntegratedMouseButtonModifiers () : | ||
3035 | 420 | mIntegratedSettingMBM (AutoDestroy (ccsMockIntegratedSettingNew (&ccsDefaultObjectAllocator), | ||
3036 | 421 | ccsIntegratedSettingUnref)), | ||
3037 | 422 | mIntegratedSettingMBMMock (*(reinterpret_cast <CCSIntegratedSettingGMock *> (ccsObjectGetPrivate (mIntegratedSettingMBM.get ())))), | ||
3038 | 423 | mIntegratedSettingsMBM (constructCCSIntegratedSettingListWrapper (mIntegratedSettingMBM.get ())), | ||
3039 | 424 | mIntegratedSettingResizeWithRB (AutoDestroy (ccsMockIntegratedSettingNew (&ccsDefaultObjectAllocator), | ||
3040 | 425 | ccsIntegratedSettingUnref)), | ||
3041 | 426 | mIntegratedSettingResizeWithRBMock (*(reinterpret_cast <CCSIntegratedSettingGMock *> (ccsObjectGetPrivate (mIntegratedSettingResizeWithRB.get ())))), | ||
3042 | 427 | mIntegratedSettingsResizeWithRB (constructCCSIntegratedSettingListWrapper (mIntegratedSettingResizeWithRB.get ())) | ||
3043 | 428 | { | ||
3044 | 429 | memset (&mButtonValue, 0, sizeof (CCSSettingButtonValue)); | ||
3045 | 430 | |||
3046 | 431 | mButtonValue.button = MIDDLE_BUTTON; | ||
3047 | 432 | mButtonValue.buttonModMask = DEFAULT_MOUSE_BUTTON_MODIFIERS; | ||
3048 | 433 | mButtonValue.edgeMask = 0; | ||
3049 | 434 | } | ||
3050 | 435 | |||
3051 | 436 | virtual void SetUp (CCSGNOMEIntegrationWithMocks &integration) | ||
3052 | 437 | { | ||
3053 | 438 | CCSIntegratedSettingList integratedSettingsMBM = | ||
3054 | 439 | *mIntegratedSettingsMBM; | ||
3055 | 440 | CCSIntegratedSettingList integratedSettingsResizeWithRB = | ||
3056 | 441 | *mIntegratedSettingsResizeWithRB; | ||
3057 | 442 | |||
3058 | 443 | EXPECT_CALL (MockStorage (integration), | ||
3059 | 444 | findMatchingSettingsByPluginAndSettingName (Eq (std::string (ccsGNOMEIntegratedPluginNames.SPECIAL)), | ||
3060 | 445 | Eq (std::string (ccsGNOMEIntegratedSettingNames.NULL_MOUSE_BUTTON_MODIFIER.compizName)))) | ||
3061 | 446 | .WillOnce (Return (integratedSettingsMBM)); | ||
3062 | 447 | EXPECT_CALL (MockStorage (integration), | ||
3063 | 448 | findMatchingSettingsByPluginAndSettingName (Eq (std::string (ccsGNOMEIntegratedPluginNames.SPECIAL)), | ||
3064 | 449 | Eq (std::string (ccsGNOMEIntegratedSettingNames.NULL_RESIZE_WITH_RIGHT_BUTTON.compizName)))) | ||
3065 | 450 | .WillOnce (Return (integratedSettingsResizeWithRB)); | ||
3066 | 451 | } | ||
3067 | 452 | |||
3068 | 453 | |||
3069 | 454 | protected: | ||
3070 | 455 | |||
3071 | 456 | boost::shared_ptr <CCSIntegratedSetting> mIntegratedSettingMBM; | ||
3072 | 457 | CCSIntegratedSettingGMock &mIntegratedSettingMBMMock; | ||
3073 | 458 | CCSIntegratedSettingListWrapperPtr mIntegratedSettingsMBM; | ||
3074 | 459 | boost::shared_ptr <CCSIntegratedSetting> mIntegratedSettingResizeWithRB; | ||
3075 | 460 | CCSIntegratedSettingGMock &mIntegratedSettingResizeWithRBMock; | ||
3076 | 461 | CCSIntegratedSettingListWrapperPtr mIntegratedSettingsResizeWithRB; | ||
3077 | 462 | CCSSettingButtonValue mButtonValue; | ||
3078 | 463 | }; | ||
3079 | 464 | |||
3080 | 465 | class CCSGNOMEIntegrationTestWithMocksReadIntegratedMouseButtonModifiers : | ||
3081 | 466 | public CCSGNOMEIntegrationTestReadIntegrated, | ||
3082 | 467 | public CCSGNOMEIntegrationTestWithMocksIntegratedMouseButtonModifiers | ||
3083 | 468 | { | ||
3084 | 469 | public: | ||
3085 | 470 | |||
3086 | 471 | virtual void SetUp () | ||
3087 | 472 | { | ||
3088 | 473 | CCSSettingValue *vRB = MakeSettingValue (); | ||
3089 | 474 | CCSSettingValue *vMBM = MakeSettingValue (); | ||
3090 | 475 | vRB->value.asBool = TRUE; | ||
3091 | 476 | vMBM->value.asString = strdup (GNOME_MOUSE_BUTTON_MODIFIERS_STRING.c_str ()); | ||
3092 | 477 | |||
3093 | 478 | CCSGNOMEIntegrationTestReadIntegrated::SetUp (); | ||
3094 | 479 | CCSGNOMEIntegrationTestWithMocksIntegratedMouseButtonModifiers::SetUp (mIntegration); | ||
3095 | 480 | |||
3096 | 481 | EXPECT_CALL (mSettingMock, getButton (_)) | ||
3097 | 482 | .WillOnce (DoAll ( | ||
3098 | 483 | SetArgPointee <0> ( | ||
3099 | 484 | mButtonValue), | ||
3100 | 485 | Return (TRUE))); | ||
3101 | 486 | |||
3102 | 487 | /* Get the GNOME Mouse button modifier */ | ||
3103 | 488 | EXPECT_CALL (mIntegratedSettingMBMMock, readValue (TypeString)).WillOnce (Return (vMBM)); | ||
3104 | 489 | EXPECT_CALL (mIntegratedSettingResizeWithRBMock, readValue (TypeBool)).WillOnce (Return (vRB)); | ||
3105 | 490 | } | ||
3106 | 491 | }; | ||
3107 | 492 | |||
3108 | 493 | class CCSGNOMEIntegrationTestWithMocksWriteIntegratedMouseButtonModifiers : | ||
3109 | 494 | public CCSGNOMEIntegrationTestWriteIntegrated, | ||
3110 | 495 | public CCSGNOMEIntegrationTestWithMocksIntegratedMouseButtonModifiers | ||
3111 | 496 | { | ||
3112 | 497 | public: | ||
3113 | 498 | |||
3114 | 499 | CCSGNOMEIntegrationTestWithMocksWriteIntegratedMouseButtonModifiers () : | ||
3115 | 500 | corePlugin (AutoDestroy (ccsMockPluginNew (), | ||
3116 | 501 | ccsPluginUnref)), | ||
3117 | 502 | corePluginMock (*(reinterpret_cast <CCSPluginGMock *> (ccsObjectGetPrivate (corePlugin.get ())))), | ||
3118 | 503 | resizePlugin (AutoDestroy (ccsMockPluginNew (), | ||
3119 | 504 | ccsPluginUnref)), | ||
3120 | 505 | resizePluginMock (*(reinterpret_cast <CCSPluginGMock *> (ccsObjectGetPrivate (resizePlugin.get ())))), | ||
3121 | 506 | movePlugin (AutoDestroy (ccsMockPluginNew (), | ||
3122 | 507 | ccsPluginUnref)), | ||
3123 | 508 | movePluginMock (*(reinterpret_cast <CCSPluginGMock *> (ccsObjectGetPrivate (movePlugin.get ())))), | ||
3124 | 509 | resizeInitiateButtonSetting (AutoDestroy (ccsMockSettingNew (), | ||
3125 | 510 | ccsSettingUnref)), | ||
3126 | 511 | resizeInitiateButtonSettingMock (*(reinterpret_cast <CCSSettingGMock *> (ccsObjectGetPrivate (resizeInitiateButtonSetting.get ())))), | ||
3127 | 512 | moveInitiateButtonSetting (AutoDestroy (ccsMockSettingNew (), | ||
3128 | 513 | ccsSettingUnref)), | ||
3129 | 514 | moveInitiateButtonSettingMock (*(reinterpret_cast <CCSSettingGMock *> (ccsObjectGetPrivate (moveInitiateButtonSetting.get ())))), | ||
3130 | 515 | coreWindowMenuSetting (AutoDestroy (ccsMockSettingNew (), | ||
3131 | 516 | ccsSettingUnref)), | ||
3132 | 517 | coreWindowMenuSettingMock (*(reinterpret_cast <CCSSettingGMock *> (ccsObjectGetPrivate (coreWindowMenuSetting.get ())))), | ||
3133 | 518 | resizeInitiateButton (MakeAutoDestroySettingValue (TypeButton)), | ||
3134 | 519 | moveInitiateButton (MakeAutoDestroySettingValue (TypeButton)), | ||
3135 | 520 | coreWindowMenuButton (MakeAutoDestroySettingValue (TypeButton)) | ||
3136 | 521 | { | ||
3137 | 522 | resizeInitiateButton->value.asButton.button = LEFT_BUTTON; | ||
3138 | 523 | resizeInitiateButton->value.asButton.buttonModMask = 0; | ||
3139 | 524 | resizeInitiateButton->value.asButton.edgeMask = 0; | ||
3140 | 525 | moveInitiateButton->value.asButton.button = LEFT_BUTTON; | ||
3141 | 526 | moveInitiateButton->value.asButton.buttonModMask = DEFAULT_MOUSE_BUTTON_MODIFIERS; | ||
3142 | 527 | moveInitiateButton->value.asButton.edgeMask = 0; | ||
3143 | 528 | coreWindowMenuButton->value.asButton.button = MIDDLE_BUTTON; | ||
3144 | 529 | coreWindowMenuButton->value.asButton.buttonModMask = 0; | ||
3145 | 530 | coreWindowMenuButton->value.asButton.edgeMask = 0; | ||
3146 | 531 | } | ||
3147 | 532 | |||
3148 | 533 | virtual void SetUp () | ||
3149 | 534 | { | ||
3150 | 535 | CCSGNOMEIntegrationTestWriteIntegrated::SetUp (); | ||
3151 | 536 | CCSGNOMEIntegrationTestWithMocksIntegratedMouseButtonModifiers::SetUp (mIntegration); | ||
3152 | 537 | } | ||
3153 | 538 | |||
3154 | 539 | protected: | ||
3155 | 540 | |||
3156 | 541 | boost::shared_ptr <CCSPlugin> corePlugin; | ||
3157 | 542 | CCSPluginGMock &corePluginMock; | ||
3158 | 543 | boost::shared_ptr <CCSPlugin> resizePlugin; | ||
3159 | 544 | CCSPluginGMock &resizePluginMock; | ||
3160 | 545 | boost::shared_ptr <CCSPlugin> movePlugin; | ||
3161 | 546 | CCSPluginGMock &movePluginMock; | ||
3162 | 547 | |||
3163 | 548 | boost::shared_ptr <CCSSetting> resizeInitiateButtonSetting; | ||
3164 | 549 | CCSSettingGMock &resizeInitiateButtonSettingMock; | ||
3165 | 550 | boost::shared_ptr <CCSSetting> moveInitiateButtonSetting; | ||
3166 | 551 | CCSSettingGMock &moveInitiateButtonSettingMock; | ||
3167 | 552 | boost::shared_ptr <CCSSetting> coreWindowMenuSetting; | ||
3168 | 553 | CCSSettingGMock &coreWindowMenuSettingMock; | ||
3169 | 554 | |||
3170 | 555 | boost::shared_ptr <CCSSettingValue> resizeInitiateButton; | ||
3171 | 556 | boost::shared_ptr <CCSSettingValue> moveInitiateButton; | ||
3172 | 557 | boost::shared_ptr <CCSSettingValue> coreWindowMenuButton; | ||
3173 | 558 | }; | ||
3174 | 559 | |||
3175 | 560 | TEST_F (CCSGNOMEIntegrationTestWithMocksReadIntegratedMouseButtonModifiers, TestReadInSpecialOptionMoveInitiateButton) | ||
3176 | 561 | { | ||
3177 | 562 | const std::string settingName ("initiate_button"); | ||
3178 | 563 | const std::string pluginName ("move"); | ||
3179 | 564 | |||
3180 | 565 | CCSSettingButtonValue newButtonValue = mButtonValue; | ||
3181 | 566 | newButtonValue.button = LEFT_BUTTON; | ||
3182 | 567 | newButtonValue.buttonModMask = GNOME_MOUSE_BUTTON_MODIFIERS; | ||
3183 | 568 | |||
3184 | 569 | mIntegratedSetting = createIntegratedSettingCompositionFromMock (pluginName, | ||
3185 | 570 | settingName, | ||
3186 | 571 | TypeBool, | ||
3187 | 572 | OptionSpecial, | ||
3188 | 573 | MOCK_GNOME_NAME, | ||
3189 | 574 | &ccsDefaultObjectAllocator); | ||
3190 | 575 | SetNames (mSettingMock, mPluginMock, settingName, pluginName); | ||
3191 | 576 | |||
3192 | 577 | /* Set the new mouse button modifier */ | ||
3193 | 578 | EXPECT_CALL (mSettingMock, setButton (Eq (newButtonValue), | ||
3194 | 579 | IsTrue ())); | ||
3195 | 580 | |||
3196 | 581 | EXPECT_THAT (ccsIntegrationReadOptionIntoSetting (Real (mIntegration), | ||
3197 | 582 | NULL, | ||
3198 | 583 | mSetting.get (), | ||
3199 | 584 | Real (*mIntegratedSetting)), IsTrue ()); | ||
3200 | 585 | } | ||
3201 | 586 | |||
3202 | 587 | TEST_F (CCSGNOMEIntegrationTestWithMocksReadIntegratedMouseButtonModifiers, TestReadInSpecialOptionResizeInitiateButton) | ||
3203 | 588 | { | ||
3204 | 589 | const std::string settingName ("initiate_button"); | ||
3205 | 590 | const std::string pluginName ("resize"); | ||
3206 | 591 | |||
3207 | 592 | CCSSettingButtonValue newButtonValue = mButtonValue; | ||
3208 | 593 | newButtonValue.button = RIGHT_BUTTON; | ||
3209 | 594 | newButtonValue.buttonModMask = GNOME_MOUSE_BUTTON_MODIFIERS; | ||
3210 | 595 | |||
3211 | 596 | mIntegratedSetting = createIntegratedSettingCompositionFromMock (pluginName, | ||
3212 | 597 | settingName, | ||
3213 | 598 | TypeBool, | ||
3214 | 599 | OptionSpecial, | ||
3215 | 600 | MOCK_GNOME_NAME, | ||
3216 | 601 | &ccsDefaultObjectAllocator); | ||
3217 | 602 | SetNames (mSettingMock, mPluginMock, settingName, pluginName); | ||
3218 | 603 | |||
3219 | 604 | /* Set the new mouse button modifier */ | ||
3220 | 605 | EXPECT_CALL (mSettingMock, setButton (Eq (newButtonValue), | ||
3221 | 606 | IsTrue ())); | ||
3222 | 607 | |||
3223 | 608 | EXPECT_THAT (ccsIntegrationReadOptionIntoSetting (Real (mIntegration), | ||
3224 | 609 | NULL, | ||
3225 | 610 | mSetting.get (), | ||
3226 | 611 | Real (*mIntegratedSetting)), IsTrue ()); | ||
3227 | 612 | } | ||
3228 | 613 | |||
3229 | 614 | TEST_F (CCSGNOMEIntegrationTestWithMocksReadIntegratedMouseButtonModifiers, TestReadInSpecialOptionWhereIntegratedOptionReturnsNull) | ||
3230 | 615 | { | ||
3231 | 616 | const std::string settingName ("initiate_button"); | ||
3232 | 617 | const std::string pluginName ("move"); | ||
3233 | 618 | |||
3234 | 619 | CCSSettingButtonValue newButtonValue = mButtonValue; | ||
3235 | 620 | newButtonValue.button = LEFT_BUTTON; | ||
3236 | 621 | /* Reading the gnome mouse button modifiers failed, so default to zero */ | ||
3237 | 622 | newButtonValue.buttonModMask = 0; | ||
3238 | 623 | |||
3239 | 624 | /* Clear the old expectation */ | ||
3240 | 625 | ccsIntegratedSettingReadValue (mIntegratedSettingMBM.get (), TypeString); | ||
3241 | 626 | /* Now return null */ | ||
3242 | 627 | EXPECT_CALL (mIntegratedSettingMBMMock, readValue (TypeString)).WillOnce (ReturnNull ()); | ||
3243 | 628 | |||
3244 | 629 | mIntegratedSetting = createIntegratedSettingCompositionFromMock (pluginName, | ||
3245 | 630 | settingName, | ||
3246 | 631 | TypeBool, | ||
3247 | 632 | OptionSpecial, | ||
3248 | 633 | MOCK_GNOME_NAME, | ||
3249 | 634 | &ccsDefaultObjectAllocator); | ||
3250 | 635 | SetNames (mSettingMock, mPluginMock, settingName, pluginName); | ||
3251 | 636 | |||
3252 | 637 | /* Set the new mouse button modifier */ | ||
3253 | 638 | EXPECT_CALL (mSettingMock, setButton (Eq (newButtonValue), | ||
3254 | 639 | IsTrue ())); | ||
3255 | 640 | |||
3256 | 641 | EXPECT_THAT (ccsIntegrationReadOptionIntoSetting (Real (mIntegration), | ||
3257 | 642 | NULL, | ||
3258 | 643 | mSetting.get (), | ||
3259 | 644 | Real (*mIntegratedSetting)), IsTrue ()); | ||
3260 | 645 | } | ||
3261 | 646 | |||
3262 | 647 | TEST_F (CCSGNOMEIntegrationTestWriteIntegrated, TestWriteCurrentViewport) | ||
3263 | 648 | { | ||
3264 | 649 | const std::string settingName ("current_viewport"); | ||
3265 | 650 | boost::shared_ptr <CCSSettingValue> compizValue (MakeAutoDestroySettingValue (TypeBool)); | ||
3266 | 651 | boost::shared_ptr <CCSSettingValue> gnomeValue (MakeAutoDestroySettingValue (TypeBool)); | ||
3267 | 652 | CCSSettingInfo info; | ||
3268 | 653 | |||
3269 | 654 | compizValue->value.asBool = TRUE; | ||
3270 | 655 | gnomeValue->value.asBool = FALSE; | ||
3271 | 656 | |||
3272 | 657 | mIntegratedSetting = createIntegratedSettingCompositionFromMock (MOCK_PLUGIN, | ||
3273 | 658 | settingName, | ||
3274 | 659 | TypeBool, | ||
3275 | 660 | OptionSpecial, | ||
3276 | 661 | MOCK_GNOME_NAME, | ||
3277 | 662 | &ccsDefaultObjectAllocator); | ||
3278 | 663 | SetNames (mSettingMock, mPluginMock, settingName, MOCK_PLUGIN); | ||
3279 | 664 | |||
3280 | 665 | EXPECT_CALL (mSettingMock, getValue ()).WillOnce (Return (compizValue.get ())); | ||
3281 | 666 | EXPECT_CALL (Mock (*mIntegratedSetting), writeValue (Pointee (SettingValueMatch (*gnomeValue, | ||
3282 | 667 | TypeBool, | ||
3283 | 668 | &info)), | ||
3284 | 669 | TypeBool)); | ||
3285 | 670 | ccsIntegrationWriteSettingIntoOption (Real (mIntegration), | ||
3286 | 671 | NULL, | ||
3287 | 672 | mSetting.get (), | ||
3288 | 673 | Real (*mIntegratedSetting)); | ||
3289 | 674 | } | ||
3290 | 675 | |||
3291 | 676 | TEST_F (CCSGNOMEIntegrationTestWriteIntegrated, TestWriteFullscreenVisualBell) | ||
3292 | 677 | { | ||
3293 | 678 | const std::string settingName ("fullscreen_visual_bell"); | ||
3294 | 679 | boost::shared_ptr <CCSSettingValue> compizValue (MakeAutoDestroySettingValue (TypeBool)); | ||
3295 | 680 | boost::shared_ptr <CCSSettingValue> gnomeValue (MakeAutoDestroySettingValue (TypeString)); | ||
3296 | 681 | CCSSettingInfo info; | ||
3297 | 682 | |||
3298 | 683 | compizValue->value.asBool = TRUE; | ||
3299 | 684 | gnomeValue->value.asString = strdup ("fullscreen"); | ||
3300 | 685 | |||
3301 | 686 | mIntegratedSetting = createIntegratedSettingCompositionFromMock (MOCK_PLUGIN, | ||
3302 | 687 | settingName, | ||
3303 | 688 | TypeBool, | ||
3304 | 689 | OptionSpecial, | ||
3305 | 690 | MOCK_GNOME_NAME, | ||
3306 | 691 | &ccsDefaultObjectAllocator); | ||
3307 | 692 | SetNames (mSettingMock, mPluginMock, settingName, MOCK_PLUGIN); | ||
3308 | 693 | |||
3309 | 694 | EXPECT_CALL (mSettingMock, getValue ()).WillOnce (Return (compizValue.get ())); | ||
3310 | 695 | EXPECT_CALL (Mock (*mIntegratedSetting), writeValue (Pointee (SettingValueMatch (*gnomeValue, | ||
3311 | 696 | TypeString, | ||
3312 | 697 | &info)), | ||
3313 | 698 | TypeString)); | ||
3314 | 699 | ccsIntegrationWriteSettingIntoOption (Real (mIntegration), | ||
3315 | 700 | NULL, | ||
3316 | 701 | mSetting.get (), | ||
3317 | 702 | Real (*mIntegratedSetting)); | ||
3318 | 703 | } | ||
3319 | 704 | |||
3320 | 705 | TEST_F (CCSGNOMEIntegrationTestWriteIntegrated, TestWriteClickToFocus) | ||
3321 | 706 | { | ||
3322 | 707 | const std::string settingName ("click_to_focus"); | ||
3323 | 708 | boost::shared_ptr <CCSSettingValue> compizValue (MakeAutoDestroySettingValue (TypeBool)); | ||
3324 | 709 | boost::shared_ptr <CCSSettingValue> gnomeValue (MakeAutoDestroySettingValue (TypeString)); | ||
3325 | 710 | CCSSettingInfo info; | ||
3326 | 711 | |||
3327 | 712 | compizValue->value.asBool = TRUE; | ||
3328 | 713 | gnomeValue->value.asString = strdup ("click"); | ||
3329 | 714 | |||
3330 | 715 | mIntegratedSetting = createIntegratedSettingCompositionFromMock (MOCK_PLUGIN, | ||
3331 | 716 | settingName, | ||
3332 | 717 | TypeBool, | ||
3333 | 718 | OptionSpecial, | ||
3334 | 719 | MOCK_GNOME_NAME, | ||
3335 | 720 | &ccsDefaultObjectAllocator); | ||
3336 | 721 | SetNames (mSettingMock, mPluginMock, settingName, MOCK_PLUGIN); | ||
3337 | 722 | |||
3338 | 723 | EXPECT_CALL (mSettingMock, getValue ()).WillOnce (Return (compizValue.get ())); | ||
3339 | 724 | EXPECT_CALL (Mock (*mIntegratedSetting), writeValue (Pointee (SettingValueMatch (*gnomeValue, | ||
3340 | 725 | TypeString, | ||
3341 | 726 | &info)), | ||
3342 | 727 | TypeString)); | ||
3343 | 728 | ccsIntegrationWriteSettingIntoOption (Real (mIntegration), | ||
3344 | 729 | NULL, | ||
3345 | 730 | mSetting.get (), | ||
3346 | 731 | Real (*mIntegratedSetting)); | ||
3347 | 732 | } | ||
3348 | 733 | |||
3349 | 734 | /* | ||
3350 | 735 | * TODO: Break up the function that this test covers. Its way too complicated | ||
3351 | 736 | */ | ||
3352 | 737 | TEST_F (CCSGNOMEIntegrationTestWithMocksWriteIntegratedMouseButtonModifiers, TestWriteMouseButtonModifier) | ||
3353 | 738 | { | ||
3354 | 739 | const std::string settingName ("initiate_button"); | ||
3355 | 740 | const std::string pluginName ("move"); | ||
3356 | 741 | CCSSettingInfo info; | ||
3357 | 742 | |||
3358 | 743 | mIntegratedSetting = createIntegratedSettingCompositionFromMock (pluginName, | ||
3359 | 744 | settingName, | ||
3360 | 745 | TypeBool, | ||
3361 | 746 | OptionSpecial, | ||
3362 | 747 | MOCK_GNOME_NAME, | ||
3363 | 748 | &ccsDefaultObjectAllocator); | ||
3364 | 749 | SetNames (mSettingMock, mPluginMock, settingName, pluginName); | ||
3365 | 750 | |||
3366 | 751 | EXPECT_CALL (MockContext (mIntegration), findPlugin (Eq ("move"))).WillRepeatedly (Return (movePlugin.get ())); | ||
3367 | 752 | EXPECT_CALL (movePluginMock, findSetting (Eq ("initiate_button"))).WillRepeatedly (Return (moveInitiateButtonSetting.get ())); | ||
3368 | 753 | EXPECT_CALL (moveInitiateButtonSettingMock, getType ()).WillRepeatedly (Return (TypeButton)); | ||
3369 | 754 | EXPECT_CALL (moveInitiateButtonSettingMock, getValue ()).WillRepeatedly (Return (moveInitiateButton.get ())); | ||
3370 | 755 | |||
3371 | 756 | EXPECT_CALL (MockContext (mIntegration), findPlugin (Eq ("resize"))).WillRepeatedly (Return (resizePlugin.get ())); | ||
3372 | 757 | EXPECT_CALL (resizePluginMock, findSetting (Eq ("initiate_button"))).WillRepeatedly (Return (resizeInitiateButtonSetting.get ())); | ||
3373 | 758 | EXPECT_CALL (resizeInitiateButtonSettingMock, getType ()).WillRepeatedly (Return (TypeButton)); | ||
3374 | 759 | EXPECT_CALL (resizeInitiateButtonSettingMock, getValue ()).WillRepeatedly (Return (resizeInitiateButton.get ())); | ||
3375 | 760 | |||
3376 | 761 | EXPECT_CALL (MockContext (mIntegration), findPlugin (Eq ("core"))).WillRepeatedly (Return (corePlugin.get ())); | ||
3377 | 762 | EXPECT_CALL (corePluginMock, findSetting (Eq ("window_menu_button"))).WillRepeatedly (Return (coreWindowMenuSetting.get ())); | ||
3378 | 763 | EXPECT_CALL (coreWindowMenuSettingMock, getType ()).WillRepeatedly (Return (TypeButton)); | ||
3379 | 764 | EXPECT_CALL (coreWindowMenuSettingMock, getValue ()).WillRepeatedly (Return (coreWindowMenuButton.get ())); | ||
3380 | 765 | |||
3381 | 766 | boost::shared_ptr <CCSSettingValue> newResizeWithRBValue (MakeAutoDestroySettingValue (TypeBool)); | ||
3382 | 767 | newResizeWithRBValue->value.asBool = TRUE; | ||
3383 | 768 | |||
3384 | 769 | EXPECT_CALL (mIntegratedSettingResizeWithRBMock, writeValue (Pointee (SettingValueMatch (*newResizeWithRBValue, | ||
3385 | 770 | TypeBool, | ||
3386 | 771 | &info)), | ||
3387 | 772 | TypeBool)); | ||
3388 | 773 | |||
3389 | 774 | boost::shared_ptr <CCSSettingValue> newMBMValue (MakeAutoDestroySettingValue (TypeString)); | ||
3390 | 775 | newMBMValue->value.asString = strdup (DEFAULT_MOUSE_BUTTON_MODIFIERS_STRING.c_str ()); | ||
3391 | 776 | |||
3392 | 777 | EXPECT_CALL (mSettingMock, getValue ()).WillOnce (Return (moveInitiateButton.get ())); | ||
3393 | 778 | |||
3394 | 779 | EXPECT_CALL (mIntegratedSettingMBMMock, writeValue (Pointee (SettingValueMatch (*newMBMValue, | ||
3395 | 780 | TypeString, | ||
3396 | 781 | &info)), | ||
3397 | 782 | TypeString)); | ||
3398 | 783 | |||
3399 | 784 | unsigned int modifiers = moveInitiateButton->value.asButton.buttonModMask; | ||
3400 | 785 | |||
3401 | 786 | CCSSettingButtonValue newResizeInitiateButton; | ||
3402 | 787 | CCSSettingButtonValue newMoveInitiateButton; | ||
3403 | 788 | CCSSettingButtonValue newWindowMenuButton; | ||
3404 | 789 | |||
3405 | 790 | memset (&newResizeInitiateButton, 0, sizeof (CCSSettingButtonValue)); | ||
3406 | 791 | memset (&newMoveInitiateButton, 0, sizeof (CCSSettingButtonValue)); | ||
3407 | 792 | memset (&newWindowMenuButton, 0, sizeof (CCSSettingButtonValue)); | ||
3408 | 793 | |||
3409 | 794 | newResizeInitiateButton.button = RIGHT_BUTTON; | ||
3410 | 795 | newResizeInitiateButton.buttonModMask = modifiers; | ||
3411 | 796 | newMoveInitiateButton.button = LEFT_BUTTON; | ||
3412 | 797 | newMoveInitiateButton.buttonModMask = modifiers; | ||
3413 | 798 | newWindowMenuButton.button = MIDDLE_BUTTON; | ||
3414 | 799 | newWindowMenuButton.buttonModMask = modifiers; | ||
3415 | 800 | |||
3416 | 801 | EXPECT_CALL (resizeInitiateButtonSettingMock, setButton (Eq (newResizeInitiateButton), | ||
3417 | 802 | IsTrue ())); | ||
3418 | 803 | /* The move button is exactly the same, so it is not updated */ | ||
3419 | 804 | EXPECT_CALL (moveInitiateButtonSettingMock, setButton (Eq (newMoveInitiateButton), | ||
3420 | 805 | IsTrue ())).Times (0); | ||
3421 | 806 | EXPECT_CALL (coreWindowMenuSettingMock, setButton (Eq (newWindowMenuButton), | ||
3422 | 807 | IsTrue ())); | ||
3423 | 808 | |||
3424 | 809 | ccsIntegrationWriteSettingIntoOption (Real (mIntegration), | ||
3425 | 810 | NULL, | ||
3426 | 811 | mSetting.get (), | ||
3427 | 812 | Real (*mIntegratedSetting)); | ||
3428 | 813 | } | ||
3429 | 0 | 814 | ||
3430 | === modified file 'compizconfig/libcompizconfig/src/main.c' | |||
3431 | --- compizconfig/libcompizconfig/src/main.c 2012-09-24 03:58:20 +0000 | |||
3432 | +++ compizconfig/libcompizconfig/src/main.c 2012-09-24 03:58:20 +0000 | |||
3433 | @@ -1109,7 +1109,6 @@ | |||
3434 | 1109 | void | 1109 | void |
3435 | 1110 | ccsFreeBackend (CCSBackend *backend) | 1110 | ccsFreeBackend (CCSBackend *backend) |
3436 | 1111 | { | 1111 | { |
3437 | 1112 | ccsBackendFini (backend); | ||
3438 | 1113 | ccsObjectFinalize (backend); | 1112 | ccsObjectFinalize (backend); |
3439 | 1114 | free (backend); | 1113 | free (backend); |
3440 | 1115 | } | 1114 | } |
3441 | @@ -1119,6 +1118,7 @@ | |||
3442 | 1119 | { | 1118 | { |
3443 | 1120 | CCSDynamicBackendPrivate *dbPrivate = GET_PRIVATE (CCSDynamicBackendPrivate, backend); | 1119 | CCSDynamicBackendPrivate *dbPrivate = GET_PRIVATE (CCSDynamicBackendPrivate, backend); |
3444 | 1121 | 1120 | ||
3445 | 1121 | ccsBackendFini (dbPrivate->backend); | ||
3446 | 1122 | ccsBackendUnref (dbPrivate->backend); | 1122 | ccsBackendUnref (dbPrivate->backend); |
3447 | 1123 | 1123 | ||
3448 | 1124 | if (dbPrivate->dlhand) | 1124 | if (dbPrivate->dlhand) |
3449 | @@ -5655,7 +5655,7 @@ | |||
3450 | 5655 | void | 5655 | void |
3451 | 5656 | ccsFreeIntegratedSettingsStorage (CCSIntegratedSettingsStorage *storage) | 5656 | ccsFreeIntegratedSettingsStorage (CCSIntegratedSettingsStorage *storage) |
3452 | 5657 | { | 5657 | { |
3454 | 5658 | (*(GET_INTERFACE (CCSIntegratedSettingsStorageInterface, storage))->empty) (storage); | 5658 | (*(GET_INTERFACE (CCSIntegratedSettingsStorageInterface, storage))->free) (storage); |
3455 | 5659 | } | 5659 | } |
3456 | 5660 | 5660 | ||
3457 | 5661 | /* CCSIntegratedSettingsStorageDefault implementation */ | 5661 | /* CCSIntegratedSettingsStorageDefault implementation */ |
3458 | 5662 | 5662 | ||
3459 | === modified file 'compizconfig/libcompizconfig/tests/CMakeLists.txt' | |||
3460 | --- compizconfig/libcompizconfig/tests/CMakeLists.txt 2012-09-24 03:58:20 +0000 | |||
3461 | +++ compizconfig/libcompizconfig/tests/CMakeLists.txt 2012-09-24 03:58:20 +0000 | |||
3462 | @@ -93,7 +93,13 @@ | |||
3463 | 93 | compizconfig_ccs_context_mock | 93 | compizconfig_ccs_context_mock |
3464 | 94 | compizconfig_ccs_plugin_mock | 94 | compizconfig_ccs_plugin_mock |
3465 | 95 | compizconfig_ccs_setting_mock | 95 | compizconfig_ccs_setting_mock |
3467 | 96 | compizconfig_ccs_backend_mock) | 96 | compizconfig_ccs_backend_mock |
3468 | 97 | compizconfig_ccs_backend_conformance_test | ||
3469 | 98 | compizconfig_ccs_item_in_list_matcher | ||
3470 | 99 | compizconfig_ccs_list_equality | ||
3471 | 100 | compizconfig_ccs_list_wrapper | ||
3472 | 101 | compizconfig_ccs_setting_value_operators | ||
3473 | 102 | compizconfig_ccs_test_value_combinations) | ||
3474 | 97 | 103 | ||
3475 | 98 | target_link_libraries (compizconfig_test_ccs_setting | 104 | target_link_libraries (compizconfig_test_ccs_setting |
3476 | 99 | ${GTEST_BOTH_LIBRARIES} | 105 | ${GTEST_BOTH_LIBRARIES} |
3477 | @@ -126,6 +132,8 @@ | |||
3478 | 126 | compizconfig_ccs_context_mock | 132 | compizconfig_ccs_context_mock |
3479 | 127 | compizconfig_ccs_plugin_mock | 133 | compizconfig_ccs_plugin_mock |
3480 | 128 | compizconfig_ccs_setting_mock | 134 | compizconfig_ccs_setting_mock |
3481 | 135 | compizconfig_ccs_item_in_list_matcher | ||
3482 | 136 | compizconfig_ccs_setting_value_matcher | ||
3483 | 129 | ) | 137 | ) |
3484 | 130 | 138 | ||
3485 | 131 | compiz_discover_tests (compizconfig_test_ccs_object COVERAGE compizconfig) | 139 | compiz_discover_tests (compizconfig_test_ccs_object COVERAGE compizconfig) |
3486 | 132 | 140 | ||
3487 | === modified file 'compizconfig/libcompizconfig/tests/compizconfig_test_ccs_mock_backend_conformance.cpp' | |||
3488 | --- compizconfig/libcompizconfig/tests/compizconfig_test_ccs_mock_backend_conformance.cpp 2012-09-24 03:58:20 +0000 | |||
3489 | +++ compizconfig/libcompizconfig/tests/compizconfig_test_ccs_mock_backend_conformance.cpp 2012-09-24 03:58:20 +0000 | |||
3490 | @@ -151,61 +151,73 @@ | |||
3491 | 151 | virtual Bool ReadBoolAtKey (const std::string &plugin, | 151 | virtual Bool ReadBoolAtKey (const std::string &plugin, |
3492 | 152 | const std::string &key) | 152 | const std::string &key) |
3493 | 153 | { | 153 | { |
3495 | 154 | return boolToBool (ValueForKeyRetreival <bool> ().GetValueForKey (keynameFromPluginKey (plugin, key), mValues)); | 154 | return compizconfig::test::boolToBool ( |
3496 | 155 | ValueForKeyRetreival <bool> ().GetValueForKey ( | ||
3497 | 156 | keynameFromPluginKey (plugin, key), mValues)); | ||
3498 | 155 | } | 157 | } |
3499 | 156 | 158 | ||
3500 | 157 | virtual int ReadIntegerAtKey (const std::string &plugin, | 159 | virtual int ReadIntegerAtKey (const std::string &plugin, |
3501 | 158 | const std::string &key) | 160 | const std::string &key) |
3502 | 159 | { | 161 | { |
3504 | 160 | return ValueForKeyRetreival <int> ().GetValueForKey (keynameFromPluginKey (plugin, key), mValues); | 162 | return ValueForKeyRetreival <int> ().GetValueForKey ( |
3505 | 163 | keynameFromPluginKey (plugin, key), mValues); | ||
3506 | 161 | } | 164 | } |
3507 | 162 | 165 | ||
3508 | 163 | virtual float ReadFloatAtKey (const std::string &plugin, | 166 | virtual float ReadFloatAtKey (const std::string &plugin, |
3509 | 164 | const std::string &key) | 167 | const std::string &key) |
3510 | 165 | { | 168 | { |
3512 | 166 | return ValueForKeyRetreival <float> ().GetValueForKey (keynameFromPluginKey (plugin, key), mValues); | 169 | return ValueForKeyRetreival <float> ().GetValueForKey ( |
3513 | 170 | keynameFromPluginKey (plugin, key), mValues); | ||
3514 | 167 | } | 171 | } |
3515 | 168 | 172 | ||
3516 | 169 | virtual const char * ReadStringAtKey (const std::string &plugin, | 173 | virtual const char * ReadStringAtKey (const std::string &plugin, |
3517 | 170 | const std::string &key) | 174 | const std::string &key) |
3518 | 171 | { | 175 | { |
3520 | 172 | return ValueForKeyRetreival <const char *> ().GetValueForKey (keynameFromPluginKey (plugin, key), mValues); | 176 | return ValueForKeyRetreival <const char *> ().GetValueForKey ( |
3521 | 177 | keynameFromPluginKey (plugin, key), mValues); | ||
3522 | 173 | } | 178 | } |
3523 | 174 | 179 | ||
3524 | 175 | virtual CCSSettingColorValue ReadColorAtKey (const std::string &plugin, | 180 | virtual CCSSettingColorValue ReadColorAtKey (const std::string &plugin, |
3525 | 176 | const std::string &key) | 181 | const std::string &key) |
3526 | 177 | { | 182 | { |
3528 | 178 | return ValueForKeyRetreival <CCSSettingColorValue> ().GetValueForKey (keynameFromPluginKey (plugin, key), mValues); | 183 | return ValueForKeyRetreival <CCSSettingColorValue> ().GetValueForKey ( |
3529 | 184 | keynameFromPluginKey (plugin, key), mValues); | ||
3530 | 179 | } | 185 | } |
3531 | 180 | 186 | ||
3532 | 181 | virtual CCSSettingKeyValue ReadKeyAtKey (const std::string &plugin, | 187 | virtual CCSSettingKeyValue ReadKeyAtKey (const std::string &plugin, |
3533 | 182 | const std::string &key) | 188 | const std::string &key) |
3534 | 183 | { | 189 | { |
3536 | 184 | return ValueForKeyRetreival <CCSSettingKeyValue> ().GetValueForKey (keynameFromPluginKey (plugin, key), mValues); | 190 | return ValueForKeyRetreival <CCSSettingKeyValue> ().GetValueForKey ( |
3537 | 191 | keynameFromPluginKey (plugin, key), mValues); | ||
3538 | 185 | } | 192 | } |
3539 | 186 | 193 | ||
3540 | 187 | virtual CCSSettingButtonValue ReadButtonAtKey (const std::string &plugin, | 194 | virtual CCSSettingButtonValue ReadButtonAtKey (const std::string &plugin, |
3541 | 188 | const std::string &key) | 195 | const std::string &key) |
3542 | 189 | { | 196 | { |
3544 | 190 | return ValueForKeyRetreival <CCSSettingButtonValue> ().GetValueForKey (keynameFromPluginKey (plugin, key), mValues); | 197 | return ValueForKeyRetreival <CCSSettingButtonValue> ().GetValueForKey ( |
3545 | 198 | keynameFromPluginKey (plugin, key), mValues); | ||
3546 | 191 | } | 199 | } |
3547 | 192 | 200 | ||
3548 | 193 | virtual unsigned int ReadEdgeAtKey (const std::string &plugin, | 201 | virtual unsigned int ReadEdgeAtKey (const std::string &plugin, |
3549 | 194 | const std::string &key) | 202 | const std::string &key) |
3550 | 195 | { | 203 | { |
3552 | 196 | return ValueForKeyRetreival <unsigned int> ().GetValueForKey (keynameFromPluginKey (plugin, key), mValues); | 204 | return ValueForKeyRetreival <unsigned int> ().GetValueForKey ( |
3553 | 205 | keynameFromPluginKey (plugin, key), mValues); | ||
3554 | 197 | } | 206 | } |
3555 | 198 | 207 | ||
3556 | 199 | virtual const char * ReadMatchAtKey (const std::string &plugin, | 208 | virtual const char * ReadMatchAtKey (const std::string &plugin, |
3557 | 200 | const std::string &key) | 209 | const std::string &key) |
3558 | 201 | { | 210 | { |
3560 | 202 | return ValueForKeyRetreival <const char *> ().GetValueForKey (keynameFromPluginKey (plugin, key), mValues); | 211 | return ValueForKeyRetreival <const char *> ().GetValueForKey ( |
3561 | 212 | keynameFromPluginKey (plugin, key), mValues); | ||
3562 | 203 | } | 213 | } |
3563 | 204 | 214 | ||
3564 | 205 | virtual Bool ReadBellAtKey (const std::string &plugin, | 215 | virtual Bool ReadBellAtKey (const std::string &plugin, |
3565 | 206 | const std::string &key) | 216 | const std::string &key) |
3566 | 207 | { | 217 | { |
3568 | 208 | return boolToBool (ValueForKeyRetreival <bool> ().GetValueForKey (keynameFromPluginKey (plugin, key), mValues)); | 218 | return compizconfig::test::boolToBool ( |
3569 | 219 | ValueForKeyRetreival <bool> ().GetValueForKey ( | ||
3570 | 220 | keynameFromPluginKey (plugin, key), mValues)); | ||
3571 | 209 | } | 221 | } |
3572 | 210 | 222 | ||
3573 | 211 | virtual CCSSettingValueList ReadListAtKey (const std::string &plugin, | 223 | virtual CCSSettingValueList ReadListAtKey (const std::string &plugin, |
3574 | 212 | 224 | ||
3575 | === modified file 'compizconfig/libcompizconfig/tests/compizconfig_test_ccs_settings_upgrade_internal.cpp' | |||
3576 | --- compizconfig/libcompizconfig/tests/compizconfig_test_ccs_settings_upgrade_internal.cpp 2012-09-24 03:58:20 +0000 | |||
3577 | +++ compizconfig/libcompizconfig/tests/compizconfig_test_ccs_settings_upgrade_internal.cpp 2012-09-24 03:58:20 +0000 | |||
3578 | @@ -38,10 +38,12 @@ | |||
3579 | 38 | #include "ccs_settings_upgrade_internal.h" | 38 | #include "ccs_settings_upgrade_internal.h" |
3580 | 39 | #include "gtest_shared_characterwrapper.h" | 39 | #include "gtest_shared_characterwrapper.h" |
3581 | 40 | #include "gtest_shared_autodestroy.h" | 40 | #include "gtest_shared_autodestroy.h" |
3582 | 41 | #include "gtest_unspecified_bool_type_matcher.h" | ||
3583 | 41 | #include "compizconfig_ccs_list_equality.h" | 42 | #include "compizconfig_ccs_list_equality.h" |
3584 | 42 | #include "compizconfig_ccs_item_in_list_matcher.h" | 43 | #include "compizconfig_ccs_item_in_list_matcher.h" |
3585 | 43 | #include "compizconfig_ccs_list_wrapper.h" | 44 | #include "compizconfig_ccs_list_wrapper.h" |
3586 | 44 | #include "compizconfig_ccs_setting_value_operators.h" | 45 | #include "compizconfig_ccs_setting_value_operators.h" |
3587 | 46 | #include "compizconfig_ccs_setting_value_matcher.h" | ||
3588 | 45 | 47 | ||
3589 | 46 | using ::testing::IsNull; | 48 | using ::testing::IsNull; |
3590 | 47 | using ::testing::Eq; | 49 | using ::testing::Eq; |
3591 | @@ -73,9 +75,6 @@ | |||
3592 | 73 | static const unsigned int CCS_SETTINGS_UPGRADE_TEST_CORRECT_NUM = 1; | 75 | static const unsigned int CCS_SETTINGS_UPGRADE_TEST_CORRECT_NUM = 1; |
3593 | 74 | } | 76 | } |
3594 | 75 | 77 | ||
3595 | 76 | MATCHER(BoolTrue, "Bool True") { if (arg) return true; else return false; } | ||
3596 | 77 | MATCHER(BoolFalse, "Bool False") { if (!arg) return true; else return false; } | ||
3597 | 78 | |||
3598 | 79 | TEST (CCSSettingsUpgradeInternalTest, TestDetokenizeAndSetValues) | 78 | TEST (CCSSettingsUpgradeInternalTest, TestDetokenizeAndSetValues) |
3599 | 80 | { | 79 | { |
3600 | 81 | char *profileName = NULL; | 80 | char *profileName = NULL; |
3601 | @@ -86,7 +85,7 @@ | |||
3602 | 86 | EXPECT_THAT (ccsUpgradeGetDomainNumAndProfile (CCS_SETTINGS_UPGRADE_TEST_CORRECT_FILENAME.c_str (), | 85 | EXPECT_THAT (ccsUpgradeGetDomainNumAndProfile (CCS_SETTINGS_UPGRADE_TEST_CORRECT_FILENAME.c_str (), |
3603 | 87 | &domainName, | 86 | &domainName, |
3604 | 88 | &num, | 87 | &num, |
3606 | 89 | &profileName), BoolTrue ()); | 88 | &profileName), IsTrue ()); |
3607 | 90 | 89 | ||
3608 | 91 | CharacterWrapper profileNameC (profileName); | 90 | CharacterWrapper profileNameC (profileName); |
3609 | 92 | CharacterWrapper domainNameC (domainName); | 91 | CharacterWrapper domainNameC (domainName); |
3610 | @@ -106,7 +105,7 @@ | |||
3611 | 106 | EXPECT_THAT (ccsUpgradeGetDomainNumAndProfile (CCS_SETTINGS_UPGRADE_TEST_INCORRECT_FILENAME.c_str (), | 105 | EXPECT_THAT (ccsUpgradeGetDomainNumAndProfile (CCS_SETTINGS_UPGRADE_TEST_INCORRECT_FILENAME.c_str (), |
3612 | 107 | &domainName, | 106 | &domainName, |
3613 | 108 | &num, | 107 | &num, |
3615 | 109 | &profileName), BoolFalse ()); | 108 | &profileName), IsFalse ()); |
3616 | 110 | 109 | ||
3617 | 111 | EXPECT_THAT (profileName, IsNull ()); | 110 | EXPECT_THAT (profileName, IsNull ()); |
3618 | 112 | EXPECT_THAT (domainName, IsNull ()); | 111 | EXPECT_THAT (domainName, IsNull ()); |
3619 | @@ -114,7 +113,7 @@ | |||
3620 | 114 | EXPECT_THAT (ccsUpgradeGetDomainNumAndProfile (CCS_SETTINGS_UPGRADE_TEST_VERY_INCORRECT_FILENAME.c_str (), | 113 | EXPECT_THAT (ccsUpgradeGetDomainNumAndProfile (CCS_SETTINGS_UPGRADE_TEST_VERY_INCORRECT_FILENAME.c_str (), |
3621 | 115 | &domainName, | 114 | &domainName, |
3622 | 116 | &num, | 115 | &num, |
3624 | 117 | &profileName), BoolFalse ()); | 116 | &profileName), IsFalse ()); |
3625 | 118 | 117 | ||
3626 | 119 | EXPECT_THAT (profileName, IsNull ()); | 118 | EXPECT_THAT (profileName, IsNull ()); |
3627 | 120 | EXPECT_THAT (domainName, IsNull ()); | 119 | EXPECT_THAT (domainName, IsNull ()); |
3628 | @@ -122,13 +121,13 @@ | |||
3629 | 122 | 121 | ||
3630 | 123 | TEST (CCSSettingsUpgradeInternalTest, TestDetokenizeAndReturnTrueForUpgradeFileName) | 122 | TEST (CCSSettingsUpgradeInternalTest, TestDetokenizeAndReturnTrueForUpgradeFileName) |
3631 | 124 | { | 123 | { |
3633 | 125 | EXPECT_THAT (ccsUpgradeNameFilter (CCS_SETTINGS_UPGRADE_TEST_CORRECT_FILENAME.c_str ()), BoolTrue ()); | 124 | EXPECT_THAT (ccsUpgradeNameFilter (CCS_SETTINGS_UPGRADE_TEST_CORRECT_FILENAME.c_str ()), IsTrue ()); |
3634 | 126 | } | 125 | } |
3635 | 127 | 126 | ||
3636 | 128 | TEST (CCSSettingsUpgradeInternalTest, TestDetokenizeAndReturnFalseForNoUpgradeFileName) | 127 | TEST (CCSSettingsUpgradeInternalTest, TestDetokenizeAndReturnFalseForNoUpgradeFileName) |
3637 | 129 | { | 128 | { |
3640 | 130 | EXPECT_THAT (ccsUpgradeNameFilter (CCS_SETTINGS_UPGRADE_TEST_INCORRECT_FILENAME.c_str ()), BoolFalse ()); | 129 | EXPECT_THAT (ccsUpgradeNameFilter (CCS_SETTINGS_UPGRADE_TEST_INCORRECT_FILENAME.c_str ()), IsFalse ()); |
3641 | 131 | EXPECT_THAT (ccsUpgradeNameFilter (CCS_SETTINGS_UPGRADE_TEST_VERY_INCORRECT_FILENAME.c_str ()), BoolFalse ()); | 130 | EXPECT_THAT (ccsUpgradeNameFilter (CCS_SETTINGS_UPGRADE_TEST_VERY_INCORRECT_FILENAME.c_str ()), IsFalse ()); |
3642 | 132 | } | 131 | } |
3643 | 133 | 132 | ||
3644 | 134 | namespace | 133 | namespace |
3645 | @@ -242,57 +241,6 @@ | |||
3646 | 242 | 241 | ||
3647 | 243 | namespace | 242 | namespace |
3648 | 244 | { | 243 | { |
3649 | 245 | class CCSSettingValueMatcher : | ||
3650 | 246 | public ::testing::MatcherInterface <CCSSettingValue> | ||
3651 | 247 | { | ||
3652 | 248 | public: | ||
3653 | 249 | |||
3654 | 250 | CCSSettingValueMatcher (const CCSSettingValue &match, | ||
3655 | 251 | CCSSettingType type, | ||
3656 | 252 | CCSSettingInfo *info) : | ||
3657 | 253 | mMatch (match), | ||
3658 | 254 | mType (type), | ||
3659 | 255 | mInfo (info) | ||
3660 | 256 | { | ||
3661 | 257 | } | ||
3662 | 258 | |||
3663 | 259 | virtual bool MatchAndExplain (CCSSettingValue x, MatchResultListener *listener) const | ||
3664 | 260 | { | ||
3665 | 261 | if (ccsCheckValueEq (&x, | ||
3666 | 262 | mType, | ||
3667 | 263 | mInfo, | ||
3668 | 264 | &mMatch, | ||
3669 | 265 | mType, | ||
3670 | 266 | mInfo)) | ||
3671 | 267 | return true; | ||
3672 | 268 | return false; | ||
3673 | 269 | } | ||
3674 | 270 | |||
3675 | 271 | virtual void DescribeTo (std::ostream *os) const | ||
3676 | 272 | { | ||
3677 | 273 | *os << "Value Matches"; | ||
3678 | 274 | } | ||
3679 | 275 | |||
3680 | 276 | virtual void DescribeNegationTo (std::ostream *os) const | ||
3681 | 277 | { | ||
3682 | 278 | *os << "Value does not Match"; | ||
3683 | 279 | } | ||
3684 | 280 | |||
3685 | 281 | private: | ||
3686 | 282 | |||
3687 | 283 | const CCSSettingValue &mMatch; | ||
3688 | 284 | CCSSettingType mType; | ||
3689 | 285 | CCSSettingInfo *mInfo; | ||
3690 | 286 | }; | ||
3691 | 287 | |||
3692 | 288 | Matcher <CCSSettingValue> | ||
3693 | 289 | SettingValueMatch (const CCSSettingValue &match, | ||
3694 | 290 | CCSSettingType type, | ||
3695 | 291 | CCSSettingInfo *info) | ||
3696 | 292 | { | ||
3697 | 293 | return MakeMatcher (new CCSSettingValueMatcher (match, type, info)); | ||
3698 | 294 | } | ||
3699 | 295 | |||
3700 | 296 | typedef boost::shared_ptr <cc::ListWrapper <CCSSettingList, CCSSetting *> > CCSSettingListWrapperPtr; | 244 | typedef boost::shared_ptr <cc::ListWrapper <CCSSettingList, CCSSetting *> > CCSSettingListWrapperPtr; |
3701 | 297 | 245 | ||
3702 | 298 | CCSSettingListWrapperPtr | 246 | CCSSettingListWrapperPtr |
3703 | @@ -362,7 +310,7 @@ | |||
3704 | 362 | EXPECT_CALL (Mock (resetSettingIdentifier), getValue ()).WillOnce (Return (&valueResetIdentifier)); | 310 | EXPECT_CALL (Mock (resetSettingIdentifier), getValue ()).WillOnce (Return (&valueResetIdentifier)); |
3705 | 363 | EXPECT_CALL (Mock (settingToReset), getValue ()).WillOnce (Return (&valueToReset)); | 311 | EXPECT_CALL (Mock (settingToReset), getValue ()).WillOnce (Return (&valueToReset)); |
3706 | 364 | 312 | ||
3708 | 365 | EXPECT_CALL (Mock (settingToReset), resetToDefault (BoolTrue ())); | 313 | EXPECT_CALL (Mock (settingToReset), resetToDefault (IsTrue ())); |
3709 | 366 | 314 | ||
3710 | 367 | ccsUpgradeClearValues (*list); | 315 | ccsUpgradeClearValues (*list); |
3711 | 368 | } | 316 | } |
3712 | @@ -465,7 +413,7 @@ | |||
3713 | 465 | 413 | ||
3714 | 466 | EXPECT_CALL (Mock (settingToBeChanged), setValue (Pointee (SettingValueMatch (valueResetIdentifier, | 414 | EXPECT_CALL (Mock (settingToBeChanged), setValue (Pointee (SettingValueMatch (valueResetIdentifier, |
3715 | 467 | TypeInt, | 415 | TypeInt, |
3717 | 468 | &info)), BoolTrue ())); | 416 | &info)), IsTrue ())); |
3718 | 469 | 417 | ||
3719 | 470 | ccsUpgradeAddValues (*list); | 418 | ccsUpgradeAddValues (*list); |
3720 | 471 | } | 419 | } |
3721 | @@ -547,7 +495,7 @@ | |||
3722 | 547 | 495 | ||
3723 | 548 | EXPECT_CALL (Mock (settingToBeChanged), setValue (Pointee (SettingValueMatch (toSettingIdentifierValue, | 496 | EXPECT_CALL (Mock (settingToBeChanged), setValue (Pointee (SettingValueMatch (toSettingIdentifierValue, |
3724 | 549 | TypeInt, | 497 | TypeInt, |
3726 | 550 | &info)), BoolTrue ())); | 498 | &info)), IsTrue ())); |
3727 | 551 | 499 | ||
3728 | 552 | ccsUpgradeReplaceValues (*replaceFromValueSettings, | 500 | ccsUpgradeReplaceValues (*replaceFromValueSettings, |
3729 | 553 | *replaceToValueSettings); | 501 | *replaceToValueSettings); |
3730 | @@ -712,7 +660,7 @@ | |||
3731 | 712 | 660 | ||
3732 | 713 | EXPECT_CALL (Mock (settingToAppendValuesTo), setList ( | 661 | EXPECT_CALL (Mock (settingToAppendValuesTo), setList ( |
3733 | 714 | IsSettingValueInSettingValueCCSList ( | 662 | IsSettingValueInSettingValueCCSList ( |
3735 | 715 | SettingValueMatch (appendedStringInListValue, TypeString, &info)), BoolTrue ())); | 663 | SettingValueMatch (appendedStringInListValue, TypeString, &info)), IsTrue ())); |
3736 | 716 | 664 | ||
3737 | 717 | ccsUpgradeAddValues (*list); | 665 | ccsUpgradeAddValues (*list); |
3738 | 718 | } | 666 | } |
3739 | @@ -777,7 +725,7 @@ | |||
3740 | 777 | EXPECT_CALL (Mock (settingToRemoveValuesFrom), setList ( | 725 | EXPECT_CALL (Mock (settingToRemoveValuesFrom), setList ( |
3741 | 778 | Not ( | 726 | Not ( |
3742 | 779 | IsSettingValueInSettingValueCCSList ( | 727 | IsSettingValueInSettingValueCCSList ( |
3744 | 780 | SettingValueMatch (removedStringInListValue, TypeString, &info))), BoolTrue ())); | 728 | SettingValueMatch (removedStringInListValue, TypeString, &info))), IsTrue ())); |
3745 | 781 | 729 | ||
3746 | 782 | ccsUpgradeClearValues (*list); | 730 | ccsUpgradeClearValues (*list); |
3747 | 783 | } | 731 | } |
3748 | 784 | 732 | ||
3749 | === modified file 'compizconfig/mocks/libcompizconfig/CMakeLists.txt' | |||
3750 | --- compizconfig/mocks/libcompizconfig/CMakeLists.txt 2012-09-24 03:58:20 +0000 | |||
3751 | +++ compizconfig/mocks/libcompizconfig/CMakeLists.txt 2012-09-24 03:58:20 +0000 | |||
3752 | @@ -25,6 +25,18 @@ | |||
3753 | 25 | add_library (compizconfig_ccs_text_file_mock | 25 | add_library (compizconfig_ccs_text_file_mock |
3754 | 26 | ${CMAKE_CURRENT_SOURCE_DIR}/compizconfig_ccs_text_file_mock.cpp) | 26 | ${CMAKE_CURRENT_SOURCE_DIR}/compizconfig_ccs_text_file_mock.cpp) |
3755 | 27 | 27 | ||
3756 | 28 | add_library (compizconfig_ccs_integration_mock | ||
3757 | 29 | ${CMAKE_CURRENT_SOURCE_DIR}/compizconfig_ccs_integration_mock.cpp) | ||
3758 | 30 | |||
3759 | 31 | add_library (compizconfig_ccs_integrated_setting_mock | ||
3760 | 32 | ${CMAKE_CURRENT_SOURCE_DIR}/compizconfig_ccs_integrated_setting_mock.cpp) | ||
3761 | 33 | |||
3762 | 34 | add_library (compizconfig_ccs_integrated_setting_storage_mock | ||
3763 | 35 | ${CMAKE_CURRENT_SOURCE_DIR}/compizconfig_ccs_integrated_setting_storage_mock.cpp) | ||
3764 | 36 | |||
3765 | 37 | add_library (compizconfig_ccs_integrated_setting_factory_mock | ||
3766 | 38 | ${CMAKE_CURRENT_SOURCE_DIR}/compizconfig_ccs_integrated_setting_factory_mock.cpp) | ||
3767 | 39 | |||
3768 | 28 | target_link_libraries (compizconfig_ccs_context_mock | 40 | target_link_libraries (compizconfig_ccs_context_mock |
3769 | 29 | ${GTEST_BOTH_LIBRARIES} | 41 | ${GTEST_BOTH_LIBRARIES} |
3770 | 30 | ${GMOCK_LIBRARY} | 42 | ${GMOCK_LIBRARY} |
3771 | @@ -62,3 +74,31 @@ | |||
3772 | 62 | ${GMOCK_LIBRARY} | 74 | ${GMOCK_LIBRARY} |
3773 | 63 | ${GMOCK_MAIN_LIBRARY} | 75 | ${GMOCK_MAIN_LIBRARY} |
3774 | 64 | ${CMAKE_THREAD_LIBS_INIT}) | 76 | ${CMAKE_THREAD_LIBS_INIT}) |
3775 | 77 | |||
3776 | 78 | target_link_libraries (compizconfig_ccs_integration_mock | ||
3777 | 79 | ${GTEST_BOTH_LIBRARIES} | ||
3778 | 80 | ${GMOCK_LIBRARY} | ||
3779 | 81 | ${GMOCK_MAIN_LIBRARY} | ||
3780 | 82 | ${CMAKE_THREAD_LIBS_INIT} | ||
3781 | 83 | compizconfig) | ||
3782 | 84 | |||
3783 | 85 | target_link_libraries (compizconfig_ccs_integrated_setting_mock | ||
3784 | 86 | ${GTEST_BOTH_LIBRARIES} | ||
3785 | 87 | ${GMOCK_LIBRARY} | ||
3786 | 88 | ${GMOCK_MAIN_LIBRARY} | ||
3787 | 89 | ${CMAKE_THREAD_LIBS_INIT} | ||
3788 | 90 | compizconfig) | ||
3789 | 91 | |||
3790 | 92 | target_link_libraries (compizconfig_ccs_integrated_setting_factory_mock | ||
3791 | 93 | ${GTEST_BOTH_LIBRARIES} | ||
3792 | 94 | ${GMOCK_LIBRARY} | ||
3793 | 95 | ${GMOCK_MAIN_LIBRARY} | ||
3794 | 96 | ${CMAKE_THREAD_LIBS_INIT} | ||
3795 | 97 | compizconfig) | ||
3796 | 98 | |||
3797 | 99 | target_link_libraries (compizconfig_ccs_integrated_setting_storage_mock | ||
3798 | 100 | ${GTEST_BOTH_LIBRARIES} | ||
3799 | 101 | ${GMOCK_LIBRARY} | ||
3800 | 102 | ${GMOCK_MAIN_LIBRARY} | ||
3801 | 103 | ${CMAKE_THREAD_LIBS_INIT} | ||
3802 | 104 | compizconfig) | ||
3803 | 65 | 105 | ||
3804 | === added file 'compizconfig/mocks/libcompizconfig/compizconfig_ccs_integrated_setting_factory_mock.cpp' | |||
3805 | --- compizconfig/mocks/libcompizconfig/compizconfig_ccs_integrated_setting_factory_mock.cpp 1970-01-01 00:00:00 +0000 | |||
3806 | +++ compizconfig/mocks/libcompizconfig/compizconfig_ccs_integrated_setting_factory_mock.cpp 2012-09-24 03:58:20 +0000 | |||
3807 | @@ -0,0 +1,70 @@ | |||
3808 | 1 | /* | ||
3809 | 2 | * Compiz configuration system library | ||
3810 | 3 | * | ||
3811 | 4 | * Copyright (C) 2012 Canonical Ltd. | ||
3812 | 5 | * | ||
3813 | 6 | * This library is free software; you can redistribute it and/or | ||
3814 | 7 | * modify it under the terms of the GNU Lesser General Public | ||
3815 | 8 | * License as published by the Free Software Foundation; either | ||
3816 | 9 | * version 2.1 of the License, or (at your option) any later version. | ||
3817 | 10 | |||
3818 | 11 | * This library is distributed in the hope that it will be useful, | ||
3819 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3820 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
3821 | 14 | * Lesser General Public License for more details. | ||
3822 | 15 | |||
3823 | 16 | * You should have received a copy of the GNU Lesser General Public | ||
3824 | 17 | * License along with this library; if not, write to the Free Software | ||
3825 | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
3826 | 19 | * | ||
3827 | 20 | * Authored By: | ||
3828 | 21 | * Sam Spilsbury <sam.spilsbury@canonical.com> | ||
3829 | 22 | */ | ||
3830 | 23 | #include <gtest/gtest.h> | ||
3831 | 24 | #include <gmock/gmock.h> | ||
3832 | 25 | |||
3833 | 26 | #include <ccs.h> | ||
3834 | 27 | |||
3835 | 28 | #include "compizconfig_ccs_integrated_setting_factory_mock.h" | ||
3836 | 29 | |||
3837 | 30 | const CCSIntegratedSettingFactoryInterface mockIntegratedSettingFactoryInterface = | ||
3838 | 31 | { | ||
3839 | 32 | CCSIntegratedSettingFactoryGMock::ccsIntegratedSettingFactoryCreateIntegratedSettingForCCSSettingNameAndType, | ||
3840 | 33 | CCSIntegratedSettingFactoryGMock::ccsIntegratedSettingFactoryFree | ||
3841 | 34 | }; | ||
3842 | 35 | |||
3843 | 36 | CCSIntegratedSettingFactory * | ||
3844 | 37 | ccsMockIntegratedSettingFactoryNew (CCSObjectAllocationInterface *ai) | ||
3845 | 38 | { | ||
3846 | 39 | CCSIntegratedSettingFactory *integratedSettingFactory = | ||
3847 | 40 | reinterpret_cast <CCSIntegratedSettingFactory *> ((*ai->calloc_) (ai->allocator, 1, sizeof (CCSIntegratedSettingFactory))); | ||
3848 | 41 | |||
3849 | 42 | if (!integratedSettingFactory) | ||
3850 | 43 | return NULL; | ||
3851 | 44 | |||
3852 | 45 | CCSIntegratedSettingFactoryGMock *gmockFactory = new CCSIntegratedSettingFactoryGMock (integratedSettingFactory); | ||
3853 | 46 | |||
3854 | 47 | ccsObjectInit (integratedSettingFactory, ai); | ||
3855 | 48 | ccsObjectSetPrivate (integratedSettingFactory, (CCSPrivate *) gmockFactory); | ||
3856 | 49 | ccsObjectAddInterface (integratedSettingFactory, | ||
3857 | 50 | reinterpret_cast <const CCSInterface *> (&mockIntegratedSettingFactoryInterface), | ||
3858 | 51 | GET_INTERFACE_TYPE (CCSIntegratedSettingFactoryInterface)); | ||
3859 | 52 | |||
3860 | 53 | ccsObjectRef (integratedSettingFactory); | ||
3861 | 54 | |||
3862 | 55 | return integratedSettingFactory; | ||
3863 | 56 | } | ||
3864 | 57 | |||
3865 | 58 | void | ||
3866 | 59 | ccsMockIntegratedSettingFactoryFree (CCSIntegratedSettingFactory *integratedSettingFactory) | ||
3867 | 60 | { | ||
3868 | 61 | CCSIntegratedSettingFactoryGMock *gmockFactory = | ||
3869 | 62 | GET_PRIVATE (CCSIntegratedSettingFactoryGMock, integratedSettingFactory); | ||
3870 | 63 | |||
3871 | 64 | delete gmockFactory; | ||
3872 | 65 | |||
3873 | 66 | ccsObjectSetPrivate (integratedSettingFactory, NULL); | ||
3874 | 67 | ccsObjectFinalize (integratedSettingFactory); | ||
3875 | 68 | (*integratedSettingFactory->object.object_allocation->free_) | ||
3876 | 69 | (integratedSettingFactory->object.object_allocation->allocator, integratedSettingFactory); | ||
3877 | 70 | } | ||
3878 | 0 | 71 | ||
3879 | === added file 'compizconfig/mocks/libcompizconfig/compizconfig_ccs_integrated_setting_factory_mock.h' | |||
3880 | --- compizconfig/mocks/libcompizconfig/compizconfig_ccs_integrated_setting_factory_mock.h 1970-01-01 00:00:00 +0000 | |||
3881 | +++ compizconfig/mocks/libcompizconfig/compizconfig_ccs_integrated_setting_factory_mock.h 2012-09-24 03:58:20 +0000 | |||
3882 | @@ -0,0 +1,99 @@ | |||
3883 | 1 | /* | ||
3884 | 2 | * Compiz configuration system library | ||
3885 | 3 | * | ||
3886 | 4 | * Copyright (C) 2012 Canonical Ltd. | ||
3887 | 5 | * | ||
3888 | 6 | * This library is free software; you can redistribute it and/or | ||
3889 | 7 | * modify it under the terms of the GNU Lesser General Public | ||
3890 | 8 | * License as published by the Free Software Foundation; either | ||
3891 | 9 | * version 2.1 of the License, or (at your option) any later version. | ||
3892 | 10 | |||
3893 | 11 | * This library is distributed in the hope that it will be useful, | ||
3894 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3895 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
3896 | 14 | * Lesser General Public License for more details. | ||
3897 | 15 | |||
3898 | 16 | * You should have received a copy of the GNU Lesser General Public | ||
3899 | 17 | * License along with this library; if not, write to the Free Software | ||
3900 | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
3901 | 19 | * | ||
3902 | 20 | * Authored By: | ||
3903 | 21 | * Sam Spilsbury <sam.spilsbury@canonical.com> | ||
3904 | 22 | */ | ||
3905 | 23 | #ifndef _COMPIZCONFIG_CCS_INTEGRATED_SETTING_FACTORY_MOCK_H | ||
3906 | 24 | #define _COMPIZCONFIG_CCS_INTEGRATED_SETTING_FACTORY_MOCK_H | ||
3907 | 25 | |||
3908 | 26 | #include <gtest/gtest.h> | ||
3909 | 27 | #include <gmock/gmock.h> | ||
3910 | 28 | |||
3911 | 29 | #include <ccs.h> | ||
3912 | 30 | #include <ccs-backend.h> | ||
3913 | 31 | |||
3914 | 32 | CCSIntegratedSettingFactory * | ||
3915 | 33 | ccsMockIntegratedSettingFactoryNew (CCSObjectAllocationInterface *ai); | ||
3916 | 34 | |||
3917 | 35 | void | ||
3918 | 36 | ccsMockIntegratedSettingFactoryFree (CCSIntegratedSettingFactory *); | ||
3919 | 37 | |||
3920 | 38 | class CCSIntegratedSettingFactoryGMockInterface | ||
3921 | 39 | { | ||
3922 | 40 | public: | ||
3923 | 41 | |||
3924 | 42 | virtual ~CCSIntegratedSettingFactoryGMockInterface () {} | ||
3925 | 43 | |||
3926 | 44 | virtual CCSIntegratedSetting * createIntegratedSettingForCCSNameAndType (CCSIntegration *integration, | ||
3927 | 45 | const char *pluginName, | ||
3928 | 46 | const char *settingName, | ||
3929 | 47 | CCSSettingType type) = 0; | ||
3930 | 48 | }; | ||
3931 | 49 | |||
3932 | 50 | class CCSIntegratedSettingFactoryGMock : | ||
3933 | 51 | public CCSIntegratedSettingFactoryGMockInterface | ||
3934 | 52 | { | ||
3935 | 53 | public: | ||
3936 | 54 | |||
3937 | 55 | MOCK_METHOD4 (createIntegratedSettingForCCSNameAndType, CCSIntegratedSetting * (CCSIntegration *, | ||
3938 | 56 | const char *, | ||
3939 | 57 | const char *, | ||
3940 | 58 | CCSSettingType )); | ||
3941 | 59 | |||
3942 | 60 | CCSIntegratedSettingFactoryGMock (CCSIntegratedSettingFactory *integratedSettingFactory) : | ||
3943 | 61 | mIntegratedSettingFactory (integratedSettingFactory) | ||
3944 | 62 | { | ||
3945 | 63 | } | ||
3946 | 64 | |||
3947 | 65 | CCSIntegratedSettingFactory * | ||
3948 | 66 | getIntegratedSettingFactory () | ||
3949 | 67 | { | ||
3950 | 68 | return mIntegratedSettingFactory; | ||
3951 | 69 | } | ||
3952 | 70 | |||
3953 | 71 | public: | ||
3954 | 72 | |||
3955 | 73 | static CCSIntegratedSetting * | ||
3956 | 74 | ccsIntegratedSettingFactoryCreateIntegratedSettingForCCSSettingNameAndType (CCSIntegratedSettingFactory *factory, | ||
3957 | 75 | CCSIntegration *integration, | ||
3958 | 76 | const char *pluginName, | ||
3959 | 77 | const char *settingName, | ||
3960 | 78 | CCSSettingType type) | ||
3961 | 79 | { | ||
3962 | 80 | return reinterpret_cast <CCSIntegratedSettingFactoryGMockInterface *> (factory)->createIntegratedSettingForCCSNameAndType (integration, | ||
3963 | 81 | pluginName, | ||
3964 | 82 | settingName, | ||
3965 | 83 | type); | ||
3966 | 84 | } | ||
3967 | 85 | |||
3968 | 86 | static void | ||
3969 | 87 | ccsIntegratedSettingFactoryFree (CCSIntegratedSettingFactory *integratedSettingFactory) | ||
3970 | 88 | { | ||
3971 | 89 | ccsMockIntegratedSettingFactoryFree (integratedSettingFactory); | ||
3972 | 90 | } | ||
3973 | 91 | |||
3974 | 92 | private: | ||
3975 | 93 | |||
3976 | 94 | CCSIntegratedSettingFactory *mIntegratedSettingFactory; | ||
3977 | 95 | }; | ||
3978 | 96 | |||
3979 | 97 | extern const CCSIntegratedSettingFactoryInterface mockIntegratedSettingFactoryInterface; | ||
3980 | 98 | |||
3981 | 99 | #endif | ||
3982 | 0 | 100 | ||
3983 | === added file 'compizconfig/mocks/libcompizconfig/compizconfig_ccs_integrated_setting_mock.cpp' | |||
3984 | --- compizconfig/mocks/libcompizconfig/compizconfig_ccs_integrated_setting_mock.cpp 1970-01-01 00:00:00 +0000 | |||
3985 | +++ compizconfig/mocks/libcompizconfig/compizconfig_ccs_integrated_setting_mock.cpp 2012-09-24 03:58:20 +0000 | |||
3986 | @@ -0,0 +1,71 @@ | |||
3987 | 1 | /* | ||
3988 | 2 | * Compiz configuration system library | ||
3989 | 3 | * | ||
3990 | 4 | * Copyright (C) 2012 Canonical Ltd. | ||
3991 | 5 | * | ||
3992 | 6 | * This library is free software; you can redistribute it and/or | ||
3993 | 7 | * modify it under the terms of the GNU Lesser General Public | ||
3994 | 8 | * License as published by the Free Software Foundation; either | ||
3995 | 9 | * version 2.1 of the License, or (at your option) any later version. | ||
3996 | 10 | |||
3997 | 11 | * This library is distributed in the hope that it will be useful, | ||
3998 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3999 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
4000 | 14 | * Lesser General Public License for more details. | ||
4001 | 15 | |||
4002 | 16 | * You should have received a copy of the GNU Lesser General Public | ||
4003 | 17 | * License along with this library; if not, write to the Free Software | ||
4004 | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
4005 | 19 | * | ||
4006 | 20 | * Authored By: | ||
4007 | 21 | * Sam Spilsbury <sam.spilsbury@canonical.com> | ||
4008 | 22 | */ | ||
4009 | 23 | #include <gtest/gtest.h> | ||
4010 | 24 | #include <gmock/gmock.h> | ||
4011 | 25 | |||
4012 | 26 | #include <ccs.h> | ||
4013 | 27 | |||
4014 | 28 | #include "compizconfig_ccs_integrated_setting_mock.h" | ||
4015 | 29 | |||
4016 | 30 | const CCSIntegratedSettingInterface mockIntegratedSettingInterface = | ||
4017 | 31 | { | ||
4018 | 32 | CCSIntegratedSettingGMock::ccsIntegratedSettingReadValue, | ||
4019 | 33 | CCSIntegratedSettingGMock::ccsIntegratedSettingWriteValue, | ||
4020 | 34 | CCSIntegratedSettingGMock::ccsIntegratedSettingFree | ||
4021 | 35 | }; | ||
4022 | 36 | |||
4023 | 37 | CCSIntegratedSetting * | ||
4024 | 38 | ccsMockIntegratedSettingNew (CCSObjectAllocationInterface *ai) | ||
4025 | 39 | { | ||
4026 | 40 | CCSIntegratedSetting *integratedSetting = | ||
4027 | 41 | reinterpret_cast <CCSIntegratedSetting *> ((*ai->calloc_) (ai->allocator, 1, sizeof (CCSIntegratedSetting))); | ||
4028 | 42 | |||
4029 | 43 | if (!integratedSetting) | ||
4030 | 44 | return NULL; | ||
4031 | 45 | |||
4032 | 46 | CCSIntegratedSettingGMock *gmockBackend = new CCSIntegratedSettingGMock (integratedSetting); | ||
4033 | 47 | |||
4034 | 48 | ccsObjectInit (integratedSetting, ai); | ||
4035 | 49 | ccsObjectSetPrivate (integratedSetting, (CCSPrivate *) gmockBackend); | ||
4036 | 50 | ccsObjectAddInterface (integratedSetting, | ||
4037 | 51 | reinterpret_cast <const CCSInterface *> (&mockIntegratedSettingInterface), | ||
4038 | 52 | GET_INTERFACE_TYPE (CCSIntegratedSettingInterface)); | ||
4039 | 53 | |||
4040 | 54 | ccsObjectRef (integratedSetting); | ||
4041 | 55 | |||
4042 | 56 | return integratedSetting; | ||
4043 | 57 | } | ||
4044 | 58 | |||
4045 | 59 | void | ||
4046 | 60 | ccsMockIntegratedSettingFree (CCSIntegratedSetting *integration) | ||
4047 | 61 | { | ||
4048 | 62 | CCSIntegratedSettingGMock *gmockIntegration = | ||
4049 | 63 | GET_PRIVATE (CCSIntegratedSettingGMock, integration); | ||
4050 | 64 | |||
4051 | 65 | delete gmockIntegration; | ||
4052 | 66 | |||
4053 | 67 | ccsObjectSetPrivate (integration, NULL); | ||
4054 | 68 | ccsObjectFinalize (integration); | ||
4055 | 69 | (*integration->object.object_allocation->free_) | ||
4056 | 70 | (integration->object.object_allocation->allocator, integration); | ||
4057 | 71 | } | ||
4058 | 0 | 72 | ||
4059 | === added file 'compizconfig/mocks/libcompizconfig/compizconfig_ccs_integrated_setting_mock.h' | |||
4060 | --- compizconfig/mocks/libcompizconfig/compizconfig_ccs_integrated_setting_mock.h 1970-01-01 00:00:00 +0000 | |||
4061 | +++ compizconfig/mocks/libcompizconfig/compizconfig_ccs_integrated_setting_mock.h 2012-09-24 03:58:20 +0000 | |||
4062 | @@ -0,0 +1,97 @@ | |||
4063 | 1 | /* | ||
4064 | 2 | * Compiz configuration system library | ||
4065 | 3 | * | ||
4066 | 4 | * Copyright (C) 2012 Canonical Ltd. | ||
4067 | 5 | * | ||
4068 | 6 | * This library is free software; you can redistribute it and/or | ||
4069 | 7 | * modify it under the terms of the GNU Lesser General Public | ||
4070 | 8 | * License as published by the Free Software Foundation; either | ||
4071 | 9 | * version 2.1 of the License, or (at your option) any later version. | ||
4072 | 10 | |||
4073 | 11 | * This library is distributed in the hope that it will be useful, | ||
4074 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
4075 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
4076 | 14 | * Lesser General Public License for more details. | ||
4077 | 15 | |||
4078 | 16 | * You should have received a copy of the GNU Lesser General Public | ||
4079 | 17 | * License along with this library; if not, write to the Free Software | ||
4080 | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
4081 | 19 | * | ||
4082 | 20 | * Authored By: | ||
4083 | 21 | * Sam Spilsbury <sam.spilsbury@canonical.com> | ||
4084 | 22 | */ | ||
4085 | 23 | #ifndef _COMPIZCONFIG_CCS_INTEGRATED_SETTING_MOCK_H | ||
4086 | 24 | #define _COMPIZCONFIG_CCS_INTEGRATED_SETTING_MOCK_H | ||
4087 | 25 | |||
4088 | 26 | #include <gtest/gtest.h> | ||
4089 | 27 | #include <gmock/gmock.h> | ||
4090 | 28 | |||
4091 | 29 | #include <ccs.h> | ||
4092 | 30 | #include <ccs-backend.h> | ||
4093 | 31 | |||
4094 | 32 | CCSIntegratedSetting * | ||
4095 | 33 | ccsMockIntegratedSettingNew (CCSObjectAllocationInterface *ai); | ||
4096 | 34 | |||
4097 | 35 | void | ||
4098 | 36 | ccsMockIntegratedSettingFree (CCSIntegratedSetting *); | ||
4099 | 37 | |||
4100 | 38 | class CCSIntegratedSettingGMockInterface | ||
4101 | 39 | { | ||
4102 | 40 | public: | ||
4103 | 41 | |||
4104 | 42 | virtual ~CCSIntegratedSettingGMockInterface () {} | ||
4105 | 43 | |||
4106 | 44 | virtual CCSSettingValue * readValue (CCSSettingType) = 0; | ||
4107 | 45 | virtual void writeValue (CCSSettingValue *, CCSSettingType) = 0; | ||
4108 | 46 | }; | ||
4109 | 47 | |||
4110 | 48 | class CCSIntegratedSettingGMock : | ||
4111 | 49 | public CCSIntegratedSettingGMockInterface | ||
4112 | 50 | { | ||
4113 | 51 | public: | ||
4114 | 52 | |||
4115 | 53 | MOCK_METHOD1 (readValue, CCSSettingValue * (CCSSettingType)); | ||
4116 | 54 | MOCK_METHOD2 (writeValue, void (CCSSettingValue *, CCSSettingType)); | ||
4117 | 55 | |||
4118 | 56 | CCSIntegratedSettingGMock (CCSIntegratedSetting *integratedSetting) : | ||
4119 | 57 | mIntegrationSetting (integratedSetting) | ||
4120 | 58 | { | ||
4121 | 59 | } | ||
4122 | 60 | |||
4123 | 61 | CCSIntegratedSetting * | ||
4124 | 62 | getIntegratedSetting () | ||
4125 | 63 | { | ||
4126 | 64 | return mIntegrationSetting; | ||
4127 | 65 | } | ||
4128 | 66 | |||
4129 | 67 | public: | ||
4130 | 68 | |||
4131 | 69 | static CCSSettingValue * | ||
4132 | 70 | ccsIntegratedSettingReadValue (CCSIntegratedSetting *integratedSetting, | ||
4133 | 71 | CCSSettingType type) | ||
4134 | 72 | { | ||
4135 | 73 | return reinterpret_cast <CCSIntegratedSettingGMockInterface *> (ccsObjectGetPrivate (integratedSetting))->readValue (type); | ||
4136 | 74 | } | ||
4137 | 75 | |||
4138 | 76 | static void | ||
4139 | 77 | ccsIntegratedSettingWriteValue (CCSIntegratedSetting *integratedSetting, | ||
4140 | 78 | CCSSettingValue *value, | ||
4141 | 79 | CCSSettingType type) | ||
4142 | 80 | { | ||
4143 | 81 | reinterpret_cast <CCSIntegratedSettingGMockInterface *> (ccsObjectGetPrivate (integratedSetting))->writeValue (value, type); | ||
4144 | 82 | } | ||
4145 | 83 | |||
4146 | 84 | static void | ||
4147 | 85 | ccsIntegratedSettingFree (CCSIntegratedSetting *integratedSetting) | ||
4148 | 86 | { | ||
4149 | 87 | ccsMockIntegratedSettingFree (integratedSetting); | ||
4150 | 88 | } | ||
4151 | 89 | |||
4152 | 90 | private: | ||
4153 | 91 | |||
4154 | 92 | CCSIntegratedSetting *mIntegrationSetting; | ||
4155 | 93 | }; | ||
4156 | 94 | |||
4157 | 95 | extern const CCSIntegratedSettingInterface mockIntegratedSettingInterface; | ||
4158 | 96 | |||
4159 | 97 | #endif | ||
4160 | 0 | 98 | ||
4161 | === added file 'compizconfig/mocks/libcompizconfig/compizconfig_ccs_integrated_setting_storage_mock.cpp' | |||
4162 | --- compizconfig/mocks/libcompizconfig/compizconfig_ccs_integrated_setting_storage_mock.cpp 1970-01-01 00:00:00 +0000 | |||
4163 | +++ compizconfig/mocks/libcompizconfig/compizconfig_ccs_integrated_setting_storage_mock.cpp 2012-09-24 03:58:20 +0000 | |||
4164 | @@ -0,0 +1,73 @@ | |||
4165 | 1 | /* | ||
4166 | 2 | * Compiz configuration system library | ||
4167 | 3 | * | ||
4168 | 4 | * Copyright (C) 2012 Canonical Ltd. | ||
4169 | 5 | * | ||
4170 | 6 | * This library is free software; you can redistribute it and/or | ||
4171 | 7 | * modify it under the terms of the GNU Lesser General Public | ||
4172 | 8 | * License as published by the Free Software Foundation; either | ||
4173 | 9 | * version 2.1 of the License, or (at your option) any later version. | ||
4174 | 10 | |||
4175 | 11 | * This library is distributed in the hope that it will be useful, | ||
4176 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
4177 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
4178 | 14 | * Lesser General Public License for more details. | ||
4179 | 15 | |||
4180 | 16 | * You should have received a copy of the GNU Lesser General Public | ||
4181 | 17 | * License along with this library; if not, write to the Free Software | ||
4182 | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
4183 | 19 | * | ||
4184 | 20 | * Authored By: | ||
4185 | 21 | * Sam Spilsbury <sam.spilsbury@canonical.com> | ||
4186 | 22 | */ | ||
4187 | 23 | #include <gtest/gtest.h> | ||
4188 | 24 | #include <gmock/gmock.h> | ||
4189 | 25 | |||
4190 | 26 | #include <ccs.h> | ||
4191 | 27 | |||
4192 | 28 | #include "compizconfig_ccs_integrated_setting_storage_mock.h" | ||
4193 | 29 | |||
4194 | 30 | const CCSIntegratedSettingsStorageInterface mockIntegratedSettingsStorageInterface = | ||
4195 | 31 | { | ||
4196 | 32 | CCSIntegratedSettingsStorageGMock::ccsIntegratedSettingsStorageFindMatchingSettingsByPredicate, | ||
4197 | 33 | CCSIntegratedSettingsStorageGMock::ccsIntegratedSettingsStorageFindMatchingSettingsByPluginAndSettingName, | ||
4198 | 34 | CCSIntegratedSettingsStorageGMock::ccsIntegratedSettingsStorageAddSetting, | ||
4199 | 35 | CCSIntegratedSettingsStorageGMock::ccsIntegratedSettingsStorageEmpty, | ||
4200 | 36 | CCSIntegratedSettingsStorageGMock::ccsIntegratedSettingsStorageFree | ||
4201 | 37 | }; | ||
4202 | 38 | |||
4203 | 39 | CCSIntegratedSettingsStorage * | ||
4204 | 40 | ccsMockIntegratedSettingsStorageNew (CCSObjectAllocationInterface *ai) | ||
4205 | 41 | { | ||
4206 | 42 | CCSIntegratedSettingsStorage *storage = | ||
4207 | 43 | reinterpret_cast <CCSIntegratedSettingsStorage *> ((*ai->calloc_) (ai->allocator, 1, sizeof (CCSIntegratedSettingsStorage))); | ||
4208 | 44 | |||
4209 | 45 | if (!storage) | ||
4210 | 46 | return NULL; | ||
4211 | 47 | |||
4212 | 48 | CCSIntegratedSettingsStorageGMock *gmockBackend = new CCSIntegratedSettingsStorageGMock (storage); | ||
4213 | 49 | |||
4214 | 50 | ccsObjectInit (storage, ai); | ||
4215 | 51 | ccsObjectSetPrivate (storage, (CCSPrivate *) gmockBackend); | ||
4216 | 52 | ccsObjectAddInterface (storage, | ||
4217 | 53 | reinterpret_cast <const CCSInterface *> (&mockIntegratedSettingsStorageInterface), | ||
4218 | 54 | GET_INTERFACE_TYPE (CCSIntegratedSettingsStorageInterface)); | ||
4219 | 55 | |||
4220 | 56 | ccsObjectRef (storage); | ||
4221 | 57 | |||
4222 | 58 | return storage; | ||
4223 | 59 | } | ||
4224 | 60 | |||
4225 | 61 | void | ||
4226 | 62 | ccsMockIntegratedSettingsStorageFree (CCSIntegratedSettingsStorage *storage) | ||
4227 | 63 | { | ||
4228 | 64 | CCSIntegratedSettingsStorageGMock *gmockStorage = | ||
4229 | 65 | GET_PRIVATE (CCSIntegratedSettingsStorageGMock, storage); | ||
4230 | 66 | |||
4231 | 67 | delete gmockStorage; | ||
4232 | 68 | |||
4233 | 69 | ccsObjectSetPrivate (storage, NULL); | ||
4234 | 70 | ccsObjectFinalize (storage); | ||
4235 | 71 | (*storage->object.object_allocation->free_) | ||
4236 | 72 | (storage->object.object_allocation->allocator, storage); | ||
4237 | 73 | } | ||
4238 | 0 | 74 | ||
4239 | === added file 'compizconfig/mocks/libcompizconfig/compizconfig_ccs_integrated_setting_storage_mock.h' | |||
4240 | --- compizconfig/mocks/libcompizconfig/compizconfig_ccs_integrated_setting_storage_mock.h 1970-01-01 00:00:00 +0000 | |||
4241 | +++ compizconfig/mocks/libcompizconfig/compizconfig_ccs_integrated_setting_storage_mock.h 2012-09-24 03:58:20 +0000 | |||
4242 | @@ -0,0 +1,119 @@ | |||
4243 | 1 | /* | ||
4244 | 2 | * Compiz configuration system library | ||
4245 | 3 | * | ||
4246 | 4 | * Copyright (C) 2012 Canonical Ltd. | ||
4247 | 5 | * | ||
4248 | 6 | * This library is free software; you can redistribute it and/or | ||
4249 | 7 | * modify it under the terms of the GNU Lesser General Public | ||
4250 | 8 | * License as published by the Free Software Foundation; either | ||
4251 | 9 | * version 2.1 of the License, or (at your option) any later version. | ||
4252 | 10 | |||
4253 | 11 | * This library is distributed in the hope that it will be useful, | ||
4254 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
4255 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
4256 | 14 | * Lesser General Public License for more details. | ||
4257 | 15 | |||
4258 | 16 | * You should have received a copy of the GNU Lesser General Public | ||
4259 | 17 | * License along with this library; if not, write to the Free Software | ||
4260 | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
4261 | 19 | * | ||
4262 | 20 | * Authored By: | ||
4263 | 21 | * Sam Spilsbury <sam.spilsbury@canonical.com> | ||
4264 | 22 | */ | ||
4265 | 23 | #ifndef _COMPIZCONFIG_CCS_INTEGRATED_SETTING_STORAGE_MOCK_H | ||
4266 | 24 | #define _COMPIZCONFIG_CCS_INTEGRATED_SETTING_STORAGE_MOCK_H | ||
4267 | 25 | |||
4268 | 26 | #include <gtest/gtest.h> | ||
4269 | 27 | #include <gmock/gmock.h> | ||
4270 | 28 | |||
4271 | 29 | #include <ccs.h> | ||
4272 | 30 | #include <ccs-backend.h> | ||
4273 | 31 | |||
4274 | 32 | CCSIntegratedSettingsStorage * | ||
4275 | 33 | ccsMockIntegratedSettingsStorageNew (CCSObjectAllocationInterface *ai); | ||
4276 | 34 | |||
4277 | 35 | void | ||
4278 | 36 | ccsMockIntegratedSettingsStorageFree (CCSIntegratedSettingsStorage *); | ||
4279 | 37 | |||
4280 | 38 | class CCSIntegratedSettingsStorageGMockInterface | ||
4281 | 39 | { | ||
4282 | 40 | public: | ||
4283 | 41 | |||
4284 | 42 | virtual ~CCSIntegratedSettingsStorageGMockInterface () {} | ||
4285 | 43 | |||
4286 | 44 | virtual CCSIntegratedSettingList findMatchingSettingsByPluginAndSettingName (const char *pluginName, | ||
4287 | 45 | const char *settingName) = 0; | ||
4288 | 46 | virtual void addSetting (CCSIntegratedSetting *setting) = 0; | ||
4289 | 47 | virtual CCSIntegratedSettingList findMatchingSettingsByPredicate (CCSIntegratedSettingsStorageFindPredicate pred, | ||
4290 | 48 | void *data) = 0; | ||
4291 | 49 | virtual Bool empty () = 0; | ||
4292 | 50 | }; | ||
4293 | 51 | |||
4294 | 52 | class CCSIntegratedSettingsStorageGMock : | ||
4295 | 53 | public CCSIntegratedSettingsStorageGMockInterface | ||
4296 | 54 | { | ||
4297 | 55 | public: | ||
4298 | 56 | |||
4299 | 57 | MOCK_METHOD2 (findMatchingSettingsByPluginAndSettingName, CCSIntegratedSettingList (const char *, | ||
4300 | 58 | const char *)); | ||
4301 | 59 | MOCK_METHOD1 (addSetting, void (CCSIntegratedSetting *)); | ||
4302 | 60 | MOCK_METHOD2 (findMatchingSettingsByPredicate, CCSIntegratedSettingList (CCSIntegratedSettingsStorageFindPredicate , | ||
4303 | 61 | void *)); | ||
4304 | 62 | MOCK_METHOD0 (empty, Bool ()); | ||
4305 | 63 | |||
4306 | 64 | CCSIntegratedSettingsStorageGMock (CCSIntegratedSettingsStorage *integratedSetting) : | ||
4307 | 65 | mIntegrationSetting (integratedSetting) | ||
4308 | 66 | { | ||
4309 | 67 | } | ||
4310 | 68 | |||
4311 | 69 | CCSIntegratedSettingsStorage * | ||
4312 | 70 | getIntegratedSettingsStorage () | ||
4313 | 71 | { | ||
4314 | 72 | return mIntegrationSetting; | ||
4315 | 73 | } | ||
4316 | 74 | |||
4317 | 75 | public: | ||
4318 | 76 | |||
4319 | 77 | static CCSIntegratedSettingList | ||
4320 | 78 | ccsIntegratedSettingsStorageFindMatchingSettingsByPredicate (CCSIntegratedSettingsStorage *storage, | ||
4321 | 79 | CCSIntegratedSettingsStorageFindPredicate pred, | ||
4322 | 80 | void *data) | ||
4323 | 81 | { | ||
4324 | 82 | return reinterpret_cast <CCSIntegratedSettingsStorageGMockInterface *> (ccsObjectGetPrivate (storage))->findMatchingSettingsByPredicate (pred, data); | ||
4325 | 83 | } | ||
4326 | 84 | |||
4327 | 85 | static CCSIntegratedSettingList | ||
4328 | 86 | ccsIntegratedSettingsStorageFindMatchingSettingsByPluginAndSettingName (CCSIntegratedSettingsStorage *storage, | ||
4329 | 87 | const char *pluginName, | ||
4330 | 88 | const char *settingName) | ||
4331 | 89 | { | ||
4332 | 90 | return reinterpret_cast <CCSIntegratedSettingsStorageGMockInterface *> (ccsObjectGetPrivate (storage))->findMatchingSettingsByPluginAndSettingName (pluginName, settingName); | ||
4333 | 91 | } | ||
4334 | 92 | |||
4335 | 93 | static void | ||
4336 | 94 | ccsIntegratedSettingsStorageAddSetting (CCSIntegratedSettingsStorage *storage, | ||
4337 | 95 | CCSIntegratedSetting *setting) | ||
4338 | 96 | { | ||
4339 | 97 | return reinterpret_cast <CCSIntegratedSettingsStorageGMockInterface *> (ccsObjectGetPrivate (storage))->addSetting (setting); | ||
4340 | 98 | } | ||
4341 | 99 | |||
4342 | 100 | static Bool | ||
4343 | 101 | ccsIntegratedSettingsStorageEmpty (CCSIntegratedSettingsStorage *storage) | ||
4344 | 102 | { | ||
4345 | 103 | return reinterpret_cast <CCSIntegratedSettingsStorageGMockInterface *> (ccsObjectGetPrivate (storage))->empty (); | ||
4346 | 104 | } | ||
4347 | 105 | |||
4348 | 106 | static void | ||
4349 | 107 | ccsIntegratedSettingsStorageFree (CCSIntegratedSettingsStorage *integratedSetting) | ||
4350 | 108 | { | ||
4351 | 109 | ccsMockIntegratedSettingsStorageFree (integratedSetting); | ||
4352 | 110 | } | ||
4353 | 111 | |||
4354 | 112 | private: | ||
4355 | 113 | |||
4356 | 114 | CCSIntegratedSettingsStorage *mIntegrationSetting; | ||
4357 | 115 | }; | ||
4358 | 116 | |||
4359 | 117 | extern const CCSIntegratedSettingsStorageInterface mockIntegratedSettingsStorageInterface; | ||
4360 | 118 | |||
4361 | 119 | #endif | ||
4362 | 0 | 120 | ||
4363 | === added file 'compizconfig/mocks/libcompizconfig/compizconfig_ccs_integration_mock.cpp' | |||
4364 | --- compizconfig/mocks/libcompizconfig/compizconfig_ccs_integration_mock.cpp 1970-01-01 00:00:00 +0000 | |||
4365 | +++ compizconfig/mocks/libcompizconfig/compizconfig_ccs_integration_mock.cpp 2012-09-24 03:58:20 +0000 | |||
4366 | @@ -0,0 +1,70 @@ | |||
4367 | 1 | /* | ||
4368 | 2 | * Compiz configuration system library | ||
4369 | 3 | * | ||
4370 | 4 | * Copyright (C) 2012 Canonical Ltd. | ||
4371 | 5 | * | ||
4372 | 6 | * This library is free software; you can redistribute it and/or | ||
4373 | 7 | * modify it under the terms of the GNU Lesser General Public | ||
4374 | 8 | * License as published by the Free Software Foundation; either | ||
4375 | 9 | * version 2.1 of the License, or (at your option) any later version. | ||
4376 | 10 | |||
4377 | 11 | * This library is distributed in the hope that it will be useful, | ||
4378 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
4379 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
4380 | 14 | * Lesser General Public License for more details. | ||
4381 | 15 | |||
4382 | 16 | * You should have received a copy of the GNU Lesser General Public | ||
4383 | 17 | * License along with this library; if not, write to the Free Software | ||
4384 | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
4385 | 19 | * | ||
4386 | 20 | * Authored By: | ||
4387 | 21 | * Sam Spilsbury <sam.spilsbury@canonical.com> | ||
4388 | 22 | */ | ||
4389 | 23 | #include <gtest/gtest.h> | ||
4390 | 24 | #include <gmock/gmock.h> | ||
4391 | 25 | |||
4392 | 26 | #include <ccs.h> | ||
4393 | 27 | |||
4394 | 28 | #include "compizconfig_ccs_integration_mock.h" | ||
4395 | 29 | |||
4396 | 30 | const CCSIntegrationInterface mockIntegrationBackendInterface = | ||
4397 | 31 | { | ||
4398 | 32 | CCSIntegrationGMock::ccsIntegrationGetIntegratedOptionIndex, | ||
4399 | 33 | CCSIntegrationGMock::ccsIntegrationReadOptionIntoSetting, | ||
4400 | 34 | CCSIntegrationGMock::ccsIntegrationWriteSettingIntoOption, | ||
4401 | 35 | CCSIntegrationGMock::ccsIntegrationUpdateIntegratedSettings, | ||
4402 | 36 | CCSIntegrationGMock::ccsIntegrationDisallowIntegratedWrites, | ||
4403 | 37 | CCSIntegrationGMock::ccsIntegrationAllowIntegratedWrites, | ||
4404 | 38 | CCSIntegrationGMock::ccsFreeIntegration | ||
4405 | 39 | }; | ||
4406 | 40 | |||
4407 | 41 | CCSIntegration * | ||
4408 | 42 | ccsMockIntegrationBackendNew (CCSObjectAllocationInterface *ai) | ||
4409 | 43 | { | ||
4410 | 44 | CCSIntegration *integration = reinterpret_cast <CCSIntegration *> ((*ai->calloc_) (ai->allocator, 1, sizeof (CCSIntegration))); | ||
4411 | 45 | |||
4412 | 46 | if (!integration) | ||
4413 | 47 | return NULL; | ||
4414 | 48 | |||
4415 | 49 | CCSIntegrationGMock *gmockBackend = new CCSIntegrationGMock (integration); | ||
4416 | 50 | |||
4417 | 51 | ccsObjectInit (integration, ai); | ||
4418 | 52 | ccsObjectSetPrivate (integration, (CCSPrivate *) gmockBackend); | ||
4419 | 53 | ccsObjectAddInterface (integration, (const CCSInterface *) &mockIntegrationBackendInterface, GET_INTERFACE_TYPE (CCSIntegrationInterface)); | ||
4420 | 54 | |||
4421 | 55 | ccsObjectRef (integration); | ||
4422 | 56 | |||
4423 | 57 | return integration; | ||
4424 | 58 | } | ||
4425 | 59 | |||
4426 | 60 | void | ||
4427 | 61 | ccsMockIntegrationBackendFree (CCSIntegration *integration) | ||
4428 | 62 | { | ||
4429 | 63 | CCSIntegrationGMock *gmockBackend = reinterpret_cast <CCSIntegrationGMock *> (ccsObjectGetPrivate (integration)); | ||
4430 | 64 | |||
4431 | 65 | delete gmockBackend; | ||
4432 | 66 | |||
4433 | 67 | ccsObjectSetPrivate (integration, NULL); | ||
4434 | 68 | ccsObjectFinalize (integration); | ||
4435 | 69 | (*integration->object.object_allocation->free_) (integration->object.object_allocation->allocator, integration); | ||
4436 | 70 | } | ||
4437 | 0 | 71 | ||
4438 | === added file 'compizconfig/mocks/libcompizconfig/compizconfig_ccs_integration_mock.h' | |||
4439 | --- compizconfig/mocks/libcompizconfig/compizconfig_ccs_integration_mock.h 1970-01-01 00:00:00 +0000 | |||
4440 | +++ compizconfig/mocks/libcompizconfig/compizconfig_ccs_integration_mock.h 2012-09-24 03:58:20 +0000 | |||
4441 | @@ -0,0 +1,129 @@ | |||
4442 | 1 | /* | ||
4443 | 2 | * Compiz configuration system library | ||
4444 | 3 | * | ||
4445 | 4 | * Copyright (C) 2012 Canonical Ltd. | ||
4446 | 5 | * | ||
4447 | 6 | * This library is free software; you can redistribute it and/or | ||
4448 | 7 | * modify it under the terms of the GNU Lesser General Public | ||
4449 | 8 | * License as published by the Free Software Foundation; either | ||
4450 | 9 | * version 2.1 of the License, or (at your option) any later version. | ||
4451 | 10 | |||
4452 | 11 | * This library is distributed in the hope that it will be useful, | ||
4453 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
4454 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
4455 | 14 | * Lesser General Public License for more details. | ||
4456 | 15 | |||
4457 | 16 | * You should have received a copy of the GNU Lesser General Public | ||
4458 | 17 | * License along with this library; if not, write to the Free Software | ||
4459 | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
4460 | 19 | * | ||
4461 | 20 | * Authored By: | ||
4462 | 21 | * Sam Spilsbury <sam.spilsbury@canonical.com> | ||
4463 | 22 | */ | ||
4464 | 23 | #ifndef _COMPIZCONFIG_CCS_INTEGRATION_MOCK_H | ||
4465 | 24 | #define _COMPIZCONFIG_CCS_INTEGRATION_MOCK_H | ||
4466 | 25 | |||
4467 | 26 | #include <gtest/gtest.h> | ||
4468 | 27 | #include <gmock/gmock.h> | ||
4469 | 28 | |||
4470 | 29 | #include <ccs.h> | ||
4471 | 30 | |||
4472 | 31 | CCSIntegration * | ||
4473 | 32 | ccsMockIntegrationBackendNew (CCSObjectAllocationInterface *ai); | ||
4474 | 33 | |||
4475 | 34 | void | ||
4476 | 35 | ccsMockIntegrationBackendFree (CCSIntegration *integration); | ||
4477 | 36 | |||
4478 | 37 | class CCSIntegrationGMockInterface | ||
4479 | 38 | { | ||
4480 | 39 | public: | ||
4481 | 40 | |||
4482 | 41 | virtual ~CCSIntegrationGMockInterface () {} | ||
4483 | 42 | |||
4484 | 43 | virtual CCSIntegratedSetting * getIntegratedOptionIndex (const char *pluginName, const char *settingName) = 0; | ||
4485 | 44 | virtual Bool readOptionIntoSetting (CCSContext *context, CCSSetting *setting, CCSIntegratedSetting *) = 0; | ||
4486 | 45 | virtual void writeOptionFromSetting (CCSContext *context, CCSSetting *setting, CCSIntegratedSetting *) = 0; | ||
4487 | 46 | virtual void updateIntegratedSettings (CCSContext *context, CCSIntegratedSettingList settingList) = 0; | ||
4488 | 47 | virtual void disallowIntegratedWrites () = 0; | ||
4489 | 48 | virtual void allowIntegratedWrites () = 0; | ||
4490 | 49 | }; | ||
4491 | 50 | |||
4492 | 51 | class CCSIntegrationGMock : | ||
4493 | 52 | public CCSIntegrationGMockInterface | ||
4494 | 53 | { | ||
4495 | 54 | public: | ||
4496 | 55 | |||
4497 | 56 | MOCK_METHOD2 (getIntegratedOptionIndex, CCSIntegratedSetting * (const char *, const char *)); | ||
4498 | 57 | MOCK_METHOD3 (readOptionIntoSetting, Bool (CCSContext *, CCSSetting *, CCSIntegratedSetting *)); | ||
4499 | 58 | MOCK_METHOD3 (writeOptionFromSetting, void (CCSContext *, CCSSetting *, CCSIntegratedSetting *)); | ||
4500 | 59 | MOCK_METHOD2 (updateIntegratedSettings, void (CCSContext *, CCSIntegratedSettingList)); | ||
4501 | 60 | MOCK_METHOD0 (disallowIntegratedWrites, void ()); | ||
4502 | 61 | MOCK_METHOD0 (allowIntegratedWrites, void ()); | ||
4503 | 62 | |||
4504 | 63 | |||
4505 | 64 | CCSIntegrationGMock (CCSIntegration *integration) : | ||
4506 | 65 | mIntegration (integration) | ||
4507 | 66 | { | ||
4508 | 67 | } | ||
4509 | 68 | |||
4510 | 69 | CCSIntegration * | ||
4511 | 70 | getIntegrationBackend () | ||
4512 | 71 | { | ||
4513 | 72 | return mIntegration; | ||
4514 | 73 | } | ||
4515 | 74 | |||
4516 | 75 | public: | ||
4517 | 76 | |||
4518 | 77 | static CCSIntegratedSetting * ccsIntegrationGetIntegratedOptionIndex (CCSIntegration *integration, | ||
4519 | 78 | const char *pluginName, | ||
4520 | 79 | const char *settingName) | ||
4521 | 80 | { | ||
4522 | 81 | return reinterpret_cast <CCSIntegrationGMockInterface *> (ccsObjectGetPrivate (integration))->getIntegratedOptionIndex (pluginName, settingName); | ||
4523 | 82 | } | ||
4524 | 83 | |||
4525 | 84 | static Bool ccsIntegrationReadOptionIntoSetting (CCSIntegration *integration, | ||
4526 | 85 | CCSContext *context, | ||
4527 | 86 | CCSSetting *setting, | ||
4528 | 87 | CCSIntegratedSetting *integrated) | ||
4529 | 88 | { | ||
4530 | 89 | return reinterpret_cast <CCSIntegrationGMockInterface *> (ccsObjectGetPrivate (integration))->readOptionIntoSetting (context, setting, integrated); | ||
4531 | 90 | } | ||
4532 | 91 | |||
4533 | 92 | static void ccsIntegrationWriteSettingIntoOption (CCSIntegration *integration, | ||
4534 | 93 | CCSContext *context, | ||
4535 | 94 | CCSSetting *setting, | ||
4536 | 95 | CCSIntegratedSetting *integrated) | ||
4537 | 96 | { | ||
4538 | 97 | return reinterpret_cast <CCSIntegrationGMockInterface *> (ccsObjectGetPrivate (integration))->writeOptionFromSetting (context, setting, integrated); | ||
4539 | 98 | } | ||
4540 | 99 | |||
4541 | 100 | static void ccsIntegrationUpdateIntegratedSettings (CCSIntegration *integration, | ||
4542 | 101 | CCSContext *context, | ||
4543 | 102 | CCSIntegratedSettingList settingList) | ||
4544 | 103 | { | ||
4545 | 104 | return reinterpret_cast <CCSIntegrationGMockInterface *> (ccsObjectGetPrivate (integration))->updateIntegratedSettings (context, settingList); | ||
4546 | 105 | } | ||
4547 | 106 | |||
4548 | 107 | static void ccsFreeIntegration (CCSIntegration *integration) | ||
4549 | 108 | { | ||
4550 | 109 | ccsMockIntegrationBackendFree (integration); | ||
4551 | 110 | } | ||
4552 | 111 | |||
4553 | 112 | static void ccsIntegrationDisallowIntegratedWrites (CCSIntegration *integration) | ||
4554 | 113 | { | ||
4555 | 114 | reinterpret_cast <CCSIntegrationGMockInterface *> (ccsObjectGetPrivate (integration))->disallowIntegratedWrites (); | ||
4556 | 115 | } | ||
4557 | 116 | |||
4558 | 117 | static void ccsIntegrationAllowIntegratedWrites (CCSIntegration *integration) | ||
4559 | 118 | { | ||
4560 | 119 | reinterpret_cast <CCSIntegrationGMockInterface *> (ccsObjectGetPrivate (integration))->allowIntegratedWrites (); | ||
4561 | 120 | } | ||
4562 | 121 | |||
4563 | 122 | private: | ||
4564 | 123 | |||
4565 | 124 | CCSIntegration *mIntegration; | ||
4566 | 125 | }; | ||
4567 | 126 | |||
4568 | 127 | extern const CCSIntegrationInterface mockIntegrationBackendInterface; | ||
4569 | 128 | |||
4570 | 129 | #endif | ||
4571 | 0 | 130 | ||
4572 | === added file 'compizconfig/tests/CMakeLists.txt' | |||
4573 | --- compizconfig/tests/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
4574 | +++ compizconfig/tests/CMakeLists.txt 2012-09-24 03:58:20 +0000 | |||
4575 | @@ -0,0 +1,71 @@ | |||
4576 | 1 | include_directories (${CMAKE_CURRENT_SOURCE_DIR}/../libcompizconfig/include | ||
4577 | 2 | ${CMAKE_CURRENT_SOURCE_DIR}/../mocks/libcompizconfig | ||
4578 | 3 | ${CMAKE_SOURCE_DIR}/tests/shared | ||
4579 | 4 | ${CMAKE_CURRENT_SOURCE_DIR}) | ||
4580 | 5 | |||
4581 | 6 | add_library (compizconfig_ccs_item_in_list_matcher STATIC | ||
4582 | 7 | ${CMAKE_CURRENT_SOURCE_DIR}/compizconfig_ccs_item_in_list_matcher.cpp) | ||
4583 | 8 | |||
4584 | 9 | target_link_libraries (compizconfig_ccs_item_in_list_matcher | ||
4585 | 10 | ${GTEST_BOTH_LIBRARIES} | ||
4586 | 11 | ${GMOCK_MAIN_LIBRARY} | ||
4587 | 12 | ${GMOCK_LIBRARY} | ||
4588 | 13 | compizconfig) | ||
4589 | 14 | |||
4590 | 15 | add_library (compizconfig_ccs_list_equality STATIC | ||
4591 | 16 | ${CMAKE_CURRENT_SOURCE_DIR}/compizconfig_ccs_list_equality.cpp) | ||
4592 | 17 | |||
4593 | 18 | target_link_libraries (compizconfig_ccs_list_equality | ||
4594 | 19 | ${GTEST_BOTH_LIBRARIES} | ||
4595 | 20 | ${GMOCK_MAIN_LIBRARY} | ||
4596 | 21 | ${GMOCK_LIBRARY} | ||
4597 | 22 | compizconfig) | ||
4598 | 23 | |||
4599 | 24 | add_library (compizconfig_ccs_setting_value_matcher STATIC | ||
4600 | 25 | ${CMAKE_CURRENT_SOURCE_DIR}/compizconfig_ccs_setting_value_matcher.cpp) | ||
4601 | 26 | |||
4602 | 27 | target_link_libraries (compizconfig_ccs_setting_value_matcher | ||
4603 | 28 | ${GTEST_BOTH_LIBRARIES} | ||
4604 | 29 | ${GMOCK_MAIN_LIBRARY} | ||
4605 | 30 | ${GMOCK_LIBRARY} | ||
4606 | 31 | compizconfig) | ||
4607 | 32 | |||
4608 | 33 | add_library (compizconfig_ccs_list_wrapper STATIC | ||
4609 | 34 | ${CMAKE_CURRENT_SOURCE_DIR}/compizconfig_ccs_list_wrapper.cpp) | ||
4610 | 35 | |||
4611 | 36 | target_link_libraries (compizconfig_ccs_list_wrapper | ||
4612 | 37 | ${GTEST_BOTH_LIBRARIES} | ||
4613 | 38 | ${GMOCK_MAIN_LIBRARY} | ||
4614 | 39 | ${GMOCK_LIBRARY} | ||
4615 | 40 | compizconfig) | ||
4616 | 41 | |||
4617 | 42 | add_library (compizconfig_ccs_setting_value_operators STATIC | ||
4618 | 43 | ${CMAKE_CURRENT_SOURCE_DIR}/compizconfig_ccs_setting_value_operators.cpp) | ||
4619 | 44 | |||
4620 | 45 | target_link_libraries (compizconfig_ccs_setting_value_operators | ||
4621 | 46 | ${GTEST_BOTH_LIBRARIES} | ||
4622 | 47 | ${GMOCK_MAIN_LIBRARY} | ||
4623 | 48 | ${GMOCK_LIBRARY} | ||
4624 | 49 | compizconfig) | ||
4625 | 50 | |||
4626 | 51 | add_library (compizconfig_ccs_test_value_combinations STATIC | ||
4627 | 52 | ${CMAKE_CURRENT_SOURCE_DIR}/compizconfig_test_value_combiners.cpp) | ||
4628 | 53 | |||
4629 | 54 | target_link_libraries (compizconfig_ccs_test_value_combinations | ||
4630 | 55 | ${GTEST_BOTH_LIBRARIES} | ||
4631 | 56 | ${GMOCK_MAIN_LIBRARY} | ||
4632 | 57 | ${GMOCK_LIBRARY} | ||
4633 | 58 | compizconfig) | ||
4634 | 59 | |||
4635 | 60 | add_library (compizconfig_ccs_backend_conformance_test STATIC | ||
4636 | 61 | ${CMAKE_CURRENT_SOURCE_DIR}/compizconfig_backend_concept_test.cpp) | ||
4637 | 62 | |||
4638 | 63 | target_link_libraries (compizconfig_ccs_backend_conformance_test | ||
4639 | 64 | ${GTEST_BOTH_LIBRARIES} | ||
4640 | 65 | ${GMOCK_MAIN_LIBRARY} | ||
4641 | 66 | ${GMOCK_LIBRARY} | ||
4642 | 67 | compizconfig | ||
4643 | 68 | compizconfig_ccs_test_value_combinations | ||
4644 | 69 | compizconfig_ccs_setting_value_operators | ||
4645 | 70 | compizconfig_ccs_list_equality | ||
4646 | 71 | compizconfig_ccs_item_in_list_matcher) | ||
4647 | 0 | 72 | ||
4648 | === added file 'compizconfig/tests/compizconfig_backend_concept_test.cpp' | |||
4649 | --- compizconfig/tests/compizconfig_backend_concept_test.cpp 1970-01-01 00:00:00 +0000 | |||
4650 | +++ compizconfig/tests/compizconfig_backend_concept_test.cpp 2012-09-24 03:58:20 +0000 | |||
4651 | @@ -0,0 +1,381 @@ | |||
4652 | 1 | /* | ||
4653 | 2 | * Compiz configuration system library | ||
4654 | 3 | * | ||
4655 | 4 | * Copyright (C) 2012 Canonical Ltd. | ||
4656 | 5 | * | ||
4657 | 6 | * This library is free software; you can redistribute it and/or | ||
4658 | 7 | * modify it under the terms of the GNU Lesser General Public | ||
4659 | 8 | * License as published by the Free Software Foundation; either | ||
4660 | 9 | * version 2.1 of the License, or (at your option) any later version. | ||
4661 | 10 | |||
4662 | 11 | * This library is distributed in the hope that it will be useful, | ||
4663 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
4664 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
4665 | 14 | * Lesser General Public License for more details. | ||
4666 | 15 | |||
4667 | 16 | * You should have received a copy of the GNU Lesser General Public | ||
4668 | 17 | * License along with this library; if not, write to the Free Software | ||
4669 | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
4670 | 19 | * | ||
4671 | 20 | * Authored By: | ||
4672 | 21 | * Sam Spilsbury <sam.spilsbury@canonical.com> | ||
4673 | 22 | */ | ||
4674 | 23 | #include <gtest/gtest.h> | ||
4675 | 24 | #include <gmock/gmock.h> | ||
4676 | 25 | |||
4677 | 26 | #include <gtest_unspecified_bool_type_matcher.h> | ||
4678 | 27 | |||
4679 | 28 | #include <compizconfig_ccs_setting_mock.h> | ||
4680 | 29 | |||
4681 | 30 | #include <boost/function.hpp> | ||
4682 | 31 | #include <boost/bind.hpp> | ||
4683 | 32 | #include <boost/shared_ptr.hpp> | ||
4684 | 33 | #include <boost/make_shared.hpp> | ||
4685 | 34 | |||
4686 | 35 | #include <compizconfig_backend_concept_test_internal.h> | ||
4687 | 36 | #include <compizconfig_backend_concept_test_environment_interface.h> | ||
4688 | 37 | |||
4689 | 38 | using ::testing::NiceMock; | ||
4690 | 39 | using ::testing::Return; | ||
4691 | 40 | using ::testing::ReturnNull; | ||
4692 | 41 | using ::testing::SetArgPointee; | ||
4693 | 42 | using ::testing::DoAll; | ||
4694 | 43 | using ::testing::AtLeast; | ||
4695 | 44 | using ::testing::Eq; | ||
4696 | 45 | |||
4697 | 46 | |||
4698 | 47 | namespace cct = compizconfig::test; | ||
4699 | 48 | |||
4700 | 49 | Bool cct::boolToBool (bool v) | ||
4701 | 50 | { | ||
4702 | 51 | return v ? TRUE : FALSE; | ||
4703 | 52 | } | ||
4704 | 53 | |||
4705 | 54 | cci::SettingValueListWrapper::Ptr | ||
4706 | 55 | cct::CCSListConstructionExpectationsSetter (const cct::ConstructorFunc &c, | ||
4707 | 56 | CCSSettingType type, | ||
4708 | 57 | cci::ListStorageType storageType) | ||
4709 | 58 | { | ||
4710 | 59 | boost::function <void (CCSSetting *)> f (boost::bind (ccsSettingUnref, _1)); | ||
4711 | 60 | boost::shared_ptr <CCSSetting> mockSetting (ccsNiceMockSettingNew (), f); | ||
4712 | 61 | NiceMock <CCSSettingGMock> *gmockSetting = reinterpret_cast <NiceMock <CCSSettingGMock> *> (ccsObjectGetPrivate (mockSetting.get ())); | ||
4713 | 62 | |||
4714 | 63 | ON_CALL (*gmockSetting, getType ()).WillByDefault (Return (TypeList)); | ||
4715 | 64 | |||
4716 | 65 | boost::shared_ptr <CCSSettingInfo> listInfo (new CCSSettingInfo); | ||
4717 | 66 | |||
4718 | 67 | listInfo->forList.listType = type; | ||
4719 | 68 | |||
4720 | 69 | ON_CALL (*gmockSetting, getInfo ()).WillByDefault (Return (listInfo.get ())); | ||
4721 | 70 | ON_CALL (*gmockSetting, getDefaultValue ()).WillByDefault (ReturnNull ()); | ||
4722 | 71 | return boost::make_shared <cci::SettingValueListWrapper> (c (mockSetting.get ()), storageType, type, listInfo, mockSetting); | ||
4723 | 72 | } | ||
4724 | 73 | |||
4725 | 74 | CCSSettingGMock * | ||
4726 | 75 | cct::getSettingGMockFromSetting (const boost::shared_ptr <CCSSetting> &setting) | ||
4727 | 76 | { | ||
4728 | 77 | return reinterpret_cast <CCSSettingGMock *> (ccsObjectGetPrivate (setting.get ())); | ||
4729 | 78 | } | ||
4730 | 79 | |||
4731 | 80 | void | ||
4732 | 81 | cct::SetIntWriteExpectation (const std::string &plugin, | ||
4733 | 82 | const std::string &key, | ||
4734 | 83 | const VariantTypes &value, | ||
4735 | 84 | const boost::shared_ptr <CCSSetting> &setting, | ||
4736 | 85 | const WriteFunc &write, | ||
4737 | 86 | const CCSBackendConceptTestEnvironmentInterface::Ptr &env) | ||
4738 | 87 | { | ||
4739 | 88 | CCSSettingGMock *gmock (getSettingGMockFromSetting (setting)); | ||
4740 | 89 | EXPECT_CALL (*gmock, getInt (_)).WillRepeatedly (DoAll ( | ||
4741 | 90 | SetArgPointee <0> ( | ||
4742 | 91 | boost::get <int> (value)), | ||
4743 | 92 | Return (TRUE))); | ||
4744 | 93 | write (); | ||
4745 | 94 | EXPECT_EQ (env->ReadIntegerAtKey (plugin, key), boost::get <int> (value)); | ||
4746 | 95 | } | ||
4747 | 96 | |||
4748 | 97 | void | ||
4749 | 98 | cct::SetBoolWriteExpectation (const std::string &plugin, | ||
4750 | 99 | const std::string &key, | ||
4751 | 100 | const VariantTypes &value, | ||
4752 | 101 | const boost::shared_ptr <CCSSetting> &setting, | ||
4753 | 102 | const WriteFunc &write, | ||
4754 | 103 | const CCSBackendConceptTestEnvironmentInterface::Ptr &env) | ||
4755 | 104 | { | ||
4756 | 105 | CCSSettingGMock *gmock (getSettingGMockFromSetting (setting)); | ||
4757 | 106 | EXPECT_CALL (*gmock, getBool (_)).WillRepeatedly (DoAll ( | ||
4758 | 107 | SetArgPointee <0> ( | ||
4759 | 108 | boolToBool (boost::get <bool> (value))), | ||
4760 | 109 | Return (TRUE))); | ||
4761 | 110 | write (); | ||
4762 | 111 | |||
4763 | 112 | bool v (boost::get <bool> (value)); | ||
4764 | 113 | |||
4765 | 114 | if (v) | ||
4766 | 115 | EXPECT_THAT (env->ReadBoolAtKey (plugin, key), IsTrue ()); | ||
4767 | 116 | else | ||
4768 | 117 | EXPECT_THAT (env->ReadBoolAtKey (plugin, key), IsFalse ()); | ||
4769 | 118 | } | ||
4770 | 119 | |||
4771 | 120 | void | ||
4772 | 121 | cct::SetFloatWriteExpectation (const std::string &plugin, | ||
4773 | 122 | const std::string &key, | ||
4774 | 123 | const VariantTypes &value, | ||
4775 | 124 | const boost::shared_ptr <CCSSetting> &setting, | ||
4776 | 125 | const WriteFunc &write, | ||
4777 | 126 | const CCSBackendConceptTestEnvironmentInterface::Ptr &env) | ||
4778 | 127 | { | ||
4779 | 128 | CCSSettingGMock *gmock (getSettingGMockFromSetting (setting)); | ||
4780 | 129 | EXPECT_CALL (*gmock, getFloat (_)).WillRepeatedly (DoAll ( | ||
4781 | 130 | SetArgPointee <0> ( | ||
4782 | 131 | boost::get <float> (value)), | ||
4783 | 132 | Return (TRUE))); | ||
4784 | 133 | write (); | ||
4785 | 134 | EXPECT_EQ (env->ReadFloatAtKey (plugin, key), boost::get <float> (value)); | ||
4786 | 135 | } | ||
4787 | 136 | |||
4788 | 137 | void | ||
4789 | 138 | cct::SetStringWriteExpectation (const std::string &plugin, | ||
4790 | 139 | const std::string &key, | ||
4791 | 140 | const VariantTypes &value, | ||
4792 | 141 | const boost::shared_ptr <CCSSetting> &setting, | ||
4793 | 142 | const WriteFunc &write, | ||
4794 | 143 | const CCSBackendConceptTestEnvironmentInterface::Ptr &env) | ||
4795 | 144 | { | ||
4796 | 145 | CCSSettingGMock *gmock (getSettingGMockFromSetting (setting)); | ||
4797 | 146 | EXPECT_CALL (*gmock, getString (_)).WillRepeatedly (DoAll ( | ||
4798 | 147 | SetArgPointee <0> ( | ||
4799 | 148 | const_cast <char *> (boost::get <const char *> (value))), | ||
4800 | 149 | Return (TRUE))); | ||
4801 | 150 | write (); | ||
4802 | 151 | EXPECT_EQ (std::string (env->ReadStringAtKey (plugin, key)), std::string (boost::get <const char *> (value))); | ||
4803 | 152 | } | ||
4804 | 153 | |||
4805 | 154 | void | ||
4806 | 155 | cct::SetColorWriteExpectation (const std::string &plugin, | ||
4807 | 156 | const std::string &key, | ||
4808 | 157 | const VariantTypes &value, | ||
4809 | 158 | const boost::shared_ptr <CCSSetting> &setting, | ||
4810 | 159 | const WriteFunc &write, | ||
4811 | 160 | const CCSBackendConceptTestEnvironmentInterface::Ptr &env) | ||
4812 | 161 | { | ||
4813 | 162 | CCSSettingGMock *gmock (getSettingGMockFromSetting (setting)); | ||
4814 | 163 | EXPECT_CALL (*gmock, getColor (_)).WillRepeatedly (DoAll ( | ||
4815 | 164 | SetArgPointee <0> ( | ||
4816 | 165 | boost::get <CCSSettingColorValue> (value)), | ||
4817 | 166 | Return (TRUE))); | ||
4818 | 167 | write (); | ||
4819 | 168 | |||
4820 | 169 | EXPECT_EQ (env->ReadColorAtKey (plugin, key), boost::get <CCSSettingColorValue> (value)); | ||
4821 | 170 | } | ||
4822 | 171 | |||
4823 | 172 | void | ||
4824 | 173 | cct::SetKeyWriteExpectation (const std::string &plugin, | ||
4825 | 174 | const std::string &key, | ||
4826 | 175 | const VariantTypes &value, | ||
4827 | 176 | const boost::shared_ptr <CCSSetting> &setting, | ||
4828 | 177 | const WriteFunc &write, | ||
4829 | 178 | const CCSBackendConceptTestEnvironmentInterface::Ptr &env) | ||
4830 | 179 | { | ||
4831 | 180 | CCSSettingGMock *gmock (getSettingGMockFromSetting (setting)); | ||
4832 | 181 | EXPECT_CALL (*gmock, getKey (_)).WillRepeatedly (DoAll ( | ||
4833 | 182 | SetArgPointee <0> ( | ||
4834 | 183 | boost::get <CCSSettingKeyValue> (value)), | ||
4835 | 184 | Return (TRUE))); | ||
4836 | 185 | write (); | ||
4837 | 186 | EXPECT_EQ (env->ReadKeyAtKey (plugin, key), boost::get <CCSSettingKeyValue> (value)); | ||
4838 | 187 | } | ||
4839 | 188 | |||
4840 | 189 | void | ||
4841 | 190 | cct::SetButtonWriteExpectation (const std::string &plugin, | ||
4842 | 191 | const std::string &key, | ||
4843 | 192 | const VariantTypes &value, | ||
4844 | 193 | const boost::shared_ptr <CCSSetting> &setting, | ||
4845 | 194 | const WriteFunc &write, | ||
4846 | 195 | const CCSBackendConceptTestEnvironmentInterface::Ptr &env) | ||
4847 | 196 | { | ||
4848 | 197 | CCSSettingGMock *gmock (getSettingGMockFromSetting (setting)); | ||
4849 | 198 | EXPECT_CALL (*gmock, getButton (_)).WillRepeatedly (DoAll ( | ||
4850 | 199 | SetArgPointee <0> ( | ||
4851 | 200 | boost::get <CCSSettingButtonValue> (value)), | ||
4852 | 201 | Return (TRUE))); | ||
4853 | 202 | write (); | ||
4854 | 203 | EXPECT_EQ (env->ReadButtonAtKey (plugin, key), boost::get <CCSSettingButtonValue> (value)); | ||
4855 | 204 | } | ||
4856 | 205 | |||
4857 | 206 | void | ||
4858 | 207 | cct::SetEdgeWriteExpectation (const std::string &plugin, | ||
4859 | 208 | const std::string &key, | ||
4860 | 209 | const VariantTypes &value, | ||
4861 | 210 | const boost::shared_ptr <CCSSetting> &setting, | ||
4862 | 211 | const WriteFunc &write, | ||
4863 | 212 | const CCSBackendConceptTestEnvironmentInterface::Ptr &env) | ||
4864 | 213 | { | ||
4865 | 214 | CCSSettingGMock *gmock (getSettingGMockFromSetting (setting)); | ||
4866 | 215 | EXPECT_CALL (*gmock, getEdge (_)).WillRepeatedly (DoAll ( | ||
4867 | 216 | SetArgPointee <0> ( | ||
4868 | 217 | boost::get <unsigned int> (value)), | ||
4869 | 218 | Return (TRUE))); | ||
4870 | 219 | write (); | ||
4871 | 220 | EXPECT_EQ (env->ReadEdgeAtKey (plugin, key), boost::get <unsigned int> (value)); | ||
4872 | 221 | } | ||
4873 | 222 | |||
4874 | 223 | void | ||
4875 | 224 | cct::SetBellWriteExpectation (const std::string &plugin, | ||
4876 | 225 | const std::string &key, | ||
4877 | 226 | const VariantTypes &value, | ||
4878 | 227 | const boost::shared_ptr <CCSSetting> &setting, | ||
4879 | 228 | const WriteFunc &write, | ||
4880 | 229 | const CCSBackendConceptTestEnvironmentInterface::Ptr &env) | ||
4881 | 230 | { | ||
4882 | 231 | CCSSettingGMock *gmock (getSettingGMockFromSetting (setting)); | ||
4883 | 232 | EXPECT_CALL (*gmock, getBell (_)).WillRepeatedly (DoAll ( | ||
4884 | 233 | SetArgPointee <0> ( | ||
4885 | 234 | boolToBool (boost::get <bool> (value))), | ||
4886 | 235 | Return (TRUE))); | ||
4887 | 236 | write (); | ||
4888 | 237 | bool v (boost::get <bool> (value)); | ||
4889 | 238 | |||
4890 | 239 | if (v) | ||
4891 | 240 | EXPECT_THAT (env->ReadBellAtKey (plugin, key), IsTrue ()); | ||
4892 | 241 | else | ||
4893 | 242 | EXPECT_THAT (env->ReadBellAtKey (plugin, key), IsFalse ()); | ||
4894 | 243 | } | ||
4895 | 244 | |||
4896 | 245 | void | ||
4897 | 246 | cct::SetMatchWriteExpectation (const std::string &plugin, | ||
4898 | 247 | const std::string &key, | ||
4899 | 248 | const VariantTypes &value, | ||
4900 | 249 | const boost::shared_ptr <CCSSetting> &setting, | ||
4901 | 250 | const WriteFunc &write, | ||
4902 | 251 | const CCSBackendConceptTestEnvironmentInterface::Ptr &env) | ||
4903 | 252 | { | ||
4904 | 253 | CCSSettingGMock *gmock (getSettingGMockFromSetting (setting)); | ||
4905 | 254 | EXPECT_CALL (*gmock, getMatch (_)).WillRepeatedly (DoAll ( | ||
4906 | 255 | SetArgPointee <0> ( | ||
4907 | 256 | const_cast <char *> ( | ||
4908 | 257 | boost::get <const char *> ( | ||
4909 | 258 | value))), | ||
4910 | 259 | Return (TRUE))); | ||
4911 | 260 | write (); | ||
4912 | 261 | EXPECT_EQ (std::string (env->ReadMatchAtKey (plugin, key)), | ||
4913 | 262 | std::string (boost::get <const char *> (value))); | ||
4914 | 263 | } | ||
4915 | 264 | |||
4916 | 265 | void | ||
4917 | 266 | cct::SetListWriteExpectation (const std::string &plugin, | ||
4918 | 267 | const std::string &key, | ||
4919 | 268 | const VariantTypes &value, | ||
4920 | 269 | const boost::shared_ptr <CCSSetting> &setting, | ||
4921 | 270 | const WriteFunc &write, | ||
4922 | 271 | const CCSBackendConceptTestEnvironmentInterface::Ptr &env) | ||
4923 | 272 | { | ||
4924 | 273 | CCSSettingGMock *gmock (getSettingGMockFromSetting (setting)); | ||
4925 | 274 | CCSSettingValueList list = *(boost::get <boost::shared_ptr <cci::SettingValueListWrapper> > (value)); | ||
4926 | 275 | |||
4927 | 276 | EXPECT_CALL (*gmock, getInfo ()); | ||
4928 | 277 | |||
4929 | 278 | CCSSettingInfo *info = ccsSettingGetInfo (setting.get ()); | ||
4930 | 279 | info->forList.listType = | ||
4931 | 280 | (boost::get <boost::shared_ptr <cci::SettingValueListWrapper> > (value))->type (); | ||
4932 | 281 | |||
4933 | 282 | EXPECT_CALL (*gmock, getInfo ()).Times (AtLeast (1)); | ||
4934 | 283 | EXPECT_CALL (*gmock, getList (_)).WillRepeatedly (DoAll ( | ||
4935 | 284 | SetArgPointee <0> ( | ||
4936 | 285 | list), | ||
4937 | 286 | Return (TRUE))); | ||
4938 | 287 | write (); | ||
4939 | 288 | |||
4940 | 289 | EXPECT_THAT (cci::SettingValueListWrapper (env->ReadListAtKey (plugin, key, setting.get ()), | ||
4941 | 290 | cci::Deep, | ||
4942 | 291 | info->forList.listType, | ||
4943 | 292 | boost::shared_ptr <CCSSettingInfo> (), | ||
4944 | 293 | setting), | ||
4945 | 294 | ListEqual (&info->forList, list)); | ||
4946 | 295 | } | ||
4947 | 296 | |||
4948 | 297 | void | ||
4949 | 298 | cct::SetIntReadExpectation (CCSSettingGMock *gmock, const VariantTypes &value) | ||
4950 | 299 | { | ||
4951 | 300 | EXPECT_CALL (*gmock, setInt (boost::get <int> (value), _)); | ||
4952 | 301 | } | ||
4953 | 302 | |||
4954 | 303 | void | ||
4955 | 304 | cct::SetBoolReadExpectation (CCSSettingGMock *gmock, const VariantTypes &value) | ||
4956 | 305 | { | ||
4957 | 306 | bool v (boost::get <bool> (value)); | ||
4958 | 307 | |||
4959 | 308 | if (v) | ||
4960 | 309 | EXPECT_CALL (*gmock, setBool (IsTrue (), _)); | ||
4961 | 310 | else | ||
4962 | 311 | EXPECT_CALL (*gmock, setBool (IsFalse (), _)); | ||
4963 | 312 | } | ||
4964 | 313 | |||
4965 | 314 | void | ||
4966 | 315 | cct::SetBellReadExpectation (CCSSettingGMock *gmock, const VariantTypes &value) | ||
4967 | 316 | { | ||
4968 | 317 | bool v (boost::get <bool> (value)); | ||
4969 | 318 | |||
4970 | 319 | if (v) | ||
4971 | 320 | EXPECT_CALL (*gmock, setBell (IsTrue (), _)); | ||
4972 | 321 | else | ||
4973 | 322 | EXPECT_CALL (*gmock, setBell (IsFalse (), _)); | ||
4974 | 323 | } | ||
4975 | 324 | |||
4976 | 325 | void | ||
4977 | 326 | cct::SetFloatReadExpectation (CCSSettingGMock *gmock, const VariantTypes &value) | ||
4978 | 327 | { | ||
4979 | 328 | EXPECT_CALL (*gmock, setFloat (boost::get <float> (value), _)); | ||
4980 | 329 | } | ||
4981 | 330 | |||
4982 | 331 | void | ||
4983 | 332 | cct::SetStringReadExpectation (CCSSettingGMock *gmock, const VariantTypes &value) | ||
4984 | 333 | { | ||
4985 | 334 | EXPECT_CALL (*gmock, setString (Eq (std::string (boost::get <const char *> (value))), _)); | ||
4986 | 335 | } | ||
4987 | 336 | |||
4988 | 337 | void | ||
4989 | 338 | cct::SetMatchReadExpectation (CCSSettingGMock *gmock, const VariantTypes &value) | ||
4990 | 339 | { | ||
4991 | 340 | EXPECT_CALL (*gmock, setMatch (Eq (std::string (boost::get <const char *> (value))), _)); | ||
4992 | 341 | } | ||
4993 | 342 | |||
4994 | 343 | void | ||
4995 | 344 | cct::SetColorReadExpectation (CCSSettingGMock *gmock, const VariantTypes &value) | ||
4996 | 345 | { | ||
4997 | 346 | EXPECT_CALL (*gmock, setColor (boost::get <CCSSettingColorValue> (value), _)); | ||
4998 | 347 | } | ||
4999 | 348 | |||
5000 | 349 | void |
FAILED: Continuous integration, rev:3389 jenkins. qa.ubuntu. com/job/ compiz- ci/96/ jenkins. qa.ubuntu. com/job/ compiz- ci/./build= pbuilder, distribution= quantal, flavor= amd64/96/ console
http://
Executed test runs:
FAILURE: http://