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