Merge lp:~compiz-team/compiz/compiz.tests_1041535 into lp:compiz/0.9.8

Proposed by Sam Spilsbury
Status: Superseded
Proposed branch: lp:~compiz-team/compiz/compiz.tests_1041535
Merge into: lp:compiz/0.9.8
Prerequisite: lp:~compiz-team/compiz/compiz.tests_1042537.3
Diff against target: 7931 lines (+5072/-1295)
76 files modified
compizconfig/CMakeLists.txt (+1/-0)
compizconfig/gsettings/CMakeLists.txt (+2/-0)
compizconfig/gsettings/gsettings_backend_shared/CMakeLists.txt (+0/-1)
compizconfig/gsettings/gsettings_backend_shared/ccs_gsettings_backend.c (+0/-23)
compizconfig/gsettings/gsettings_backend_shared/ccs_gsettings_backend_interface.c (+23/-0)
compizconfig/gsettings/mocks/CMakeLists.txt (+21/-0)
compizconfig/gsettings/tests/CMakeLists.txt (+19/-10)
compizconfig/gsettings/tests/compizconfig_ccs_gsettings_settings_env_test.cpp (+364/-0)
compizconfig/gsettings/tests/compizconfig_ccs_gsettings_settings_env_test.h (+134/-0)
compizconfig/gsettings/tests/gsettings-mock-schemas-config.h.in (+2/-0)
compizconfig/gsettings/tests/gsettings_settings_test_fixture.h (+29/-0)
compizconfig/gsettings/tests/test_gsettings_conformance.cpp (+25/-430)
compizconfig/gsettings/tests/test_gsettings_tests.h (+57/-14)
compizconfig/integration/gnome/CMakeLists.txt (+2/-0)
compizconfig/integration/gnome/gconf/src/ccs_gnome_integration_gconf_integrated_setting.c (+18/-3)
compizconfig/integration/gnome/gsettings/CMakeLists.txt (+2/-0)
compizconfig/integration/gnome/gsettings/src/ccs_gnome_integration_gsettings_integrated_setting.c (+62/-22)
compizconfig/integration/gnome/gsettings/tests/CMakeLists.txt (+31/-0)
compizconfig/integration/gnome/gsettings/tests/compizconfig_test_ccs_gnome_gsettings_integrated_setting.cpp (+388/-0)
compizconfig/integration/gnome/include/ccs_gnome_integrated_setting.h (+9/-1)
compizconfig/integration/gnome/include/ccs_gnome_integration_constants.h (+1/-0)
compizconfig/integration/gnome/include/ccs_gnome_integration_types.h (+2/-0)
compizconfig/integration/gnome/include/ccs_gnome_integration_types.h~ (+0/-26)
compizconfig/integration/gnome/src/ccs_gnome_integrated_setting.c (+18/-3)
compizconfig/integration/gnome/src/ccs_gnome_integration.c (+13/-10)
compizconfig/integration/gnome/tests/CMakeLists.txt (+47/-0)
compizconfig/integration/gnome/tests/compizconfig_ccs_mock_gnome_integrated_setting_composition.c (+222/-0)
compizconfig/integration/gnome/tests/compizconfig_ccs_mock_gnome_integrated_setting_composition.h (+42/-0)
compizconfig/integration/gnome/tests/compizconfig_test_ccs_gnome_integration.cpp (+813/-0)
compizconfig/libcompizconfig/src/main.c (+2/-2)
compizconfig/libcompizconfig/tests/CMakeLists.txt (+9/-1)
compizconfig/libcompizconfig/tests/compizconfig_test_ccs_mock_backend_conformance.cpp (+22/-10)
compizconfig/libcompizconfig/tests/compizconfig_test_ccs_settings_upgrade_internal.cpp (+13/-65)
compizconfig/mocks/libcompizconfig/CMakeLists.txt (+40/-0)
compizconfig/mocks/libcompizconfig/compizconfig_ccs_integrated_setting_factory_mock.cpp (+70/-0)
compizconfig/mocks/libcompizconfig/compizconfig_ccs_integrated_setting_factory_mock.h (+99/-0)
compizconfig/mocks/libcompizconfig/compizconfig_ccs_integrated_setting_mock.cpp (+71/-0)
compizconfig/mocks/libcompizconfig/compizconfig_ccs_integrated_setting_mock.h (+97/-0)
compizconfig/mocks/libcompizconfig/compizconfig_ccs_integrated_setting_storage_mock.cpp (+73/-0)
compizconfig/mocks/libcompizconfig/compizconfig_ccs_integrated_setting_storage_mock.h (+119/-0)
compizconfig/mocks/libcompizconfig/compizconfig_ccs_integration_mock.cpp (+70/-0)
compizconfig/mocks/libcompizconfig/compizconfig_ccs_integration_mock.h (+129/-0)
compizconfig/tests/CMakeLists.txt (+71/-0)
compizconfig/tests/compizconfig_backend_concept_test.cpp (+381/-0)
compizconfig/tests/compizconfig_backend_concept_test.h (+144/-189)
compizconfig/tests/compizconfig_backend_concept_test_environment_interface.h (+101/-0)
compizconfig/tests/compizconfig_backend_concept_test_internal.h (+146/-0)
compizconfig/tests/compizconfig_ccs_item_in_list_matcher.cpp (+36/-0)
compizconfig/tests/compizconfig_ccs_item_in_list_matcher.h (+8/-13)
compizconfig/tests/compizconfig_ccs_list_equality.cpp (+74/-0)
compizconfig/tests/compizconfig_ccs_list_equality.h (+15/-29)
compizconfig/tests/compizconfig_ccs_list_wrapper.cpp (+109/-0)
compizconfig/tests/compizconfig_ccs_list_wrapper.h (+0/-199)
compizconfig/tests/compizconfig_ccs_setting_value_matcher.cpp (+69/-0)
compizconfig/tests/compizconfig_ccs_setting_value_matcher.h (+64/-0)
compizconfig/tests/compizconfig_ccs_setting_value_operators.cpp (+103/-0)
compizconfig/tests/compizconfig_ccs_setting_value_operators.h (+17/-52)
compizconfig/tests/compizconfig_ccs_settings_test_fixture.h (+106/-0)
compizconfig/tests/compizconfig_ccs_variant_types.h (+40/-0)
compizconfig/tests/compizconfig_test_value_combiners.cpp (+147/-0)
compizconfig/tests/compizconfig_test_value_combiners.h (+17/-82)
gtk/window-decorator/tests/CMakeLists.txt (+3/-1)
gtk/window-decorator/tests/test_gwd_metacity_decorations.cpp (+2/-3)
gtk/window-decorator/tests/test_gwd_settings.cpp (+65/-83)
plugins/composite/CMakeLists.txt (+5/-4)
plugins/decor/CMakeLists.txt (+4/-2)
plugins/expo/CMakeLists.txt (+4/-3)
plugins/grid/CMakeLists.txt (+5/-4)
plugins/place/CMakeLists.txt (+8/-6)
plugins/resize/CMakeLists.txt (+4/-2)
plugins/wall/CMakeLists.txt (+4/-2)
tests/shared/glib/glib_gsettings_memory_backend_env.h (+45/-0)
tests/shared/glib/glib_gslice_off_env.h (+43/-0)
tests/shared/gtest_shared_autodestroy.h (+20/-0)
tests/shared/gtest_shared_characterwrapper.h (+21/-0)
tests/shared/gtest_unspecified_bool_type_matcher.h (+30/-0)
To merge this branch: bzr merge lp:~compiz-team/compiz/compiz.tests_1041535
Reviewer Review Type Date Requested Status
Daniel van Vugt Needs Fixing
jenkins (community) continuous-integration Needs Fixing
Review via email: mp+125886@code.launchpad.net

This proposal has been superseded by a proposal from 2012-09-24.

Commit message

Increased test coverage on CCSGSettingsIntegratedSetting and CCSGNOMEIntegration. Added mocks where appropriate, split out the matcher used in the previous branch. Mostly fixed bug 1049169

Description of the change

Increased test coverage on CCSGSettingsIntegratedSetting and CCSGNOMEIntegration. Added mocks where appropriate, split out the matcher used in the previous branch and added the following tests:

        Start 238: CCSGSettingsIntegratedSettingTestMismatchedValues/CCSGSettingsIntegratedSettingTest.MatchedTypesReturnValueMismatchedTypesReturnNull/0
238/582 Test #238: CCSGSettingsIntegratedSettingTestMismatchedValues/CCSGSettingsIntegratedSettingTest.MatchedTypesReturnValueMismatchedTypesReturnNull/0 ...................... Passed 0.02 sec
        Start 239: CCSGSettingsIntegratedSettingTestMismatchedValues/CCSGSettingsIntegratedSettingTest.MatchedTypesReturnValueMismatchedTypesReturnNull/1
239/582 Test #239: CCSGSettingsIntegratedSettingTestMismatchedValues/CCSGSettingsIntegratedSettingTest.MatchedTypesReturnValueMismatchedTypesReturnNull/1 ...................... Passed 0.01 sec
        Start 240: CCSGSettingsIntegratedSettingTestMismatchedValues/CCSGSettingsIntegratedSettingTest.MatchedTypesReturnValueMismatchedTypesReturnNull/2
240/582 Test #240: CCSGSettingsIntegratedSettingTestMismatchedValues/CCSGSettingsIntegratedSettingTest.MatchedTypesReturnValueMismatchedTypesReturnNull/2 ...................... Passed 0.01 sec
        Start 241: CCSGSettingsIntegratedSettingTestMismatchedValues/CCSGSettingsIntegratedSettingTest.MatchedTypesReturnValueMismatchedTypesReturnNull/3
241/582 Test #241: CCSGSettingsIntegratedSettingTestMismatchedValues/CCSGSettingsIntegratedSettingTest.MatchedTypesReturnValueMismatchedTypesReturnNull/3 ...................... Passed 0.01 sec
        Start 242: CCSGSettingsIntegratedSettingTestMismatchedValues/CCSGSettingsIntegratedSettingTest.MatchedTypesReturnValueMismatchedTypesReturnNull/4
242/582 Test #242: CCSGSettingsIntegratedSettingTestMismatchedValues/CCSGSettingsIntegratedSettingTest.MatchedTypesReturnValueMismatchedTypesReturnNull/4 ...................... Passed 0.01 sec
        Start 243: CCSGSettingsIntegratedSettingTestMismatchedValues/CCSGSettingsIntegratedSettingTest.MatchedTypesReturnValueMismatchedTypesReturnNull/5
243/582 Test #243: CCSGSettingsIntegratedSettingTestMismatchedValues/CCSGSettingsIntegratedSettingTest.MatchedTypesReturnValueMismatchedTypesReturnNull/5 ...................... Passed 0.01 sec
        Start 244: CCSGSettingsIntegratedSettingTestMismatchedValues/CCSGSettingsIntegratedSettingTest.MatchedTypesReturnValueMismatchedTypesReturnNull/6
244/582 Test #244: CCSGSettingsIntegratedSettingTestMismatchedValues/CCSGSettingsIntegratedSettingTest.MatchedTypesReturnValueMismatchedTypesReturnNull/6 ...................... Passed 0.01 sec
        Start 245: CCSGSettingsIntegratedSettingTestMismatchedValues/CCSGSettingsIntegratedSettingTest.MatchedTypesReturnValueMismatchedTypesReturnNull/7
245/582 Test #245: CCSGSettingsIntegratedSettingTestMismatchedValues/CCSGSettingsIntegratedSettingTest.MatchedTypesReturnValueMismatchedTypesReturnNull/7 ...................... Passed 0.01 sec
        Start 246: CCSGSettingsIntegratedSettingTestMismatchedValues/CCSGSettingsIntegratedSettingTest.MatchedTypesReturnValueMismatchedTypesReturnNull/8
246/582 Test #246: CCSGSettingsIntegratedSettingTestMismatchedValues/CCSGSettingsIntegratedSettingTest.MatchedTypesReturnValueMismatchedTypesReturnNull/8 ...................... Passed 0.01 sec
        Start 247: CCSGSettingsIntegratedSettingTestMismatchedValues/CCSGSettingsIntegratedSettingTest.MatchedTypesReturnValueMismatchedTypesReturnNull/9
247/582 Test #247: CCSGSettingsIntegratedSettingTestMismatchedValues/CCSGSettingsIntegratedSettingTest.MatchedTypesReturnValueMismatchedTypesReturnNull/9 ...................... Passed 0.01 sec
        Start 248: CCSGSettingsIntegratedSettingTestMismatchedValues/CCSGSettingsIntegratedSettingTest.MatchedTypesReturnValueMismatchedTypesReturnNull/10
248/582 Test #248: CCSGSettingsIntegratedSettingTestMismatchedValues/CCSGSettingsIntegratedSettingTest.MatchedTypesReturnValueMismatchedTypesReturnNull/10 ..................... Passed 0.01 sec
        Start 249: CCSGSettingsIntegratedSettingTestMismatchedValues/CCSGSettingsIntegratedSettingTest.MatchedTypesReturnValueMismatchedTypesReturnNull/11
249/582 Test #249: CCSGSettingsIntegratedSettingTestMismatchedValues/CCSGSettingsIntegratedSettingTest.MatchedTypesReturnValueMismatchedTypesReturnNull/11 ..................... Passed 0.01 sec
        Start 250: CCSGSettingsIntegratedSettingTestMismatchedValues/CCSGSettingsIntegratedSettingTest.MatchedTypesReturnValueMismatchedTypesReturnNull/12
250/582 Test #250: CCSGSettingsIntegratedSettingTestMismatchedValues/CCSGSettingsIntegratedSettingTest.MatchedTypesReturnValueMismatchedTypesReturnNull/12 ..................... Passed 0.01 sec
        Start 251: CCSGSettingsIntegratedSettingTestMismatchedValues/CCSGSettingsIntegratedSettingTest.MatchedTypesReturnValueMismatchedTypesReturnNull/13
251/582 Test #251: CCSGSettingsIntegratedSettingTestMismatchedValues/CCSGSettingsIntegratedSettingTest.MatchedTypesReturnValueMismatchedTypesReturnNull/13 ..................... Passed 0.01 sec
        Start 252: CCSGSettingsIntegratedSettingTestMismatchedValues/CCSGSettingsIntegratedSettingTest.MatchedTypesReturnValueMismatchedTypesReturnNull/14
252/582 Test #252: CCSGSettingsIntegratedSettingTestMismatchedValues/CCSGSettingsIntegratedSettingTest.MatchedTypesReturnValueMismatchedTypesReturnNull/14 ..................... Passed 0.01 sec
        Start 253: CCSGSettingsIntegratedSettingTestMismatchedValues/CCSGSettingsIntegratedSettingTest.MatchedTypesReturnValueMismatchedTypesReturnNull/15
253/582 Test #253: CCSGSettingsIntegratedSettingTestMismatchedValues/CCSGSettingsIntegratedSettingTest.MatchedTypesReturnValueMismatchedTypesReturnNull/15 ..................... Passed 0.01 sec
        Start 254: CCSGSettingsIntegratedSettingTestMismatchedValues/CCSGSettingsIntegratedSettingTest.MatchedTypesReturnValueMismatchedTypesResetOrWrite/0
254/582 Test #254: CCSGSettingsIntegratedSettingTestMismatchedValues/CCSGSettingsIntegratedSettingTest.MatchedTypesReturnValueMismatchedTypesResetOrWrite/0 .................... Passed 0.01 sec
        Start 255: CCSGSettingsIntegratedSettingTestMismatchedValues/CCSGSettingsIntegratedSettingTest.MatchedTypesReturnValueMismatchedTypesResetOrWrite/1
255/582 Test #255: CCSGSettingsIntegratedSettingTestMismatchedValues/CCSGSettingsIntegratedSettingTest.MatchedTypesReturnValueMismatchedTypesResetOrWrite/1 .................... Passed 0.01 sec
        Start 256: CCSGSettingsIntegratedSettingTestMismatchedValues/CCSGSettingsIntegratedSettingTest.MatchedTypesReturnValueMismatchedTypesResetOrWrite/2
256/582 Test #256: CCSGSettingsIntegratedSettingTestMismatchedValues/CCSGSettingsIntegratedSettingTest.MatchedTypesReturnValueMismatchedTypesResetOrWrite/2 .................... Passed 0.01 sec
        Start 257: CCSGSettingsIntegratedSettingTestMismatchedValues/CCSGSettingsIntegratedSettingTest.MatchedTypesReturnValueMismatchedTypesResetOrWrite/3
257/582 Test #257: CCSGSettingsIntegratedSettingTestMismatchedValues/CCSGSettingsIntegratedSettingTest.MatchedTypesReturnValueMismatchedTypesResetOrWrite/3 .................... Passed 0.01 sec
        Start 258: CCSGSettingsIntegratedSettingTestMismatchedValues/CCSGSettingsIntegratedSettingTest.MatchedTypesReturnValueMismatchedTypesResetOrWrite/4
258/582 Test #258: CCSGSettingsIntegratedSettingTestMismatchedValues/CCSGSettingsIntegratedSettingTest.MatchedTypesReturnValueMismatchedTypesResetOrWrite/4 .................... Passed 0.01 sec
        Start 259: CCSGSettingsIntegratedSettingTestMismatchedValues/CCSGSettingsIntegratedSettingTest.MatchedTypesReturnValueMismatchedTypesResetOrWrite/5
259/582 Test #259: CCSGSettingsIntegratedSettingTestMismatchedValues/CCSGSettingsIntegratedSettingTest.MatchedTypesReturnValueMismatchedTypesResetOrWrite/5 .................... Passed 0.01 sec
        Start 260: CCSGSettingsIntegratedSettingTestMismatchedValues/CCSGSettingsIntegratedSettingTest.MatchedTypesReturnValueMismatchedTypesResetOrWrite/6
260/582 Test #260: CCSGSettingsIntegratedSettingTestMismatchedValues/CCSGSettingsIntegratedSettingTest.MatchedTypesReturnValueMismatchedTypesResetOrWrite/6 .................... Passed 0.01 sec
        Start 261: CCSGSettingsIntegratedSettingTestMismatchedValues/CCSGSettingsIntegratedSettingTest.MatchedTypesReturnValueMismatchedTypesResetOrWrite/7
261/582 Test #261: CCSGSettingsIntegratedSettingTestMismatchedValues/CCSGSettingsIntegratedSettingTest.MatchedTypesReturnValueMismatchedTypesResetOrWrite/7 .................... Passed 0.01 sec
        Start 262: CCSGSettingsIntegratedSettingTestMismatchedValues/CCSGSettingsIntegratedSettingTest.MatchedTypesReturnValueMismatchedTypesResetOrWrite/8
262/582 Test #262: CCSGSettingsIntegratedSettingTestMismatchedValues/CCSGSettingsIntegratedSettingTest.MatchedTypesReturnValueMismatchedTypesResetOrWrite/8 .................... Passed 0.01 sec
        Start 263: CCSGSettingsIntegratedSettingTestMismatchedValues/CCSGSettingsIntegratedSettingTest.MatchedTypesReturnValueMismatchedTypesResetOrWrite/9
263/582 Test #263: CCSGSettingsIntegratedSettingTestMismatchedValues/CCSGSettingsIntegratedSettingTest.MatchedTypesReturnValueMismatchedTypesResetOrWrite/9 .................... Passed 0.01 sec
        Start 264: CCSGSettingsIntegratedSettingTestMismatchedValues/CCSGSettingsIntegratedSettingTest.MatchedTypesReturnValueMismatchedTypesResetOrWrite/10
264/582 Test #264: CCSGSettingsIntegratedSettingTestMismatchedValues/CCSGSettingsIntegratedSettingTest.MatchedTypesReturnValueMismatchedTypesResetOrWrite/10 ................... Passed 0.01 sec
        Start 265: CCSGSettingsIntegratedSettingTestMismatchedValues/CCSGSettingsIntegratedSettingTest.MatchedTypesReturnValueMismatchedTypesResetOrWrite/11
265/582 Test #265: CCSGSettingsIntegratedSettingTestMismatchedValues/CCSGSettingsIntegratedSettingTest.MatchedTypesReturnValueMismatchedTypesResetOrWrite/11 ................... Passed 0.01 sec
        Start 266: CCSGSettingsIntegratedSettingTestMismatchedValues/CCSGSettingsIntegratedSettingTest.MatchedTypesReturnValueMismatchedTypesResetOrWrite/12
266/582 Test #266: CCSGSettingsIntegratedSettingTestMismatchedValues/CCSGSettingsIntegratedSettingTest.MatchedTypesReturnValueMismatchedTypesResetOrWrite/12 ................... Passed 0.01 sec
        Start 267: CCSGSettingsIntegratedSettingTestMismatchedValues/CCSGSettingsIntegratedSettingTest.MatchedTypesReturnValueMismatchedTypesResetOrWrite/13
267/582 Test #267: CCSGSettingsIntegratedSettingTestMismatchedValues/CCSGSettingsIntegratedSettingTest.MatchedTypesReturnValueMismatchedTypesResetOrWrite/13 ................... Passed 0.01 sec
        Start 268: CCSGSettingsIntegratedSettingTestMismatchedValues/CCSGSettingsIntegratedSettingTest.MatchedTypesReturnValueMismatchedTypesResetOrWrite/14
268/582 Test #268: CCSGSettingsIntegratedSettingTestMismatchedValues/CCSGSettingsIntegratedSettingTest.MatchedTypesReturnValueMismatchedTypesResetOrWrite/14 ................... Passed 0.01 sec
        Start 269: CCSGSettingsIntegratedSettingTestMismatchedValues/CCSGSettingsIntegratedSettingTest.MatchedTypesReturnValueMismatchedTypesResetOrWrite/15
269/582 Test #269: CCSGSettingsIntegratedSettingTestMismatchedValues/CCSGSettingsIntegratedSettingTest.MatchedTypesReturnValueMismatchedTypesResetOrWrite/15 ................... Passed 0.01 sec
        Start 270: CCSGNOMEIntegrationTest.TestConstructComposition
270/582 Test #270: CCSGNOMEIntegrationTest.TestConstructComposition ............................................................................................................ Passed 0.01 sec
        Start 271: CCSGNOMEIntegrationTestReadIntegrated.TestReadInSpecialOptionCurrentViewport
271/582 Test #271: CCSGNOMEIntegrationTestReadIntegrated.TestReadInSpecialOptionCurrentViewport ................................................................................ Passed 0.01 sec
        Start 272: CCSGNOMEIntegrationTestReadIntegrated.TestReadInSpecialOptionFullscreenVisualBell
272/582 Test #272: CCSGNOMEIntegrationTestReadIntegrated.TestReadInSpecialOptionFullscreenVisualBell ........................................................................... Passed 0.01 sec
        Start 273: CCSGNOMEIntegrationTestReadIntegrated.TestReadInSpecialOptionClickToFocus
273/582 Test #273: CCSGNOMEIntegrationTestReadIntegrated.TestReadInSpecialOptionClickToFocus ................................................................................... Passed 0.01 sec
        Start 274: CCSGNOMEIntegrationTestWithMocks.TestConstructGNOMEIntegration
274/582 Test #274: CCSGNOMEIntegrationTestWithMocks.TestConstructGNOMEIntegration .............................................................................................. Passed 0.01 sec
        Start 275: CCSGNOMEIntegrationTestWithMocksReadIntegratedMouseButtonModifiers.TestReadInSpecialOptionMoveInitiateButton
275/582 Test #275: CCSGNOMEIntegrationTestWithMocksReadIntegratedMouseButtonModifiers.TestReadInSpecialOptionMoveInitiateButton ................................................ Passed 0.01 sec
        Start 276: CCSGNOMEIntegrationTestWithMocksReadIntegratedMouseButtonModifiers.TestReadInSpecialOptionResizeInitiateButton
276/582 Test #276: CCSGNOMEIntegrationTestWithMocksReadIntegratedMouseButtonModifiers.TestReadInSpecialOptionResizeInitiateButton .............................................. Passed 0.01 sec
        Start 277: CCSGNOMEIntegrationTestWithMocksWriteIntegratedMouseButtonModifiers.TestWriteMouseButtonModifier
277/582 Test #277: CCSGNOMEIntegrationTestWithMocksWriteIntegratedMouseButtonModifiers.TestWriteMouseButtonModifier ............................................................ Passed 0.01 sec
        Start 278: CCSGNOMEIntegrationTestWriteIntegrated.TestWriteCurrentViewport
278/582 Test #278: CCSGNOMEIntegrationTestWriteIntegrated.TestWriteCurrentViewport ............................................................................................. Passed 0.01 sec
        Start 279: CCSGNOMEIntegrationTestWriteIntegrated.TestWriteFullscreenVisualBell
279/582 Test #279: CCSGNOMEIntegrationTestWriteIntegrated.TestWriteFullscreenVisualBell ........................................................................................ Passed 0.01 sec
        Start 280: CCSGNOMEIntegrationTestWriteIntegrated.TestWriteClickToFocus
280/582 Test #280: CCSGNOMEIntegrationTestWriteIntegrated.TestWriteClickToFocus ................................................................................................

In order to make this work bug 1049169 was mostly fixed too (there are other memleaks so lets leave it open).

To post a comment you must log in.
Revision history for this message
jenkins (martin-mrazik+qa) wrote :
review: Needs Fixing (continuous-integration)
3390. By Sam Spilsbury

Also free and return null for the gconf integrated settings

3391. By Sam Spilsbury

Failing test: 277 - CCSGNOMEIntegrationTestWithMocksReadIntegratedMouseButtonModifiers.TestReadInSpecialOptionWhereIntegratedOptionReturnsNull (SEGFAULT)

3392. By Sam Spilsbury

Make CCSGNOMEIntegrationTestWithMocksReadIntegratedMouseButtonModifiers.TestReadInSpecialOptionWhereIntegratedOptionReturnsNull
pass

Revision history for this message
jenkins (martin-mrazik+qa) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

There's no explicit mention of fixing bug 1041535. Does it?

If so, please claim bug 1041535 and mark it in progress.

review: Needs Information
Revision history for this message
Martin Mrazik (mrazik) wrote :

This is the jenkins error:
patching file plugins/expo/src/wall_offset/tests/test-expo-wall-offset.cpp
patching file plugins/expo/CMakeLists.txt
Hunk #1 FAILED at 1.
1 out of 1 hunk FAILED -- rejects in file plugins/expo/CMakeLists.txt
patching file plugins/expo/src/windows_on_viewport/CMakeLists.txt
patching file plugins/expo/src/windows_on_viewport/include/windows-on-viewport.h
patching file plugins/expo/src/windows_on_viewport/src/windows-on-viewport.cpp
patching file plugins/expo/src/windows_on_viewport/tests/CMakeLists.txt
patching file plugins/expo/src/windows_on_viewport/tests/test-windows-on-viewport.cpp
patching file plugins/expo/src/client-list-generator.h
patching file plugins/expo/src/viewport-member-window.h
Patch 100_expo_layout.patch does not apply (enforce with -f)
dh_quilt_patch: quilt --quiltrc /dev/null push -a || test $? = 2 returned exit code 1
make[1]: *** [override_dh_quilt_patch] Error 1
make[1]: Leaving directory `/tmp/buildd/compiz-0.9.8.2+bzr3377'
make: *** [build] Error 2
dpkg-buildpackage: error: debian/rules build gave erro

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Please add a check for NULL inside ccsStringToModifiers so we can declare bug 1041535 fixed.

review: Needs Fixing
Revision history for this message
Sam Spilsbury (smspillaz) wrote :

> This is the jenkins error:
> patching file plugins/expo/src/wall_offset/tests/test-expo-wall-offset.cpp
> patching file plugins/expo/CMakeLists.txt
> Hunk #1 FAILED at 1.
> 1 out of 1 hunk FAILED -- rejects in file plugins/expo/CMakeLists.txt
> patching file plugins/expo/src/windows_on_viewport/CMakeLists.txt
> patching file plugins/expo/src/windows_on_viewport/include/windows-on-
> viewport.h
> patching file plugins/expo/src/windows_on_viewport/src/windows-on-viewport.cpp
> patching file plugins/expo/src/windows_on_viewport/tests/CMakeLists.txt
> patching file plugins/expo/src/windows_on_viewport/tests/test-windows-on-
> viewport.cpp
> patching file plugins/expo/src/client-list-generator.h
> patching file plugins/expo/src/viewport-member-window.h
> Patch 100_expo_layout.patch does not apply (enforce with -f)
> dh_quilt_patch: quilt --quiltrc /dev/null push -a || test $? = 2 returned exit
> code 1
> make[1]: *** [override_dh_quilt_patch] Error 1
> make[1]: Leaving directory `/tmp/buildd/compiz-0.9.8.2+bzr3377'
> make: *** [build] Error 2
> dpkg-buildpackage: error: debian/rules build gave erro

Hmm, this branch doesn't touch the expo plugin, so that error is suprising. However, maybe trunk has broken CI. I'll look into it.

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'compizconfig/CMakeLists.txt'
--- compizconfig/CMakeLists.txt 2012-08-22 06:15:40 +0000
+++ compizconfig/CMakeLists.txt 2012-09-24 03:58:20 +0000
@@ -21,6 +21,7 @@
2121
22if (COMPIZ_BUILD_TESTING)22if (COMPIZ_BUILD_TESTING)
23 add_subdirectory (mocks)23 add_subdirectory (mocks)
24 add_subdirectory (tests)
24endif (COMPIZ_BUILD_TESTING)25endif (COMPIZ_BUILD_TESTING)
2526
26add_custom_target (pyclean)27add_custom_target (pyclean)
2728
=== modified file 'compizconfig/gsettings/CMakeLists.txt'
--- compizconfig/gsettings/CMakeLists.txt 2012-08-15 06:45:13 +0000
+++ compizconfig/gsettings/CMakeLists.txt 2012-09-24 03:58:20 +0000
@@ -14,6 +14,8 @@
14 add_definitions (-DUSE_GCONF)14 add_definitions (-DUSE_GCONF)
15endif (USE_GCONF)15endif (USE_GCONF)
1616
17add_subdirectory (mocks)
18add_subdirectory (testenvironments)
17add_subdirectory (gsettings_backend_shared)19add_subdirectory (gsettings_backend_shared)
1820
19include_directories (${CMAKE_CURRENT_SOURCE_DIR}/gsettings_backend_shared21include_directories (${CMAKE_CURRENT_SOURCE_DIR}/gsettings_backend_shared
2022
=== modified file 'compizconfig/gsettings/gsettings_backend_shared/CMakeLists.txt'
--- compizconfig/gsettings/gsettings_backend_shared/CMakeLists.txt 2012-08-19 10:02:23 +0000
+++ compizconfig/gsettings/gsettings_backend_shared/CMakeLists.txt 2012-09-24 03:58:20 +0000
@@ -41,7 +41,6 @@
41 compizconfig_gsettings_backend_interface41 compizconfig_gsettings_backend_interface
42 compizconfig_gsettings_wrapper_interface42 compizconfig_gsettings_wrapper_interface
43 compizconfig43 compizconfig
44 compizconfig
45 ${GSETTINGS_UTIL_LIBRARIES})44 ${GSETTINGS_UTIL_LIBRARIES})
4645
47 add_library (compizconfig_gsettings_backend SHARED46 add_library (compizconfig_gsettings_backend SHARED
4847
=== modified file 'compizconfig/gsettings/gsettings_backend_shared/ccs_gsettings_backend.c'
--- compizconfig/gsettings/gsettings_backend_shared/ccs_gsettings_backend.c 2012-08-17 23:50:08 +0000
+++ compizconfig/gsettings/gsettings_backend_shared/ccs_gsettings_backend.c 2012-09-24 03:58:20 +0000
@@ -223,29 +223,6 @@
223 }223 }
224}224}
225225
226CCSContext *
227ccsGSettingsBackendGetContext (CCSBackend *backend)
228{
229 return (*(GET_INTERFACE (CCSGSettingsBackendInterface, backend))->gsettingsBackendGetContext) (backend);
230}
231
232
233void
234ccsGSettingsBackendConnectToChangedSignal (CCSBackend *backend,
235 CCSGSettingsWrapper *object)
236{
237 (*(GET_INTERFACE (CCSGSettingsBackendInterface, backend))->gsettingsBackendConnectToChangedSignal) (backend, object);
238}
239
240CCSGSettingsWrapper *
241ccsGSettingsGetSettingsObjectForPluginWithPath (CCSBackend *backend,
242 const char *plugin,
243 const char *path,
244 CCSContext *context)
245{
246 return (*(GET_INTERFACE (CCSGSettingsBackendInterface, backend))->gsettingsBackendGetSettingsObjectForPluginWithPath) (backend, plugin, path, context);
247}
248
249static CCSContext *226static CCSContext *
250ccsGSettingsBackendGetContextDefault (CCSBackend *backend)227ccsGSettingsBackendGetContextDefault (CCSBackend *backend)
251{228{
252229
=== modified file 'compizconfig/gsettings/gsettings_backend_shared/ccs_gsettings_backend_interface.c'
--- compizconfig/gsettings/gsettings_backend_shared/ccs_gsettings_backend_interface.c 2012-08-13 14:41:20 +0000
+++ compizconfig/gsettings/gsettings_backend_shared/ccs_gsettings_backend_interface.c 2012-09-24 03:58:20 +0000
@@ -3,6 +3,29 @@
33
4INTERFACE_TYPE (CCSGSettingsBackendInterface);4INTERFACE_TYPE (CCSGSettingsBackendInterface);
55
6CCSContext *
7ccsGSettingsBackendGetContext (CCSBackend *backend)
8{
9 return (*(GET_INTERFACE (CCSGSettingsBackendInterface, backend))->gsettingsBackendGetContext) (backend);
10}
11
12
13void
14ccsGSettingsBackendConnectToChangedSignal (CCSBackend *backend,
15 CCSGSettingsWrapper *object)
16{
17 (*(GET_INTERFACE (CCSGSettingsBackendInterface, backend))->gsettingsBackendConnectToChangedSignal) (backend, object);
18}
19
20CCSGSettingsWrapper *
21ccsGSettingsGetSettingsObjectForPluginWithPath (CCSBackend *backend,
22 const char *plugin,
23 const char *path,
24 CCSContext *context)
25{
26 return (*(GET_INTERFACE (CCSGSettingsBackendInterface, backend))->gsettingsBackendGetSettingsObjectForPluginWithPath) (backend, plugin, path, context);
27}
28
6const char *29const char *
7ccsGSettingsBackendGetCurrentProfile (CCSBackend *backend)30ccsGSettingsBackendGetCurrentProfile (CCSBackend *backend)
8{31{
932
=== added directory 'compizconfig/gsettings/mocks'
=== added file 'compizconfig/gsettings/mocks/CMakeLists.txt'
--- compizconfig/gsettings/mocks/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ compizconfig/gsettings/mocks/CMakeLists.txt 2012-09-24 03:58:20 +0000
@@ -0,0 +1,21 @@
1pkg_check_modules (GLIB glib-2.0)
2
3if (GLIB_FOUND)
4
5 include_directories (${CMAKE_CURRENT_SOURCE_DIR}
6 ${CMAKE_CURRENT_BINARY_DIR}
7 ${CMAKE_CURRENT_SOURCE_DIR}/../../libcompizconfig/include
8 ${CMAKE_CURRENT_SOURCE_DIR}/../gsettings_backend_shared
9 ${GLIB_INCLUDE_DIRS})
10
11set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
12
13 add_library (compizconfig_ccs_gsettings_wrapper_mock STATIC
14 ${CMAKE_CURRENT_SOURCE_DIR}/ccs_gsettings_wrapper_mock.cpp
15 ${CMAKE_CURRENT_SOURCE_DIR}/ccs_gsettings_wrapper_mock.h)
16
17 add_library (compizconfig_ccs_gsettings_backend_mock STATIC
18 ${CMAKE_CURRENT_SOURCE_DIR}/ccs_gsettings_backend_mock.cpp
19 ${CMAKE_CURRENT_SOURCE_DIR}/ccs_gsettings_backend_mock.h)
20
21endif (GLIB_FOUND)
022
=== renamed file 'compizconfig/gsettings/tests/ccs_gsettings_backend_mock.cpp' => 'compizconfig/gsettings/mocks/ccs_gsettings_backend_mock.cpp'
=== renamed file 'compizconfig/gsettings/tests/ccs_gsettings_backend_mock.h' => 'compizconfig/gsettings/mocks/ccs_gsettings_backend_mock.h'
=== renamed file 'compizconfig/gsettings/tests/ccs_gsettings_wrapper_mock.cpp' => 'compizconfig/gsettings/mocks/ccs_gsettings_wrapper_mock.cpp'
=== renamed file 'compizconfig/gsettings/tests/ccs_gsettings_wrapper_mock.h' => 'compizconfig/gsettings/mocks/ccs_gsettings_wrapper_mock.h'
=== added directory 'compizconfig/gsettings/testenvironments'
=== added file 'compizconfig/gsettings/testenvironments/CMakeLists.txt'
=== modified file 'compizconfig/gsettings/tests/CMakeLists.txt'
--- compizconfig/gsettings/tests/CMakeLists.txt 2012-08-16 10:22:05 +0000
+++ compizconfig/gsettings/tests/CMakeLists.txt 2012-09-24 03:58:20 +0000
@@ -2,25 +2,25 @@
22
3include_directories (${CMAKE_CURRENT_SOURCE_DIR}3include_directories (${CMAKE_CURRENT_SOURCE_DIR}
4 ${CMAKE_CURRENT_BINARY_DIR}4 ${CMAKE_CURRENT_BINARY_DIR}
5 ${CMAKE_CURRENT_SOURCE_DIR}/../mocks
6 ${CMAKE_CURRENT_SOURCE_DIR}/../testenvironments
5 ${CMAKE_CURRENT_SOURCE_DIR}/../src7 ${CMAKE_CURRENT_SOURCE_DIR}/../src
6 ${CMAKE_CURRENT_SOURCE_DIR}/../../libcompizconfig/tests8 ${CMAKE_CURRENT_SOURCE_DIR}/../../libcompizconfig/tests
7 ${CMAKE_CURRENT_SOURCE_DIR}/../../mocks/libcompizconfig9 ${CMAKE_CURRENT_SOURCE_DIR}/../../mocks/libcompizconfig
8 ${CMAKE_CURRENT_SOURCE_DIR}/../../tests10 ${CMAKE_CURRENT_SOURCE_DIR}/../../tests
9 ${CMAKE_SOURCE_DIR}/tests/shared)11 ${CMAKE_SOURCE_DIR}/tests/shared
12 ${CMAKE_SOURCE_DIR}/tests/shared/glib)
1013
11pkg_check_modules (COMPIZCONFIG_TEST_GSETTINGS libcompizconfig)14pkg_check_modules (COMPIZCONFIG_TEST_GSETTINGS libcompizconfig_internal)
1215
13set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")16set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
1417
15link_directories (${CMAKE_CURRENT_BINARY_DIR}/../../libcompizconfig/tests)18link_directories (${CMAKE_CURRENT_BINARY_DIR}/../../libcompizconfig/tests)
1619link_directories (${CMAKE_CURRENT_BINARY_DIR}/../testenvironments)
17add_library (compizconfig_ccs_gsettings_wrapper_mock STATIC20link_directories (${CMAKE_CURRENT_BINARY_DIR}/../mocks)
18 ${CMAKE_CURRENT_SOURCE_DIR}/ccs_gsettings_wrapper_mock.cpp21
19 ${CMAKE_CURRENT_SOURCE_DIR}/ccs_gsettings_wrapper_mock.h)22add_library (compizconfig_gsettings_settings_test_env STATIC
2023 ${CMAKE_CURRENT_SOURCE_DIR}/compizconfig_ccs_gsettings_settings_env_test.cpp)
21add_library (compizconfig_ccs_gsettings_backend_mock STATIC
22 ${CMAKE_CURRENT_SOURCE_DIR}/ccs_gsettings_backend_mock.cpp
23 ${CMAKE_CURRENT_SOURCE_DIR}/ccs_gsettings_backend_mock.h)
2424
25add_executable (compizconfig_test_gsettings25add_executable (compizconfig_test_gsettings
26 ${CMAKE_CURRENT_SOURCE_DIR}/test_gsettings_tests.cpp26 ${CMAKE_CURRENT_SOURCE_DIR}/test_gsettings_tests.cpp
@@ -38,6 +38,7 @@
38 compizconfig_ccs_context_mock38 compizconfig_ccs_context_mock
39 compizconfig_ccs_gsettings_backend_mock39 compizconfig_ccs_gsettings_backend_mock
40 compizconfig_ccs_gsettings_wrapper_mock40 compizconfig_ccs_gsettings_wrapper_mock
41 compizconfig_ccs_test_value_combinations
41 ${COMPIZCONFIG_TEST_GSETTINGS_LIBRARIES}42 ${COMPIZCONFIG_TEST_GSETTINGS_LIBRARIES}
42 ${GTEST_BOTH_LIBRARIES}43 ${GTEST_BOTH_LIBRARIES}
43 ${GMOCK_MAIN_LIBRARY})44 ${GMOCK_MAIN_LIBRARY})
@@ -59,10 +60,18 @@
59 ${CMAKE_CURRENT_BINARY_DIR}/backend-conformance-config.h)60 ${CMAKE_CURRENT_BINARY_DIR}/backend-conformance-config.h)
6061
61target_link_libraries (compizconfig_test_gsettings_conformance62target_link_libraries (compizconfig_test_gsettings_conformance
63 compizconfig_gsettings_settings_test_env
62 compizconfig_gsettings_backend64 compizconfig_gsettings_backend
63 compizconfig_ccs_setting_mock65 compizconfig_ccs_setting_mock
64 compizconfig_ccs_plugin_mock66 compizconfig_ccs_plugin_mock
65 compizconfig_ccs_context_mock67 compizconfig_ccs_context_mock
68 compizconfig_ccs_item_in_list_matcher
69 compizconfig_ccs_list_equality
70 compizconfig_ccs_list_wrapper
71 compizconfig_ccs_backend_conformance_test
72 compizconfig_ccs_setting_value_operators
73 compizconfig_ccs_test_value_combinations
74 compizconfig_ccs_integration_mock
66 ${COMPIZCONFIG_TEST_GSETTINGS_LIBRARIES}75 ${COMPIZCONFIG_TEST_GSETTINGS_LIBRARIES}
67 ${GTEST_BOTH_LIBRARIES}76 ${GTEST_BOTH_LIBRARIES}
68 ${GMOCK_MAIN_LIBRARY})77 ${GMOCK_MAIN_LIBRARY})
6978
=== added file 'compizconfig/gsettings/tests/compizconfig_ccs_gsettings_settings_env_test.cpp'
--- compizconfig/gsettings/tests/compizconfig_ccs_gsettings_settings_env_test.cpp 1970-01-01 00:00:00 +0000
+++ compizconfig/gsettings/tests/compizconfig_ccs_gsettings_settings_env_test.cpp 2012-09-24 03:58:20 +0000
@@ -0,0 +1,364 @@
1/*
2 * Compiz configuration system library
3 *
4 * Copyright (C) 2012 Canonical Ltd.
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 *
20 * Authored By:
21 * Sam Spilsbury <sam.spilsbury@canonical.com>
22 */
23
24#include <gtest/gtest.h>
25#include <gmock/gmock.h>
26
27#include <gio/gio.h>
28#include <gsettings_util.h>
29#include <ccs_gsettings_backend_interface.h>
30
31#include <gtest_shared_autodestroy.h>
32#include <gtest_shared_characterwrapper.h>
33#include "test_gsettings_tests.h"
34
35#include <glib_gslice_off_env.h>
36#include <glib_gsettings_memory_backend_env.h>
37
38#include "compizconfig_ccs_gsettings_settings_env_test.h"
39
40#include "backend-conformance-config.h"
41#include "gsettings-mock-schemas-config.h"
42
43namespace cci = compiz::config::impl;
44namespace cct = compizconfig::test;
45
46class PrivateCCSGSettingsStorageEnv
47{
48 public:
49
50 PrivateCCSGSettingsStorageEnv (CCSGSettingsWrapper *settings,
51 const std::string &profileName);
52
53 CCSGSettingsWrapper *mSettings;
54 std::string profileName;
55 CompizGLibGSettingsMemoryBackendTestingEnv gsettingsEnv;
56 CompizGLibGSliceOffEnv gsliceEnv;
57};
58
59void
60CCSGSettingsStorageEnv::WriteBoolAtKey (const std::string &plugin,
61 const std::string &key,
62 const VariantTypes &value)
63{
64 GVariant *variant = NULL;
65 if (writeBoolToVariant (cct::boolToBool (boost::get <bool> (value)), &variant))
66 writeVariantToKey (priv->mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant);
67 else
68 throw std::exception ();
69}
70
71void
72CCSGSettingsStorageEnv::WriteIntegerAtKey (const std::string &plugin,
73 const std::string &key,
74 const VariantTypes &value)
75{
76 GVariant *variant = NULL;
77 if (writeIntToVariant (boost::get <int> (value), &variant))
78 writeVariantToKey (priv->mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant);
79 else
80 throw std::exception ();
81}
82
83void
84CCSGSettingsStorageEnv::WriteFloatAtKey (const std::string &plugin,
85 const std::string &key,
86 const VariantTypes &value)
87{
88 GVariant *variant = NULL;
89 if (writeFloatToVariant (boost::get <float> (value), &variant))
90 writeVariantToKey (priv->mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant);
91 else
92 throw std::exception ();
93}
94
95void
96CCSGSettingsStorageEnv::WriteStringAtKey (const std::string &plugin,
97 const std::string &key,
98 const VariantTypes &value)
99{
100 GVariant *variant = NULL;
101 if (writeStringToVariant (boost::get <const char *> (value), &variant))
102 writeVariantToKey (priv->mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant);
103 else
104 throw std::exception ();
105}
106
107void
108CCSGSettingsStorageEnv::WriteColorAtKey (const std::string &plugin,
109 const std::string &key,
110 const VariantTypes &value)
111{
112 GVariant *variant = NULL;
113 if (writeColorToVariant (boost::get <CCSSettingColorValue> (value), &variant))
114 writeVariantToKey (priv->mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant);
115 else
116 throw std::exception ();
117}
118
119void
120CCSGSettingsStorageEnv::WriteKeyAtKey (const std::string &plugin,
121 const std::string &key,
122 const VariantTypes &value)
123{
124 GVariant *variant = NULL;
125 if (writeKeyToVariant (boost::get <CCSSettingKeyValue> (value), &variant))
126 writeVariantToKey (priv->mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant);
127 else
128 throw std::exception ();
129}
130
131void
132CCSGSettingsStorageEnv::WriteButtonAtKey (const std::string &plugin,
133 const std::string &key,
134 const VariantTypes &value)
135{
136 GVariant *variant = NULL;
137 if (writeButtonToVariant (boost::get <CCSSettingButtonValue> (value), &variant))
138 writeVariantToKey (priv->mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant);
139 else
140 throw std::exception ();
141}
142
143void
144CCSGSettingsStorageEnv::WriteEdgeAtKey (const std::string &plugin,
145 const std::string &key,
146 const VariantTypes &value)
147{
148 GVariant *variant = NULL;
149 if (writeEdgeToVariant (boost::get <unsigned int> (value), &variant))
150 writeVariantToKey (priv->mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant);
151 else
152 throw std::exception ();
153}
154
155void
156CCSGSettingsStorageEnv::WriteMatchAtKey (const std::string &plugin,
157 const std::string &key,
158 const VariantTypes &value)
159{
160 GVariant *variant = NULL;
161 if (writeStringToVariant (boost::get <const char *> (value), &variant))
162 writeVariantToKey (priv->mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant);
163 else
164 throw std::exception ();
165}
166
167void
168CCSGSettingsStorageEnv::WriteBellAtKey (const std::string &plugin,
169 const std::string &key,
170 const VariantTypes &value)
171{
172 GVariant *variant = NULL;
173 if (writeBoolToVariant (cct::boolToBool (boost::get <bool> (value)), &variant))
174 writeVariantToKey (priv->mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant);
175 else
176 throw std::exception ();
177}
178
179void
180CCSGSettingsStorageEnv::WriteListAtKey (const std::string &plugin,
181 const std::string &key,
182 const VariantTypes &value)
183{
184 GVariant *variant = NULL;
185
186 const cci::SettingValueListWrapper::Ptr &lw (boost::get <cci::SettingValueListWrapper::Ptr> (value));
187
188 if (writeListValue (*lw, lw->type (), &variant))
189 writeVariantToKey (priv->mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant);
190 else
191 throw std::exception ();
192}
193
194Bool
195CCSGSettingsStorageEnv::ReadBoolAtKey (const std::string &plugin,
196 const std::string &key)
197{
198 GVariantShared variant (ReadVariantAtKeyToShared (plugin,
199 key,
200 TypeBool));
201 return readBoolFromVariant (variant.get ());
202}
203
204
205int
206CCSGSettingsStorageEnv::ReadIntegerAtKey (const std::string &plugin,
207 const std::string &key)
208{
209 GVariantShared variant (ReadVariantAtKeyToShared (plugin,
210 key,
211 TypeInt));
212 return readIntFromVariant (variant.get ());
213}
214
215float
216CCSGSettingsStorageEnv::ReadFloatAtKey (const std::string &plugin,
217 const std::string &key)
218{
219 GVariantShared variant (ReadVariantAtKeyToShared (plugin,
220 key,
221 TypeFloat));
222 return readFloatFromVariant (variant.get ());
223}
224
225const char *
226CCSGSettingsStorageEnv::ReadStringAtKey (const std::string &plugin,
227 const std::string &key)
228{
229 GVariantShared variant (ReadVariantAtKeyToShared (plugin,
230 key,
231 TypeString));
232 return readStringFromVariant (variant.get ());
233}
234
235CCSSettingColorValue
236CCSGSettingsStorageEnv::ReadColorAtKey (const std::string &plugin,
237 const std::string &key)
238{
239 Bool success = FALSE;
240 GVariantShared variant (ReadVariantAtKeyToShared (plugin,
241 key,
242 TypeColor));
243 CCSSettingColorValue value = readColorFromVariant (variant.get (), &success);
244 EXPECT_TRUE (success);
245 return value;
246}
247
248CCSSettingKeyValue
249CCSGSettingsStorageEnv::ReadKeyAtKey (const std::string &plugin,
250 const std::string &key)
251{
252 Bool success = FALSE;
253 GVariantShared variant (ReadVariantAtKeyToShared (plugin,
254 key,
255 TypeKey));
256 CCSSettingKeyValue value = readKeyFromVariant (variant.get (), &success);
257 EXPECT_TRUE (success);
258 return value;
259}
260
261CCSSettingButtonValue
262CCSGSettingsStorageEnv::ReadButtonAtKey (const std::string &plugin,
263 const std::string &key)
264{
265 Bool success = FALSE;
266 GVariantShared variant (ReadVariantAtKeyToShared (plugin,
267 key,
268 TypeButton));
269 CCSSettingButtonValue value = readButtonFromVariant (variant.get (), &success);
270 EXPECT_TRUE (success);
271 return value;
272}
273
274unsigned int
275CCSGSettingsStorageEnv::ReadEdgeAtKey (const std::string &plugin,
276 const std::string &key)
277{
278 GVariantShared variant (ReadVariantAtKeyToShared (plugin,
279 key,
280 TypeEdge));
281 return readEdgeFromVariant (variant.get ());
282}
283
284const char *
285CCSGSettingsStorageEnv::ReadMatchAtKey (const std::string &plugin,
286 const std::string &key)
287{
288 GVariantShared variant (ReadVariantAtKeyToShared (plugin,
289 key,
290 TypeMatch));
291 return readStringFromVariant (variant.get ());
292}
293
294Bool
295CCSGSettingsStorageEnv::ReadBellAtKey (const std::string &plugin,
296 const std::string &key)
297{
298 GVariantShared variant (ReadVariantAtKeyToShared (plugin,
299 key,
300 TypeBell));
301 return readBoolFromVariant (variant.get ());
302}
303
304CCSSettingValueList
305CCSGSettingsStorageEnv::ReadListAtKey (const std::string &plugin,
306 const std::string &key,
307 CCSSetting *setting)
308{
309 GVariantShared variant (ReadVariantAtKeyToShared (plugin,
310 key,
311 TypeList));
312 return readListValue (variant.get (), setting, &ccsDefaultObjectAllocator);
313}
314
315GVariantShared
316CCSGSettingsStorageEnv::ReadVariantAtKeyToShared (const std::string &plugin,
317 const std::string &key,
318 CCSSettingType type)
319{
320 CharacterWrapper translatedKey (translateKeyForGSettings (key.c_str ()));
321 CharacterWrapper pluginPath (makeCompizPluginPath (priv->profileName.c_str (),
322 plugin.c_str ()));
323
324 GVariant *rawVariant = getVariantAtKey (priv->mSettings,
325 translatedKey,
326 pluginPath,
327 type);
328
329 GVariantShared shared (AutoDestroy (rawVariant, g_variant_unref));
330
331
332
333 return shared;
334}
335
336void
337CCSGSettingsStorageEnv::SetUp ()
338{
339 g_type_init ();
340 priv->gsliceEnv.SetUpEnv ();
341 priv->gsettingsEnv.SetUpEnv (MOCK_PATH);
342}
343
344void
345CCSGSettingsStorageEnv::TearDown ()
346{
347 priv->gsettingsEnv.TearDownEnv ();
348 priv->gsliceEnv.TearDownEnv ();
349}
350
351PrivateCCSGSettingsStorageEnv::PrivateCCSGSettingsStorageEnv (CCSGSettingsWrapper *settings,
352 const std::string &profileName) :
353 mSettings (settings),
354 profileName (profileName)
355
356{
357}
358
359CCSGSettingsStorageEnv::CCSGSettingsStorageEnv (CCSGSettingsWrapper *settings,
360 const std::string &profileName) :
361 priv (new PrivateCCSGSettingsStorageEnv (settings,
362 profileName))
363{
364}
0365
=== added file 'compizconfig/gsettings/tests/compizconfig_ccs_gsettings_settings_env_test.h'
--- compizconfig/gsettings/tests/compizconfig_ccs_gsettings_settings_env_test.h 1970-01-01 00:00:00 +0000
+++ compizconfig/gsettings/tests/compizconfig_ccs_gsettings_settings_env_test.h 2012-09-24 03:58:20 +0000
@@ -0,0 +1,134 @@
1/*
2 * Compiz configuration system library
3 *
4 * Copyright (C) 2012 Canonical Ltd.
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 *
20 * Authored By:
21 * Sam Spilsbury <sam.spilsbury@canonical.com>
22 */
23#ifndef _COMPIZCONFIG_CCS_GSETTINGS_SETTINGS_ENV_TEST_H
24#define _COMPIZCONFIG_CCS_GSETTINGS_SETTINGS_ENV_TEST_H
25
26#include <memory>
27#include <boost/shared_ptr.hpp>
28
29#include "compizconfig_ccs_settings_test_fixture.h"
30
31typedef boost::shared_ptr <GVariant> GVariantShared;
32typedef struct _CCSSetting CCSSetting;
33typedef struct _CCSGSettingsWrapper CCSGSettingsWrapper;
34typedef enum _CCSSettingType CCSSettingType;
35
36class PrivateCCSGSettingsStorageEnv;
37
38class CCSGSettingsStorageEnv :
39 public CCSSettingsConceptTestEnvironmentInterface
40{
41 public:
42
43 virtual void SetUp ();
44 virtual void TearDown ();
45
46 CCSGSettingsStorageEnv (CCSGSettingsWrapper *settings,
47 const std::string &profileName);
48
49 void WriteBoolAtKey (const std::string &plugin,
50 const std::string &key,
51 const VariantTypes &value);
52 void WriteIntegerAtKey (const std::string &plugin,
53 const std::string &key,
54 const VariantTypes &value);
55
56 void WriteFloatAtKey (const std::string &plugin,
57 const std::string &key,
58 const VariantTypes &value);
59
60 void WriteStringAtKey (const std::string &plugin,
61 const std::string &key,
62 const VariantTypes &value);
63
64 void WriteColorAtKey (const std::string &plugin,
65 const std::string &key,
66 const VariantTypes &value);
67
68 void WriteKeyAtKey (const std::string &plugin,
69 const std::string &key,
70 const VariantTypes &value);
71
72 void WriteButtonAtKey (const std::string &plugin,
73 const std::string &key,
74 const VariantTypes &value);
75
76 void WriteEdgeAtKey (const std::string &plugin,
77 const std::string &key,
78 const VariantTypes &value);
79
80 void WriteMatchAtKey (const std::string &plugin,
81 const std::string &key,
82 const VariantTypes &value);
83
84 void WriteBellAtKey (const std::string &plugin,
85 const std::string &key,
86 const VariantTypes &value);
87
88 void WriteListAtKey (const std::string &plugin,
89 const std::string &key,
90 const VariantTypes &value);
91
92 Bool ReadBoolAtKey (const std::string &plugin,
93 const std::string &key);
94
95 int ReadIntegerAtKey (const std::string &plugin,
96 const std::string &key);
97
98 float ReadFloatAtKey (const std::string &plugin,
99 const std::string &key);
100
101 const char * ReadStringAtKey (const std::string &plugin,
102 const std::string &key);
103
104 CCSSettingColorValue ReadColorAtKey (const std::string &plugin,
105 const std::string &key);
106
107 CCSSettingKeyValue ReadKeyAtKey (const std::string &plugin,
108 const std::string &key);
109 CCSSettingButtonValue ReadButtonAtKey (const std::string &plugin,
110 const std::string &key);
111
112 unsigned int ReadEdgeAtKey (const std::string &plugin,
113 const std::string &key);
114
115 const char * ReadMatchAtKey (const std::string &plugin,
116 const std::string &key);
117 Bool ReadBellAtKey (const std::string &plugin,
118 const std::string &key);
119
120 CCSSettingValueList ReadListAtKey (const std::string &plugin,
121 const std::string &key,
122 CCSSetting *setting);
123
124 private:
125
126 GVariantShared
127 ReadVariantAtKeyToShared (const std::string &plugin,
128 const std::string &key,
129 CCSSettingType type);
130
131 std::auto_ptr <PrivateCCSGSettingsStorageEnv> priv;
132};
133
134#endif
0135
=== modified file 'compizconfig/gsettings/tests/gsettings-mock-schemas-config.h.in'
--- compizconfig/gsettings/tests/gsettings-mock-schemas-config.h.in 2012-08-11 11:05:13 +0000
+++ compizconfig/gsettings/tests/gsettings-mock-schemas-config.h.in 2012-09-24 03:58:20 +0000
@@ -3,6 +3,8 @@
33
4#define MOCK_SCHEMA_PATH "@CMAKE_BINARY_DIR@/generated/glib-2.0/schemas"4#define MOCK_SCHEMA_PATH "@CMAKE_BINARY_DIR@/generated/glib-2.0/schemas"
55
6#include <string>
7
6namespace8namespace
7{9{
8const std::string MOCK_SCHEMA ("org.compiz.mock");10const std::string MOCK_SCHEMA ("org.compiz.mock");
911
=== added file 'compizconfig/gsettings/tests/gsettings_settings_test_fixture.h'
--- compizconfig/gsettings/tests/gsettings_settings_test_fixture.h 1970-01-01 00:00:00 +0000
+++ compizconfig/gsettings/tests/gsettings_settings_test_fixture.h 2012-09-24 03:58:20 +0000
@@ -0,0 +1,29 @@
1/*
2 * Compiz configuration system library
3 *
4 * Copyright (C) 2012 Canonical Ltd.
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 *
20 * Authored By:
21 * Sam Spilsbury <sam.spilsbury@canonical.com>
22 */
23#ifndef _COMPIZCONFIG_GSETTINGS_SETTINGS_TEST_FIXTURE_H
24#define _COMPIZCONFIG_GSETTINGS_SETTINGS_TEST_FIXTURE_H
25
26#include <gtest/gtest.h>
27#include <glib_gsettings_memory_backend_env.h>
28
29#endif
030
=== modified file 'compizconfig/gsettings/tests/test_gsettings_conformance.cpp'
--- compizconfig/gsettings/tests/test_gsettings_conformance.cpp 2012-09-24 03:58:20 +0000
+++ compizconfig/gsettings/tests/test_gsettings_conformance.cpp 2012-09-24 03:58:20 +0000
@@ -1,3 +1,25 @@
1/*
2 * Compiz configuration system library
3 *
4 * Copyright (C) 2012 Canonical Ltd.
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 *
20 * Authored By:
21 * Sam Spilsbury <sam.spilsbury@canonical.com>
22 */
1#include <gtest/gtest.h>23#include <gtest/gtest.h>
2#include <gmock/gmock.h>24#include <gmock/gmock.h>
325
@@ -15,441 +37,15 @@
15#include "gtest_shared_autodestroy.h"37#include "gtest_shared_autodestroy.h"
16#include "test_gsettings_tests.h"38#include "test_gsettings_tests.h"
1739
40#include "compizconfig_ccs_gsettings_settings_env_test.h"
41#include "compizconfig_ccs_integration_mock.h"
42
18using ::testing::AtLeast;43using ::testing::AtLeast;
19using ::testing::Pointee;44using ::testing::Pointee;
20using ::testing::ReturnNull;45using ::testing::ReturnNull;
2146
22namespace cci = compiz::config::impl;47namespace cci = compiz::config::impl;
2348
24CCSIntegration *
25ccsMockIntegrationBackendNew (CCSObjectAllocationInterface *ai);
26
27void
28ccsMockIntegrationBackendFree (CCSIntegration *integration);
29
30class CCSIntegrationGMockInterface
31{
32 public:
33
34 virtual ~CCSIntegrationGMockInterface () {}
35
36 virtual CCSIntegratedSetting * getIntegratedOptionIndex (const char *pluginName, const char *settingName) = 0;
37 virtual Bool readOptionIntoSetting (CCSContext *context, CCSSetting *setting, CCSIntegratedSetting *) = 0;
38 virtual void writeOptionFromSetting (CCSContext *context, CCSSetting *setting, CCSIntegratedSetting *) = 0;
39 virtual void updateIntegratedSettings (CCSContext *context, CCSIntegratedSettingList settingList) = 0;
40 virtual void disallowIntegratedWrites () = 0;
41 virtual void allowIntegratedWrites () = 0;
42};
43
44class CCSIntegrationGMock :
45 public CCSIntegrationGMockInterface
46{
47 public:
48
49 MOCK_METHOD2 (getIntegratedOptionIndex, CCSIntegratedSetting * (const char *, const char *));
50 MOCK_METHOD3 (readOptionIntoSetting, Bool (CCSContext *, CCSSetting *, CCSIntegratedSetting *));
51 MOCK_METHOD3 (writeOptionFromSetting, void (CCSContext *, CCSSetting *, CCSIntegratedSetting *));
52 MOCK_METHOD2 (updateIntegratedSettings, void (CCSContext *, CCSIntegratedSettingList));
53 MOCK_METHOD0 (disallowIntegratedWrites, void ());
54 MOCK_METHOD0 (allowIntegratedWrites, void ());
55
56
57 CCSIntegrationGMock (CCSIntegration *integration) :
58 mIntegration (integration)
59 {
60 }
61
62 CCSIntegration *
63 getIntegrationBackend ()
64 {
65 return mIntegration;
66 }
67
68 public:
69
70 static
71 CCSIntegratedSetting * CCSIntegrationGetIntegratedOptionIndex (CCSIntegration *integration,
72 const char *pluginName,
73 const char *settingName)
74 {
75 return reinterpret_cast <CCSIntegrationGMockInterface *> (ccsObjectGetPrivate (integration))->getIntegratedOptionIndex (pluginName, settingName);
76 }
77
78 static
79 Bool CCSIntegrationReadOptionIntoSetting (CCSIntegration *integration,
80 CCSContext *context,
81 CCSSetting *setting,
82 CCSIntegratedSetting *integrated)
83 {
84 return reinterpret_cast <CCSIntegrationGMockInterface *> (ccsObjectGetPrivate (integration))->readOptionIntoSetting (context, setting, integrated);
85 }
86
87 static
88 void CCSIntegrationWriteSettingIntoOption (CCSIntegration *integration,
89 CCSContext *context,
90 CCSSetting *setting,
91 CCSIntegratedSetting *integrated)
92 {
93 return reinterpret_cast <CCSIntegrationGMockInterface *> (ccsObjectGetPrivate (integration))->writeOptionFromSetting (context, setting, integrated);
94 }
95
96 static void CCSIntegrationUpdateIntegratedSettings (CCSIntegration *integration,
97 CCSContext *context,
98 CCSIntegratedSettingList settingList)
99 {
100 return reinterpret_cast <CCSIntegrationGMockInterface *> (ccsObjectGetPrivate (integration))->updateIntegratedSettings (context, settingList);
101 }
102
103 static
104 void ccsFreeIntegration (CCSIntegration *integration)
105 {
106 ccsMockIntegrationBackendFree (integration);
107 }
108
109 static void ccsIntegrationDisallowIntegratedWrites (CCSIntegration *integration)
110 {
111 reinterpret_cast <CCSIntegrationGMockInterface *> (ccsObjectGetPrivate (integration))->disallowIntegratedWrites ();
112 }
113
114 static void ccsIntegrationAllowIntegratedWrites (CCSIntegration *integration)
115 {
116 reinterpret_cast <CCSIntegrationGMockInterface *> (ccsObjectGetPrivate (integration))->allowIntegratedWrites ();
117 }
118
119 private:
120
121 CCSIntegration *mIntegration;
122};
123
124const CCSIntegrationInterface mockIntegrationBackendInterface =
125{
126 CCSIntegrationGMock::CCSIntegrationGetIntegratedOptionIndex,
127 CCSIntegrationGMock::CCSIntegrationReadOptionIntoSetting,
128 CCSIntegrationGMock::CCSIntegrationWriteSettingIntoOption,
129 CCSIntegrationGMock::CCSIntegrationUpdateIntegratedSettings,
130 CCSIntegrationGMock::ccsIntegrationDisallowIntegratedWrites,
131 CCSIntegrationGMock::ccsIntegrationAllowIntegratedWrites,
132 CCSIntegrationGMock::ccsFreeIntegration
133};
134
135CCSIntegration *
136ccsMockIntegrationBackendNew (CCSObjectAllocationInterface *ai)
137{
138 CCSIntegration *integration = reinterpret_cast <CCSIntegration *> ((*ai->calloc_) (ai->allocator, 1, sizeof (CCSIntegration)));
139
140 if (!integration)
141 return NULL;
142
143 CCSIntegrationGMock *gmockBackend = new CCSIntegrationGMock (integration);
144
145 ccsObjectInit (integration, ai);
146 ccsObjectSetPrivate (integration, (CCSPrivate *) gmockBackend);
147 ccsObjectAddInterface (integration, (const CCSInterface *) &mockIntegrationBackendInterface, GET_INTERFACE_TYPE (CCSIntegrationInterface));
148
149 ccsObjectRef (integration);
150
151 return integration;
152}
153
154void
155ccsMockIntegrationBackendFree (CCSIntegration *integration)
156{
157 CCSIntegrationGMock *gmockBackend = reinterpret_cast <CCSIntegrationGMock *> (ccsObjectGetPrivate (integration));
158
159 delete gmockBackend;
160
161 ccsObjectSetPrivate (integration, NULL);
162 ccsObjectFinalize (integration);
163 (*integration->object.object_allocation->free_) (integration->object.object_allocation->allocator, integration);
164}
165
166class CCSGSettingsStorageEnv :
167 public CCSSettingsConceptTestEnvironmentInterface,
168 public CCSGSettingsMemoryBackendTestingEnv
169{
170 public:
171
172 typedef boost::shared_ptr <GVariant> GVariantShared;
173
174 virtual void SetUp ()
175 {
176 SetUpEnv ();
177 }
178
179 virtual void TearDown ()
180 {
181 TearDownEnv ();
182 }
183
184 CCSGSettingsStorageEnv (CCSGSettingsWrapper *settings,
185 const std::string &profileName) :
186 mSettings (settings),
187 profileName (profileName)
188 {
189 }
190
191 void WriteBoolAtKey (const std::string &plugin,
192 const std::string &key,
193 const VariantTypes &value)
194 {
195 GVariant *variant = NULL;
196 if (writeBoolToVariant (boolToBool (boost::get <bool> (value)), &variant))
197 writeVariantToKey (mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant);
198 else
199 throw std::exception ();
200 }
201
202 void WriteIntegerAtKey (const std::string &plugin,
203 const std::string &key,
204 const VariantTypes &value)
205 {
206 GVariant *variant = NULL;
207 if (writeIntToVariant (boost::get <int> (value), &variant))
208 writeVariantToKey (mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant);
209 else
210 throw std::exception ();
211 }
212
213 void WriteFloatAtKey (const std::string &plugin,
214 const std::string &key,
215 const VariantTypes &value)
216 {
217 GVariant *variant = NULL;
218 if (writeFloatToVariant (boost::get <float> (value), &variant))
219 writeVariantToKey (mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant);
220 else
221 throw std::exception ();
222 }
223
224 void WriteStringAtKey (const std::string &plugin,
225 const std::string &key,
226 const VariantTypes &value)
227 {
228 GVariant *variant = NULL;
229 if (writeStringToVariant (boost::get <const char *> (value), &variant))
230 writeVariantToKey (mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant);
231 else
232 throw std::exception ();
233 }
234
235 void WriteColorAtKey (const std::string &plugin,
236 const std::string &key,
237 const VariantTypes &value)
238 {
239 GVariant *variant = NULL;
240 if (writeColorToVariant (boost::get <CCSSettingColorValue> (value), &variant))
241 writeVariantToKey (mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant);
242 else
243 throw std::exception ();
244 }
245
246 void WriteKeyAtKey (const std::string &plugin,
247 const std::string &key,
248 const VariantTypes &value)
249 {
250 GVariant *variant = NULL;
251 if (writeKeyToVariant (boost::get <CCSSettingKeyValue> (value), &variant))
252 writeVariantToKey (mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant);
253 else
254 throw std::exception ();
255 }
256
257 void WriteButtonAtKey (const std::string &plugin,
258 const std::string &key,
259 const VariantTypes &value)
260 {
261 GVariant *variant = NULL;
262 if (writeButtonToVariant (boost::get <CCSSettingButtonValue> (value), &variant))
263 writeVariantToKey (mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant);
264 else
265 throw std::exception ();
266 }
267
268 void WriteEdgeAtKey (const std::string &plugin,
269 const std::string &key,
270 const VariantTypes &value)
271 {
272 GVariant *variant = NULL;
273 if (writeEdgeToVariant (boost::get <unsigned int> (value), &variant))
274 writeVariantToKey (mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant);
275 else
276 throw std::exception ();
277 }
278
279 void WriteMatchAtKey (const std::string &plugin,
280 const std::string &key,
281 const VariantTypes &value)
282 {
283 GVariant *variant = NULL;
284 if (writeStringToVariant (boost::get <const char *> (value), &variant))
285 writeVariantToKey (mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant);
286 else
287 throw std::exception ();
288 }
289
290 void WriteBellAtKey (const std::string &plugin,
291 const std::string &key,
292 const VariantTypes &value)
293 {
294 GVariant *variant = NULL;
295 if (writeBoolToVariant (boolToBool (boost::get <bool> (value)), &variant))
296 writeVariantToKey (mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant);
297 else
298 throw std::exception ();
299 }
300
301 void WriteListAtKey (const std::string &plugin,
302 const std::string &key,
303 const VariantTypes &value)
304 {
305 GVariant *variant = NULL;
306
307 const cci::SettingValueListWrapper::Ptr &lw (boost::get <cci::SettingValueListWrapper::Ptr> (value));
308
309 if (writeListValue (*lw, lw->type (), &variant))
310 writeVariantToKey (mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant);
311 else
312 throw std::exception ();
313 }
314
315 Bool ReadBoolAtKey (const std::string &plugin,
316 const std::string &key)
317 {
318 GVariantShared variant (ReadVariantAtKeyToShared (plugin,
319 key,
320 TypeBool));
321 return readBoolFromVariant (variant.get ());
322 }
323
324 int ReadIntegerAtKey (const std::string &plugin,
325 const std::string &key)
326 {
327 GVariantShared variant (ReadVariantAtKeyToShared (plugin,
328 key,
329 TypeInt));
330 return readIntFromVariant (variant.get ());
331 }
332
333 float ReadFloatAtKey (const std::string &plugin,
334 const std::string &key)
335 {
336 GVariantShared variant (ReadVariantAtKeyToShared (plugin,
337 key,
338 TypeFloat));
339 return readFloatFromVariant (variant.get ());
340 }
341
342 const char * ReadStringAtKey (const std::string &plugin,
343 const std::string &key)
344 {
345 GVariantShared variant (ReadVariantAtKeyToShared (plugin,
346 key,
347 TypeString));
348 return readStringFromVariant (variant.get ());
349 }
350
351 CCSSettingColorValue ReadColorAtKey (const std::string &plugin,
352 const std::string &key)
353 {
354 Bool success = FALSE;
355 GVariantShared variant (ReadVariantAtKeyToShared (plugin,
356 key,
357 TypeColor));
358 CCSSettingColorValue value = readColorFromVariant (variant.get (), &success);
359 EXPECT_TRUE (success);
360 return value;
361 }
362
363 CCSSettingKeyValue ReadKeyAtKey (const std::string &plugin,
364 const std::string &key)
365 {
366 Bool success = FALSE;
367 GVariantShared variant (ReadVariantAtKeyToShared (plugin,
368 key,
369 TypeKey));
370 CCSSettingKeyValue value = readKeyFromVariant (variant.get (), &success);
371 EXPECT_TRUE (success);
372 return value;
373 }
374
375 CCSSettingButtonValue ReadButtonAtKey (const std::string &plugin,
376 const std::string &key)
377 {
378 Bool success = FALSE;
379 GVariantShared variant (ReadVariantAtKeyToShared (plugin,
380 key,
381 TypeButton));
382 CCSSettingButtonValue value = readButtonFromVariant (variant.get (), &success);
383 EXPECT_TRUE (success);
384 return value;
385 }
386
387 unsigned int ReadEdgeAtKey (const std::string &plugin,
388 const std::string &key)
389 {
390 GVariantShared variant (ReadVariantAtKeyToShared (plugin,
391 key,
392 TypeEdge));
393 return readEdgeFromVariant (variant.get ());
394 }
395
396 const char * ReadMatchAtKey (const std::string &plugin,
397 const std::string &key)
398 {
399 GVariantShared variant (ReadVariantAtKeyToShared (plugin,
400 key,
401 TypeMatch));
402 return readStringFromVariant (variant.get ());
403 }
404
405 Bool ReadBellAtKey (const std::string &plugin,
406 const std::string &key)
407 {
408 GVariantShared variant (ReadVariantAtKeyToShared (plugin,
409 key,
410 TypeBell));
411 return readBoolFromVariant (variant.get ());
412 }
413
414 CCSSettingValueList ReadListAtKey (const std::string &plugin,
415 const std::string &key,
416 CCSSetting *setting)
417 {
418 GVariantShared variant (ReadVariantAtKeyToShared (plugin,
419 key,
420 TypeList));
421 return readListValue (variant.get (), setting, &ccsDefaultObjectAllocator);
422 }
423
424 private:
425
426 GVariantShared
427 ReadVariantAtKeyToShared (const std::string &plugin,
428 const std::string &key,
429 CCSSettingType type)
430 {
431 CharacterWrapper translatedKey (translateKeyForGSettings (key.c_str ()));
432 CharacterWrapper pluginPath (makeCompizPluginPath (profileName.c_str (),
433 plugin.c_str ()));
434
435 GVariant *rawVariant = getVariantAtKey (mSettings,
436 translatedKey,
437 pluginPath,
438 type);
439
440 GVariantShared shared (AutoDestroy (rawVariant, g_variant_unref));
441
442
443
444 return shared;
445 }
446
447 CCSGSettingsWrapper *mSettings;
448 std::string profileName;
449
450
451};
452
453class CCSGSettingsBackendEnv :49class CCSGSettingsBackendEnv :
454 public CCSBackendConceptTestEnvironmentInterface,50 public CCSBackendConceptTestEnvironmentInterface,
455 public CCSGSettingsMemoryBackendTestingEnv51 public CCSGSettingsMemoryBackendTestingEnv
@@ -551,7 +147,6 @@
551147
552 ccsFreeDynamicBackend (mBackend);148 ccsFreeDynamicBackend (mBackend);
553149
554 ccsGSettingsWrapperUnref (mSettings);
555 mStorage.reset ();150 mStorage.reset ();
556151
557 g_variant_unref (pluginKeys);152 g_variant_unref (pluginKeys);
558153
=== modified file 'compizconfig/gsettings/tests/test_gsettings_tests.h'
--- compizconfig/gsettings/tests/test_gsettings_tests.h 2012-08-17 14:59:52 +0000
+++ compizconfig/gsettings/tests/test_gsettings_tests.h 2012-09-24 03:58:20 +0000
@@ -1,9 +1,33 @@
1/*
2 * Compiz configuration system library
3 *
4 * Copyright (C) 2012 Canonical Ltd.
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 *
20 * Authored By:
21 * Sam Spilsbury <sam.spilsbury@canonical.com>
22 */
1#ifndef _COMPIZCONFIG_TEST_GSETTINGS_TESTS_H23#ifndef _COMPIZCONFIG_TEST_GSETTINGS_TESTS_H
2#define _COMPIZCONFIG_TEST_GSETTINGS_TESTS_H24#define _COMPIZCONFIG_TEST_GSETTINGS_TESTS_H
325
4#include <gtest/gtest.h>26#include <gtest/gtest.h>
5#include <glib.h>27#include <glib.h>
6#include <glib-object.h>28#include <glib-object.h>
29#include <glib_gslice_off_env.h>
30#include <glib_gsettings_memory_backend_env.h>
7#include <gsettings-mock-schemas-config.h>31#include <gsettings-mock-schemas-config.h>
832
9using ::testing::TestWithParam;33using ::testing::TestWithParam;
@@ -52,9 +76,29 @@
52 }76 }
53};77};
5478
79class CCSGSettingsTestCommon :
80 public ::testing::Test
81{
82 public:
83
84 virtual void SetUp ()
85 {
86 env.SetUpEnv ();
87 }
88
89 virtual void TearDown ()
90 {
91 env.TearDownEnv ();
92 }
93
94 private:
95
96 CompizGLibGSliceOffEnv env;
97};
98
55class CCSGSettingsTest :99class CCSGSettingsTest :
56 public CCSGSettingsTestingEnv,100 public CCSGSettingsTestCommon,
57 public ::testing::TestWithParam <CCSGSettingsTeardownSetupInterface *>101 public ::testing::WithParamInterface <CCSGSettingsTeardownSetupInterface *>
58{102{
59 public:103 public:
60104
@@ -65,13 +109,13 @@
65109
66 virtual void SetUp ()110 virtual void SetUp ()
67 {111 {
68 CCSGSettingsTestingEnv::SetUpEnv ();112 CCSGSettingsTestCommon::SetUp ();
69 mFuncs->SetUp ();113 mFuncs->SetUp ();
70 }114 }
71115
72 virtual void TearDown ()116 virtual void TearDown ()
73 {117 {
74 CCSGSettingsTestingEnv::TearDownEnv ();118 CCSGSettingsTestCommon::TearDown ();
75 mFuncs->TearDown ();119 mFuncs->TearDown ();
76 }120 }
77121
@@ -81,41 +125,40 @@
81};125};
82126
83class CCSGSettingsTestIndependent :127class CCSGSettingsTestIndependent :
84 public CCSGSettingsTestingEnv,128 public CCSGSettingsTestCommon
85 public ::testing::Test
86{129{
87 public:130 public:
88131
89 virtual void SetUp ()132 virtual void SetUp ()
90 {133 {
134 CCSGSettingsTestCommon::SetUp ();
91 g_type_init ();135 g_type_init ();
92
93 CCSGSettingsTestingEnv::SetUpEnv ();
94 }136 }
95137
96 virtual void TearDown ()138 virtual void TearDown ()
97 {139 {
98 CCSGSettingsTestingEnv::TearDownEnv ();140 CCSGSettingsTestCommon::TearDown ();
99 }141 }
100};142};
101143
102class CCSGSettingsTestWithMemoryBackend :144class CCSGSettingsTestWithMemoryBackend :
103 public CCSGSettingsTestIndependent,145 public CCSGSettingsTestIndependent
104 public CCSGSettingsMemoryBackendTestingEnv
105{146{
106 public:147 public:
107148
108 virtual void SetUp ()149 virtual void SetUp ()
109 {150 {
110 CCSGSettingsTestIndependent::SetUp ();151 CCSGSettingsTestIndependent::SetUp ();
111 CCSGSettingsMemoryBackendTestingEnv::SetUpEnv ();152 env.SetUpEnv (MOCK_PATH);
112 }153 }
113154
114 virtual void TearDown ()155 virtual void TearDown ()
115 {156 {
116 CCSGSettingsMemoryBackendTestingEnv::TearDownEnv ();157 env.TearDownEnv ();
117 CCSGSettingsTestIndependent::TearDown ();
118 }158 }
159 private:
160
161 CompizGLibGSettingsMemoryBackendTestingEnv env;
119};162};
120163
121#endif164#endif
122165
=== modified file 'compizconfig/integration/gnome/CMakeLists.txt'
--- compizconfig/integration/gnome/CMakeLists.txt 2012-08-18 13:15:30 +0000
+++ compizconfig/integration/gnome/CMakeLists.txt 2012-09-24 03:58:20 +0000
@@ -38,4 +38,6 @@
38 compizconfig38 compizconfig
39 ${COMPIZCONFIG_GNOME_INTEGRATION_LIBRARIES})39 ${COMPIZCONFIG_GNOME_INTEGRATION_LIBRARIES})
4040
41 add_subdirectory (tests)
42
41endif (COMPIZCONFIG_GNOME_INTEGRATION_FOUND)43endif (COMPIZCONFIG_GNOME_INTEGRATION_FOUND)
4244
=== modified file 'compizconfig/integration/gnome/gconf/src/ccs_gnome_integration_gconf_integrated_setting.c'
--- compizconfig/integration/gnome/gconf/src/ccs_gnome_integration_gconf_integrated_setting.c 2012-08-17 07:33:02 +0000
+++ compizconfig/integration/gnome/gconf/src/ccs_gnome_integration_gconf_integrated_setting.c 2012-09-24 03:58:20 +0000
@@ -63,7 +63,8 @@
63 {63 {
64 ccsError ("NULL encountered while reading GConf setting");64 ccsError ("NULL encountered while reading GConf setting");
65 free (gnomeKeyPath);65 free (gnomeKeyPath);
66 return v;66 free (v);
67 return NULL;
67 }68 }
6869
69 if (err)70 if (err)
@@ -71,7 +72,8 @@
71 ccsError ("%s", err->message);72 ccsError ("%s", err->message);
72 g_error_free (err);73 g_error_free (err);
73 free (gnomeKeyPath);74 free (gnomeKeyPath);
74 return v;75 free (v);
76 return NULL;
75 }77 }
7678
77 switch (type)79 switch (type)
@@ -80,6 +82,8 @@
80 if (gconfValue->type != GCONF_VALUE_INT)82 if (gconfValue->type != GCONF_VALUE_INT)
81 {83 {
82 ccsError ("Expected integer value");84 ccsError ("Expected integer value");
85 free (v);
86 v = NULL;
83 break;87 break;
84 }88 }
8589
@@ -89,6 +93,8 @@
89 if (gconfValue->type != GCONF_VALUE_BOOL)93 if (gconfValue->type != GCONF_VALUE_BOOL)
90 {94 {
91 ccsError ("Expected boolean value");95 ccsError ("Expected boolean value");
96 free (v);
97 v = NULL;
92 break;98 break;
93 }99 }
94100
@@ -99,6 +105,8 @@
99 if (gconfValue->type != GCONF_VALUE_STRING)105 if (gconfValue->type != GCONF_VALUE_STRING)
100 {106 {
101 ccsError ("Expected string value");107 ccsError ("Expected string value");
108 free (v);
109 v = NULL;
102 break;110 break;
103 }111 }
104112
@@ -220,10 +228,17 @@
220 ccsGConfIntegratedSettingFree ((CCSIntegratedSetting *) info);228 ccsGConfIntegratedSettingFree ((CCSIntegratedSetting *) info);
221}229}
222230
231void
232ccsGConfGNOMEIntegratedSettingInfoFree (CCSGNOMEIntegratedSettingInfo *info)
233{
234 ccsGConfIntegratedSettingFree ((CCSIntegratedSetting *) info);
235}
236
223const CCSGNOMEIntegratedSettingInfoInterface ccsGConfGNOMEIntegratedSettingInfoInterface =237const CCSGNOMEIntegratedSettingInfoInterface ccsGConfGNOMEIntegratedSettingInfoInterface =
224{238{
225 ccsGConfIntegratedSettingGetSpecialOptionType,239 ccsGConfIntegratedSettingGetSpecialOptionType,
226 ccsGConfIntegratedSettingGetGNOMEName240 ccsGConfIntegratedSettingGetGNOMEName,
241 ccsGConfGNOMEIntegratedSettingInfoFree
227};242};
228243
229const CCSIntegratedSettingInterface ccsGConfIntegratedSettingInterface =244const CCSIntegratedSettingInterface ccsGConfIntegratedSettingInterface =
230245
=== modified file 'compizconfig/integration/gnome/gsettings/CMakeLists.txt'
--- compizconfig/integration/gnome/gsettings/CMakeLists.txt 2012-08-18 13:15:30 +0000
+++ compizconfig/integration/gnome/gsettings/CMakeLists.txt 2012-09-24 03:58:20 +0000
@@ -71,6 +71,8 @@
7171
72 endif (GLIB_COMPILE_SCHEMAS)72 endif (GLIB_COMPILE_SCHEMAS)
7373
74 add_subdirectory (tests)
75
74 endif (COMPIZCONFIG_GNOME_GSETTINGS_INTEGRATION_FOUND)76 endif (COMPIZCONFIG_GNOME_GSETTINGS_INTEGRATION_FOUND)
7577
76endif (USE_GSETTINGS)78endif (USE_GSETTINGS)
7779
=== modified file 'compizconfig/integration/gnome/gsettings/src/ccs_gnome_integration_gsettings_integrated_setting.c'
--- compizconfig/integration/gnome/gsettings/src/ccs_gnome_integration_gsettings_integrated_setting.c 2012-08-17 07:33:02 +0000
+++ compizconfig/integration/gnome/gsettings/src/ccs_gnome_integration_gsettings_integrated_setting.c 2012-09-24 03:58:20 +0000
@@ -55,7 +55,11 @@
55 GVariant *variant = ccsGSettingsWrapperGetValue (priv->wrapper, gsettingsTranslatedName);55 GVariant *variant = ccsGSettingsWrapperGetValue (priv->wrapper, gsettingsTranslatedName);
5656
57 if (!variant)57 if (!variant)
58 {
58 free (gsettingsTranslatedName);59 free (gsettingsTranslatedName);
60 free (v);
61 return NULL;
62 }
5963
60 const GVariantType *variantType = G_VARIANT_TYPE (g_variant_get_type_string (variant));64 const GVariantType *variantType = G_VARIANT_TYPE (g_variant_get_type_string (variant));
6165
@@ -65,6 +69,8 @@
65 if (!g_variant_type_equal (variantType, G_VARIANT_TYPE_INT32))69 if (!g_variant_type_equal (variantType, G_VARIANT_TYPE_INT32))
66 {70 {
67 ccsError ("Expected integer value");71 ccsError ("Expected integer value");
72 free (v);
73 v = NULL;
68 break;74 break;
69 }75 }
7076
@@ -74,6 +80,8 @@
74 if (!g_variant_type_equal (variantType, G_VARIANT_TYPE_BOOLEAN))80 if (!g_variant_type_equal (variantType, G_VARIANT_TYPE_BOOLEAN))
75 {81 {
76 ccsError ("Expected boolean value");82 ccsError ("Expected boolean value");
83 free (v);
84 v = NULL;
77 break;85 break;
78 }86 }
7987
@@ -84,6 +92,8 @@
84 if (!g_variant_type_equal (variantType, G_VARIANT_TYPE_STRING))92 if (!g_variant_type_equal (variantType, G_VARIANT_TYPE_STRING))
85 {93 {
86 ccsError ("Expected string value");94 ccsError ("Expected string value");
95 free (v);
96 v = NULL;
87 break;97 break;
88 }98 }
8999
@@ -96,6 +106,8 @@
96 if (!g_variant_type_equal (variantType, G_VARIANT_TYPE ("as")))106 if (!g_variant_type_equal (variantType, G_VARIANT_TYPE ("as")))
97 {107 {
98 ccsError ("Expected array-of-string value");108 ccsError ("Expected array-of-string value");
109 free (v);
110 v = NULL;
99 break;111 break;
100 }112 }
101113
@@ -127,8 +139,9 @@
127 const char *gnomeKeyName = ccsGNOMEIntegratedSettingInfoGetGNOMEName ((CCSGNOMEIntegratedSettingInfo *) setting);139 const char *gnomeKeyName = ccsGNOMEIntegratedSettingInfoGetGNOMEName ((CCSGNOMEIntegratedSettingInfo *) setting);
128 char *gsettingsTranslatedName = translateKeyForGSettings (gnomeKeyName);140 char *gsettingsTranslatedName = translateKeyForGSettings (gnomeKeyName);
129141
130 GVariant *variant = ccsGSettingsWrapperGetValue (priv->wrapper, gsettingsTranslatedName);142 GVariant *variant = ccsGSettingsWrapperGetValue (priv->wrapper, gsettingsTranslatedName);
131 GVariant *newVariant = NULL;143 const GVariantType *variantType = g_variant_get_type (variant);
144 GVariant *newVariant = NULL;
132145
133 if (!variant)146 if (!variant)
134 {147 {
@@ -141,42 +154,62 @@
141 {154 {
142 case TypeInt:155 case TypeInt:
143 {156 {
144 int currentValue = readIntFromVariant (variant);157 if (!g_variant_type_equal (variantType, G_VARIANT_TYPE_INT32))
158 ccsError ("Expected integer value");
159 else
160 {
161 int currentValue = readIntFromVariant (variant);
145162
146 if ((currentValue != v->value.asInt))163 if ((currentValue != v->value.asInt))
147 writeIntToVariant (v->value.asInt, &newVariant);164 writeIntToVariant (v->value.asInt, &newVariant);
165 }
148 }166 }
149 break;167 break;
150 case TypeBool:168 case TypeBool:
151 {169 {
152 gboolean currentValue = readBoolFromVariant (variant);170 if (!g_variant_type_equal (variantType, G_VARIANT_TYPE_BOOLEAN))
171 ccsError ("Expected boolean value");
172 else
173 {
174 gboolean currentValue = readBoolFromVariant (variant);
153175
154 if ((currentValue != v->value.asBool))176 if ((currentValue != v->value.asBool))
155 writeBoolToVariant (v->value.asBool, &newVariant);177 writeBoolToVariant (v->value.asBool, &newVariant);
178 }
156 }179 }
157 break;180 break;
158 case TypeString:181 case TypeString:
159 {182 {
160 const char *defaultValue = "";183 if (!g_variant_type_equal (variantType, G_VARIANT_TYPE_STRING))
161 const char *newValue = v->value.asString ? v->value.asString : defaultValue;184 ccsError ("Expected string value");
162 gsize len = 0;185 else
163 const gchar *currentValue = g_variant_get_string (variant, &len);186 {
187 const char *defaultValue = "";
188 const char *newValue = v->value.asString ? v->value.asString : defaultValue;
189 gsize len = 0;
190 const gchar *currentValue = g_variant_get_string (variant, &len);
164191
165 if (currentValue)192 if (currentValue)
166 {193 {
167 if (strcmp (currentValue, newValue) != 0)194 if (strcmp (currentValue, newValue) != 0)
168 writeStringToVariant (currentValue, &newVariant);195 writeStringToVariant (currentValue, &newVariant);
196 }
169 }197 }
170 }198 }
171 break;199 break;
172 case TypeKey:200 case TypeKey:
173 {201 {
174 const char *defaultValue = "";202 if (!g_variant_type_equal (variantType, G_VARIANT_TYPE ("as")))
175 GVariantBuilder strvBuilder;203 ccsError ("Expected array-of-string value");
204 else
205 {
206 const char *defaultValue = "";
207 GVariantBuilder strvBuilder;
176208
177 g_variant_builder_init (&strvBuilder, G_VARIANT_TYPE ("as"));209 g_variant_builder_init (&strvBuilder, G_VARIANT_TYPE ("as"));
178 g_variant_builder_add (&strvBuilder, "s", v->value.asString ? v->value.asString : defaultValue);210 g_variant_builder_add (&strvBuilder, "s", v->value.asString ? v->value.asString : defaultValue);
179 newVariant = g_variant_builder_end (&strvBuilder);211 newVariant = g_variant_builder_end (&strvBuilder);
212 }
180 }213 }
181 break;214 break;
182 default:215 default:
@@ -238,10 +271,17 @@
238 return ccsGSettingsIntegratedSettingFree ((CCSIntegratedSetting *) info);271 return ccsGSettingsIntegratedSettingFree ((CCSIntegratedSetting *) info);
239}272}
240273
274void
275ccsGSettingsGNOMEIntegratedSettingInfoFree (CCSGNOMEIntegratedSettingInfo *info)
276{
277 return ccsGSettingsIntegratedSettingFree ((CCSIntegratedSetting *) info);
278}
279
241const CCSGNOMEIntegratedSettingInfoInterface ccsGSettingsGNOMEIntegratedSettingInterface =280const CCSGNOMEIntegratedSettingInfoInterface ccsGSettingsGNOMEIntegratedSettingInterface =
242{281{
243 ccsGSettingsIntegratedSettingGetSpecialOptionType,282 ccsGSettingsIntegratedSettingGetSpecialOptionType,
244 ccsGSettingsIntegratedSettingGetGNOMEName283 ccsGSettingsIntegratedSettingGetGNOMEName,
284 ccsGSettingsGNOMEIntegratedSettingInfoFree
245};285};
246286
247const CCSIntegratedSettingInterface ccsGSettingsIntegratedSettingInterface =287const CCSIntegratedSettingInterface ccsGSettingsIntegratedSettingInterface =
248288
=== added directory 'compizconfig/integration/gnome/gsettings/tests'
=== added file 'compizconfig/integration/gnome/gsettings/tests/CMakeLists.txt'
--- compizconfig/integration/gnome/gsettings/tests/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ compizconfig/integration/gnome/gsettings/tests/CMakeLists.txt 2012-09-24 03:58:20 +0000
@@ -0,0 +1,31 @@
1include_directories (${GTEST_INCLUDE_DIRS})
2include_directories (${CMAKE_SOURCE_DIR}/include)
3include_directories (${CMAKE_SOURCE_DIR}/tests/shared)
4include_directories (${CMAKE_SOURCE_DIR}/tests/shared/glib)
5include_directories (${CMAKE_CURRENT_SOURCE_DIR}/../../../../mocks/libcompizconfig)
6include_directories (${CMAKE_CURRENT_SOURCE_DIR}/../../../../gsettings/tests)
7include_directories (${CMAKE_CURRENT_SOURCE_DIR}/../../../../gsettings/mocks)
8include_directories (${CMAKE_SOURCE_DIR}/compizconfig/tests)
9link_directories (${CMAKE_INSTALL_PREFIX}/lib)
10link_directories (${CMAKE_CURRENT_BINARY_DIR}/../../mocks/libcompizconfig)
11link_directories (${CMAKE_CURRENT_BINARY_DIR}/../../tests/)
12link_directories (${CMAKE_CURRENT_BINARY_DIR}/../src/)
13
14set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
15
16add_executable (compizconfig_test_ccs_gnome_gsettings_integrated_setting
17 ${CMAKE_CURRENT_SOURCE_DIR}/compizconfig_test_ccs_gnome_gsettings_integrated_setting.cpp)
18
19target_link_libraries (compizconfig_test_ccs_gnome_gsettings_integrated_setting
20 ${GTEST_BOTH_LIBRARIES}
21 ${GMOCK_LIBRARY}
22 ${GMOCK_MAIN_LIBRARY}
23 ${CMAKE_THREAD_LIBS_INIT}
24 ${LIBCOMPIZCONFIG_LIBRARIES}
25 compizconfig
26 compizconfig_gsettings_settings_test_env
27 compizconfig_ccs_gsettings_wrapper_mock
28 compizconfig_gnome_integration_gsettings_integrated_setting
29 compizconfig_gsettings_backend_interface)
30
31compiz_discover_tests (compizconfig_test_ccs_gnome_gsettings_integrated_setting COVERAGE compizconfig_gnome_gsettings_integrated_setting)
032
=== added file 'compizconfig/integration/gnome/gsettings/tests/compizconfig_test_ccs_gnome_gsettings_integrated_setting.cpp'
--- compizconfig/integration/gnome/gsettings/tests/compizconfig_test_ccs_gnome_gsettings_integrated_setting.cpp 1970-01-01 00:00:00 +0000
+++ compizconfig/integration/gnome/gsettings/tests/compizconfig_test_ccs_gnome_gsettings_integrated_setting.cpp 2012-09-24 03:58:20 +0000
@@ -0,0 +1,388 @@
1/*
2 * Compiz configuration system library
3 *
4 * Copyright (C) 2012 Canonical Ltd.
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 *
20 * Authored By:
21 * Sam Spilsbury <sam.spilsbury@canonical.com>
22 */
23#include <gtest/gtest.h>
24#include <gmock/gmock.h>
25
26#include <map>
27#include <memory>
28#include <tr1/tuple>
29#include <boost/shared_ptr.hpp>
30
31#include <glib_gslice_off_env.h>
32#include <gtest_shared_autodestroy.h>
33
34#include <ccs.h>
35#include <ccs-backend.h>
36#include <ccs_gnome_integrated_setting.h>
37#include <ccs_gnome_integration_gsettings_integrated_setting.h>
38#include <ccs_gsettings_wrapper_mock.h>
39
40using ::testing::Combine;
41using ::testing::Return;
42using ::testing::IsNull;
43using ::testing::ValuesIn;
44using ::testing::Values;
45using ::testing::Eq;
46using ::testing::_;
47
48namespace compiz
49{
50 namespace config
51 {
52 namespace integration
53 {
54 namespace test
55 {
56 const std::string KEYBINDING_ONE = "keybinding_one";
57 const std::string KEYBINDING_TWO = "keybinding_two";
58 const std::string STRING = "string";
59 const Bool BOOLEAN = TRUE;
60 const int INTEGER = 2;
61
62 const std::string STRING_ALT = "string_alt";
63 const Bool BOOLEAN_ALT = FALSE;
64 const int INTEGER_ALT = 1;
65
66 namespace variant_generators
67 {
68 GVariant * i ();
69 GVariant * s ();
70 GVariant * b ();
71 GVariant * as ();
72 }
73
74 namespace value_generators
75 {
76 CCSSettingValue * integer ();
77 CCSSettingValue * string ();
78 CCSSettingValue * key ();
79 CCSSettingValue * boolean ();
80 }
81
82 namespace expectations
83 {
84 void integer (CCSSettingValue *);
85 void string (CCSSettingValue *);
86 void boolean (CCSSettingValue *);
87 void key (CCSSettingValue *);
88
89 void integerVariant (GVariant *, int);
90 void stringVariant (GVariant *, const std::string &);
91 void booleanVariant (GVariant *, bool);
92 void keyVariant (GVariant *, const std::string &);
93 }
94
95 typedef GVariant * (*VariantGenerator) ();
96 typedef CCSSettingValue * (*ValueGenerator) ();
97 typedef void (*Expectation) (CCSSettingValue *);
98
99 struct GSettingsIntegratedSettingInfo
100 {
101 VariantGenerator variantGenerator;
102 ValueGenerator valueGenerator;
103 Expectation expectation;
104 CCSSettingType settingType;
105 };
106
107 namespace impl
108 {
109 namespace ccit = compiz::config::integration::test;
110 namespace vg = compiz::config::integration::test::variant_generators;
111 namespace cvg = compiz::config::integration::test::value_generators;
112 namespace ex = compiz::config::integration::test::expectations;
113
114 ccit::GSettingsIntegratedSettingInfo settingsInfo[] =
115 {
116 { vg::i, cvg::integer, ex::integer, TypeInt },
117 { vg::b, cvg::boolean, ex::boolean, TypeBool },
118 { vg::s, cvg::string, ex::string, TypeString },
119 { vg::as, cvg::key, ex::key, TypeKey }
120 };
121 }
122 }
123 }
124 }
125}
126
127namespace
128{
129 std::map <CCSSettingType, SpecialOptionType> &
130 ccsTypeToSpecialType ()
131 {
132 static std::map <CCSSettingType, SpecialOptionType> types;
133 static bool initialized = false;
134
135 if (!initialized)
136 {
137 types[TypeInt] = OptionInt;
138 types[TypeBool] = OptionBool;
139 types[TypeString] = OptionString;
140 types[TypeKey] = OptionKey;
141 }
142
143 return types;
144 }
145}
146
147namespace ccit = compiz::config::integration::test;
148namespace cciti = compiz::config::integration::test::impl;
149namespace ccvg = compiz::config::integration::test::variant_generators;
150namespace ccvalg = compiz::config::integration::test::value_generators;
151namespace ccex = compiz::config::integration::test::expectations;
152
153typedef std::tr1::tuple <CCSSettingType,
154 ccit::GSettingsIntegratedSettingInfo> CCSGSettingsIntegratedSettingTestInfo;
155
156class CCSGSettingsIntegratedSettingTest :
157 public ::testing::TestWithParam <CCSGSettingsIntegratedSettingTestInfo>
158{
159 public:
160
161 virtual void SetUp ();
162 virtual void TearDown ();
163
164 protected:
165
166 CompizGLibGSliceOffEnv env;
167 boost::shared_ptr <CCSGSettingsWrapper> mWrapper;
168 CCSGSettingsWrapperGMock *mWrapperMock;
169};
170
171GVariant *
172ccvg::as ()
173{
174 GVariantBuilder builder;
175 g_variant_builder_init (&builder, G_VARIANT_TYPE ("as"));
176 g_variant_builder_add (&builder, "s", ccit::KEYBINDING_ONE.c_str ());
177 g_variant_builder_add (&builder, "s", ccit::KEYBINDING_TWO.c_str ());
178
179 return g_variant_builder_end (&builder);
180}
181
182GVariant *
183ccvg::i ()
184{
185 return g_variant_new ("i", ccit::INTEGER);
186}
187
188GVariant *
189ccvg::b ()
190{
191 return g_variant_new ("b", ccit::BOOLEAN);
192}
193
194GVariant *
195ccvg::s ()
196{
197 return g_variant_new ("s", ccit::STRING.c_str ());
198}
199
200namespace
201{
202 CCSSettingValue * createSettingValue ()
203 {
204 CCSSettingValue *v = reinterpret_cast <CCSSettingValue *> (calloc (1, sizeof (CCSSettingValue)));
205
206 v->isListChild = FALSE;
207 v->parent = NULL;
208 v->refCount = 1;
209
210 return v;
211 }
212}
213
214CCSSettingValue *
215ccvalg::integer ()
216{
217 CCSSettingValue *v = createSettingValue ();
218 v->value.asInt = ccit::INTEGER_ALT;
219 return v;
220}
221
222CCSSettingValue *
223ccvalg::string ()
224{
225 CCSSettingValue *v = createSettingValue ();
226 v->value.asString = strdup (ccit::STRING_ALT.c_str ());
227 return v;
228}
229
230CCSSettingValue *
231ccvalg::key ()
232{
233 CCSSettingValue *v = createSettingValue ();
234 v->value.asString = strdup (ccit::KEYBINDING_TWO.c_str ());
235 return v;
236}
237
238CCSSettingValue *
239ccvalg::boolean ()
240{
241 CCSSettingValue *v = createSettingValue ();
242 v->value.asBool = ccit::BOOLEAN_ALT;
243 return v;
244}
245
246void
247ccex::boolean (CCSSettingValue *v)
248{
249 EXPECT_EQ (v->value.asBool, ccit::BOOLEAN);
250}
251
252void
253ccex::integer (CCSSettingValue *v)
254{
255 EXPECT_EQ (v->value.asInt, ccit::INTEGER);
256}
257
258void
259ccex::string (CCSSettingValue *v)
260{
261 EXPECT_EQ (v->value.asString, ccit::STRING);
262}
263
264void
265ccex::key (CCSSettingValue *v)
266{
267 EXPECT_EQ (v->value.asString, ccit::KEYBINDING_ONE);
268}
269
270void
271ccex::integerVariant (GVariant *v , int i)
272{
273 EXPECT_EQ (g_variant_get_int32 (v), i);
274}
275
276void
277ccex::stringVariant (GVariant *v, const std::string &s)
278{
279 gsize len;
280 EXPECT_EQ (g_variant_get_string (v, &len), s);
281}
282
283void
284ccex::booleanVariant (GVariant *v, bool b)
285{
286 EXPECT_EQ (g_variant_get_boolean (v), b);
287}
288
289void
290ccex::keyVariant (GVariant *v, const std::string &s)
291{
292 gsize len;
293 const gchar * const *strv = g_variant_get_strv (v, &len);
294 EXPECT_EQ (strv[0], s);
295}
296
297void
298CCSGSettingsIntegratedSettingTest::SetUp ()
299{
300 env.SetUpEnv ();
301 mWrapper.reset (ccsMockGSettingsWrapperNew (),
302 boost::bind (ccsMockGSettingsWrapperFree, _1));
303 mWrapperMock = reinterpret_cast <CCSGSettingsWrapperGMock *> (
304 ccsObjectGetPrivate (mWrapper.get ()));
305}
306
307void
308CCSGSettingsIntegratedSettingTest::TearDown ()
309{
310 mWrapper.reset ();
311 mWrapperMock = NULL;
312 env.TearDownEnv ();
313}
314
315TEST_P (CCSGSettingsIntegratedSettingTest, MatchedTypesReturnValueMismatchedTypesReturnNull)
316{
317 const std::string keyName ("mock");
318 const ccit::GSettingsIntegratedSettingInfo &integratedSettingInfo =
319 std::tr1::get <1> (GetParam ());
320 const CCSSettingType createSettingType =
321 std::tr1::get <0> (GetParam ());
322
323 CCSIntegratedSettingInfo *integratedSetting = ccsSharedIntegratedSettingInfoNew (keyName.c_str (),
324 keyName.c_str (),
325 integratedSettingInfo.settingType,
326 &ccsDefaultObjectAllocator);
327 SpecialOptionType specialType = ccsTypeToSpecialType ()[integratedSettingInfo.settingType];
328 CCSGNOMEIntegratedSettingInfo *gnomeIntegratedSetting = ccsGNOMEIntegratedSettingInfoNew (integratedSetting,
329 specialType,
330 keyName.c_str (),
331 &ccsDefaultObjectAllocator);
332 CCSIntegratedSetting *gsettingsIntegrated = ccsGSettingsIntegratedSettingNew (gnomeIntegratedSetting,
333 mWrapper.get (),
334 &ccsDefaultObjectAllocator);
335
336 GVariant *variant = (*integratedSettingInfo.variantGenerator) ();
337 EXPECT_CALL (*mWrapperMock, getValue (Eq (keyName))).WillOnce (Return (variant));
338
339 CCSSettingValue *value = ccsIntegratedSettingReadValue (gsettingsIntegrated, createSettingType);
340
341 if (createSettingType == integratedSettingInfo.settingType)
342 (*integratedSettingInfo.expectation) (value);
343 else
344 EXPECT_THAT (value, IsNull ());
345
346 if (value)
347 ccsFreeSettingValueWithType (value, integratedSettingInfo.settingType);
348}
349
350TEST_P (CCSGSettingsIntegratedSettingTest, MatchedTypesReturnValueMismatchedTypesResetOrWrite)
351{
352 const std::string keyName ("mock");
353 const ccit::GSettingsIntegratedSettingInfo &integratedSettingInfo =
354 std::tr1::get <1> (GetParam ());
355 const CCSSettingType createSettingType =
356 std::tr1::get <0> (GetParam ());
357
358 CCSIntegratedSettingInfo *integratedSetting = ccsSharedIntegratedSettingInfoNew (keyName.c_str (),
359 keyName.c_str (),
360 integratedSettingInfo.settingType,
361 &ccsDefaultObjectAllocator);
362 SpecialOptionType specialType = ccsTypeToSpecialType ()[integratedSettingInfo.settingType];
363 CCSGNOMEIntegratedSettingInfo *gnomeIntegratedSetting = ccsGNOMEIntegratedSettingInfoNew (integratedSetting,
364 specialType,
365 keyName.c_str (),
366 &ccsDefaultObjectAllocator);
367 CCSIntegratedSetting *gsettingsIntegrated = ccsGSettingsIntegratedSettingNew (gnomeIntegratedSetting,
368 mWrapper.get (),
369 &ccsDefaultObjectAllocator);
370
371 CCSSettingValue *value = (*integratedSettingInfo.valueGenerator) ();
372 GVariant *variant = (*integratedSettingInfo.variantGenerator) ();
373 EXPECT_CALL (*mWrapperMock, getValue (Eq (keyName))).WillOnce (Return (variant));
374
375 if (createSettingType == integratedSettingInfo.settingType)
376 EXPECT_CALL (*mWrapperMock, setValue (Eq (keyName), _)); // can't verify this right yet
377 else
378 EXPECT_CALL (*mWrapperMock, resetKey (Eq (keyName)));
379
380 ccsIntegratedSettingWriteValue (gsettingsIntegrated, value, createSettingType);
381
382 if (value)
383 ccsFreeSettingValueWithType (value, integratedSettingInfo.settingType);
384}
385
386INSTANTIATE_TEST_CASE_P (CCSGSettingsIntegratedSettingTestMismatchedValues, CCSGSettingsIntegratedSettingTest,
387 Combine (Values (TypeInt, TypeString, TypeBool, TypeKey),
388 ValuesIn (cciti::settingsInfo)));
0389
=== modified file 'compizconfig/integration/gnome/include/ccs_gnome_integrated_setting.h'
--- compizconfig/integration/gnome/include/ccs_gnome_integrated_setting.h 2012-08-17 07:33:02 +0000
+++ compizconfig/integration/gnome/include/ccs_gnome_integrated_setting.h 2012-09-24 03:58:20 +0000
@@ -15,11 +15,13 @@
1515
16typedef SpecialOptionType (*CCSGNOMEIntegratedSettingInfoGetSpecialOptionType) (CCSGNOMEIntegratedSettingInfo *);16typedef SpecialOptionType (*CCSGNOMEIntegratedSettingInfoGetSpecialOptionType) (CCSGNOMEIntegratedSettingInfo *);
17typedef const char * (*CCSGNOMEIntegratedSettingInfoGetGNOMEName) (CCSGNOMEIntegratedSettingInfo *);17typedef const char * (*CCSGNOMEIntegratedSettingInfoGetGNOMEName) (CCSGNOMEIntegratedSettingInfo *);
18typedef void (*CCSGNOMEIntegratedSettingInfoFree) (CCSGNOMEIntegratedSettingInfo *);
1819
19struct _CCSGNOMEIntegratedSettingInfoInterface20struct _CCSGNOMEIntegratedSettingInfoInterface
20{21{
21 CCSGNOMEIntegratedSettingInfoGetSpecialOptionType getSpecialOptionType;22 CCSGNOMEIntegratedSettingInfoGetSpecialOptionType getSpecialOptionType;
22 CCSGNOMEIntegratedSettingInfoGetGNOMEName getGNOMEName;23 CCSGNOMEIntegratedSettingInfoGetGNOMEName getGNOMEName;
24 CCSGNOMEIntegratedSettingInfoFree free;
23};25};
2426
25/**27/**
@@ -53,6 +55,12 @@
53 const char *gnomeName,55 const char *gnomeName,
54 CCSObjectAllocationInterface *ai);56 CCSObjectAllocationInterface *ai);
5557
58void
59ccsFreeGNOMEIntegratedSettingInfo (CCSGNOMEIntegratedSettingInfo *);
60
61CCSREF_HDR (GNOMEIntegratedSettingInfo, CCSGNOMEIntegratedSettingInfo);
62CCSLIST_HDR (GNOMEIntegratedSettingInfo, CCSGNOMEIntegratedSettingInfo);
63
56COMPIZCONFIG_END_DECLS64COMPIZCONFIG_END_DECLS
5765
58#endif66#endif
5967
=== modified file 'compizconfig/integration/gnome/include/ccs_gnome_integration_constants.h'
--- compizconfig/integration/gnome/include/ccs_gnome_integration_constants.h 2012-09-05 09:02:56 +0000
+++ compizconfig/integration/gnome/include/ccs_gnome_integration_constants.h 2012-09-24 03:58:20 +0000
@@ -2,6 +2,7 @@
2#define _CCS_GNOME_INTEGRATION_CONSTANTS_H2#define _CCS_GNOME_INTEGRATION_CONSTANTS_H
33
4#include <ccs-defs.h>4#include <ccs-defs.h>
5#include <glib.h>
56
6COMPIZCONFIG_BEGIN_DECLS7COMPIZCONFIG_BEGIN_DECLS
78
89
=== modified file 'compizconfig/integration/gnome/include/ccs_gnome_integration_types.h'
--- compizconfig/integration/gnome/include/ccs_gnome_integration_types.h 2012-08-14 04:46:41 +0000
+++ compizconfig/integration/gnome/include/ccs_gnome_integration_types.h 2012-09-24 03:58:20 +0000
@@ -22,5 +22,7 @@
22 OptionSpecial,22 OptionSpecial,
23} SpecialOptionType;23} SpecialOptionType;
2424
25COMPIZCONFIG_END_DECLS
26
25#endif27#endif
2628
2729
=== removed file 'compizconfig/integration/gnome/include/ccs_gnome_integration_types.h~'
--- compizconfig/integration/gnome/include/ccs_gnome_integration_types.h~ 2012-08-14 06:42:11 +0000
+++ compizconfig/integration/gnome/include/ccs_gnome_integration_types.h~ 1970-01-01 00:00:00 +0000
@@ -1,26 +0,0 @@
1#ifndef _CCS_GNOME_INTEGRATION_TYPES_H
2#define _CCS_GNOME_INTEGRATION_TYPES_H
3
4#include <ccs-defs.h>
5
6COMPIZCONFIG_BEGIN_DECLS
7
8typedef struct _CCSBackend CCSBackend;
9typedef struct _CCSContext CCSContext;
10typedef struct _CCSObjectAllocationInterface CCSObjectAllocationInterface;
11typedef struct _CCSIntegration CCSIntegration;
12typedef struct _CCSIntegratedSetting CCSIntegratedSetting;
13typedef struct _CCSIntegratedSettingFactory CCSIntegratedSettingFactory;
14typedef struct _CCSIntegratedSettingsStorage CCSIntegratedSettingsStorage;
15typedef struct _GConfClient GConfClient;
16
17typedef enum {
18 OptionInt,
19 OptionBool,
20 OptionKey,
21 OptionString,
22 OptionSpecial,
23} SpecialOptionType;
24
25#endif
26
270
=== modified file 'compizconfig/integration/gnome/src/ccs_gnome_integrated_setting.c'
--- compizconfig/integration/gnome/src/ccs_gnome_integrated_setting.c 2012-08-18 13:15:30 +0000
+++ compizconfig/integration/gnome/src/ccs_gnome_integrated_setting.c 2012-09-24 03:58:20 +0000
@@ -12,6 +12,8 @@
1212
13INTERFACE_TYPE (CCSGNOMEIntegratedSettingInfoInterface);13INTERFACE_TYPE (CCSGNOMEIntegratedSettingInfoInterface);
1414
15CCSREF_OBJ (GNOMEIntegratedSettingInfo, CCSGNOMEIntegratedSettingInfo);
16
15SpecialOptionType17SpecialOptionType
16ccsGNOMEIntegratedSettingInfoGetSpecialOptionType (CCSGNOMEIntegratedSettingInfo *info)18ccsGNOMEIntegratedSettingInfoGetSpecialOptionType (CCSGNOMEIntegratedSettingInfo *info)
17{19{
@@ -89,7 +91,7 @@
89}91}
9092
91void93void
92ccsGNOMEIntegratedSettingInfoFree (CCSIntegratedSettingInfo *info)94ccsGNOMESharedIntegratedSettingInfoFree (CCSIntegratedSettingInfo *info)
93{95{
94 CCSGNOMEIntegratedSettingInfoDefaultImplPrivate *priv = (CCSGNOMEIntegratedSettingInfoDefaultImplPrivate *) ccsObjectGetPrivate (info);96 CCSGNOMEIntegratedSettingInfoDefaultImplPrivate *priv = (CCSGNOMEIntegratedSettingInfoDefaultImplPrivate *) ccsObjectGetPrivate (info);
9597
@@ -99,10 +101,17 @@
99 (*info->object.object_allocation->free_) (info->object.object_allocation->allocator, info);101 (*info->object.object_allocation->free_) (info->object.object_allocation->allocator, info);
100}102}
101103
104static void
105ccsGNOMEIntegratedSettingInfoFree (CCSGNOMEIntegratedSettingInfo *info)
106{
107 ccsGNOMESharedIntegratedSettingInfoFree ((CCSIntegratedSettingInfo *) info);
108}
109
102CCSGNOMEIntegratedSettingInfoInterface ccsGNOMEIntegratedSettingInfoDefaultImplInterface =110CCSGNOMEIntegratedSettingInfoInterface ccsGNOMEIntegratedSettingInfoDefaultImplInterface =
103{111{
104 ccsGNOMEIntegratedSettingGetSpecialOptionDefault,112 ccsGNOMEIntegratedSettingGetSpecialOptionDefault,
105 ccsGNOMEIntegratedSettingGetGNOMENameDefault113 ccsGNOMEIntegratedSettingGetGNOMENameDefault,
114 ccsGNOMEIntegratedSettingInfoFree
106};115};
107116
108const CCSIntegratedSettingInfoInterface ccsGNOMEIntegratedSettingInfoInterface =117const CCSIntegratedSettingInfoInterface ccsGNOMEIntegratedSettingInfoInterface =
@@ -110,9 +119,15 @@
110 ccsGNOMEIntegratedSettingInfoPluginName,119 ccsGNOMEIntegratedSettingInfoPluginName,
111 ccsGNOMEIntegratedSettingInfoSettingName,120 ccsGNOMEIntegratedSettingInfoSettingName,
112 ccsGNOMEIntegratedSettingInfoGetType,121 ccsGNOMEIntegratedSettingInfoGetType,
113 ccsGNOMEIntegratedSettingInfoFree122 ccsGNOMESharedIntegratedSettingInfoFree
114};123};
115124
125void
126ccsFreeGNOMEIntegratedSettingInfo (CCSGNOMEIntegratedSettingInfo *info)
127{
128 (*(GET_INTERFACE (CCSGNOMEIntegratedSettingInfoInterface, info))->free) (info);
129}
130
116CCSGNOMEIntegratedSettingInfo *131CCSGNOMEIntegratedSettingInfo *
117ccsGNOMEIntegratedSettingInfoNew (CCSIntegratedSettingInfo *base,132ccsGNOMEIntegratedSettingInfoNew (CCSIntegratedSettingInfo *base,
118 SpecialOptionType type,133 SpecialOptionType type,
119134
=== modified file 'compizconfig/integration/gnome/src/ccs_gnome_integration.c'
--- compizconfig/integration/gnome/src/ccs_gnome_integration.c 2012-08-17 07:33:02 +0000
+++ compizconfig/integration/gnome/src/ccs_gnome_integration.c 2012-09-24 03:58:20 +0000
@@ -132,9 +132,12 @@
132 CCSSettingType type = TypeString;132 CCSSettingType type = TypeString;
133 CCSSettingValue *v = ccsIntegratedSettingReadValue (mouseButtonModifierSetting, type);133 CCSSettingValue *v = ccsIntegratedSettingReadValue (mouseButtonModifierSetting, type);
134134
135 modMask = ccsStringToModifiers (v->value.asString);135 if (v)
136 {
137 modMask = ccsStringToModifiers (v->value.asString);
136138
137 ccsFreeSettingValueWithType (v, type);139 ccsFreeSettingValueWithType (v, type);
140 }
138141
139 return modMask;142 return modMask;
140}143}
@@ -445,7 +448,7 @@
445 }448 }
446 else if (strcmp (settingName, "fullscreen_visual_bell") == 0)449 else if (strcmp (settingName, "fullscreen_visual_bell") == 0)
447 {450 {
448 const char *newValueString = v->value.asString ? "fullscreen" : "frame_flash";451 const char *newValueString = v->value.asBool ? "fullscreen" : "frame_flash";
449 newValue->value.asString = strdup (newValueString);452 newValue->value.asString = strdup (newValueString);
450 type = TypeString;453 type = TypeString;
451454
@@ -453,7 +456,7 @@
453 }456 }
454 else if (strcmp (settingName, "click_to_focus") == 0)457 else if (strcmp (settingName, "click_to_focus") == 0)
455 {458 {
456 const char *newValueString = v->value.asString ? "click" : "sloppy";459 const char *newValueString = v->value.asBool ? "click" : "sloppy";
457 newValue->value.asString = strdup (newValueString);460 newValue->value.asString = strdup (newValueString);
458 type = TypeString;461 type = TypeString;
459462
@@ -468,9 +471,9 @@
468 unsigned int modMask;471 unsigned int modMask;
469 Bool resizeWithRightButton = FALSE;472 Bool resizeWithRightButton = FALSE;
470473
471 if ((getButtonBindingForSetting (context, "resize",474 if ((getButtonBindingForSetting (priv->context, "resize",
472 "initiate_button") == 3) ||475 "initiate_button") == 3) ||
473 (getButtonBindingForSetting (context, "core",476 (getButtonBindingForSetting (priv->context, "core",
474 "window_menu_button") == 2))477 "window_menu_button") == 2))
475 {478 {
476 resizeWithRightButton = TRUE;479 resizeWithRightButton = TRUE;
@@ -489,16 +492,16 @@
489 ccsGNOMEIntegratedPluginNames.SPECIAL,492 ccsGNOMEIntegratedPluginNames.SPECIAL,
490 ccsGNOMEIntegratedSettingNames.NULL_MOUSE_BUTTON_MODIFIER.compizName);493 ccsGNOMEIntegratedSettingNames.NULL_MOUSE_BUTTON_MODIFIER.compizName);
491494
492 modMask = ccsSettingGetValue (setting)->value.asButton.buttonModMask;495 modMask = v->value.asButton.buttonModMask;
493 if (setGnomeMouseButtonModifier (integratedSettingsMBM->data, modMask))496 if (setGnomeMouseButtonModifier (integratedSettingsMBM->data, modMask))
494 {497 {
495 setButtonBindingForSetting (context, "move",498 setButtonBindingForSetting (priv->context, "move",
496 "initiate_button", 1, modMask);499 "initiate_button", 1, modMask);
497 setButtonBindingForSetting (context, "resize",500 setButtonBindingForSetting (priv->context, "resize",
498 "initiate_button", 501 "initiate_button",
499 resizeWithRightButton ? 3 : 2,502 resizeWithRightButton ? 3 : 2,
500 modMask);503 modMask);
501 setButtonBindingForSetting (context, "core",504 setButtonBindingForSetting (priv->context, "core",
502 "window_menu_button",505 "window_menu_button",
503 resizeWithRightButton ? 2 : 3,506 resizeWithRightButton ? 2 : 3,
504 modMask);507 modMask);
505508
=== added directory 'compizconfig/integration/gnome/tests'
=== added file 'compizconfig/integration/gnome/tests/CMakeLists.txt'
--- compizconfig/integration/gnome/tests/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ compizconfig/integration/gnome/tests/CMakeLists.txt 2012-09-24 03:58:20 +0000
@@ -0,0 +1,47 @@
1include_directories (${GTEST_INCLUDE_DIRS})
2include_directories (${CMAKE_SOURCE_DIR}/include)
3include_directories (${CMAKE_SOURCE_DIR}/tests/shared)
4include_directories (${CMAKE_SOURCE_DIR}/tests/shared/glib)
5include_directories (${CMAKE_CURRENT_SOURCE_DIR}/../../../mocks/libcompizconfig)
6include_directories (${CMAKE_CURRENT_SOURCE_DIR}/../../../gsettings/tests)
7include_directories (${CMAKE_CURRENT_SOURCE_DIR}/../../../gsettings/mocks)
8include_directories (${CMAKE_SOURCE_DIR}/compizconfig/tests)
9link_directories (${CMAKE_INSTALL_PREFIX}/lib)
10
11set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
12
13add_library (compizconfig_ccs_mock_gnome_integrated_setting_composition
14 ${CMAKE_CURRENT_SOURCE_DIR}/compizconfig_ccs_mock_gnome_integrated_setting_composition.c)
15
16target_link_libraries (compizconfig_ccs_mock_gnome_integrated_setting_composition
17 compizconfig_ccs_integrated_setting_mock
18 compizconfig_gnome_integrated_setting
19 compizconfig)
20
21add_executable (compizconfig_test_ccs_gnome_integration
22 ${CMAKE_CURRENT_SOURCE_DIR}/compizconfig_test_ccs_gnome_integration.cpp)
23
24target_link_libraries (compizconfig_test_ccs_gnome_integration
25 ${GTEST_BOTH_LIBRARIES}
26 ${GMOCK_LIBRARY}
27 ${GMOCK_MAIN_LIBRARY}
28 ${CMAKE_THREAD_LIBS_INIT}
29 ${LIBCOMPIZCONFIG_LIBRARIES}
30 compizconfig
31 compizconfig_ccs_context_mock
32 compizconfig_ccs_backend_mock
33 compizconfig_ccs_setting_mock
34 compizconfig_ccs_plugin_mock
35 compizconfig_ccs_list_wrapper
36 compizconfig_ccs_setting_value_operators
37 compizconfig_ccs_setting_value_matcher
38 compizconfig_ccs_integrated_setting_mock
39 compizconfig_ccs_integrated_setting_factory_mock
40 compizconfig_ccs_integrated_setting_storage_mock
41 compizconfig_ccs_mock_gnome_integrated_setting_composition
42 compizconfig_gnome_integration)
43
44compiz_discover_tests (compizconfig_test_ccs_gnome_integration
45 COVERAGE
46 compizconfig_gnome_integration
47 compizconfig_gnome_integration_constants)
048
=== added file 'compizconfig/integration/gnome/tests/compizconfig_ccs_mock_gnome_integrated_setting_composition.c'
--- compizconfig/integration/gnome/tests/compizconfig_ccs_mock_gnome_integrated_setting_composition.c 1970-01-01 00:00:00 +0000
+++ compizconfig/integration/gnome/tests/compizconfig_ccs_mock_gnome_integrated_setting_composition.c 2012-09-24 03:58:20 +0000
@@ -0,0 +1,222 @@
1/*
2 * Compiz configuration system library
3 *
4 * Copyright (C) 2012 Canonical Ltd.
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 *
20 * Authored By:
21 * Sam Spilsbury <sam.spilsbury@canonical.com>
22 */
23
24#include <ccs.h>
25#include <ccs-backend.h>
26#include <ccs_gnome_integrated_setting.h>
27#include "compizconfig_ccs_mock_gnome_integrated_setting_composition.h"
28
29typedef struct _CCSMockGNOMEIntegratedSettingCompositionPrivate
30{
31 CCSIntegratedSetting *integratedSetting;
32 CCSGNOMEIntegratedSettingInfo *gnomeIntegratedSettingInfo;
33 CCSIntegratedSettingInfo *integratedSettingInfo;
34} CCSMockGNOMEIntegratedSettingCompositionPrivate;
35
36static CCSIntegratedSetting *
37allocateCCSIntegratedSetting (CCSObjectAllocationInterface *allocator)
38{
39 CCSIntegratedSetting *setting =
40 (*allocator->calloc_) (allocator->allocator,
41 1,
42 sizeof (CCSIntegratedSetting));
43
44 ccsObjectInit (setting, allocator);
45
46 return setting;
47}
48
49static CCSMockGNOMEIntegratedSettingCompositionPrivate *
50allocatePrivate (CCSIntegratedSetting *integratedSetting,
51 CCSObjectAllocationInterface *allocator)
52{
53 CCSMockGNOMEIntegratedSettingCompositionPrivate *priv =
54 (*allocator->calloc_) (allocator->allocator,
55 1,
56 sizeof (CCSMockGNOMEIntegratedSettingCompositionPrivate));
57
58 if (!priv)
59 {
60 ccsObjectFinalize (integratedSetting);
61 (*allocator->free_) (allocator->allocator, integratedSetting);
62 return NULL;
63 }
64
65 return priv;
66}
67
68static SpecialOptionType
69ccsMockCompositionIntegratedSettingGetSpecialOptionType (CCSGNOMEIntegratedSettingInfo *setting)
70{
71 CCSMockGNOMEIntegratedSettingCompositionPrivate *priv = GET_PRIVATE (CCSMockGNOMEIntegratedSettingCompositionPrivate, setting);
72
73 return ccsGNOMEIntegratedSettingInfoGetSpecialOptionType (priv->gnomeIntegratedSettingInfo);
74}
75
76static const char *
77ccsMockCompositionIntegratedSettingGetGNOMEName (CCSGNOMEIntegratedSettingInfo *setting)
78{
79 CCSMockGNOMEIntegratedSettingCompositionPrivate *priv = GET_PRIVATE (CCSMockGNOMEIntegratedSettingCompositionPrivate, setting);
80
81 return ccsGNOMEIntegratedSettingInfoGetGNOMEName (priv->gnomeIntegratedSettingInfo);
82}
83
84static CCSSettingValue *
85ccsMockCompositionIntegratedSettingReadValue (CCSIntegratedSetting *setting, CCSSettingType type)
86{
87 CCSMockGNOMEIntegratedSettingCompositionPrivate *priv =
88 GET_PRIVATE (CCSMockGNOMEIntegratedSettingCompositionPrivate, setting);
89
90 return ccsIntegratedSettingReadValue (priv->integratedSetting, type);
91}
92
93static void
94ccsMockCompositionIntegratedSettingWriteValue (CCSIntegratedSetting *setting, CCSSettingValue *v, CCSSettingType type)
95{
96 CCSMockGNOMEIntegratedSettingCompositionPrivate *priv =
97 GET_PRIVATE (CCSMockGNOMEIntegratedSettingCompositionPrivate, setting);
98
99 ccsIntegratedSettingWriteValue (priv->integratedSetting, v, type);
100}
101
102static const char *
103ccsMockCompositionIntegratedSettingInfoPluginName (CCSIntegratedSettingInfo *setting)
104{
105 CCSMockGNOMEIntegratedSettingCompositionPrivate *priv = GET_PRIVATE (CCSMockGNOMEIntegratedSettingCompositionPrivate, setting);
106
107 return ccsIntegratedSettingInfoPluginName (priv->integratedSettingInfo);
108}
109
110static const char *
111ccsMockCompositionIntegratedSettingInfoSettingName (CCSIntegratedSettingInfo *setting)
112{
113 CCSMockGNOMEIntegratedSettingCompositionPrivate *priv = GET_PRIVATE (CCSMockGNOMEIntegratedSettingCompositionPrivate, setting);
114
115 return ccsIntegratedSettingInfoSettingName (priv->integratedSettingInfo);
116}
117
118static CCSSettingType
119ccsMockCompositionIntegratedSettingInfoGetType (CCSIntegratedSettingInfo *setting)
120{
121 CCSMockGNOMEIntegratedSettingCompositionPrivate *priv = GET_PRIVATE (CCSMockGNOMEIntegratedSettingCompositionPrivate, setting);
122
123 return ccsIntegratedSettingInfoGetType (priv->integratedSettingInfo);
124}
125
126static void
127ccsMockCompositionIntegratedSettingFree (CCSIntegratedSetting *integratedSetting)
128{
129 CCSMockGNOMEIntegratedSettingCompositionPrivate *priv =
130 GET_PRIVATE (CCSMockGNOMEIntegratedSettingCompositionPrivate, integratedSetting);
131
132 ccsIntegratedSettingUnref (priv->integratedSetting);
133 ccsGNOMEIntegratedSettingInfoUnref (priv->gnomeIntegratedSettingInfo);
134 ccsIntegratedSettingInfoUnref (priv->integratedSettingInfo);
135
136 ccsObjectFinalize (integratedSetting);
137 (*integratedSetting->object.object_allocation->free_)
138 (integratedSetting->object.object_allocation->allocator, integratedSetting);
139}
140
141static void
142ccsMockCompositionIntegratedSettingInfoFree (CCSIntegratedSettingInfo *info)
143{
144 return ccsMockCompositionIntegratedSettingFree ((CCSIntegratedSetting *) info);
145}
146
147static void
148ccsMockCompositionGNOMEIntegratedSettingInfoFree (CCSGNOMEIntegratedSettingInfo *info)
149{
150 return ccsMockCompositionIntegratedSettingFree ((CCSIntegratedSetting *) info);
151}
152
153const CCSGNOMEIntegratedSettingInfoInterface ccsMockCompositionGNOMEIntegratedSettingInfo =
154{
155 ccsMockCompositionIntegratedSettingGetSpecialOptionType,
156 ccsMockCompositionIntegratedSettingGetGNOMEName,
157 ccsMockCompositionGNOMEIntegratedSettingInfoFree
158};
159
160const CCSIntegratedSettingInterface ccsMockCompositionIntegratedSetting =
161{
162 ccsMockCompositionIntegratedSettingReadValue,
163 ccsMockCompositionIntegratedSettingWriteValue,
164 ccsMockCompositionIntegratedSettingFree
165};
166
167const CCSIntegratedSettingInfoInterface ccsMockCompositionIntegratedSettingInfo =
168{
169 ccsMockCompositionIntegratedSettingInfoPluginName,
170 ccsMockCompositionIntegratedSettingInfoSettingName,
171 ccsMockCompositionIntegratedSettingInfoGetType,
172 ccsMockCompositionIntegratedSettingInfoFree
173};
174
175CCSIntegratedSetting *
176ccsMockCompositionIntegratedSettingNew (CCSIntegratedSetting *integratedSetting,
177 CCSGNOMEIntegratedSettingInfo *gnomeInfo,
178 CCSIntegratedSettingInfo *settingInfo,
179 CCSObjectAllocationInterface *allocator)
180{
181 CCSIntegratedSetting *composition = allocateCCSIntegratedSetting (allocator);
182
183 if (!composition)
184 return NULL;
185
186 CCSMockGNOMEIntegratedSettingCompositionPrivate *priv = allocatePrivate (composition,
187 allocator);
188
189 if (!priv)
190 return NULL;
191
192 const CCSInterface *integratedSettingImpl =
193 (const CCSInterface *) (&ccsMockCompositionIntegratedSetting);
194 const CCSInterface *integratedSettingInfoImpl =
195 (const CCSInterface *) (&ccsMockCompositionIntegratedSettingInfo);
196 const CCSInterface *gnomeSettingImpl =
197 (const CCSInterface *) (&ccsMockCompositionGNOMEIntegratedSettingInfo);
198
199 priv->integratedSetting = integratedSetting;
200 priv->gnomeIntegratedSettingInfo = gnomeInfo;
201 priv->integratedSettingInfo = settingInfo;
202
203 ccsIntegratedSettingRef (priv->integratedSetting);
204 ccsGNOMEIntegratedSettingInfoRef (priv->gnomeIntegratedSettingInfo);
205 ccsIntegratedSettingInfoRef (priv->integratedSettingInfo);
206
207 ccsObjectSetPrivate (composition, (CCSPrivate *) (priv));
208 ccsObjectAddInterface (composition,
209 integratedSettingImpl,
210 GET_INTERFACE_TYPE (CCSIntegratedSettingInterface));
211 ccsObjectAddInterface (composition,
212 integratedSettingInfoImpl,
213 GET_INTERFACE_TYPE (CCSIntegratedSettingInfoInterface));
214 ccsObjectAddInterface (composition,
215 gnomeSettingImpl,
216 GET_INTERFACE_TYPE (CCSGNOMEIntegratedSettingInfoInterface));
217
218 ccsObjectRef (composition);
219
220 return composition;
221}
222
0223
=== added file 'compizconfig/integration/gnome/tests/compizconfig_ccs_mock_gnome_integrated_setting_composition.h'
--- compizconfig/integration/gnome/tests/compizconfig_ccs_mock_gnome_integrated_setting_composition.h 1970-01-01 00:00:00 +0000
+++ compizconfig/integration/gnome/tests/compizconfig_ccs_mock_gnome_integrated_setting_composition.h 2012-09-24 03:58:20 +0000
@@ -0,0 +1,42 @@
1/*
2 * Compiz configuration system library
3 *
4 * Copyright (C) 2012 Canonical Ltd.
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 *
20 * Authored By:
21 * Sam Spilsbury <sam.spilsbury@canonical.com>
22 */
23#ifndef _COMPIZCONFIG_CCS_MOCK_GNOME_INTEGRATED_SETTING_COMPOSITION_H
24#define _COMPIZCONFIG_CCS_MOCK_GNOME_INTEGRATED_SETTING_COMPOSITION_H
25
26COMPIZCONFIG_BEGIN_DECLS
27
28typedef struct _CCSIntegratedSetting CCSIntegratedSetting;
29typedef struct _CCSGNOMEIntegratedSettingInfo CCSGNOMEIntegratedSettingInfo;
30typedef struct _CCSIntegratedSettingInfo CCSIntegratedSettingInfo;
31typedef struct _CCSObjectAllocationInterface CCSObjectAllocationInterface;
32
33CCSIntegratedSetting *
34ccsMockCompositionIntegratedSettingNew (CCSIntegratedSetting *integratedSetting,
35 CCSGNOMEIntegratedSettingInfo *gnomeInfo,
36 CCSIntegratedSettingInfo *settingInfo,
37 CCSObjectAllocationInterface *allocator);
38
39COMPIZCONFIG_END_DECLS
40
41#endif
42
043
=== added file 'compizconfig/integration/gnome/tests/compizconfig_test_ccs_gnome_integration.cpp'
--- compizconfig/integration/gnome/tests/compizconfig_test_ccs_gnome_integration.cpp 1970-01-01 00:00:00 +0000
+++ compizconfig/integration/gnome/tests/compizconfig_test_ccs_gnome_integration.cpp 2012-09-24 03:58:20 +0000
@@ -0,0 +1,813 @@
1/*
2 * Compiz configuration system library
3 *
4 * Copyright (C) 2012 Canonical Ltd.
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 *
20 * Authored By:
21 * Sam Spilsbury <sam.spilsbury@canonical.com>
22 */
23#include <tr1/tuple>
24
25#include <gtest/gtest.h>
26#include <gmock/gmock.h>
27
28#include <boost/shared_ptr.hpp>
29#include <boost/make_shared.hpp>
30
31#include <gtest_shared_autodestroy.h>
32#include <gtest_unspecified_bool_type_matcher.h>
33
34#include <compizconfig_ccs_list_wrapper.h>
35#include <compizconfig_ccs_setting_value_operators.h>
36
37#include <ccs.h>
38#include <ccs-backend.h>
39#include <ccs_gnome_integrated_setting.h>
40#include <ccs_gnome_integration.h>
41#include <ccs_gnome_integration_constants.h>
42#include <compizconfig_ccs_context_mock.h>
43#include <compizconfig_ccs_setting_mock.h>
44#include <compizconfig_ccs_plugin_mock.h>
45#include <compizconfig_ccs_backend_mock.h>
46#include <compizconfig_ccs_integrated_setting_factory_mock.h>
47#include <compizconfig_ccs_integrated_setting_storage_mock.h>
48#include <compizconfig_ccs_integrated_setting_mock.h>
49#include "compizconfig_ccs_mock_gnome_integrated_setting_composition.h"
50#include "compizconfig_ccs_setting_value_matcher.h"
51
52namespace cc = compiz::config;
53namespace cci = compiz::config::impl;
54
55using ::testing::Pointee;
56using ::testing::Eq;
57using ::testing::Return;
58using ::testing::ReturnNull;
59using ::testing::SetArgPointee;
60using ::testing::DoAll;
61using ::testing::_;
62
63namespace
64{
65 typedef std::tr1::tuple <CCSIntegratedSettingGMock &,
66 boost::shared_ptr <CCSIntegratedSetting> > IntegratedSettingWithMock;
67
68 typedef boost::shared_ptr <IntegratedSettingWithMock> IntegratedSettingWithMockPtr;
69
70 IntegratedSettingWithMockPtr
71 createIntegratedSettingCompositionFromMock (const std::string &plugin,
72 const std::string &setting,
73 CCSSettingType type,
74 SpecialOptionType gnomeType,
75 const std::string &gnomeName,
76 CCSObjectAllocationInterface *allocator)
77 {
78 CCSIntegratedSettingInfo *integratedSettingInfo =
79 ccsSharedIntegratedSettingInfoNew (plugin.c_str (),
80 setting.c_str (),
81 type,
82 allocator);
83 CCSGNOMEIntegratedSettingInfo *gnomeIntegratedSettingInfo =
84 ccsGNOMEIntegratedSettingInfoNew (integratedSettingInfo,
85 gnomeType,
86 gnomeName.c_str (),
87 allocator);
88 CCSIntegratedSetting *integratedSetting =
89 ccsMockIntegratedSettingNew (allocator);
90
91 CCSIntegratedSettingGMock *mockPtr = GET_PRIVATE (CCSIntegratedSettingGMock, integratedSetting)
92 CCSIntegratedSettingGMock &mock (*mockPtr);
93
94 boost::shared_ptr <CCSIntegratedSetting> composition =
95 AutoDestroy (ccsMockCompositionIntegratedSettingNew (integratedSetting,
96 gnomeIntegratedSettingInfo,
97 integratedSettingInfo,
98 allocator),
99 ccsIntegratedSettingUnref);
100
101 /* We want the composition to take ownership here, so unref the
102 * original members of the composition */
103 ccsIntegratedSettingInfoUnref (integratedSettingInfo);
104 ccsGNOMEIntegratedSettingInfoUnref (gnomeIntegratedSettingInfo);
105 ccsIntegratedSettingUnref (integratedSetting);
106
107 return boost::make_shared <IntegratedSettingWithMock> (mock, composition);
108 }
109
110 CCSIntegratedSettingGMock &
111 Mock (IntegratedSettingWithMock &integratedSettingWithMocks)
112 {
113 return std::tr1::get <0> (integratedSettingWithMocks);
114 }
115
116 CCSIntegratedSetting *
117 Real (IntegratedSettingWithMock &integratedSettingWithMocks)
118 {
119 return std::tr1::get <1> (integratedSettingWithMocks).get ();
120 }
121
122 typedef std::tr1::tuple <CCSContextGMock &,
123 CCSBackendGMock &,
124 CCSIntegratedSettingsStorageGMock &,
125 CCSIntegratedSettingFactoryGMock &,
126 boost::shared_ptr <CCSContext> ,
127 boost::shared_ptr <CCSBackend> ,
128 boost::shared_ptr <CCSIntegratedSettingsStorage> ,
129 boost::shared_ptr <CCSIntegratedSettingFactory> ,
130 boost::shared_ptr <CCSIntegration> > CCSGNOMEIntegrationWithMocks;
131
132 CCSGNOMEIntegrationWithMocks
133 createIntegrationWithMocks (CCSObjectAllocationInterface *ai)
134 {
135 boost::shared_ptr <CCSContext> context (AutoDestroy (ccsMockContextNew (),
136 ccsFreeContext));
137 boost::shared_ptr <CCSBackend> backend (AutoDestroy (ccsMockBackendNew (),
138 ccsBackendUnref));
139 boost::shared_ptr <CCSIntegratedSettingsStorage> storage (AutoDestroy (ccsMockIntegratedSettingsStorageNew (ai),
140 ccsIntegratedSettingsStorageUnref));
141 boost::shared_ptr <CCSIntegratedSettingFactory> factory (AutoDestroy (ccsMockIntegratedSettingFactoryNew (ai),
142 ccsIntegratedSettingFactoryUnref));
143 boost::shared_ptr <CCSIntegration> integration (AutoDestroy (ccsGNOMEIntegrationBackendNew (backend.get (),
144 context.get (),
145 factory.get (),
146 storage.get (),
147 ai),
148 ccsIntegrationUnref));
149
150 CCSContextGMock &gmockContext = *(reinterpret_cast <CCSContextGMock *> (ccsObjectGetPrivate (context.get ())));
151 CCSBackendGMock &gmockBackend = *(reinterpret_cast <CCSBackendGMock *> (ccsObjectGetPrivate (backend.get ())));
152 CCSIntegratedSettingsStorageGMock &gmockStorage = *(reinterpret_cast <CCSIntegratedSettingsStorageGMock *> (ccsObjectGetPrivate (storage.get ())));
153 CCSIntegratedSettingFactoryGMock &gmockFactory = *(reinterpret_cast <CCSIntegratedSettingFactoryGMock *> (ccsObjectGetPrivate (factory.get ())));
154
155 return CCSGNOMEIntegrationWithMocks (gmockContext,
156 gmockBackend,
157 gmockStorage,
158 gmockFactory,
159 context,
160 backend,
161 storage,
162 factory,
163 integration);
164 }
165
166 CCSIntegration *
167 Real (CCSGNOMEIntegrationWithMocks &integrationWithMocks)
168 {
169 return std::tr1::get <8> (integrationWithMocks).get ();
170 }
171
172 CCSContextGMock &
173 MockContext (CCSGNOMEIntegrationWithMocks &integrationWithMocks)
174 {
175 return std::tr1::get <0> (integrationWithMocks);
176 }
177
178 CCSBackendGMock &
179 MockBackend (CCSGNOMEIntegrationWithMocks &integrationWithMocks)
180 {
181 return std::tr1::get <1> (integrationWithMocks);
182 }
183
184 CCSIntegratedSettingsStorageGMock &
185 MockStorage (CCSGNOMEIntegrationWithMocks &integrationWithMocks)
186 {
187 return std::tr1::get <2> (integrationWithMocks);
188 }
189
190 CCSIntegratedSettingFactoryGMock &
191 MockFactory (CCSGNOMEIntegrationWithMocks &integrationWithMocks)
192 {
193 return std::tr1::get <3> (integrationWithMocks);
194 }
195
196 void
197 IgnoreRegistration (CCSIntegratedSettingsStorageGMock &storage)
198 {
199 EXPECT_CALL (storage, empty ()).WillOnce (Return (FALSE));
200 }
201
202 void
203 AllowReadability (CCSSettingGMock &setting)
204 {
205 EXPECT_CALL (setting, isReadableByBackend ()).WillOnce (Return (TRUE));
206 }
207
208 void
209 ExpectWriteSettings (CCSContextGMock &context)
210 {
211 EXPECT_CALL (context, writeChangedSettings ());
212 }
213
214 void
215 SetNames (CCSSettingGMock &setting,
216 CCSPluginGMock &plugin,
217 const std::string &settingName,
218 const std::string &pluginName)
219 {
220 EXPECT_CALL (setting, getName ()).WillOnce (Return (settingName.c_str ()));
221 EXPECT_CALL (setting, getParent ());
222 EXPECT_CALL (plugin, getName ()).WillOnce (Return (pluginName.c_str ()));
223 }
224
225 CCSSettingValue *
226 MakeSettingValue ()
227 {
228 CCSSettingValue *v = new CCSSettingValue;
229 v->parent = NULL;
230 v->isListChild = FALSE;
231 v->refCount = 1;
232
233 return v;
234 }
235
236 boost::shared_ptr <CCSSettingValue>
237 MakeAutoDestroySettingValue (CCSSettingType type)
238 {
239 CCSSettingValue *v = new CCSSettingValue;
240 v->parent = NULL;
241 v->isListChild = FALSE;
242 v->refCount = 1;
243
244 return boost::shared_ptr <CCSSettingValue> (v,
245 boost::bind (ccsFreeSettingValueWithType, _1, type));
246 }
247
248 const std::string MOCK_PLUGIN ("mock");
249 const std::string MOCK_SETTING ("mock");
250 const std::string MOCK_GNOME_NAME ("mock");
251 const CCSSettingType MOCK_SETTING_TYPE = TypeInt;
252 const SpecialOptionType MOCK_GNOME_SETTING_TYPE = OptionInt;
253}
254
255TEST (CCSGNOMEIntegrationTest, TestConstructComposition)
256{
257 IntegratedSettingWithMockPtr settingWithMock (
258 createIntegratedSettingCompositionFromMock (MOCK_PLUGIN,
259 MOCK_SETTING,
260 MOCK_SETTING_TYPE,
261 MOCK_GNOME_SETTING_TYPE,
262 MOCK_GNOME_NAME,
263 &ccsDefaultObjectAllocator));
264}
265
266class CCSGNOMEIntegrationTestWithMocks :
267 public ::testing::Test
268{
269 public:
270
271 CCSGNOMEIntegrationTestWithMocks () :
272 mIntegration (createIntegrationWithMocks (&ccsDefaultObjectAllocator)),
273 mSetting (AutoDestroy (ccsMockSettingNew (),
274 ccsSettingUnref)),
275 mSettingMock ((*(reinterpret_cast <CCSSettingGMock *> (ccsObjectGetPrivate (mSetting.get ()))))),
276 mIntegratedSetting (),
277 mPlugin (AutoDestroy (ccsMockPluginNew (),
278 ccsPluginUnref)),
279 mPluginMock ((*(reinterpret_cast <CCSPluginGMock *> (ccsObjectGetPrivate (mPlugin.get ())))))
280 {
281 ON_CALL (mSettingMock, getParent ()).WillByDefault (Return (mPlugin.get ()));
282 }
283
284 protected:
285
286 CCSGNOMEIntegrationWithMocks mIntegration;
287 boost::shared_ptr <CCSSetting> mSetting;
288 CCSSettingGMock &mSettingMock;
289 IntegratedSettingWithMockPtr mIntegratedSetting;
290 boost::shared_ptr <CCSPlugin> mPlugin;
291 CCSPluginGMock &mPluginMock;
292};
293
294class CCSGNOMEIntegrationTestReadIntegrated :
295 public CCSGNOMEIntegrationTestWithMocks
296{
297 public:
298
299 virtual void SetUp ()
300 {
301 IgnoreRegistration (MockStorage (mIntegration));
302 AllowReadability (mSettingMock);
303 }
304};
305
306class CCSGNOMEIntegrationTestWriteIntegrated :
307 public CCSGNOMEIntegrationTestWithMocks
308{
309 public:
310
311 virtual void SetUp ()
312 {
313 IgnoreRegistration (MockStorage (mIntegration));
314 ExpectWriteSettings (MockContext (mIntegration));
315 }
316};
317
318TEST_F (CCSGNOMEIntegrationTestWithMocks, TestConstructGNOMEIntegration)
319{
320}
321
322TEST_F (CCSGNOMEIntegrationTestReadIntegrated, TestReadInSpecialOptionCurrentViewport)
323{
324 const std::string settingName ("current_viewport");
325 CCSSettingValue *v = MakeSettingValue ();
326 v->value.asBool = FALSE;
327
328 mIntegratedSetting = createIntegratedSettingCompositionFromMock (MOCK_PLUGIN,
329 settingName,
330 TypeBool,
331 OptionSpecial,
332 MOCK_GNOME_NAME,
333 &ccsDefaultObjectAllocator);
334 SetNames (mSettingMock, mPluginMock, settingName, MOCK_PLUGIN);
335 EXPECT_CALL (Mock (*mIntegratedSetting), readValue (TypeBool)).WillOnce (Return (v));
336 EXPECT_CALL (mSettingMock, setBool (IsTrue (), IsTrue ()));
337
338 EXPECT_THAT (ccsIntegrationReadOptionIntoSetting (Real (mIntegration),
339 NULL,
340 mSetting.get (),
341 Real (*mIntegratedSetting)), IsTrue ());
342}
343
344TEST_F (CCSGNOMEIntegrationTestReadIntegrated, TestReadInSpecialOptionFullscreenVisualBell)
345{
346 const std::string settingName ("fullscreen_visual_bell");
347 CCSSettingValue *v = MakeSettingValue ();
348 v->value.asString = strdup ("fullscreen");
349
350 mIntegratedSetting = createIntegratedSettingCompositionFromMock (MOCK_PLUGIN,
351 settingName,
352 TypeString,
353 OptionSpecial,
354 MOCK_GNOME_NAME,
355 &ccsDefaultObjectAllocator);
356 SetNames (mSettingMock, mPluginMock, settingName, MOCK_PLUGIN);
357 EXPECT_CALL (Mock (*mIntegratedSetting), readValue (TypeString)).WillOnce (Return (v));
358 EXPECT_CALL (mSettingMock, setBool (IsTrue (), IsTrue ()));
359
360 EXPECT_THAT (ccsIntegrationReadOptionIntoSetting (Real (mIntegration),
361 NULL,
362 mSetting.get (),
363 Real (*mIntegratedSetting)), IsTrue ());
364}
365
366TEST_F (CCSGNOMEIntegrationTestReadIntegrated, TestReadInSpecialOptionClickToFocus)
367{
368 const std::string settingName ("click_to_focus");
369 CCSSettingValue *v = MakeSettingValue ();
370 v->value.asString = strdup ("click");
371
372 mIntegratedSetting = createIntegratedSettingCompositionFromMock (MOCK_PLUGIN,
373 settingName,
374 TypeString,
375 OptionSpecial,
376 MOCK_GNOME_NAME,
377 &ccsDefaultObjectAllocator);
378 SetNames (mSettingMock, mPluginMock, settingName, MOCK_PLUGIN);
379 EXPECT_CALL (Mock (*mIntegratedSetting), readValue (TypeString)).WillOnce (Return (v));
380 EXPECT_CALL (mSettingMock, setBool (IsTrue (), IsTrue ()));
381
382 EXPECT_THAT (ccsIntegrationReadOptionIntoSetting (Real (mIntegration),
383 NULL,
384 mSetting.get (),
385 Real (*mIntegratedSetting)), IsTrue ());
386}
387
388namespace
389{
390 const std::string DEFAULT_MOUSE_BUTTON_MODIFIERS_STRING ("<Alt>");
391 const std::string GNOME_MOUSE_BUTTON_MODIFIERS_STRING ("<Super>");
392 const unsigned int DEFAULT_MOUSE_BUTTON_MODIFIERS =
393 ccsStringToModifiers (DEFAULT_MOUSE_BUTTON_MODIFIERS_STRING.c_str ());
394 const unsigned int GNOME_MOUSE_BUTTON_MODIFIERS =
395 ccsStringToModifiers (GNOME_MOUSE_BUTTON_MODIFIERS_STRING.c_str ());
396
397 const unsigned int LEFT_BUTTON = 1;
398 const unsigned int MIDDLE_BUTTON = 2;
399 const unsigned int RIGHT_BUTTON = 3;
400
401 typedef cci::ListWrapper <CCSIntegratedSettingList, CCSIntegratedSetting *> CCSIntegratedSettingListWrapper;
402 typedef boost::shared_ptr <CCSIntegratedSettingListWrapper> CCSIntegratedSettingListWrapperPtr;
403
404 CCSIntegratedSettingListWrapperPtr
405 constructCCSIntegratedSettingListWrapper (CCSIntegratedSetting *setting)
406 {
407 return boost::make_shared <CCSIntegratedSettingListWrapper> (ccsIntegratedSettingListAppend (NULL, setting),
408 ccsIntegratedSettingListFree,
409 ccsIntegratedSettingListAppend,
410 ccsIntegratedSettingListRemove,
411 cci::Shallow);
412 }
413}
414
415class CCSGNOMEIntegrationTestWithMocksIntegratedMouseButtonModifiers
416{
417 public:
418
419 CCSGNOMEIntegrationTestWithMocksIntegratedMouseButtonModifiers () :
420 mIntegratedSettingMBM (AutoDestroy (ccsMockIntegratedSettingNew (&ccsDefaultObjectAllocator),
421 ccsIntegratedSettingUnref)),
422 mIntegratedSettingMBMMock (*(reinterpret_cast <CCSIntegratedSettingGMock *> (ccsObjectGetPrivate (mIntegratedSettingMBM.get ())))),
423 mIntegratedSettingsMBM (constructCCSIntegratedSettingListWrapper (mIntegratedSettingMBM.get ())),
424 mIntegratedSettingResizeWithRB (AutoDestroy (ccsMockIntegratedSettingNew (&ccsDefaultObjectAllocator),
425 ccsIntegratedSettingUnref)),
426 mIntegratedSettingResizeWithRBMock (*(reinterpret_cast <CCSIntegratedSettingGMock *> (ccsObjectGetPrivate (mIntegratedSettingResizeWithRB.get ())))),
427 mIntegratedSettingsResizeWithRB (constructCCSIntegratedSettingListWrapper (mIntegratedSettingResizeWithRB.get ()))
428 {
429 memset (&mButtonValue, 0, sizeof (CCSSettingButtonValue));
430
431 mButtonValue.button = MIDDLE_BUTTON;
432 mButtonValue.buttonModMask = DEFAULT_MOUSE_BUTTON_MODIFIERS;
433 mButtonValue.edgeMask = 0;
434 }
435
436 virtual void SetUp (CCSGNOMEIntegrationWithMocks &integration)
437 {
438 CCSIntegratedSettingList integratedSettingsMBM =
439 *mIntegratedSettingsMBM;
440 CCSIntegratedSettingList integratedSettingsResizeWithRB =
441 *mIntegratedSettingsResizeWithRB;
442
443 EXPECT_CALL (MockStorage (integration),
444 findMatchingSettingsByPluginAndSettingName (Eq (std::string (ccsGNOMEIntegratedPluginNames.SPECIAL)),
445 Eq (std::string (ccsGNOMEIntegratedSettingNames.NULL_MOUSE_BUTTON_MODIFIER.compizName))))
446 .WillOnce (Return (integratedSettingsMBM));
447 EXPECT_CALL (MockStorage (integration),
448 findMatchingSettingsByPluginAndSettingName (Eq (std::string (ccsGNOMEIntegratedPluginNames.SPECIAL)),
449 Eq (std::string (ccsGNOMEIntegratedSettingNames.NULL_RESIZE_WITH_RIGHT_BUTTON.compizName))))
450 .WillOnce (Return (integratedSettingsResizeWithRB));
451 }
452
453
454 protected:
455
456 boost::shared_ptr <CCSIntegratedSetting> mIntegratedSettingMBM;
457 CCSIntegratedSettingGMock &mIntegratedSettingMBMMock;
458 CCSIntegratedSettingListWrapperPtr mIntegratedSettingsMBM;
459 boost::shared_ptr <CCSIntegratedSetting> mIntegratedSettingResizeWithRB;
460 CCSIntegratedSettingGMock &mIntegratedSettingResizeWithRBMock;
461 CCSIntegratedSettingListWrapperPtr mIntegratedSettingsResizeWithRB;
462 CCSSettingButtonValue mButtonValue;
463};
464
465class CCSGNOMEIntegrationTestWithMocksReadIntegratedMouseButtonModifiers :
466 public CCSGNOMEIntegrationTestReadIntegrated,
467 public CCSGNOMEIntegrationTestWithMocksIntegratedMouseButtonModifiers
468{
469 public:
470
471 virtual void SetUp ()
472 {
473 CCSSettingValue *vRB = MakeSettingValue ();
474 CCSSettingValue *vMBM = MakeSettingValue ();
475 vRB->value.asBool = TRUE;
476 vMBM->value.asString = strdup (GNOME_MOUSE_BUTTON_MODIFIERS_STRING.c_str ());
477
478 CCSGNOMEIntegrationTestReadIntegrated::SetUp ();
479 CCSGNOMEIntegrationTestWithMocksIntegratedMouseButtonModifiers::SetUp (mIntegration);
480
481 EXPECT_CALL (mSettingMock, getButton (_))
482 .WillOnce (DoAll (
483 SetArgPointee <0> (
484 mButtonValue),
485 Return (TRUE)));
486
487 /* Get the GNOME Mouse button modifier */
488 EXPECT_CALL (mIntegratedSettingMBMMock, readValue (TypeString)).WillOnce (Return (vMBM));
489 EXPECT_CALL (mIntegratedSettingResizeWithRBMock, readValue (TypeBool)).WillOnce (Return (vRB));
490 }
491};
492
493class CCSGNOMEIntegrationTestWithMocksWriteIntegratedMouseButtonModifiers :
494 public CCSGNOMEIntegrationTestWriteIntegrated,
495 public CCSGNOMEIntegrationTestWithMocksIntegratedMouseButtonModifiers
496{
497 public:
498
499 CCSGNOMEIntegrationTestWithMocksWriteIntegratedMouseButtonModifiers () :
500 corePlugin (AutoDestroy (ccsMockPluginNew (),
501 ccsPluginUnref)),
502 corePluginMock (*(reinterpret_cast <CCSPluginGMock *> (ccsObjectGetPrivate (corePlugin.get ())))),
503 resizePlugin (AutoDestroy (ccsMockPluginNew (),
504 ccsPluginUnref)),
505 resizePluginMock (*(reinterpret_cast <CCSPluginGMock *> (ccsObjectGetPrivate (resizePlugin.get ())))),
506 movePlugin (AutoDestroy (ccsMockPluginNew (),
507 ccsPluginUnref)),
508 movePluginMock (*(reinterpret_cast <CCSPluginGMock *> (ccsObjectGetPrivate (movePlugin.get ())))),
509 resizeInitiateButtonSetting (AutoDestroy (ccsMockSettingNew (),
510 ccsSettingUnref)),
511 resizeInitiateButtonSettingMock (*(reinterpret_cast <CCSSettingGMock *> (ccsObjectGetPrivate (resizeInitiateButtonSetting.get ())))),
512 moveInitiateButtonSetting (AutoDestroy (ccsMockSettingNew (),
513 ccsSettingUnref)),
514 moveInitiateButtonSettingMock (*(reinterpret_cast <CCSSettingGMock *> (ccsObjectGetPrivate (moveInitiateButtonSetting.get ())))),
515 coreWindowMenuSetting (AutoDestroy (ccsMockSettingNew (),
516 ccsSettingUnref)),
517 coreWindowMenuSettingMock (*(reinterpret_cast <CCSSettingGMock *> (ccsObjectGetPrivate (coreWindowMenuSetting.get ())))),
518 resizeInitiateButton (MakeAutoDestroySettingValue (TypeButton)),
519 moveInitiateButton (MakeAutoDestroySettingValue (TypeButton)),
520 coreWindowMenuButton (MakeAutoDestroySettingValue (TypeButton))
521 {
522 resizeInitiateButton->value.asButton.button = LEFT_BUTTON;
523 resizeInitiateButton->value.asButton.buttonModMask = 0;
524 resizeInitiateButton->value.asButton.edgeMask = 0;
525 moveInitiateButton->value.asButton.button = LEFT_BUTTON;
526 moveInitiateButton->value.asButton.buttonModMask = DEFAULT_MOUSE_BUTTON_MODIFIERS;
527 moveInitiateButton->value.asButton.edgeMask = 0;
528 coreWindowMenuButton->value.asButton.button = MIDDLE_BUTTON;
529 coreWindowMenuButton->value.asButton.buttonModMask = 0;
530 coreWindowMenuButton->value.asButton.edgeMask = 0;
531 }
532
533 virtual void SetUp ()
534 {
535 CCSGNOMEIntegrationTestWriteIntegrated::SetUp ();
536 CCSGNOMEIntegrationTestWithMocksIntegratedMouseButtonModifiers::SetUp (mIntegration);
537 }
538
539 protected:
540
541 boost::shared_ptr <CCSPlugin> corePlugin;
542 CCSPluginGMock &corePluginMock;
543 boost::shared_ptr <CCSPlugin> resizePlugin;
544 CCSPluginGMock &resizePluginMock;
545 boost::shared_ptr <CCSPlugin> movePlugin;
546 CCSPluginGMock &movePluginMock;
547
548 boost::shared_ptr <CCSSetting> resizeInitiateButtonSetting;
549 CCSSettingGMock &resizeInitiateButtonSettingMock;
550 boost::shared_ptr <CCSSetting> moveInitiateButtonSetting;
551 CCSSettingGMock &moveInitiateButtonSettingMock;
552 boost::shared_ptr <CCSSetting> coreWindowMenuSetting;
553 CCSSettingGMock &coreWindowMenuSettingMock;
554
555 boost::shared_ptr <CCSSettingValue> resizeInitiateButton;
556 boost::shared_ptr <CCSSettingValue> moveInitiateButton;
557 boost::shared_ptr <CCSSettingValue> coreWindowMenuButton;
558};
559
560TEST_F (CCSGNOMEIntegrationTestWithMocksReadIntegratedMouseButtonModifiers, TestReadInSpecialOptionMoveInitiateButton)
561{
562 const std::string settingName ("initiate_button");
563 const std::string pluginName ("move");
564
565 CCSSettingButtonValue newButtonValue = mButtonValue;
566 newButtonValue.button = LEFT_BUTTON;
567 newButtonValue.buttonModMask = GNOME_MOUSE_BUTTON_MODIFIERS;
568
569 mIntegratedSetting = createIntegratedSettingCompositionFromMock (pluginName,
570 settingName,
571 TypeBool,
572 OptionSpecial,
573 MOCK_GNOME_NAME,
574 &ccsDefaultObjectAllocator);
575 SetNames (mSettingMock, mPluginMock, settingName, pluginName);
576
577 /* Set the new mouse button modifier */
578 EXPECT_CALL (mSettingMock, setButton (Eq (newButtonValue),
579 IsTrue ()));
580
581 EXPECT_THAT (ccsIntegrationReadOptionIntoSetting (Real (mIntegration),
582 NULL,
583 mSetting.get (),
584 Real (*mIntegratedSetting)), IsTrue ());
585}
586
587TEST_F (CCSGNOMEIntegrationTestWithMocksReadIntegratedMouseButtonModifiers, TestReadInSpecialOptionResizeInitiateButton)
588{
589 const std::string settingName ("initiate_button");
590 const std::string pluginName ("resize");
591
592 CCSSettingButtonValue newButtonValue = mButtonValue;
593 newButtonValue.button = RIGHT_BUTTON;
594 newButtonValue.buttonModMask = GNOME_MOUSE_BUTTON_MODIFIERS;
595
596 mIntegratedSetting = createIntegratedSettingCompositionFromMock (pluginName,
597 settingName,
598 TypeBool,
599 OptionSpecial,
600 MOCK_GNOME_NAME,
601 &ccsDefaultObjectAllocator);
602 SetNames (mSettingMock, mPluginMock, settingName, pluginName);
603
604 /* Set the new mouse button modifier */
605 EXPECT_CALL (mSettingMock, setButton (Eq (newButtonValue),
606 IsTrue ()));
607
608 EXPECT_THAT (ccsIntegrationReadOptionIntoSetting (Real (mIntegration),
609 NULL,
610 mSetting.get (),
611 Real (*mIntegratedSetting)), IsTrue ());
612}
613
614TEST_F (CCSGNOMEIntegrationTestWithMocksReadIntegratedMouseButtonModifiers, TestReadInSpecialOptionWhereIntegratedOptionReturnsNull)
615{
616 const std::string settingName ("initiate_button");
617 const std::string pluginName ("move");
618
619 CCSSettingButtonValue newButtonValue = mButtonValue;
620 newButtonValue.button = LEFT_BUTTON;
621 /* Reading the gnome mouse button modifiers failed, so default to zero */
622 newButtonValue.buttonModMask = 0;
623
624 /* Clear the old expectation */
625 ccsIntegratedSettingReadValue (mIntegratedSettingMBM.get (), TypeString);
626 /* Now return null */
627 EXPECT_CALL (mIntegratedSettingMBMMock, readValue (TypeString)).WillOnce (ReturnNull ());
628
629 mIntegratedSetting = createIntegratedSettingCompositionFromMock (pluginName,
630 settingName,
631 TypeBool,
632 OptionSpecial,
633 MOCK_GNOME_NAME,
634 &ccsDefaultObjectAllocator);
635 SetNames (mSettingMock, mPluginMock, settingName, pluginName);
636
637 /* Set the new mouse button modifier */
638 EXPECT_CALL (mSettingMock, setButton (Eq (newButtonValue),
639 IsTrue ()));
640
641 EXPECT_THAT (ccsIntegrationReadOptionIntoSetting (Real (mIntegration),
642 NULL,
643 mSetting.get (),
644 Real (*mIntegratedSetting)), IsTrue ());
645}
646
647TEST_F (CCSGNOMEIntegrationTestWriteIntegrated, TestWriteCurrentViewport)
648{
649 const std::string settingName ("current_viewport");
650 boost::shared_ptr <CCSSettingValue> compizValue (MakeAutoDestroySettingValue (TypeBool));
651 boost::shared_ptr <CCSSettingValue> gnomeValue (MakeAutoDestroySettingValue (TypeBool));
652 CCSSettingInfo info;
653
654 compizValue->value.asBool = TRUE;
655 gnomeValue->value.asBool = FALSE;
656
657 mIntegratedSetting = createIntegratedSettingCompositionFromMock (MOCK_PLUGIN,
658 settingName,
659 TypeBool,
660 OptionSpecial,
661 MOCK_GNOME_NAME,
662 &ccsDefaultObjectAllocator);
663 SetNames (mSettingMock, mPluginMock, settingName, MOCK_PLUGIN);
664
665 EXPECT_CALL (mSettingMock, getValue ()).WillOnce (Return (compizValue.get ()));
666 EXPECT_CALL (Mock (*mIntegratedSetting), writeValue (Pointee (SettingValueMatch (*gnomeValue,
667 TypeBool,
668 &info)),
669 TypeBool));
670 ccsIntegrationWriteSettingIntoOption (Real (mIntegration),
671 NULL,
672 mSetting.get (),
673 Real (*mIntegratedSetting));
674}
675
676TEST_F (CCSGNOMEIntegrationTestWriteIntegrated, TestWriteFullscreenVisualBell)
677{
678 const std::string settingName ("fullscreen_visual_bell");
679 boost::shared_ptr <CCSSettingValue> compizValue (MakeAutoDestroySettingValue (TypeBool));
680 boost::shared_ptr <CCSSettingValue> gnomeValue (MakeAutoDestroySettingValue (TypeString));
681 CCSSettingInfo info;
682
683 compizValue->value.asBool = TRUE;
684 gnomeValue->value.asString = strdup ("fullscreen");
685
686 mIntegratedSetting = createIntegratedSettingCompositionFromMock (MOCK_PLUGIN,
687 settingName,
688 TypeBool,
689 OptionSpecial,
690 MOCK_GNOME_NAME,
691 &ccsDefaultObjectAllocator);
692 SetNames (mSettingMock, mPluginMock, settingName, MOCK_PLUGIN);
693
694 EXPECT_CALL (mSettingMock, getValue ()).WillOnce (Return (compizValue.get ()));
695 EXPECT_CALL (Mock (*mIntegratedSetting), writeValue (Pointee (SettingValueMatch (*gnomeValue,
696 TypeString,
697 &info)),
698 TypeString));
699 ccsIntegrationWriteSettingIntoOption (Real (mIntegration),
700 NULL,
701 mSetting.get (),
702 Real (*mIntegratedSetting));
703}
704
705TEST_F (CCSGNOMEIntegrationTestWriteIntegrated, TestWriteClickToFocus)
706{
707 const std::string settingName ("click_to_focus");
708 boost::shared_ptr <CCSSettingValue> compizValue (MakeAutoDestroySettingValue (TypeBool));
709 boost::shared_ptr <CCSSettingValue> gnomeValue (MakeAutoDestroySettingValue (TypeString));
710 CCSSettingInfo info;
711
712 compizValue->value.asBool = TRUE;
713 gnomeValue->value.asString = strdup ("click");
714
715 mIntegratedSetting = createIntegratedSettingCompositionFromMock (MOCK_PLUGIN,
716 settingName,
717 TypeBool,
718 OptionSpecial,
719 MOCK_GNOME_NAME,
720 &ccsDefaultObjectAllocator);
721 SetNames (mSettingMock, mPluginMock, settingName, MOCK_PLUGIN);
722
723 EXPECT_CALL (mSettingMock, getValue ()).WillOnce (Return (compizValue.get ()));
724 EXPECT_CALL (Mock (*mIntegratedSetting), writeValue (Pointee (SettingValueMatch (*gnomeValue,
725 TypeString,
726 &info)),
727 TypeString));
728 ccsIntegrationWriteSettingIntoOption (Real (mIntegration),
729 NULL,
730 mSetting.get (),
731 Real (*mIntegratedSetting));
732}
733
734/*
735 * TODO: Break up the function that this test covers. Its way too complicated
736 */
737TEST_F (CCSGNOMEIntegrationTestWithMocksWriteIntegratedMouseButtonModifiers, TestWriteMouseButtonModifier)
738{
739 const std::string settingName ("initiate_button");
740 const std::string pluginName ("move");
741 CCSSettingInfo info;
742
743 mIntegratedSetting = createIntegratedSettingCompositionFromMock (pluginName,
744 settingName,
745 TypeBool,
746 OptionSpecial,
747 MOCK_GNOME_NAME,
748 &ccsDefaultObjectAllocator);
749 SetNames (mSettingMock, mPluginMock, settingName, pluginName);
750
751 EXPECT_CALL (MockContext (mIntegration), findPlugin (Eq ("move"))).WillRepeatedly (Return (movePlugin.get ()));
752 EXPECT_CALL (movePluginMock, findSetting (Eq ("initiate_button"))).WillRepeatedly (Return (moveInitiateButtonSetting.get ()));
753 EXPECT_CALL (moveInitiateButtonSettingMock, getType ()).WillRepeatedly (Return (TypeButton));
754 EXPECT_CALL (moveInitiateButtonSettingMock, getValue ()).WillRepeatedly (Return (moveInitiateButton.get ()));
755
756 EXPECT_CALL (MockContext (mIntegration), findPlugin (Eq ("resize"))).WillRepeatedly (Return (resizePlugin.get ()));
757 EXPECT_CALL (resizePluginMock, findSetting (Eq ("initiate_button"))).WillRepeatedly (Return (resizeInitiateButtonSetting.get ()));
758 EXPECT_CALL (resizeInitiateButtonSettingMock, getType ()).WillRepeatedly (Return (TypeButton));
759 EXPECT_CALL (resizeInitiateButtonSettingMock, getValue ()).WillRepeatedly (Return (resizeInitiateButton.get ()));
760
761 EXPECT_CALL (MockContext (mIntegration), findPlugin (Eq ("core"))).WillRepeatedly (Return (corePlugin.get ()));
762 EXPECT_CALL (corePluginMock, findSetting (Eq ("window_menu_button"))).WillRepeatedly (Return (coreWindowMenuSetting.get ()));
763 EXPECT_CALL (coreWindowMenuSettingMock, getType ()).WillRepeatedly (Return (TypeButton));
764 EXPECT_CALL (coreWindowMenuSettingMock, getValue ()).WillRepeatedly (Return (coreWindowMenuButton.get ()));
765
766 boost::shared_ptr <CCSSettingValue> newResizeWithRBValue (MakeAutoDestroySettingValue (TypeBool));
767 newResizeWithRBValue->value.asBool = TRUE;
768
769 EXPECT_CALL (mIntegratedSettingResizeWithRBMock, writeValue (Pointee (SettingValueMatch (*newResizeWithRBValue,
770 TypeBool,
771 &info)),
772 TypeBool));
773
774 boost::shared_ptr <CCSSettingValue> newMBMValue (MakeAutoDestroySettingValue (TypeString));
775 newMBMValue->value.asString = strdup (DEFAULT_MOUSE_BUTTON_MODIFIERS_STRING.c_str ());
776
777 EXPECT_CALL (mSettingMock, getValue ()).WillOnce (Return (moveInitiateButton.get ()));
778
779 EXPECT_CALL (mIntegratedSettingMBMMock, writeValue (Pointee (SettingValueMatch (*newMBMValue,
780 TypeString,
781 &info)),
782 TypeString));
783
784 unsigned int modifiers = moveInitiateButton->value.asButton.buttonModMask;
785
786 CCSSettingButtonValue newResizeInitiateButton;
787 CCSSettingButtonValue newMoveInitiateButton;
788 CCSSettingButtonValue newWindowMenuButton;
789
790 memset (&newResizeInitiateButton, 0, sizeof (CCSSettingButtonValue));
791 memset (&newMoveInitiateButton, 0, sizeof (CCSSettingButtonValue));
792 memset (&newWindowMenuButton, 0, sizeof (CCSSettingButtonValue));
793
794 newResizeInitiateButton.button = RIGHT_BUTTON;
795 newResizeInitiateButton.buttonModMask = modifiers;
796 newMoveInitiateButton.button = LEFT_BUTTON;
797 newMoveInitiateButton.buttonModMask = modifiers;
798 newWindowMenuButton.button = MIDDLE_BUTTON;
799 newWindowMenuButton.buttonModMask = modifiers;
800
801 EXPECT_CALL (resizeInitiateButtonSettingMock, setButton (Eq (newResizeInitiateButton),
802 IsTrue ()));
803 /* The move button is exactly the same, so it is not updated */
804 EXPECT_CALL (moveInitiateButtonSettingMock, setButton (Eq (newMoveInitiateButton),
805 IsTrue ())).Times (0);
806 EXPECT_CALL (coreWindowMenuSettingMock, setButton (Eq (newWindowMenuButton),
807 IsTrue ()));
808
809 ccsIntegrationWriteSettingIntoOption (Real (mIntegration),
810 NULL,
811 mSetting.get (),
812 Real (*mIntegratedSetting));
813}
0814
=== modified file 'compizconfig/libcompizconfig/src/main.c'
--- compizconfig/libcompizconfig/src/main.c 2012-09-24 03:58:20 +0000
+++ compizconfig/libcompizconfig/src/main.c 2012-09-24 03:58:20 +0000
@@ -1109,7 +1109,6 @@
1109void1109void
1110ccsFreeBackend (CCSBackend *backend)1110ccsFreeBackend (CCSBackend *backend)
1111{1111{
1112 ccsBackendFini (backend);
1113 ccsObjectFinalize (backend);1112 ccsObjectFinalize (backend);
1114 free (backend);1113 free (backend);
1115}1114}
@@ -1119,6 +1118,7 @@
1119{1118{
1120 CCSDynamicBackendPrivate *dbPrivate = GET_PRIVATE (CCSDynamicBackendPrivate, backend);1119 CCSDynamicBackendPrivate *dbPrivate = GET_PRIVATE (CCSDynamicBackendPrivate, backend);
11211120
1121 ccsBackendFini (dbPrivate->backend);
1122 ccsBackendUnref (dbPrivate->backend);1122 ccsBackendUnref (dbPrivate->backend);
11231123
1124 if (dbPrivate->dlhand)1124 if (dbPrivate->dlhand)
@@ -5655,7 +5655,7 @@
5655void5655void
5656ccsFreeIntegratedSettingsStorage (CCSIntegratedSettingsStorage *storage)5656ccsFreeIntegratedSettingsStorage (CCSIntegratedSettingsStorage *storage)
5657{5657{
5658 (*(GET_INTERFACE (CCSIntegratedSettingsStorageInterface, storage))->empty) (storage);5658 (*(GET_INTERFACE (CCSIntegratedSettingsStorageInterface, storage))->free) (storage);
5659}5659}
56605660
5661/* CCSIntegratedSettingsStorageDefault implementation */5661/* CCSIntegratedSettingsStorageDefault implementation */
56625662
=== modified file 'compizconfig/libcompizconfig/tests/CMakeLists.txt'
--- compizconfig/libcompizconfig/tests/CMakeLists.txt 2012-09-24 03:58:20 +0000
+++ compizconfig/libcompizconfig/tests/CMakeLists.txt 2012-09-24 03:58:20 +0000
@@ -93,7 +93,13 @@
93 compizconfig_ccs_context_mock93 compizconfig_ccs_context_mock
94 compizconfig_ccs_plugin_mock94 compizconfig_ccs_plugin_mock
95 compizconfig_ccs_setting_mock95 compizconfig_ccs_setting_mock
96 compizconfig_ccs_backend_mock)96 compizconfig_ccs_backend_mock
97 compizconfig_ccs_backend_conformance_test
98 compizconfig_ccs_item_in_list_matcher
99 compizconfig_ccs_list_equality
100 compizconfig_ccs_list_wrapper
101 compizconfig_ccs_setting_value_operators
102 compizconfig_ccs_test_value_combinations)
97103
98target_link_libraries (compizconfig_test_ccs_setting104target_link_libraries (compizconfig_test_ccs_setting
99 ${GTEST_BOTH_LIBRARIES}105 ${GTEST_BOTH_LIBRARIES}
@@ -126,6 +132,8 @@
126 compizconfig_ccs_context_mock132 compizconfig_ccs_context_mock
127 compizconfig_ccs_plugin_mock133 compizconfig_ccs_plugin_mock
128 compizconfig_ccs_setting_mock134 compizconfig_ccs_setting_mock
135 compizconfig_ccs_item_in_list_matcher
136 compizconfig_ccs_setting_value_matcher
129)137)
130138
131compiz_discover_tests (compizconfig_test_ccs_object COVERAGE compizconfig)139compiz_discover_tests (compizconfig_test_ccs_object COVERAGE compizconfig)
132140
=== modified file 'compizconfig/libcompizconfig/tests/compizconfig_test_ccs_mock_backend_conformance.cpp'
--- compizconfig/libcompizconfig/tests/compizconfig_test_ccs_mock_backend_conformance.cpp 2012-09-24 03:58:20 +0000
+++ compizconfig/libcompizconfig/tests/compizconfig_test_ccs_mock_backend_conformance.cpp 2012-09-24 03:58:20 +0000
@@ -151,61 +151,73 @@
151 virtual Bool ReadBoolAtKey (const std::string &plugin,151 virtual Bool ReadBoolAtKey (const std::string &plugin,
152 const std::string &key)152 const std::string &key)
153 {153 {
154 return boolToBool (ValueForKeyRetreival <bool> ().GetValueForKey (keynameFromPluginKey (plugin, key), mValues));154 return compizconfig::test::boolToBool (
155 ValueForKeyRetreival <bool> ().GetValueForKey (
156 keynameFromPluginKey (plugin, key), mValues));
155 }157 }
156158
157 virtual int ReadIntegerAtKey (const std::string &plugin,159 virtual int ReadIntegerAtKey (const std::string &plugin,
158 const std::string &key)160 const std::string &key)
159 {161 {
160 return ValueForKeyRetreival <int> ().GetValueForKey (keynameFromPluginKey (plugin, key), mValues);162 return ValueForKeyRetreival <int> ().GetValueForKey (
163 keynameFromPluginKey (plugin, key), mValues);
161 }164 }
162165
163 virtual float ReadFloatAtKey (const std::string &plugin,166 virtual float ReadFloatAtKey (const std::string &plugin,
164 const std::string &key)167 const std::string &key)
165 {168 {
166 return ValueForKeyRetreival <float> ().GetValueForKey (keynameFromPluginKey (plugin, key), mValues);169 return ValueForKeyRetreival <float> ().GetValueForKey (
170 keynameFromPluginKey (plugin, key), mValues);
167 }171 }
168172
169 virtual const char * ReadStringAtKey (const std::string &plugin,173 virtual const char * ReadStringAtKey (const std::string &plugin,
170 const std::string &key)174 const std::string &key)
171 {175 {
172 return ValueForKeyRetreival <const char *> ().GetValueForKey (keynameFromPluginKey (plugin, key), mValues);176 return ValueForKeyRetreival <const char *> ().GetValueForKey (
177 keynameFromPluginKey (plugin, key), mValues);
173 }178 }
174179
175 virtual CCSSettingColorValue ReadColorAtKey (const std::string &plugin,180 virtual CCSSettingColorValue ReadColorAtKey (const std::string &plugin,
176 const std::string &key)181 const std::string &key)
177 {182 {
178 return ValueForKeyRetreival <CCSSettingColorValue> ().GetValueForKey (keynameFromPluginKey (plugin, key), mValues);183 return ValueForKeyRetreival <CCSSettingColorValue> ().GetValueForKey (
184 keynameFromPluginKey (plugin, key), mValues);
179 }185 }
180186
181 virtual CCSSettingKeyValue ReadKeyAtKey (const std::string &plugin,187 virtual CCSSettingKeyValue ReadKeyAtKey (const std::string &plugin,
182 const std::string &key)188 const std::string &key)
183 {189 {
184 return ValueForKeyRetreival <CCSSettingKeyValue> ().GetValueForKey (keynameFromPluginKey (plugin, key), mValues);190 return ValueForKeyRetreival <CCSSettingKeyValue> ().GetValueForKey (
191 keynameFromPluginKey (plugin, key), mValues);
185 }192 }
186193
187 virtual CCSSettingButtonValue ReadButtonAtKey (const std::string &plugin,194 virtual CCSSettingButtonValue ReadButtonAtKey (const std::string &plugin,
188 const std::string &key)195 const std::string &key)
189 {196 {
190 return ValueForKeyRetreival <CCSSettingButtonValue> ().GetValueForKey (keynameFromPluginKey (plugin, key), mValues);197 return ValueForKeyRetreival <CCSSettingButtonValue> ().GetValueForKey (
198 keynameFromPluginKey (plugin, key), mValues);
191 }199 }
192200
193 virtual unsigned int ReadEdgeAtKey (const std::string &plugin,201 virtual unsigned int ReadEdgeAtKey (const std::string &plugin,
194 const std::string &key)202 const std::string &key)
195 {203 {
196 return ValueForKeyRetreival <unsigned int> ().GetValueForKey (keynameFromPluginKey (plugin, key), mValues);204 return ValueForKeyRetreival <unsigned int> ().GetValueForKey (
205 keynameFromPluginKey (plugin, key), mValues);
197 }206 }
198207
199 virtual const char * ReadMatchAtKey (const std::string &plugin,208 virtual const char * ReadMatchAtKey (const std::string &plugin,
200 const std::string &key)209 const std::string &key)
201 {210 {
202 return ValueForKeyRetreival <const char *> ().GetValueForKey (keynameFromPluginKey (plugin, key), mValues);211 return ValueForKeyRetreival <const char *> ().GetValueForKey (
212 keynameFromPluginKey (plugin, key), mValues);
203 }213 }
204214
205 virtual Bool ReadBellAtKey (const std::string &plugin,215 virtual Bool ReadBellAtKey (const std::string &plugin,
206 const std::string &key)216 const std::string &key)
207 {217 {
208 return boolToBool (ValueForKeyRetreival <bool> ().GetValueForKey (keynameFromPluginKey (plugin, key), mValues));218 return compizconfig::test::boolToBool (
219 ValueForKeyRetreival <bool> ().GetValueForKey (
220 keynameFromPluginKey (plugin, key), mValues));
209 }221 }
210222
211 virtual CCSSettingValueList ReadListAtKey (const std::string &plugin,223 virtual CCSSettingValueList ReadListAtKey (const std::string &plugin,
212224
=== modified file 'compizconfig/libcompizconfig/tests/compizconfig_test_ccs_settings_upgrade_internal.cpp'
--- compizconfig/libcompizconfig/tests/compizconfig_test_ccs_settings_upgrade_internal.cpp 2012-09-24 03:58:20 +0000
+++ compizconfig/libcompizconfig/tests/compizconfig_test_ccs_settings_upgrade_internal.cpp 2012-09-24 03:58:20 +0000
@@ -38,10 +38,12 @@
38#include "ccs_settings_upgrade_internal.h"38#include "ccs_settings_upgrade_internal.h"
39#include "gtest_shared_characterwrapper.h"39#include "gtest_shared_characterwrapper.h"
40#include "gtest_shared_autodestroy.h"40#include "gtest_shared_autodestroy.h"
41#include "gtest_unspecified_bool_type_matcher.h"
41#include "compizconfig_ccs_list_equality.h"42#include "compizconfig_ccs_list_equality.h"
42#include "compizconfig_ccs_item_in_list_matcher.h"43#include "compizconfig_ccs_item_in_list_matcher.h"
43#include "compizconfig_ccs_list_wrapper.h"44#include "compizconfig_ccs_list_wrapper.h"
44#include "compizconfig_ccs_setting_value_operators.h"45#include "compizconfig_ccs_setting_value_operators.h"
46#include "compizconfig_ccs_setting_value_matcher.h"
4547
46using ::testing::IsNull;48using ::testing::IsNull;
47using ::testing::Eq;49using ::testing::Eq;
@@ -73,9 +75,6 @@
73 static const unsigned int CCS_SETTINGS_UPGRADE_TEST_CORRECT_NUM = 1;75 static const unsigned int CCS_SETTINGS_UPGRADE_TEST_CORRECT_NUM = 1;
74}76}
7577
76MATCHER(BoolTrue, "Bool True") { if (arg) return true; else return false; }
77MATCHER(BoolFalse, "Bool False") { if (!arg) return true; else return false; }
78
79TEST (CCSSettingsUpgradeInternalTest, TestDetokenizeAndSetValues)78TEST (CCSSettingsUpgradeInternalTest, TestDetokenizeAndSetValues)
80{79{
81 char *profileName = NULL;80 char *profileName = NULL;
@@ -86,7 +85,7 @@
86 EXPECT_THAT (ccsUpgradeGetDomainNumAndProfile (CCS_SETTINGS_UPGRADE_TEST_CORRECT_FILENAME.c_str (),85 EXPECT_THAT (ccsUpgradeGetDomainNumAndProfile (CCS_SETTINGS_UPGRADE_TEST_CORRECT_FILENAME.c_str (),
87 &domainName,86 &domainName,
88 &num,87 &num,
89 &profileName), BoolTrue ());88 &profileName), IsTrue ());
9089
91 CharacterWrapper profileNameC (profileName);90 CharacterWrapper profileNameC (profileName);
92 CharacterWrapper domainNameC (domainName);91 CharacterWrapper domainNameC (domainName);
@@ -106,7 +105,7 @@
106 EXPECT_THAT (ccsUpgradeGetDomainNumAndProfile (CCS_SETTINGS_UPGRADE_TEST_INCORRECT_FILENAME.c_str (),105 EXPECT_THAT (ccsUpgradeGetDomainNumAndProfile (CCS_SETTINGS_UPGRADE_TEST_INCORRECT_FILENAME.c_str (),
107 &domainName,106 &domainName,
108 &num,107 &num,
109 &profileName), BoolFalse ());108 &profileName), IsFalse ());
110109
111 EXPECT_THAT (profileName, IsNull ());110 EXPECT_THAT (profileName, IsNull ());
112 EXPECT_THAT (domainName, IsNull ());111 EXPECT_THAT (domainName, IsNull ());
@@ -114,7 +113,7 @@
114 EXPECT_THAT (ccsUpgradeGetDomainNumAndProfile (CCS_SETTINGS_UPGRADE_TEST_VERY_INCORRECT_FILENAME.c_str (),113 EXPECT_THAT (ccsUpgradeGetDomainNumAndProfile (CCS_SETTINGS_UPGRADE_TEST_VERY_INCORRECT_FILENAME.c_str (),
115 &domainName,114 &domainName,
116 &num,115 &num,
117 &profileName), BoolFalse ());116 &profileName), IsFalse ());
118117
119 EXPECT_THAT (profileName, IsNull ());118 EXPECT_THAT (profileName, IsNull ());
120 EXPECT_THAT (domainName, IsNull ());119 EXPECT_THAT (domainName, IsNull ());
@@ -122,13 +121,13 @@
122121
123TEST (CCSSettingsUpgradeInternalTest, TestDetokenizeAndReturnTrueForUpgradeFileName)122TEST (CCSSettingsUpgradeInternalTest, TestDetokenizeAndReturnTrueForUpgradeFileName)
124{123{
125 EXPECT_THAT (ccsUpgradeNameFilter (CCS_SETTINGS_UPGRADE_TEST_CORRECT_FILENAME.c_str ()), BoolTrue ());124 EXPECT_THAT (ccsUpgradeNameFilter (CCS_SETTINGS_UPGRADE_TEST_CORRECT_FILENAME.c_str ()), IsTrue ());
126}125}
127126
128TEST (CCSSettingsUpgradeInternalTest, TestDetokenizeAndReturnFalseForNoUpgradeFileName)127TEST (CCSSettingsUpgradeInternalTest, TestDetokenizeAndReturnFalseForNoUpgradeFileName)
129{128{
130 EXPECT_THAT (ccsUpgradeNameFilter (CCS_SETTINGS_UPGRADE_TEST_INCORRECT_FILENAME.c_str ()), BoolFalse ());129 EXPECT_THAT (ccsUpgradeNameFilter (CCS_SETTINGS_UPGRADE_TEST_INCORRECT_FILENAME.c_str ()), IsFalse ());
131 EXPECT_THAT (ccsUpgradeNameFilter (CCS_SETTINGS_UPGRADE_TEST_VERY_INCORRECT_FILENAME.c_str ()), BoolFalse ());130 EXPECT_THAT (ccsUpgradeNameFilter (CCS_SETTINGS_UPGRADE_TEST_VERY_INCORRECT_FILENAME.c_str ()), IsFalse ());
132}131}
133132
134namespace133namespace
@@ -242,57 +241,6 @@
242241
243namespace242namespace
244{243{
245 class CCSSettingValueMatcher :
246 public ::testing::MatcherInterface <CCSSettingValue>
247 {
248 public:
249
250 CCSSettingValueMatcher (const CCSSettingValue &match,
251 CCSSettingType type,
252 CCSSettingInfo *info) :
253 mMatch (match),
254 mType (type),
255 mInfo (info)
256 {
257 }
258
259 virtual bool MatchAndExplain (CCSSettingValue x, MatchResultListener *listener) const
260 {
261 if (ccsCheckValueEq (&x,
262 mType,
263 mInfo,
264 &mMatch,
265 mType,
266 mInfo))
267 return true;
268 return false;
269 }
270
271 virtual void DescribeTo (std::ostream *os) const
272 {
273 *os << "Value Matches";
274 }
275
276 virtual void DescribeNegationTo (std::ostream *os) const
277 {
278 *os << "Value does not Match";
279 }
280
281 private:
282
283 const CCSSettingValue &mMatch;
284 CCSSettingType mType;
285 CCSSettingInfo *mInfo;
286 };
287
288 Matcher <CCSSettingValue>
289 SettingValueMatch (const CCSSettingValue &match,
290 CCSSettingType type,
291 CCSSettingInfo *info)
292 {
293 return MakeMatcher (new CCSSettingValueMatcher (match, type, info));
294 }
295
296 typedef boost::shared_ptr <cc::ListWrapper <CCSSettingList, CCSSetting *> > CCSSettingListWrapperPtr;244 typedef boost::shared_ptr <cc::ListWrapper <CCSSettingList, CCSSetting *> > CCSSettingListWrapperPtr;
297245
298 CCSSettingListWrapperPtr246 CCSSettingListWrapperPtr
@@ -362,7 +310,7 @@
362 EXPECT_CALL (Mock (resetSettingIdentifier), getValue ()).WillOnce (Return (&valueResetIdentifier));310 EXPECT_CALL (Mock (resetSettingIdentifier), getValue ()).WillOnce (Return (&valueResetIdentifier));
363 EXPECT_CALL (Mock (settingToReset), getValue ()).WillOnce (Return (&valueToReset));311 EXPECT_CALL (Mock (settingToReset), getValue ()).WillOnce (Return (&valueToReset));
364312
365 EXPECT_CALL (Mock (settingToReset), resetToDefault (BoolTrue ()));313 EXPECT_CALL (Mock (settingToReset), resetToDefault (IsTrue ()));
366314
367 ccsUpgradeClearValues (*list);315 ccsUpgradeClearValues (*list);
368}316}
@@ -465,7 +413,7 @@
465413
466 EXPECT_CALL (Mock (settingToBeChanged), setValue (Pointee (SettingValueMatch (valueResetIdentifier,414 EXPECT_CALL (Mock (settingToBeChanged), setValue (Pointee (SettingValueMatch (valueResetIdentifier,
467 TypeInt,415 TypeInt,
468 &info)), BoolTrue ()));416 &info)), IsTrue ()));
469417
470 ccsUpgradeAddValues (*list);418 ccsUpgradeAddValues (*list);
471}419}
@@ -547,7 +495,7 @@
547495
548 EXPECT_CALL (Mock (settingToBeChanged), setValue (Pointee (SettingValueMatch (toSettingIdentifierValue,496 EXPECT_CALL (Mock (settingToBeChanged), setValue (Pointee (SettingValueMatch (toSettingIdentifierValue,
549 TypeInt,497 TypeInt,
550 &info)), BoolTrue ()));498 &info)), IsTrue ()));
551499
552 ccsUpgradeReplaceValues (*replaceFromValueSettings,500 ccsUpgradeReplaceValues (*replaceFromValueSettings,
553 *replaceToValueSettings);501 *replaceToValueSettings);
@@ -712,7 +660,7 @@
712660
713 EXPECT_CALL (Mock (settingToAppendValuesTo), setList (661 EXPECT_CALL (Mock (settingToAppendValuesTo), setList (
714 IsSettingValueInSettingValueCCSList (662 IsSettingValueInSettingValueCCSList (
715 SettingValueMatch (appendedStringInListValue, TypeString, &info)), BoolTrue ()));663 SettingValueMatch (appendedStringInListValue, TypeString, &info)), IsTrue ()));
716664
717 ccsUpgradeAddValues (*list);665 ccsUpgradeAddValues (*list);
718}666}
@@ -777,7 +725,7 @@
777 EXPECT_CALL (Mock (settingToRemoveValuesFrom), setList (725 EXPECT_CALL (Mock (settingToRemoveValuesFrom), setList (
778 Not (726 Not (
779 IsSettingValueInSettingValueCCSList (727 IsSettingValueInSettingValueCCSList (
780 SettingValueMatch (removedStringInListValue, TypeString, &info))), BoolTrue ()));728 SettingValueMatch (removedStringInListValue, TypeString, &info))), IsTrue ()));
781729
782 ccsUpgradeClearValues (*list);730 ccsUpgradeClearValues (*list);
783}731}
784732
=== modified file 'compizconfig/mocks/libcompizconfig/CMakeLists.txt'
--- compizconfig/mocks/libcompizconfig/CMakeLists.txt 2012-09-24 03:58:20 +0000
+++ compizconfig/mocks/libcompizconfig/CMakeLists.txt 2012-09-24 03:58:20 +0000
@@ -25,6 +25,18 @@
25add_library (compizconfig_ccs_text_file_mock25add_library (compizconfig_ccs_text_file_mock
26 ${CMAKE_CURRENT_SOURCE_DIR}/compizconfig_ccs_text_file_mock.cpp)26 ${CMAKE_CURRENT_SOURCE_DIR}/compizconfig_ccs_text_file_mock.cpp)
2727
28add_library (compizconfig_ccs_integration_mock
29 ${CMAKE_CURRENT_SOURCE_DIR}/compizconfig_ccs_integration_mock.cpp)
30
31add_library (compizconfig_ccs_integrated_setting_mock
32 ${CMAKE_CURRENT_SOURCE_DIR}/compizconfig_ccs_integrated_setting_mock.cpp)
33
34add_library (compizconfig_ccs_integrated_setting_storage_mock
35 ${CMAKE_CURRENT_SOURCE_DIR}/compizconfig_ccs_integrated_setting_storage_mock.cpp)
36
37add_library (compizconfig_ccs_integrated_setting_factory_mock
38 ${CMAKE_CURRENT_SOURCE_DIR}/compizconfig_ccs_integrated_setting_factory_mock.cpp)
39
28target_link_libraries (compizconfig_ccs_context_mock40target_link_libraries (compizconfig_ccs_context_mock
29 ${GTEST_BOTH_LIBRARIES}41 ${GTEST_BOTH_LIBRARIES}
30 ${GMOCK_LIBRARY}42 ${GMOCK_LIBRARY}
@@ -62,3 +74,31 @@
62 ${GMOCK_LIBRARY}74 ${GMOCK_LIBRARY}
63 ${GMOCK_MAIN_LIBRARY}75 ${GMOCK_MAIN_LIBRARY}
64 ${CMAKE_THREAD_LIBS_INIT})76 ${CMAKE_THREAD_LIBS_INIT})
77
78target_link_libraries (compizconfig_ccs_integration_mock
79 ${GTEST_BOTH_LIBRARIES}
80 ${GMOCK_LIBRARY}
81 ${GMOCK_MAIN_LIBRARY}
82 ${CMAKE_THREAD_LIBS_INIT}
83 compizconfig)
84
85target_link_libraries (compizconfig_ccs_integrated_setting_mock
86 ${GTEST_BOTH_LIBRARIES}
87 ${GMOCK_LIBRARY}
88 ${GMOCK_MAIN_LIBRARY}
89 ${CMAKE_THREAD_LIBS_INIT}
90 compizconfig)
91
92target_link_libraries (compizconfig_ccs_integrated_setting_factory_mock
93 ${GTEST_BOTH_LIBRARIES}
94 ${GMOCK_LIBRARY}
95 ${GMOCK_MAIN_LIBRARY}
96 ${CMAKE_THREAD_LIBS_INIT}
97 compizconfig)
98
99target_link_libraries (compizconfig_ccs_integrated_setting_storage_mock
100 ${GTEST_BOTH_LIBRARIES}
101 ${GMOCK_LIBRARY}
102 ${GMOCK_MAIN_LIBRARY}
103 ${CMAKE_THREAD_LIBS_INIT}
104 compizconfig)
65105
=== added file 'compizconfig/mocks/libcompizconfig/compizconfig_ccs_integrated_setting_factory_mock.cpp'
--- compizconfig/mocks/libcompizconfig/compizconfig_ccs_integrated_setting_factory_mock.cpp 1970-01-01 00:00:00 +0000
+++ compizconfig/mocks/libcompizconfig/compizconfig_ccs_integrated_setting_factory_mock.cpp 2012-09-24 03:58:20 +0000
@@ -0,0 +1,70 @@
1/*
2 * Compiz configuration system library
3 *
4 * Copyright (C) 2012 Canonical Ltd.
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 *
20 * Authored By:
21 * Sam Spilsbury <sam.spilsbury@canonical.com>
22 */
23#include <gtest/gtest.h>
24#include <gmock/gmock.h>
25
26#include <ccs.h>
27
28#include "compizconfig_ccs_integrated_setting_factory_mock.h"
29
30const CCSIntegratedSettingFactoryInterface mockIntegratedSettingFactoryInterface =
31{
32 CCSIntegratedSettingFactoryGMock::ccsIntegratedSettingFactoryCreateIntegratedSettingForCCSSettingNameAndType,
33 CCSIntegratedSettingFactoryGMock::ccsIntegratedSettingFactoryFree
34};
35
36CCSIntegratedSettingFactory *
37ccsMockIntegratedSettingFactoryNew (CCSObjectAllocationInterface *ai)
38{
39 CCSIntegratedSettingFactory *integratedSettingFactory =
40 reinterpret_cast <CCSIntegratedSettingFactory *> ((*ai->calloc_) (ai->allocator, 1, sizeof (CCSIntegratedSettingFactory)));
41
42 if (!integratedSettingFactory)
43 return NULL;
44
45 CCSIntegratedSettingFactoryGMock *gmockFactory = new CCSIntegratedSettingFactoryGMock (integratedSettingFactory);
46
47 ccsObjectInit (integratedSettingFactory, ai);
48 ccsObjectSetPrivate (integratedSettingFactory, (CCSPrivate *) gmockFactory);
49 ccsObjectAddInterface (integratedSettingFactory,
50 reinterpret_cast <const CCSInterface *> (&mockIntegratedSettingFactoryInterface),
51 GET_INTERFACE_TYPE (CCSIntegratedSettingFactoryInterface));
52
53 ccsObjectRef (integratedSettingFactory);
54
55 return integratedSettingFactory;
56}
57
58void
59ccsMockIntegratedSettingFactoryFree (CCSIntegratedSettingFactory *integratedSettingFactory)
60{
61 CCSIntegratedSettingFactoryGMock *gmockFactory =
62 GET_PRIVATE (CCSIntegratedSettingFactoryGMock, integratedSettingFactory);
63
64 delete gmockFactory;
65
66 ccsObjectSetPrivate (integratedSettingFactory, NULL);
67 ccsObjectFinalize (integratedSettingFactory);
68 (*integratedSettingFactory->object.object_allocation->free_)
69 (integratedSettingFactory->object.object_allocation->allocator, integratedSettingFactory);
70}
071
=== added file 'compizconfig/mocks/libcompizconfig/compizconfig_ccs_integrated_setting_factory_mock.h'
--- compizconfig/mocks/libcompizconfig/compizconfig_ccs_integrated_setting_factory_mock.h 1970-01-01 00:00:00 +0000
+++ compizconfig/mocks/libcompizconfig/compizconfig_ccs_integrated_setting_factory_mock.h 2012-09-24 03:58:20 +0000
@@ -0,0 +1,99 @@
1/*
2 * Compiz configuration system library
3 *
4 * Copyright (C) 2012 Canonical Ltd.
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 *
20 * Authored By:
21 * Sam Spilsbury <sam.spilsbury@canonical.com>
22 */
23#ifndef _COMPIZCONFIG_CCS_INTEGRATED_SETTING_FACTORY_MOCK_H
24#define _COMPIZCONFIG_CCS_INTEGRATED_SETTING_FACTORY_MOCK_H
25
26#include <gtest/gtest.h>
27#include <gmock/gmock.h>
28
29#include <ccs.h>
30#include <ccs-backend.h>
31
32CCSIntegratedSettingFactory *
33ccsMockIntegratedSettingFactoryNew (CCSObjectAllocationInterface *ai);
34
35void
36ccsMockIntegratedSettingFactoryFree (CCSIntegratedSettingFactory *);
37
38class CCSIntegratedSettingFactoryGMockInterface
39{
40 public:
41
42 virtual ~CCSIntegratedSettingFactoryGMockInterface () {}
43
44 virtual CCSIntegratedSetting * createIntegratedSettingForCCSNameAndType (CCSIntegration *integration,
45 const char *pluginName,
46 const char *settingName,
47 CCSSettingType type) = 0;
48};
49
50class CCSIntegratedSettingFactoryGMock :
51 public CCSIntegratedSettingFactoryGMockInterface
52{
53 public:
54
55 MOCK_METHOD4 (createIntegratedSettingForCCSNameAndType, CCSIntegratedSetting * (CCSIntegration *,
56 const char *,
57 const char *,
58 CCSSettingType ));
59
60 CCSIntegratedSettingFactoryGMock (CCSIntegratedSettingFactory *integratedSettingFactory) :
61 mIntegratedSettingFactory (integratedSettingFactory)
62 {
63 }
64
65 CCSIntegratedSettingFactory *
66 getIntegratedSettingFactory ()
67 {
68 return mIntegratedSettingFactory;
69 }
70
71 public:
72
73 static CCSIntegratedSetting *
74 ccsIntegratedSettingFactoryCreateIntegratedSettingForCCSSettingNameAndType (CCSIntegratedSettingFactory *factory,
75 CCSIntegration *integration,
76 const char *pluginName,
77 const char *settingName,
78 CCSSettingType type)
79 {
80 return reinterpret_cast <CCSIntegratedSettingFactoryGMockInterface *> (factory)->createIntegratedSettingForCCSNameAndType (integration,
81 pluginName,
82 settingName,
83 type);
84 }
85
86 static void
87 ccsIntegratedSettingFactoryFree (CCSIntegratedSettingFactory *integratedSettingFactory)
88 {
89 ccsMockIntegratedSettingFactoryFree (integratedSettingFactory);
90 }
91
92 private:
93
94 CCSIntegratedSettingFactory *mIntegratedSettingFactory;
95};
96
97extern const CCSIntegratedSettingFactoryInterface mockIntegratedSettingFactoryInterface;
98
99#endif
0100
=== added file 'compizconfig/mocks/libcompizconfig/compizconfig_ccs_integrated_setting_mock.cpp'
--- compizconfig/mocks/libcompizconfig/compizconfig_ccs_integrated_setting_mock.cpp 1970-01-01 00:00:00 +0000
+++ compizconfig/mocks/libcompizconfig/compizconfig_ccs_integrated_setting_mock.cpp 2012-09-24 03:58:20 +0000
@@ -0,0 +1,71 @@
1/*
2 * Compiz configuration system library
3 *
4 * Copyright (C) 2012 Canonical Ltd.
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 *
20 * Authored By:
21 * Sam Spilsbury <sam.spilsbury@canonical.com>
22 */
23#include <gtest/gtest.h>
24#include <gmock/gmock.h>
25
26#include <ccs.h>
27
28#include "compizconfig_ccs_integrated_setting_mock.h"
29
30const CCSIntegratedSettingInterface mockIntegratedSettingInterface =
31{
32 CCSIntegratedSettingGMock::ccsIntegratedSettingReadValue,
33 CCSIntegratedSettingGMock::ccsIntegratedSettingWriteValue,
34 CCSIntegratedSettingGMock::ccsIntegratedSettingFree
35};
36
37CCSIntegratedSetting *
38ccsMockIntegratedSettingNew (CCSObjectAllocationInterface *ai)
39{
40 CCSIntegratedSetting *integratedSetting =
41 reinterpret_cast <CCSIntegratedSetting *> ((*ai->calloc_) (ai->allocator, 1, sizeof (CCSIntegratedSetting)));
42
43 if (!integratedSetting)
44 return NULL;
45
46 CCSIntegratedSettingGMock *gmockBackend = new CCSIntegratedSettingGMock (integratedSetting);
47
48 ccsObjectInit (integratedSetting, ai);
49 ccsObjectSetPrivate (integratedSetting, (CCSPrivate *) gmockBackend);
50 ccsObjectAddInterface (integratedSetting,
51 reinterpret_cast <const CCSInterface *> (&mockIntegratedSettingInterface),
52 GET_INTERFACE_TYPE (CCSIntegratedSettingInterface));
53
54 ccsObjectRef (integratedSetting);
55
56 return integratedSetting;
57}
58
59void
60ccsMockIntegratedSettingFree (CCSIntegratedSetting *integration)
61{
62 CCSIntegratedSettingGMock *gmockIntegration =
63 GET_PRIVATE (CCSIntegratedSettingGMock, integration);
64
65 delete gmockIntegration;
66
67 ccsObjectSetPrivate (integration, NULL);
68 ccsObjectFinalize (integration);
69 (*integration->object.object_allocation->free_)
70 (integration->object.object_allocation->allocator, integration);
71}
072
=== added file 'compizconfig/mocks/libcompizconfig/compizconfig_ccs_integrated_setting_mock.h'
--- compizconfig/mocks/libcompizconfig/compizconfig_ccs_integrated_setting_mock.h 1970-01-01 00:00:00 +0000
+++ compizconfig/mocks/libcompizconfig/compizconfig_ccs_integrated_setting_mock.h 2012-09-24 03:58:20 +0000
@@ -0,0 +1,97 @@
1/*
2 * Compiz configuration system library
3 *
4 * Copyright (C) 2012 Canonical Ltd.
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 *
20 * Authored By:
21 * Sam Spilsbury <sam.spilsbury@canonical.com>
22 */
23#ifndef _COMPIZCONFIG_CCS_INTEGRATED_SETTING_MOCK_H
24#define _COMPIZCONFIG_CCS_INTEGRATED_SETTING_MOCK_H
25
26#include <gtest/gtest.h>
27#include <gmock/gmock.h>
28
29#include <ccs.h>
30#include <ccs-backend.h>
31
32CCSIntegratedSetting *
33ccsMockIntegratedSettingNew (CCSObjectAllocationInterface *ai);
34
35void
36ccsMockIntegratedSettingFree (CCSIntegratedSetting *);
37
38class CCSIntegratedSettingGMockInterface
39{
40 public:
41
42 virtual ~CCSIntegratedSettingGMockInterface () {}
43
44 virtual CCSSettingValue * readValue (CCSSettingType) = 0;
45 virtual void writeValue (CCSSettingValue *, CCSSettingType) = 0;
46};
47
48class CCSIntegratedSettingGMock :
49 public CCSIntegratedSettingGMockInterface
50{
51 public:
52
53 MOCK_METHOD1 (readValue, CCSSettingValue * (CCSSettingType));
54 MOCK_METHOD2 (writeValue, void (CCSSettingValue *, CCSSettingType));
55
56 CCSIntegratedSettingGMock (CCSIntegratedSetting *integratedSetting) :
57 mIntegrationSetting (integratedSetting)
58 {
59 }
60
61 CCSIntegratedSetting *
62 getIntegratedSetting ()
63 {
64 return mIntegrationSetting;
65 }
66
67 public:
68
69 static CCSSettingValue *
70 ccsIntegratedSettingReadValue (CCSIntegratedSetting *integratedSetting,
71 CCSSettingType type)
72 {
73 return reinterpret_cast <CCSIntegratedSettingGMockInterface *> (ccsObjectGetPrivate (integratedSetting))->readValue (type);
74 }
75
76 static void
77 ccsIntegratedSettingWriteValue (CCSIntegratedSetting *integratedSetting,
78 CCSSettingValue *value,
79 CCSSettingType type)
80 {
81 reinterpret_cast <CCSIntegratedSettingGMockInterface *> (ccsObjectGetPrivate (integratedSetting))->writeValue (value, type);
82 }
83
84 static void
85 ccsIntegratedSettingFree (CCSIntegratedSetting *integratedSetting)
86 {
87 ccsMockIntegratedSettingFree (integratedSetting);
88 }
89
90 private:
91
92 CCSIntegratedSetting *mIntegrationSetting;
93};
94
95extern const CCSIntegratedSettingInterface mockIntegratedSettingInterface;
96
97#endif
098
=== added file 'compizconfig/mocks/libcompizconfig/compizconfig_ccs_integrated_setting_storage_mock.cpp'
--- compizconfig/mocks/libcompizconfig/compizconfig_ccs_integrated_setting_storage_mock.cpp 1970-01-01 00:00:00 +0000
+++ compizconfig/mocks/libcompizconfig/compizconfig_ccs_integrated_setting_storage_mock.cpp 2012-09-24 03:58:20 +0000
@@ -0,0 +1,73 @@
1/*
2 * Compiz configuration system library
3 *
4 * Copyright (C) 2012 Canonical Ltd.
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 *
20 * Authored By:
21 * Sam Spilsbury <sam.spilsbury@canonical.com>
22 */
23#include <gtest/gtest.h>
24#include <gmock/gmock.h>
25
26#include <ccs.h>
27
28#include "compizconfig_ccs_integrated_setting_storage_mock.h"
29
30const CCSIntegratedSettingsStorageInterface mockIntegratedSettingsStorageInterface =
31{
32 CCSIntegratedSettingsStorageGMock::ccsIntegratedSettingsStorageFindMatchingSettingsByPredicate,
33 CCSIntegratedSettingsStorageGMock::ccsIntegratedSettingsStorageFindMatchingSettingsByPluginAndSettingName,
34 CCSIntegratedSettingsStorageGMock::ccsIntegratedSettingsStorageAddSetting,
35 CCSIntegratedSettingsStorageGMock::ccsIntegratedSettingsStorageEmpty,
36 CCSIntegratedSettingsStorageGMock::ccsIntegratedSettingsStorageFree
37};
38
39CCSIntegratedSettingsStorage *
40ccsMockIntegratedSettingsStorageNew (CCSObjectAllocationInterface *ai)
41{
42 CCSIntegratedSettingsStorage *storage =
43 reinterpret_cast <CCSIntegratedSettingsStorage *> ((*ai->calloc_) (ai->allocator, 1, sizeof (CCSIntegratedSettingsStorage)));
44
45 if (!storage)
46 return NULL;
47
48 CCSIntegratedSettingsStorageGMock *gmockBackend = new CCSIntegratedSettingsStorageGMock (storage);
49
50 ccsObjectInit (storage, ai);
51 ccsObjectSetPrivate (storage, (CCSPrivate *) gmockBackend);
52 ccsObjectAddInterface (storage,
53 reinterpret_cast <const CCSInterface *> (&mockIntegratedSettingsStorageInterface),
54 GET_INTERFACE_TYPE (CCSIntegratedSettingsStorageInterface));
55
56 ccsObjectRef (storage);
57
58 return storage;
59}
60
61void
62ccsMockIntegratedSettingsStorageFree (CCSIntegratedSettingsStorage *storage)
63{
64 CCSIntegratedSettingsStorageGMock *gmockStorage =
65 GET_PRIVATE (CCSIntegratedSettingsStorageGMock, storage);
66
67 delete gmockStorage;
68
69 ccsObjectSetPrivate (storage, NULL);
70 ccsObjectFinalize (storage);
71 (*storage->object.object_allocation->free_)
72 (storage->object.object_allocation->allocator, storage);
73}
074
=== added file 'compizconfig/mocks/libcompizconfig/compizconfig_ccs_integrated_setting_storage_mock.h'
--- compizconfig/mocks/libcompizconfig/compizconfig_ccs_integrated_setting_storage_mock.h 1970-01-01 00:00:00 +0000
+++ compizconfig/mocks/libcompizconfig/compizconfig_ccs_integrated_setting_storage_mock.h 2012-09-24 03:58:20 +0000
@@ -0,0 +1,119 @@
1/*
2 * Compiz configuration system library
3 *
4 * Copyright (C) 2012 Canonical Ltd.
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 *
20 * Authored By:
21 * Sam Spilsbury <sam.spilsbury@canonical.com>
22 */
23#ifndef _COMPIZCONFIG_CCS_INTEGRATED_SETTING_STORAGE_MOCK_H
24#define _COMPIZCONFIG_CCS_INTEGRATED_SETTING_STORAGE_MOCK_H
25
26#include <gtest/gtest.h>
27#include <gmock/gmock.h>
28
29#include <ccs.h>
30#include <ccs-backend.h>
31
32CCSIntegratedSettingsStorage *
33ccsMockIntegratedSettingsStorageNew (CCSObjectAllocationInterface *ai);
34
35void
36ccsMockIntegratedSettingsStorageFree (CCSIntegratedSettingsStorage *);
37
38class CCSIntegratedSettingsStorageGMockInterface
39{
40 public:
41
42 virtual ~CCSIntegratedSettingsStorageGMockInterface () {}
43
44 virtual CCSIntegratedSettingList findMatchingSettingsByPluginAndSettingName (const char *pluginName,
45 const char *settingName) = 0;
46 virtual void addSetting (CCSIntegratedSetting *setting) = 0;
47 virtual CCSIntegratedSettingList findMatchingSettingsByPredicate (CCSIntegratedSettingsStorageFindPredicate pred,
48 void *data) = 0;
49 virtual Bool empty () = 0;
50};
51
52class CCSIntegratedSettingsStorageGMock :
53 public CCSIntegratedSettingsStorageGMockInterface
54{
55 public:
56
57 MOCK_METHOD2 (findMatchingSettingsByPluginAndSettingName, CCSIntegratedSettingList (const char *,
58 const char *));
59 MOCK_METHOD1 (addSetting, void (CCSIntegratedSetting *));
60 MOCK_METHOD2 (findMatchingSettingsByPredicate, CCSIntegratedSettingList (CCSIntegratedSettingsStorageFindPredicate ,
61 void *));
62 MOCK_METHOD0 (empty, Bool ());
63
64 CCSIntegratedSettingsStorageGMock (CCSIntegratedSettingsStorage *integratedSetting) :
65 mIntegrationSetting (integratedSetting)
66 {
67 }
68
69 CCSIntegratedSettingsStorage *
70 getIntegratedSettingsStorage ()
71 {
72 return mIntegrationSetting;
73 }
74
75 public:
76
77 static CCSIntegratedSettingList
78 ccsIntegratedSettingsStorageFindMatchingSettingsByPredicate (CCSIntegratedSettingsStorage *storage,
79 CCSIntegratedSettingsStorageFindPredicate pred,
80 void *data)
81 {
82 return reinterpret_cast <CCSIntegratedSettingsStorageGMockInterface *> (ccsObjectGetPrivate (storage))->findMatchingSettingsByPredicate (pred, data);
83 }
84
85 static CCSIntegratedSettingList
86 ccsIntegratedSettingsStorageFindMatchingSettingsByPluginAndSettingName (CCSIntegratedSettingsStorage *storage,
87 const char *pluginName,
88 const char *settingName)
89 {
90 return reinterpret_cast <CCSIntegratedSettingsStorageGMockInterface *> (ccsObjectGetPrivate (storage))->findMatchingSettingsByPluginAndSettingName (pluginName, settingName);
91 }
92
93 static void
94 ccsIntegratedSettingsStorageAddSetting (CCSIntegratedSettingsStorage *storage,
95 CCSIntegratedSetting *setting)
96 {
97 return reinterpret_cast <CCSIntegratedSettingsStorageGMockInterface *> (ccsObjectGetPrivate (storage))->addSetting (setting);
98 }
99
100 static Bool
101 ccsIntegratedSettingsStorageEmpty (CCSIntegratedSettingsStorage *storage)
102 {
103 return reinterpret_cast <CCSIntegratedSettingsStorageGMockInterface *> (ccsObjectGetPrivate (storage))->empty ();
104 }
105
106 static void
107 ccsIntegratedSettingsStorageFree (CCSIntegratedSettingsStorage *integratedSetting)
108 {
109 ccsMockIntegratedSettingsStorageFree (integratedSetting);
110 }
111
112 private:
113
114 CCSIntegratedSettingsStorage *mIntegrationSetting;
115};
116
117extern const CCSIntegratedSettingsStorageInterface mockIntegratedSettingsStorageInterface;
118
119#endif
0120
=== added file 'compizconfig/mocks/libcompizconfig/compizconfig_ccs_integration_mock.cpp'
--- compizconfig/mocks/libcompizconfig/compizconfig_ccs_integration_mock.cpp 1970-01-01 00:00:00 +0000
+++ compizconfig/mocks/libcompizconfig/compizconfig_ccs_integration_mock.cpp 2012-09-24 03:58:20 +0000
@@ -0,0 +1,70 @@
1/*
2 * Compiz configuration system library
3 *
4 * Copyright (C) 2012 Canonical Ltd.
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 *
20 * Authored By:
21 * Sam Spilsbury <sam.spilsbury@canonical.com>
22 */
23#include <gtest/gtest.h>
24#include <gmock/gmock.h>
25
26#include <ccs.h>
27
28#include "compizconfig_ccs_integration_mock.h"
29
30const CCSIntegrationInterface mockIntegrationBackendInterface =
31{
32 CCSIntegrationGMock::ccsIntegrationGetIntegratedOptionIndex,
33 CCSIntegrationGMock::ccsIntegrationReadOptionIntoSetting,
34 CCSIntegrationGMock::ccsIntegrationWriteSettingIntoOption,
35 CCSIntegrationGMock::ccsIntegrationUpdateIntegratedSettings,
36 CCSIntegrationGMock::ccsIntegrationDisallowIntegratedWrites,
37 CCSIntegrationGMock::ccsIntegrationAllowIntegratedWrites,
38 CCSIntegrationGMock::ccsFreeIntegration
39};
40
41CCSIntegration *
42ccsMockIntegrationBackendNew (CCSObjectAllocationInterface *ai)
43{
44 CCSIntegration *integration = reinterpret_cast <CCSIntegration *> ((*ai->calloc_) (ai->allocator, 1, sizeof (CCSIntegration)));
45
46 if (!integration)
47 return NULL;
48
49 CCSIntegrationGMock *gmockBackend = new CCSIntegrationGMock (integration);
50
51 ccsObjectInit (integration, ai);
52 ccsObjectSetPrivate (integration, (CCSPrivate *) gmockBackend);
53 ccsObjectAddInterface (integration, (const CCSInterface *) &mockIntegrationBackendInterface, GET_INTERFACE_TYPE (CCSIntegrationInterface));
54
55 ccsObjectRef (integration);
56
57 return integration;
58}
59
60void
61ccsMockIntegrationBackendFree (CCSIntegration *integration)
62{
63 CCSIntegrationGMock *gmockBackend = reinterpret_cast <CCSIntegrationGMock *> (ccsObjectGetPrivate (integration));
64
65 delete gmockBackend;
66
67 ccsObjectSetPrivate (integration, NULL);
68 ccsObjectFinalize (integration);
69 (*integration->object.object_allocation->free_) (integration->object.object_allocation->allocator, integration);
70}
071
=== added file 'compizconfig/mocks/libcompizconfig/compizconfig_ccs_integration_mock.h'
--- compizconfig/mocks/libcompizconfig/compizconfig_ccs_integration_mock.h 1970-01-01 00:00:00 +0000
+++ compizconfig/mocks/libcompizconfig/compizconfig_ccs_integration_mock.h 2012-09-24 03:58:20 +0000
@@ -0,0 +1,129 @@
1/*
2 * Compiz configuration system library
3 *
4 * Copyright (C) 2012 Canonical Ltd.
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 *
20 * Authored By:
21 * Sam Spilsbury <sam.spilsbury@canonical.com>
22 */
23#ifndef _COMPIZCONFIG_CCS_INTEGRATION_MOCK_H
24#define _COMPIZCONFIG_CCS_INTEGRATION_MOCK_H
25
26#include <gtest/gtest.h>
27#include <gmock/gmock.h>
28
29#include <ccs.h>
30
31CCSIntegration *
32ccsMockIntegrationBackendNew (CCSObjectAllocationInterface *ai);
33
34void
35ccsMockIntegrationBackendFree (CCSIntegration *integration);
36
37class CCSIntegrationGMockInterface
38{
39 public:
40
41 virtual ~CCSIntegrationGMockInterface () {}
42
43 virtual CCSIntegratedSetting * getIntegratedOptionIndex (const char *pluginName, const char *settingName) = 0;
44 virtual Bool readOptionIntoSetting (CCSContext *context, CCSSetting *setting, CCSIntegratedSetting *) = 0;
45 virtual void writeOptionFromSetting (CCSContext *context, CCSSetting *setting, CCSIntegratedSetting *) = 0;
46 virtual void updateIntegratedSettings (CCSContext *context, CCSIntegratedSettingList settingList) = 0;
47 virtual void disallowIntegratedWrites () = 0;
48 virtual void allowIntegratedWrites () = 0;
49};
50
51class CCSIntegrationGMock :
52 public CCSIntegrationGMockInterface
53{
54 public:
55
56 MOCK_METHOD2 (getIntegratedOptionIndex, CCSIntegratedSetting * (const char *, const char *));
57 MOCK_METHOD3 (readOptionIntoSetting, Bool (CCSContext *, CCSSetting *, CCSIntegratedSetting *));
58 MOCK_METHOD3 (writeOptionFromSetting, void (CCSContext *, CCSSetting *, CCSIntegratedSetting *));
59 MOCK_METHOD2 (updateIntegratedSettings, void (CCSContext *, CCSIntegratedSettingList));
60 MOCK_METHOD0 (disallowIntegratedWrites, void ());
61 MOCK_METHOD0 (allowIntegratedWrites, void ());
62
63
64 CCSIntegrationGMock (CCSIntegration *integration) :
65 mIntegration (integration)
66 {
67 }
68
69 CCSIntegration *
70 getIntegrationBackend ()
71 {
72 return mIntegration;
73 }
74
75 public:
76
77 static CCSIntegratedSetting * ccsIntegrationGetIntegratedOptionIndex (CCSIntegration *integration,
78 const char *pluginName,
79 const char *settingName)
80 {
81 return reinterpret_cast <CCSIntegrationGMockInterface *> (ccsObjectGetPrivate (integration))->getIntegratedOptionIndex (pluginName, settingName);
82 }
83
84 static Bool ccsIntegrationReadOptionIntoSetting (CCSIntegration *integration,
85 CCSContext *context,
86 CCSSetting *setting,
87 CCSIntegratedSetting *integrated)
88 {
89 return reinterpret_cast <CCSIntegrationGMockInterface *> (ccsObjectGetPrivate (integration))->readOptionIntoSetting (context, setting, integrated);
90 }
91
92 static void ccsIntegrationWriteSettingIntoOption (CCSIntegration *integration,
93 CCSContext *context,
94 CCSSetting *setting,
95 CCSIntegratedSetting *integrated)
96 {
97 return reinterpret_cast <CCSIntegrationGMockInterface *> (ccsObjectGetPrivate (integration))->writeOptionFromSetting (context, setting, integrated);
98 }
99
100 static void ccsIntegrationUpdateIntegratedSettings (CCSIntegration *integration,
101 CCSContext *context,
102 CCSIntegratedSettingList settingList)
103 {
104 return reinterpret_cast <CCSIntegrationGMockInterface *> (ccsObjectGetPrivate (integration))->updateIntegratedSettings (context, settingList);
105 }
106
107 static void ccsFreeIntegration (CCSIntegration *integration)
108 {
109 ccsMockIntegrationBackendFree (integration);
110 }
111
112 static void ccsIntegrationDisallowIntegratedWrites (CCSIntegration *integration)
113 {
114 reinterpret_cast <CCSIntegrationGMockInterface *> (ccsObjectGetPrivate (integration))->disallowIntegratedWrites ();
115 }
116
117 static void ccsIntegrationAllowIntegratedWrites (CCSIntegration *integration)
118 {
119 reinterpret_cast <CCSIntegrationGMockInterface *> (ccsObjectGetPrivate (integration))->allowIntegratedWrites ();
120 }
121
122 private:
123
124 CCSIntegration *mIntegration;
125};
126
127extern const CCSIntegrationInterface mockIntegrationBackendInterface;
128
129#endif
0130
=== added file 'compizconfig/tests/CMakeLists.txt'
--- compizconfig/tests/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ compizconfig/tests/CMakeLists.txt 2012-09-24 03:58:20 +0000
@@ -0,0 +1,71 @@
1include_directories (${CMAKE_CURRENT_SOURCE_DIR}/../libcompizconfig/include
2 ${CMAKE_CURRENT_SOURCE_DIR}/../mocks/libcompizconfig
3 ${CMAKE_SOURCE_DIR}/tests/shared
4 ${CMAKE_CURRENT_SOURCE_DIR})
5
6add_library (compizconfig_ccs_item_in_list_matcher STATIC
7 ${CMAKE_CURRENT_SOURCE_DIR}/compizconfig_ccs_item_in_list_matcher.cpp)
8
9target_link_libraries (compizconfig_ccs_item_in_list_matcher
10 ${GTEST_BOTH_LIBRARIES}
11 ${GMOCK_MAIN_LIBRARY}
12 ${GMOCK_LIBRARY}
13 compizconfig)
14
15add_library (compizconfig_ccs_list_equality STATIC
16 ${CMAKE_CURRENT_SOURCE_DIR}/compizconfig_ccs_list_equality.cpp)
17
18target_link_libraries (compizconfig_ccs_list_equality
19 ${GTEST_BOTH_LIBRARIES}
20 ${GMOCK_MAIN_LIBRARY}
21 ${GMOCK_LIBRARY}
22 compizconfig)
23
24add_library (compizconfig_ccs_setting_value_matcher STATIC
25 ${CMAKE_CURRENT_SOURCE_DIR}/compizconfig_ccs_setting_value_matcher.cpp)
26
27target_link_libraries (compizconfig_ccs_setting_value_matcher
28 ${GTEST_BOTH_LIBRARIES}
29 ${GMOCK_MAIN_LIBRARY}
30 ${GMOCK_LIBRARY}
31 compizconfig)
32
33add_library (compizconfig_ccs_list_wrapper STATIC
34 ${CMAKE_CURRENT_SOURCE_DIR}/compizconfig_ccs_list_wrapper.cpp)
35
36target_link_libraries (compizconfig_ccs_list_wrapper
37 ${GTEST_BOTH_LIBRARIES}
38 ${GMOCK_MAIN_LIBRARY}
39 ${GMOCK_LIBRARY}
40 compizconfig)
41
42add_library (compizconfig_ccs_setting_value_operators STATIC
43 ${CMAKE_CURRENT_SOURCE_DIR}/compizconfig_ccs_setting_value_operators.cpp)
44
45target_link_libraries (compizconfig_ccs_setting_value_operators
46 ${GTEST_BOTH_LIBRARIES}
47 ${GMOCK_MAIN_LIBRARY}
48 ${GMOCK_LIBRARY}
49 compizconfig)
50
51add_library (compizconfig_ccs_test_value_combinations STATIC
52 ${CMAKE_CURRENT_SOURCE_DIR}/compizconfig_test_value_combiners.cpp)
53
54target_link_libraries (compizconfig_ccs_test_value_combinations
55 ${GTEST_BOTH_LIBRARIES}
56 ${GMOCK_MAIN_LIBRARY}
57 ${GMOCK_LIBRARY}
58 compizconfig)
59
60add_library (compizconfig_ccs_backend_conformance_test STATIC
61 ${CMAKE_CURRENT_SOURCE_DIR}/compizconfig_backend_concept_test.cpp)
62
63target_link_libraries (compizconfig_ccs_backend_conformance_test
64 ${GTEST_BOTH_LIBRARIES}
65 ${GMOCK_MAIN_LIBRARY}
66 ${GMOCK_LIBRARY}
67 compizconfig
68 compizconfig_ccs_test_value_combinations
69 compizconfig_ccs_setting_value_operators
70 compizconfig_ccs_list_equality
71 compizconfig_ccs_item_in_list_matcher)
072
=== added file 'compizconfig/tests/compizconfig_backend_concept_test.cpp'
--- compizconfig/tests/compizconfig_backend_concept_test.cpp 1970-01-01 00:00:00 +0000
+++ compizconfig/tests/compizconfig_backend_concept_test.cpp 2012-09-24 03:58:20 +0000
@@ -0,0 +1,381 @@
1/*
2 * Compiz configuration system library
3 *
4 * Copyright (C) 2012 Canonical Ltd.
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 *
20 * Authored By:
21 * Sam Spilsbury <sam.spilsbury@canonical.com>
22 */
23#include <gtest/gtest.h>
24#include <gmock/gmock.h>
25
26#include <gtest_unspecified_bool_type_matcher.h>
27
28#include <compizconfig_ccs_setting_mock.h>
29
30#include <boost/function.hpp>
31#include <boost/bind.hpp>
32#include <boost/shared_ptr.hpp>
33#include <boost/make_shared.hpp>
34
35#include <compizconfig_backend_concept_test_internal.h>
36#include <compizconfig_backend_concept_test_environment_interface.h>
37
38using ::testing::NiceMock;
39using ::testing::Return;
40using ::testing::ReturnNull;
41using ::testing::SetArgPointee;
42using ::testing::DoAll;
43using ::testing::AtLeast;
44using ::testing::Eq;
45
46
47namespace cct = compizconfig::test;
48
49Bool cct::boolToBool (bool v)
50{
51 return v ? TRUE : FALSE;
52}
53
54cci::SettingValueListWrapper::Ptr
55cct::CCSListConstructionExpectationsSetter (const cct::ConstructorFunc &c,
56 CCSSettingType type,
57 cci::ListStorageType storageType)
58{
59 boost::function <void (CCSSetting *)> f (boost::bind (ccsSettingUnref, _1));
60 boost::shared_ptr <CCSSetting> mockSetting (ccsNiceMockSettingNew (), f);
61 NiceMock <CCSSettingGMock> *gmockSetting = reinterpret_cast <NiceMock <CCSSettingGMock> *> (ccsObjectGetPrivate (mockSetting.get ()));
62
63 ON_CALL (*gmockSetting, getType ()).WillByDefault (Return (TypeList));
64
65 boost::shared_ptr <CCSSettingInfo> listInfo (new CCSSettingInfo);
66
67 listInfo->forList.listType = type;
68
69 ON_CALL (*gmockSetting, getInfo ()).WillByDefault (Return (listInfo.get ()));
70 ON_CALL (*gmockSetting, getDefaultValue ()).WillByDefault (ReturnNull ());
71 return boost::make_shared <cci::SettingValueListWrapper> (c (mockSetting.get ()), storageType, type, listInfo, mockSetting);
72}
73
74CCSSettingGMock *
75cct::getSettingGMockFromSetting (const boost::shared_ptr <CCSSetting> &setting)
76{
77 return reinterpret_cast <CCSSettingGMock *> (ccsObjectGetPrivate (setting.get ()));
78}
79
80void
81cct::SetIntWriteExpectation (const std::string &plugin,
82 const std::string &key,
83 const VariantTypes &value,
84 const boost::shared_ptr <CCSSetting> &setting,
85 const WriteFunc &write,
86 const CCSBackendConceptTestEnvironmentInterface::Ptr &env)
87{
88 CCSSettingGMock *gmock (getSettingGMockFromSetting (setting));
89 EXPECT_CALL (*gmock, getInt (_)).WillRepeatedly (DoAll (
90 SetArgPointee <0> (
91 boost::get <int> (value)),
92 Return (TRUE)));
93 write ();
94 EXPECT_EQ (env->ReadIntegerAtKey (plugin, key), boost::get <int> (value));
95}
96
97void
98cct::SetBoolWriteExpectation (const std::string &plugin,
99 const std::string &key,
100 const VariantTypes &value,
101 const boost::shared_ptr <CCSSetting> &setting,
102 const WriteFunc &write,
103 const CCSBackendConceptTestEnvironmentInterface::Ptr &env)
104{
105 CCSSettingGMock *gmock (getSettingGMockFromSetting (setting));
106 EXPECT_CALL (*gmock, getBool (_)).WillRepeatedly (DoAll (
107 SetArgPointee <0> (
108 boolToBool (boost::get <bool> (value))),
109 Return (TRUE)));
110 write ();
111
112 bool v (boost::get <bool> (value));
113
114 if (v)
115 EXPECT_THAT (env->ReadBoolAtKey (plugin, key), IsTrue ());
116 else
117 EXPECT_THAT (env->ReadBoolAtKey (plugin, key), IsFalse ());
118}
119
120void
121cct::SetFloatWriteExpectation (const std::string &plugin,
122 const std::string &key,
123 const VariantTypes &value,
124 const boost::shared_ptr <CCSSetting> &setting,
125 const WriteFunc &write,
126 const CCSBackendConceptTestEnvironmentInterface::Ptr &env)
127{
128 CCSSettingGMock *gmock (getSettingGMockFromSetting (setting));
129 EXPECT_CALL (*gmock, getFloat (_)).WillRepeatedly (DoAll (
130 SetArgPointee <0> (
131 boost::get <float> (value)),
132 Return (TRUE)));
133 write ();
134 EXPECT_EQ (env->ReadFloatAtKey (plugin, key), boost::get <float> (value));
135}
136
137void
138cct::SetStringWriteExpectation (const std::string &plugin,
139 const std::string &key,
140 const VariantTypes &value,
141 const boost::shared_ptr <CCSSetting> &setting,
142 const WriteFunc &write,
143 const CCSBackendConceptTestEnvironmentInterface::Ptr &env)
144{
145 CCSSettingGMock *gmock (getSettingGMockFromSetting (setting));
146 EXPECT_CALL (*gmock, getString (_)).WillRepeatedly (DoAll (
147 SetArgPointee <0> (
148 const_cast <char *> (boost::get <const char *> (value))),
149 Return (TRUE)));
150 write ();
151 EXPECT_EQ (std::string (env->ReadStringAtKey (plugin, key)), std::string (boost::get <const char *> (value)));
152}
153
154void
155cct::SetColorWriteExpectation (const std::string &plugin,
156 const std::string &key,
157 const VariantTypes &value,
158 const boost::shared_ptr <CCSSetting> &setting,
159 const WriteFunc &write,
160 const CCSBackendConceptTestEnvironmentInterface::Ptr &env)
161{
162 CCSSettingGMock *gmock (getSettingGMockFromSetting (setting));
163 EXPECT_CALL (*gmock, getColor (_)).WillRepeatedly (DoAll (
164 SetArgPointee <0> (
165 boost::get <CCSSettingColorValue> (value)),
166 Return (TRUE)));
167 write ();
168
169 EXPECT_EQ (env->ReadColorAtKey (plugin, key), boost::get <CCSSettingColorValue> (value));
170}
171
172void
173cct::SetKeyWriteExpectation (const std::string &plugin,
174 const std::string &key,
175 const VariantTypes &value,
176 const boost::shared_ptr <CCSSetting> &setting,
177 const WriteFunc &write,
178 const CCSBackendConceptTestEnvironmentInterface::Ptr &env)
179{
180 CCSSettingGMock *gmock (getSettingGMockFromSetting (setting));
181 EXPECT_CALL (*gmock, getKey (_)).WillRepeatedly (DoAll (
182 SetArgPointee <0> (
183 boost::get <CCSSettingKeyValue> (value)),
184 Return (TRUE)));
185 write ();
186 EXPECT_EQ (env->ReadKeyAtKey (plugin, key), boost::get <CCSSettingKeyValue> (value));
187}
188
189void
190cct::SetButtonWriteExpectation (const std::string &plugin,
191 const std::string &key,
192 const VariantTypes &value,
193 const boost::shared_ptr <CCSSetting> &setting,
194 const WriteFunc &write,
195 const CCSBackendConceptTestEnvironmentInterface::Ptr &env)
196{
197 CCSSettingGMock *gmock (getSettingGMockFromSetting (setting));
198 EXPECT_CALL (*gmock, getButton (_)).WillRepeatedly (DoAll (
199 SetArgPointee <0> (
200 boost::get <CCSSettingButtonValue> (value)),
201 Return (TRUE)));
202 write ();
203 EXPECT_EQ (env->ReadButtonAtKey (plugin, key), boost::get <CCSSettingButtonValue> (value));
204}
205
206void
207cct::SetEdgeWriteExpectation (const std::string &plugin,
208 const std::string &key,
209 const VariantTypes &value,
210 const boost::shared_ptr <CCSSetting> &setting,
211 const WriteFunc &write,
212 const CCSBackendConceptTestEnvironmentInterface::Ptr &env)
213{
214 CCSSettingGMock *gmock (getSettingGMockFromSetting (setting));
215 EXPECT_CALL (*gmock, getEdge (_)).WillRepeatedly (DoAll (
216 SetArgPointee <0> (
217 boost::get <unsigned int> (value)),
218 Return (TRUE)));
219 write ();
220 EXPECT_EQ (env->ReadEdgeAtKey (plugin, key), boost::get <unsigned int> (value));
221}
222
223void
224cct::SetBellWriteExpectation (const std::string &plugin,
225 const std::string &key,
226 const VariantTypes &value,
227 const boost::shared_ptr <CCSSetting> &setting,
228 const WriteFunc &write,
229 const CCSBackendConceptTestEnvironmentInterface::Ptr &env)
230{
231 CCSSettingGMock *gmock (getSettingGMockFromSetting (setting));
232 EXPECT_CALL (*gmock, getBell (_)).WillRepeatedly (DoAll (
233 SetArgPointee <0> (
234 boolToBool (boost::get <bool> (value))),
235 Return (TRUE)));
236 write ();
237 bool v (boost::get <bool> (value));
238
239 if (v)
240 EXPECT_THAT (env->ReadBellAtKey (plugin, key), IsTrue ());
241 else
242 EXPECT_THAT (env->ReadBellAtKey (plugin, key), IsFalse ());
243}
244
245void
246cct::SetMatchWriteExpectation (const std::string &plugin,
247 const std::string &key,
248 const VariantTypes &value,
249 const boost::shared_ptr <CCSSetting> &setting,
250 const WriteFunc &write,
251 const CCSBackendConceptTestEnvironmentInterface::Ptr &env)
252{
253 CCSSettingGMock *gmock (getSettingGMockFromSetting (setting));
254 EXPECT_CALL (*gmock, getMatch (_)).WillRepeatedly (DoAll (
255 SetArgPointee <0> (
256 const_cast <char *> (
257 boost::get <const char *> (
258 value))),
259 Return (TRUE)));
260 write ();
261 EXPECT_EQ (std::string (env->ReadMatchAtKey (plugin, key)),
262 std::string (boost::get <const char *> (value)));
263}
264
265void
266cct::SetListWriteExpectation (const std::string &plugin,
267 const std::string &key,
268 const VariantTypes &value,
269 const boost::shared_ptr <CCSSetting> &setting,
270 const WriteFunc &write,
271 const CCSBackendConceptTestEnvironmentInterface::Ptr &env)
272{
273 CCSSettingGMock *gmock (getSettingGMockFromSetting (setting));
274 CCSSettingValueList list = *(boost::get <boost::shared_ptr <cci::SettingValueListWrapper> > (value));
275
276 EXPECT_CALL (*gmock, getInfo ());
277
278 CCSSettingInfo *info = ccsSettingGetInfo (setting.get ());
279 info->forList.listType =
280 (boost::get <boost::shared_ptr <cci::SettingValueListWrapper> > (value))->type ();
281
282 EXPECT_CALL (*gmock, getInfo ()).Times (AtLeast (1));
283 EXPECT_CALL (*gmock, getList (_)).WillRepeatedly (DoAll (
284 SetArgPointee <0> (
285 list),
286 Return (TRUE)));
287 write ();
288
289 EXPECT_THAT (cci::SettingValueListWrapper (env->ReadListAtKey (plugin, key, setting.get ()),
290 cci::Deep,
291 info->forList.listType,
292 boost::shared_ptr <CCSSettingInfo> (),
293 setting),
294 ListEqual (&info->forList, list));
295}
296
297void
298cct::SetIntReadExpectation (CCSSettingGMock *gmock, const VariantTypes &value)
299{
300 EXPECT_CALL (*gmock, setInt (boost::get <int> (value), _));
301}
302
303void
304cct::SetBoolReadExpectation (CCSSettingGMock *gmock, const VariantTypes &value)
305{
306 bool v (boost::get <bool> (value));
307
308 if (v)
309 EXPECT_CALL (*gmock, setBool (IsTrue (), _));
310 else
311 EXPECT_CALL (*gmock, setBool (IsFalse (), _));
312}
313
314void
315cct::SetBellReadExpectation (CCSSettingGMock *gmock, const VariantTypes &value)
316{
317 bool v (boost::get <bool> (value));
318
319 if (v)
320 EXPECT_CALL (*gmock, setBell (IsTrue (), _));
321 else
322 EXPECT_CALL (*gmock, setBell (IsFalse (), _));
323}
324
325void
326cct::SetFloatReadExpectation (CCSSettingGMock *gmock, const VariantTypes &value)
327{
328 EXPECT_CALL (*gmock, setFloat (boost::get <float> (value), _));
329}
330
331void
332cct::SetStringReadExpectation (CCSSettingGMock *gmock, const VariantTypes &value)
333{
334 EXPECT_CALL (*gmock, setString (Eq (std::string (boost::get <const char *> (value))), _));
335}
336
337void
338cct::SetMatchReadExpectation (CCSSettingGMock *gmock, const VariantTypes &value)
339{
340 EXPECT_CALL (*gmock, setMatch (Eq (std::string (boost::get <const char *> (value))), _));
341}
342
343void
344cct::SetColorReadExpectation (CCSSettingGMock *gmock, const VariantTypes &value)
345{
346 EXPECT_CALL (*gmock, setColor (boost::get <CCSSettingColorValue> (value), _));
347}
348
349void
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches