diff -Nru compiz-0.9.8.2+bzr3377/NEWS compiz-0.9.8.4/NEWS --- compiz-0.9.8.2+bzr3377/NEWS 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/NEWS 2012-09-27 11:04:02.000000000 +0000 @@ -1,3 +1,85 @@ +Release 0.9.8.4 (2012-09-27 Daniel van Vugt ) +============================================================================ + +Highlights + + * Fixed a few crashes affecting a lot of people. Especially users of VMs and + LLVMpipe. + * Significant improvements to "Unredirect Fullscreen Windows" mode, which + is particularly useful for fullscreen gaming performance. + - Flickering is mostly fixed. + - Multi-monitor unredirect is dramatically faster than previous versions. + - Fixed automatic redirect/unredirect entry/exit bugs. + To try it out, enable: CCSM > Composite > Unredirect Fullscreen Windows. + The option is not enabled by default yet because there are some issues + with driver stability, particularly with nouveau and intel. + * Major gsettings/compizconfig bug fixes and refactoring with lots more + test cases. + +Bugs Fixed (https://launchpad.net/compiz/+milestone/0.9.8.4) + + 92599 - Incorrect (low/stuttering) refresh rate with NVIDIA driver + (regressed in compiz 0.9.8 series) + 927168 - compiz crashed with SIGSEGV in memmove() from + drisw_update_tex_buffer() from dri_set_tex_buffer2() from + drisw_bind_tex_image() from __glXBindTexImageEXT() from + TfpTexture::enable() from + enableFragmentOperationsAndDrawGeometry() + 944653 - compiz crashed on startup with SIGSEGV in strstr() from + GLScreen::GLScreen() + 1004336 - _itoa_word() from window.cpp:1989: Use of uninitialised value of + size 8 + 1030891 - Compiz r3275 breaks VirtualBox Guest Additions: black screen or + just wallpaper + 1035261 - Port compiz to gsettings and consequently remove unity-2d + 1037142 - Week33 - Grid highlight window appears while switching between + workspaces + 1037411 - [regression][DRI] SubBuffer rendering is much slower in compiz + 0.9.8.0 than it was in 0.9.7 + 1039406 - Benchmark default placement overlaps (damages) Unity launcher + and panel, resulting in artificially low benchmark results + 1041535 - compiz crashed with SIGSEGV in __strcasestr_ia32() from + ccsStringToModifiers(binding=NULL) + 1042041 - 1:0.9.8+bzr3319-0ubuntu1 regression: keeps setting gsettings + keys to wrong values + 1042537 - ccsm crashed with SIGSEGV in ccsContextNew + 1042552 - Paint List is often full of 1x1 offscreen windows from + gtk-window-decorator + 1045127 - Close from spread is unreliable + 1046664 - Unredirected fullscreen windows flicker briefly when another + window (like a menu) opens above them + 1046701 - Random test failures in CCSGSettingsBackendConcept + 1047168 - scale mode is not visible if a fullscreen window is unredirected + 1048551 - multiple GObject warnings if gtk-window-decorator is started + without org.gnome.mutter being installed + 1048964 - cmake fails on python 2.6 as sys.version_info does not contain + major_version or minor_version + 1049100 - Build failure if COMPIZ_DISABLE_PLUGIN_RESIZE=ON + 1049169 - [valgrind] Up to 520,000 bytes lost when runningi + CCSGSettingsBackendConceptTest + 1050704 - Unity 6.6: panel shadow is always on top of the active window + 1050749 - Unredirecting a fullscreen window on a secondary monitor causes + that monitor to flicker + 1050752 - opacify plugin toggling by default doesn't work + 1050757 - opacify plugin: opacity isn't reset after switching window + 1050796 - Double shortcuts conflict with gnome-control-center ones + 1051286 - [performance] glXSwapIntervalEXT called every frame, which is + very slow on Nvidia. + 1051885 - Unredirect Fullscreen Windows makes multi-monitor rendering much + slower + 1052838 - compiz.fix_927168 broke ARM building + 1053902 - Maximized window gets unredirected when it's not fullscreen + 1054724 - [fglrx] compiz crashed with SIGSEGV in glXDestroyContext() + [/usr/lib/fglrx/libGL.so.1] from GLScreen::~GLScreen() + 1050610 - gtk-window-decorator leaking window handles. Window operations + become sluggish after a few days of usage + 1056645 - ARM build broken with 'swapInterval' is not a member of 'GL' + 1057263 - gtk-window-decorator leaks large numbers of pixmaps and pixmap + memory + 1057421 - FTBFS with -DCOMPIZ_BUILD_TESTING=OFF if libgtest-dev is not + installed + + Release 0.9.8.2 (2012-09-10 Daniel van Vugt ) ============================================================================ diff -Nru compiz-0.9.8.2+bzr3377/VERSION compiz-0.9.8.4/VERSION --- compiz-0.9.8.2+bzr3377/VERSION 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/VERSION 2012-09-27 11:04:02.000000000 +0000 @@ -1 +1 @@ -0.9.8.3 +0.9.8.4 diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/CMakeLists.txt compiz-0.9.8.4/compizconfig/CMakeLists.txt --- compiz-0.9.8.2+bzr3377/compizconfig/CMakeLists.txt 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/CMakeLists.txt 2012-09-27 11:04:02.000000000 +0000 @@ -21,6 +21,7 @@ if (COMPIZ_BUILD_TESTING) add_subdirectory (mocks) + add_subdirectory (tests) endif (COMPIZ_BUILD_TESTING) add_custom_target (pyclean) diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/ccsm/CMakeLists.txt compiz-0.9.8.4/compizconfig/ccsm/CMakeLists.txt --- compiz-0.9.8.2+bzr3377/compizconfig/ccsm/CMakeLists.txt 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/ccsm/CMakeLists.txt 2012-09-27 11:04:02.000000000 +0000 @@ -12,7 +12,7 @@ execute_process (COMMAND uname -p OUTPUT_VARIABLE PROC_ARCH) # Get Python Version -execute_process (COMMAND python -c "import sys; print str (sys.version_info.major) + '.' + str (sys.version_info.minor)" +execute_process (COMMAND python -c "import sys; print str (sys.version_info[0]) + '.' + str (sys.version_info[1])" OUTPUT_VARIABLE PY_VERSION) string (REPLACE "\n" "" PROC_ARCH ${PROC_ARCH}) diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/compizconfig-python/CMakeLists.txt compiz-0.9.8.4/compizconfig/compizconfig-python/CMakeLists.txt --- compiz-0.9.8.2+bzr3377/compizconfig/compizconfig-python/CMakeLists.txt 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/compizconfig-python/CMakeLists.txt 2012-09-27 11:04:02.000000000 +0000 @@ -12,7 +12,7 @@ execute_process (COMMAND uname -p OUTPUT_VARIABLE PROC_ARCH) # Get Python Version -execute_process (COMMAND python -c "import sys; print str (sys.version_info.major) + '.' + str (sys.version_info.minor)" +execute_process (COMMAND python -c "import sys; print str (sys.version_info[0]) + '.' + str (sys.version_info[1])" OUTPUT_VARIABLE PY_VERSION) string (REPLACE "\n" "" PROC_ARCH ${PROC_ARCH}) diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/gsettings/CMakeLists.txt compiz-0.9.8.4/compizconfig/gsettings/CMakeLists.txt --- compiz-0.9.8.2+bzr3377/compizconfig/gsettings/CMakeLists.txt 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/gsettings/CMakeLists.txt 2012-09-27 11:04:02.000000000 +0000 @@ -14,6 +14,10 @@ add_definitions (-DUSE_GCONF) endif (USE_GCONF) +if (COMPIZ_BUILD_TESTING) + add_subdirectory (mocks) +endif (COMPIZ_BUILD_TESTING) + add_subdirectory (gsettings_backend_shared) include_directories (${CMAKE_CURRENT_SOURCE_DIR}/gsettings_backend_shared diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/gsettings/gsettings_backend_shared/CMakeLists.txt compiz-0.9.8.4/compizconfig/gsettings/gsettings_backend_shared/CMakeLists.txt --- compiz-0.9.8.2+bzr3377/compizconfig/gsettings/gsettings_backend_shared/CMakeLists.txt 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/gsettings/gsettings_backend_shared/CMakeLists.txt 2012-09-27 11:04:02.000000000 +0000 @@ -41,7 +41,6 @@ compizconfig_gsettings_backend_interface compizconfig_gsettings_wrapper_interface compizconfig - compizconfig ${GSETTINGS_UTIL_LIBRARIES}) add_library (compizconfig_gsettings_backend SHARED diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/gsettings/gsettings_backend_shared/ccs_gsettings_backend.c compiz-0.9.8.4/compizconfig/gsettings/gsettings_backend_shared/ccs_gsettings_backend.c --- compiz-0.9.8.2+bzr3377/compizconfig/gsettings/gsettings_backend_shared/ccs_gsettings_backend.c 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/gsettings/gsettings_backend_shared/ccs_gsettings_backend.c 2012-09-27 11:04:02.000000000 +0000 @@ -223,29 +223,6 @@ } } -CCSContext * -ccsGSettingsBackendGetContext (CCSBackend *backend) -{ - return (*(GET_INTERFACE (CCSGSettingsBackendInterface, backend))->gsettingsBackendGetContext) (backend); -} - - -void -ccsGSettingsBackendConnectToChangedSignal (CCSBackend *backend, - CCSGSettingsWrapper *object) -{ - (*(GET_INTERFACE (CCSGSettingsBackendInterface, backend))->gsettingsBackendConnectToChangedSignal) (backend, object); -} - -CCSGSettingsWrapper * -ccsGSettingsGetSettingsObjectForPluginWithPath (CCSBackend *backend, - const char *plugin, - const char *path, - CCSContext *context) -{ - return (*(GET_INTERFACE (CCSGSettingsBackendInterface, backend))->gsettingsBackendGetSettingsObjectForPluginWithPath) (backend, plugin, path, context); -} - static CCSContext * ccsGSettingsBackendGetContextDefault (CCSBackend *backend) { diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/gsettings/gsettings_backend_shared/ccs_gsettings_backend_interface.c compiz-0.9.8.4/compizconfig/gsettings/gsettings_backend_shared/ccs_gsettings_backend_interface.c --- compiz-0.9.8.2+bzr3377/compizconfig/gsettings/gsettings_backend_shared/ccs_gsettings_backend_interface.c 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/gsettings/gsettings_backend_shared/ccs_gsettings_backend_interface.c 2012-09-27 11:04:02.000000000 +0000 @@ -3,6 +3,29 @@ INTERFACE_TYPE (CCSGSettingsBackendInterface); +CCSContext * +ccsGSettingsBackendGetContext (CCSBackend *backend) +{ + return (*(GET_INTERFACE (CCSGSettingsBackendInterface, backend))->gsettingsBackendGetContext) (backend); +} + + +void +ccsGSettingsBackendConnectToChangedSignal (CCSBackend *backend, + CCSGSettingsWrapper *object) +{ + (*(GET_INTERFACE (CCSGSettingsBackendInterface, backend))->gsettingsBackendConnectToChangedSignal) (backend, object); +} + +CCSGSettingsWrapper * +ccsGSettingsGetSettingsObjectForPluginWithPath (CCSBackend *backend, + const char *plugin, + const char *path, + CCSContext *context) +{ + return (*(GET_INTERFACE (CCSGSettingsBackendInterface, backend))->gsettingsBackendGetSettingsObjectForPluginWithPath) (backend, plugin, path, context); +} + const char * ccsGSettingsBackendGetCurrentProfile (CCSBackend *backend) { diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/gsettings/gsettings_backend_shared/gsettings_util.c compiz-0.9.8.4/compizconfig/gsettings/gsettings_backend_shared/gsettings_util.c --- compiz-0.9.8.2+bzr3377/compizconfig/gsettings/gsettings_backend_shared/gsettings_util.c 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/gsettings/gsettings_backend_shared/gsettings_util.c 2012-09-27 11:04:02.000000000 +0000 @@ -343,7 +343,7 @@ { CCSSetting *s = (CCSSetting *) iter->data; - char *name = ccsSettingGetName (s); + const char *name = ccsSettingGetName (s); char *underscores_as_dashes = translateUnderscoresToDashesForGSettings (name); if (g_ascii_strncasecmp (underscores_as_dashes, keyName, strlen (keyName)) == 0) diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/gsettings/mocks/CMakeLists.txt compiz-0.9.8.4/compizconfig/gsettings/mocks/CMakeLists.txt --- compiz-0.9.8.2+bzr3377/compizconfig/gsettings/mocks/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/gsettings/mocks/CMakeLists.txt 2012-09-27 11:04:02.000000000 +0000 @@ -0,0 +1,21 @@ +pkg_check_modules (GLIB glib-2.0) + +if (GLIB_FOUND) + + include_directories (${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/../../libcompizconfig/include + ${CMAKE_CURRENT_SOURCE_DIR}/../gsettings_backend_shared + ${GLIB_INCLUDE_DIRS}) + +set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") + + add_library (compizconfig_ccs_gsettings_wrapper_mock STATIC + ${CMAKE_CURRENT_SOURCE_DIR}/ccs_gsettings_wrapper_mock.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/ccs_gsettings_wrapper_mock.h) + + add_library (compizconfig_ccs_gsettings_backend_mock STATIC + ${CMAKE_CURRENT_SOURCE_DIR}/ccs_gsettings_backend_mock.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/ccs_gsettings_backend_mock.h) + +endif (GLIB_FOUND) diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/gsettings/mocks/ccs_gsettings_backend_mock.cpp compiz-0.9.8.4/compizconfig/gsettings/mocks/ccs_gsettings_backend_mock.cpp --- compiz-0.9.8.2+bzr3377/compizconfig/gsettings/mocks/ccs_gsettings_backend_mock.cpp 1970-01-01 00:00:00.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/gsettings/mocks/ccs_gsettings_backend_mock.cpp 2012-09-27 11:04:02.000000000 +0000 @@ -0,0 +1,62 @@ +#include +#include + +#include + +#include "ccs_gsettings_backend_mock.h" + +CCSGSettingsBackendInterface ccsGSettingsBackendGMockInterface = +{ + CCSGSettingsBackendGMock::ccsGSettingsBackendGetContext, + CCSGSettingsBackendGMock::ccsGSettingsBackendConnectToValueChangedSignal, + CCSGSettingsBackendGMock::ccsGSettingsBackendGetSettingsObjectForPluginWithPath, + CCSGSettingsBackendGMock::ccsGSettingsBackendGetCurrentProfile, + CCSGSettingsBackendGMock::ccsGSettingsBackendGetExistingProfiles, + CCSGSettingsBackendGMock::ccsGSettingsBackendSetExistingProfiles, + CCSGSettingsBackendGMock::ccsGSettingsBackendSetCurrentProfile, + CCSGSettingsBackendGMock::ccsGSettingsBackendGetPluginsWithSetKeys, + CCSGSettingsBackendGMock::ccsGSettingsBackendClearPluginsWithSetKeys, + CCSGSettingsBackendGMock::ccsGSettingsBackendUnsetAllChangedPluginKeysInProfile, + CCSGSettingsBackendGMock::ccsGSettingsBackendUpdateProfile, + CCSGSettingsBackendGMock::ccsGSettingsBackendUpdateCurrentProfileName, + CCSGSettingsBackendGMock::ccsGSettingsBackendAddProfile, + CCSGSettingsBackendGMock::ccsGSettingsBackendGetIntegratedSetting, + CCSGSettingsBackendGMock::ccsGSettingsBackendReadIntegratedOption, + CCSGSettingsBackendGMock::ccsGSettingsBackendWriteIntegratedOption +}; + +CCSBackend * +ccsGSettingsBackendGMockNew () +{ + CCSBackend *backend = (CCSBackend *) calloc (1, sizeof (CCSBackend)); + + if (!backend) + return NULL; + + CCSGSettingsBackendGMock *gmock = new CCSGSettingsBackendGMock (backend); + + if (!gmock) + { + free (backend); + return NULL; + } + + ccsObjectInit (backend, &ccsDefaultObjectAllocator); + ccsObjectAddInterface (backend, (const CCSInterface *) &ccsGSettingsBackendGMockInterface, GET_INTERFACE_TYPE (CCSGSettingsBackendInterface)); + ccsObjectSetPrivate (backend, reinterpret_cast (gmock)); + + return backend; +} + +void +ccsGSettingsBackendGMockFree (CCSBackend *backend) +{ + CCSGSettingsBackendGMock *mock = reinterpret_cast (ccsObjectGetPrivate (backend)); + + delete mock; + + ccsObjectSetPrivate (backend, NULL); + ccsObjectFinalize (backend); + + free (backend); +} diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/gsettings/mocks/ccs_gsettings_backend_mock.h compiz-0.9.8.4/compizconfig/gsettings/mocks/ccs_gsettings_backend_mock.h --- compiz-0.9.8.2+bzr3377/compizconfig/gsettings/mocks/ccs_gsettings_backend_mock.h 1970-01-01 00:00:00.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/gsettings/mocks/ccs_gsettings_backend_mock.h 2012-09-27 11:04:02.000000000 +0000 @@ -0,0 +1,186 @@ +#ifndef _COMPIZCONFIG_CCS_GSETTINGS_BACKEND_MOCK +#define _COMPIZCONFIG_CCS_GSETTINGS_BACKEND_MOCK + +#include +#include + +#include +#include "ccs_gsettings_backend_interface.h" + +using ::testing::_; +using ::testing::Return; + +CCSBackend * ccsGSettingsBackendGMockNew (); +void ccsGSettingsBackendGMockFree (CCSBackend *backend); + +class CCSGSettingsBackendGMockInterface +{ + public: + + virtual ~CCSGSettingsBackendGMockInterface () {} + + virtual CCSContext * getContext () = 0; + virtual void connectToChangedSignal (CCSGSettingsWrapper *) = 0; + virtual CCSGSettingsWrapper * getSettingsObjectForPluginWithPath (const char * plugin, + const char * path, + CCSContext * context) = 0; + virtual const char * getCurrentProfile () = 0; + virtual GVariant * getExistingProfiles () = 0; + virtual void setExistingProfiles (GVariant *) = 0; + virtual void setCurrentProfile (const gchar *) = 0; + virtual GVariant * getPluginsWithSetKeys () = 0; + virtual void clearPluginsWithSetKeys () = 0; + virtual void unsetAllChangedPluginKeysInProfile (CCSContext *, GVariant *, const char *) = 0; + virtual gboolean updateProfile (CCSContext *) = 0; + virtual void updateCurrentProfileName (const char *) = 0; + virtual gboolean addProfile (const char *) = 0; + virtual CCSIntegratedSetting * getIntegratedSetting (CCSSetting *) = 0; + virtual Bool readIntegratedOption (CCSSetting *, CCSIntegratedSetting *) = 0; + virtual void writeIntegratedOption (CCSSetting *, CCSIntegratedSetting *) = 0; + +}; + +class CCSGSettingsBackendGMock : + public CCSGSettingsBackendGMockInterface +{ + public: + + CCSGSettingsBackendGMock (CCSBackend *backend) : + mBackend (backend) + { + } + + MOCK_METHOD0 (getContext, CCSContext * ()); + MOCK_METHOD1 (connectToChangedSignal, void (CCSGSettingsWrapper *)); + MOCK_METHOD3 (getSettingsObjectForPluginWithPath, CCSGSettingsWrapper * (const char * plugin, + const char * path, + CCSContext * context)); + MOCK_METHOD0 (getCurrentProfile, const char * ()); + MOCK_METHOD0 (getExistingProfiles, GVariant * ()); + MOCK_METHOD1 (setExistingProfiles, void (GVariant *)); + MOCK_METHOD1 (setCurrentProfile, void (const gchar *)); + MOCK_METHOD0 (getPluginsWithSetKeys, GVariant * ()); + MOCK_METHOD0 (clearPluginsWithSetKeys, void ()); + MOCK_METHOD3 (unsetAllChangedPluginKeysInProfile, void (CCSContext *, GVariant *, const char *)); + MOCK_METHOD1 (updateProfile, gboolean (CCSContext *)); + MOCK_METHOD1 (updateCurrentProfileName, void (const char *)); + MOCK_METHOD1 (addProfile, gboolean (const char *)); + MOCK_METHOD1 (getIntegratedSetting, CCSIntegratedSetting * (CCSSetting *)); + MOCK_METHOD2 (readIntegratedOption, Bool (CCSSetting *, CCSIntegratedSetting *)); + MOCK_METHOD2 (writeIntegratedOption, void (CCSSetting *, CCSIntegratedSetting *)); + + CCSBackend * getBackend () { return mBackend; } + + private: + + CCSBackend *mBackend; + + public: + + static CCSContext * + ccsGSettingsBackendGetContext (CCSBackend *backend) + { + return (reinterpret_cast (ccsObjectGetPrivate (backend)))->getContext (); + } + + static void + ccsGSettingsBackendConnectToValueChangedSignal (CCSBackend *backend, CCSGSettingsWrapper *object) + { + (reinterpret_cast (ccsObjectGetPrivate (backend)))->connectToChangedSignal(object); + } + + static CCSGSettingsWrapper * + ccsGSettingsBackendGetSettingsObjectForPluginWithPath (CCSBackend *backend, + const char *plugin, + const char *path, + CCSContext *context) + { + return (reinterpret_cast (ccsObjectGetPrivate (backend)))->getSettingsObjectForPluginWithPath (plugin, + path, + context); + } + + static const char * + ccsGSettingsBackendGetCurrentProfile (CCSBackend *backend) + { + return (reinterpret_cast (ccsObjectGetPrivate (backend)))->getCurrentProfile (); + } + + static GVariant * + ccsGSettingsBackendGetExistingProfiles (CCSBackend *backend) + { + return (reinterpret_cast (ccsObjectGetPrivate (backend)))->getExistingProfiles (); + } + + static void + ccsGSettingsBackendSetExistingProfiles (CCSBackend *backend, GVariant *value) + { + (reinterpret_cast (ccsObjectGetPrivate (backend)))->setExistingProfiles (value); + } + + static void + ccsGSettingsBackendSetCurrentProfile (CCSBackend *backend, const gchar *value) + { + (reinterpret_cast (ccsObjectGetPrivate (backend)))->setCurrentProfile (value); + } + + static GVariant * + ccsGSettingsBackendGetPluginsWithSetKeys (CCSBackend *backend) + { + return (reinterpret_cast (ccsObjectGetPrivate (backend)))->getPluginsWithSetKeys (); + } + + static void + ccsGSettingsBackendClearPluginsWithSetKeys (CCSBackend *backend) + { + return (reinterpret_cast (ccsObjectGetPrivate (backend)))->clearPluginsWithSetKeys (); + } + + static void + ccsGSettingsBackendUnsetAllChangedPluginKeysInProfile (CCSBackend *backend, + CCSContext *context, + GVariant *pluginKeys, + const char *profile) + { + return (reinterpret_cast (ccsObjectGetPrivate (backend)))->unsetAllChangedPluginKeysInProfile (context, pluginKeys, profile); + } + + static gboolean + ccsGSettingsBackendUpdateProfile (CCSBackend *backend, CCSContext *context) + { + return (reinterpret_cast (ccsObjectGetPrivate (backend)))->updateProfile (context); + } + + static void + ccsGSettingsBackendUpdateCurrentProfileName (CCSBackend *backend, const char *profile) + { + return (reinterpret_cast (ccsObjectGetPrivate (backend)))->updateCurrentProfileName (profile); + } + + static gboolean + ccsGSettingsBackendAddProfile (CCSBackend *backend, const char *profile) + { + return (reinterpret_cast (ccsObjectGetPrivate (backend)))->addProfile (profile); + } + + static CCSIntegratedSetting * + ccsGSettingsBackendGetIntegratedSetting (CCSBackend *backend, CCSSetting *setting) + { + return (reinterpret_cast (ccsObjectGetPrivate (backend)))->getIntegratedSetting (setting); + } + + static Bool + ccsGSettingsBackendReadIntegratedOption (CCSBackend *backend, CCSSetting *setting, CCSIntegratedSetting *integrated) + { + return (reinterpret_cast (ccsObjectGetPrivate (backend)))->readIntegratedOption (setting, integrated); + + } + + static void + ccsGSettingsBackendWriteIntegratedOption (CCSBackend *backend, CCSSetting *setting, CCSIntegratedSetting *integrated) + { + (reinterpret_cast (ccsObjectGetPrivate (backend)))->writeIntegratedOption (setting, integrated); + } +}; + +#endif diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/gsettings/mocks/ccs_gsettings_wrapper_mock.cpp compiz-0.9.8.4/compizconfig/gsettings/mocks/ccs_gsettings_wrapper_mock.cpp --- compiz-0.9.8.2+bzr3377/compizconfig/gsettings/mocks/ccs_gsettings_wrapper_mock.cpp 1970-01-01 00:00:00.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/gsettings/mocks/ccs_gsettings_wrapper_mock.cpp 2012-09-27 11:04:02.000000000 +0000 @@ -0,0 +1,52 @@ +#include + +const CCSGSettingsWrapperInterface mockInterface = +{ + CCSGSettingsWrapperGMock::ccsGSettingsWrapperSetValue, + CCSGSettingsWrapperGMock::ccsGSettingsWrapperGetValue, + CCSGSettingsWrapperGMock::ccsGSettingsWrapperResetKey, + CCSGSettingsWrapperGMock::ccsGSettingsWrapperListKeys, + CCSGSettingsWrapperGMock::ccsGSettingsWrapperGetGSettings, + CCSGSettingsWrapperGMock::ccsGSettingsWrapperGetSchemaName, + CCSGSettingsWrapperGMock::ccsGSettingsWrapperGetPath, + CCSGSettingsWrapperGMock::ccsGSettingsWrapperConnectToChangedSignal, + CCSGSettingsWrapperGMock::ccsFreeGSettingsWrapper +}; + +CCSGSettingsWrapper * +ccsMockGSettingsWrapperNew () +{ + CCSGSettingsWrapper *wrapper = (CCSGSettingsWrapper *) calloc (1, sizeof (CCSGSettingsWrapper)); + + if (!wrapper) + return NULL; + + CCSGSettingsWrapperGMock *gmockWrapper = new CCSGSettingsWrapperGMock (wrapper); + + if (!gmockWrapper) + { + free (wrapper); + return NULL; + } + + ccsObjectInit (wrapper, &ccsDefaultObjectAllocator); + ccsObjectAddInterface (wrapper, (const CCSInterface *) &mockInterface, GET_INTERFACE_TYPE (CCSGSettingsWrapperInterface)); + ccsObjectSetPrivate (wrapper, (CCSPrivate *) gmockWrapper); + + ccsGSettingsWrapperRef (wrapper); + + return wrapper; +} + +void +ccsMockGSettingsWrapperFree (CCSGSettingsWrapper *wrapper) +{ + CCSGSettingsWrapperGMock *gmockWrapper = reinterpret_cast (ccsObjectGetPrivate (wrapper)); + + delete gmockWrapper; + + ccsObjectSetPrivate (wrapper, NULL); + ccsObjectFinalize (wrapper); + free (wrapper); +} + diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/gsettings/mocks/ccs_gsettings_wrapper_mock.h compiz-0.9.8.4/compizconfig/gsettings/mocks/ccs_gsettings_wrapper_mock.h --- compiz-0.9.8.2+bzr3377/compizconfig/gsettings/mocks/ccs_gsettings_wrapper_mock.h 1970-01-01 00:00:00.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/gsettings/mocks/ccs_gsettings_wrapper_mock.h 2012-09-27 11:04:02.000000000 +0000 @@ -0,0 +1,113 @@ +#ifndef _COMPIZCONFIG_CCS_GSETTINGS_WRAPPER_MOCK +#define _COMPIZCONFIG_CCS_GSETTINGS_WRAPPER_MOCK + +#include +#include + +#include + +CCSGSettingsWrapper * ccsMockGSettingsWrapperNew (); +void ccsMockGSettingsWrapperFree (CCSGSettingsWrapper *); + +class CCSGSettingsWrapperMockInterface +{ + public: + + virtual ~CCSGSettingsWrapperMockInterface () {} + virtual void setValue (const char *, GVariant *) = 0; + virtual GVariant * getValue (const char *) = 0; + virtual void resetKey (const char *) = 0; + virtual char ** listKeys () = 0; + virtual GSettings * getGSettings () = 0; + virtual const char * getSchemaName () = 0; + virtual const char * getPath () = 0; + virtual void connectToChangedSignal (GCallback, gpointer) = 0; +}; + +class CCSGSettingsWrapperGMock : + public CCSGSettingsWrapperMockInterface +{ + public: + + CCSGSettingsWrapperGMock (CCSGSettingsWrapper *wrapper) : + mWrapper (wrapper) + { + } + + MOCK_METHOD2 (setValue, void (const char *, GVariant *)); + MOCK_METHOD1 (getValue, GVariant * (const char *)); + MOCK_METHOD1 (resetKey, void (const char *)); + MOCK_METHOD0 (listKeys, char ** ()); + MOCK_METHOD0 (getGSettings, GSettings * ()); + MOCK_METHOD0 (getSchemaName, const char * ()); + MOCK_METHOD0 (getPath, const char * ()); + MOCK_METHOD2 (connectToChangedSignal, void (GCallback, gpointer)); + + private: + + CCSGSettingsWrapper *mWrapper; + + public: + + static void + ccsGSettingsWrapperSetValue (CCSGSettingsWrapper *wrapper, + const char *key, + GVariant *value) + { + reinterpret_cast (ccsObjectGetPrivate (wrapper))->setValue (key, value); + } + + static GVariant * + ccsGSettingsWrapperGetValue (CCSGSettingsWrapper *wrapper, + const char *key) + { + return reinterpret_cast (ccsObjectGetPrivate (wrapper))->getValue (key); + } + + static void + ccsGSettingsWrapperResetKey (CCSGSettingsWrapper *wrapper, + const char *key) + { + reinterpret_cast (ccsObjectGetPrivate (wrapper))->resetKey (key); + } + + static char ** + ccsGSettingsWrapperListKeys (CCSGSettingsWrapper *wrapper) + { + return reinterpret_cast (ccsObjectGetPrivate (wrapper))->listKeys (); + } + + static GSettings * + ccsGSettingsWrapperGetGSettings (CCSGSettingsWrapper *wrapper) + { + return reinterpret_cast (ccsObjectGetPrivate (wrapper))->getGSettings (); + } + + static const char * + ccsGSettingsWrapperGetSchemaName (CCSGSettingsWrapper *wrapper) + { + return reinterpret_cast (ccsObjectGetPrivate (wrapper))->getSchemaName (); + } + + static const char * + ccsGSettingsWrapperGetPath (CCSGSettingsWrapper *wrapper) + { + return reinterpret_cast (ccsObjectGetPrivate (wrapper))->getPath (); + } + + static void + ccsGSettingsWrapperConnectToChangedSignal (CCSGSettingsWrapper *wrapper, + GCallback callback, + gpointer data) + { + reinterpret_cast (ccsObjectGetPrivate (wrapper))->connectToChangedSignal (callback, data); + } + + static void + ccsFreeGSettingsWrapper (CCSGSettingsWrapper *wrapper) + { + ccsMockGSettingsWrapperFree (wrapper); + } +}; + +#endif diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/gsettings/src/gsettings.c compiz-0.9.8.4/compizconfig/gsettings/src/gsettings.c --- compiz-0.9.8.2+bzr3377/compizconfig/gsettings/src/gsettings.c 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/gsettings/src/gsettings.c 2012-09-27 11:04:02.000000000 +0000 @@ -50,7 +50,8 @@ cleanSettingName, pathName, ccsSettingGetType (setting)); - + free (cleanSettingName); + g_free (pathName); return gsettingsValue; } diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/gsettings/tests/CMakeLists.txt compiz-0.9.8.4/compizconfig/gsettings/tests/CMakeLists.txt --- compiz-0.9.8.2+bzr3377/compizconfig/gsettings/tests/CMakeLists.txt 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/gsettings/tests/CMakeLists.txt 2012-09-27 11:04:02.000000000 +0000 @@ -2,25 +2,25 @@ include_directories (${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/../mocks + ${CMAKE_CURRENT_SOURCE_DIR}/../testenvironments ${CMAKE_CURRENT_SOURCE_DIR}/../src ${CMAKE_CURRENT_SOURCE_DIR}/../../libcompizconfig/tests ${CMAKE_CURRENT_SOURCE_DIR}/../../mocks/libcompizconfig ${CMAKE_CURRENT_SOURCE_DIR}/../../tests - ${CMAKE_SOURCE_DIR}/tests/shared) + ${CMAKE_SOURCE_DIR}/tests/shared + ${CMAKE_SOURCE_DIR}/tests/shared/glib) -pkg_check_modules (COMPIZCONFIG_TEST_GSETTINGS libcompizconfig) +pkg_check_modules (COMPIZCONFIG_TEST_GSETTINGS libcompizconfig_internal) set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") link_directories (${CMAKE_CURRENT_BINARY_DIR}/../../libcompizconfig/tests) +link_directories (${CMAKE_CURRENT_BINARY_DIR}/../testenvironments) +link_directories (${CMAKE_CURRENT_BINARY_DIR}/../mocks) -add_library (compizconfig_ccs_gsettings_wrapper_mock STATIC - ${CMAKE_CURRENT_SOURCE_DIR}/ccs_gsettings_wrapper_mock.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/ccs_gsettings_wrapper_mock.h) - -add_library (compizconfig_ccs_gsettings_backend_mock STATIC - ${CMAKE_CURRENT_SOURCE_DIR}/ccs_gsettings_backend_mock.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/ccs_gsettings_backend_mock.h) +add_library (compizconfig_gsettings_settings_test_env STATIC + ${CMAKE_CURRENT_SOURCE_DIR}/compizconfig_ccs_gsettings_settings_env_test.cpp) add_executable (compizconfig_test_gsettings ${CMAKE_CURRENT_SOURCE_DIR}/test_gsettings_tests.cpp @@ -38,6 +38,7 @@ compizconfig_ccs_context_mock compizconfig_ccs_gsettings_backend_mock compizconfig_ccs_gsettings_wrapper_mock + compizconfig_ccs_test_value_combinations ${COMPIZCONFIG_TEST_GSETTINGS_LIBRARIES} ${GTEST_BOTH_LIBRARIES} ${GMOCK_MAIN_LIBRARY}) @@ -59,10 +60,18 @@ ${CMAKE_CURRENT_BINARY_DIR}/backend-conformance-config.h) target_link_libraries (compizconfig_test_gsettings_conformance + compizconfig_gsettings_settings_test_env compizconfig_gsettings_backend compizconfig_ccs_setting_mock compizconfig_ccs_plugin_mock compizconfig_ccs_context_mock + compizconfig_ccs_item_in_list_matcher + compizconfig_ccs_list_equality + compizconfig_ccs_list_wrapper + compizconfig_ccs_backend_conformance_test + compizconfig_ccs_setting_value_operators + compizconfig_ccs_test_value_combinations + compizconfig_ccs_integration_mock ${COMPIZCONFIG_TEST_GSETTINGS_LIBRARIES} ${GTEST_BOTH_LIBRARIES} ${GMOCK_MAIN_LIBRARY}) diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/gsettings/tests/ccs_gsettings_backend_mock.cpp compiz-0.9.8.4/compizconfig/gsettings/tests/ccs_gsettings_backend_mock.cpp --- compiz-0.9.8.2+bzr3377/compizconfig/gsettings/tests/ccs_gsettings_backend_mock.cpp 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/gsettings/tests/ccs_gsettings_backend_mock.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,62 +0,0 @@ -#include -#include - -#include - -#include "ccs_gsettings_backend_mock.h" - -CCSGSettingsBackendInterface ccsGSettingsBackendGMockInterface = -{ - CCSGSettingsBackendGMock::ccsGSettingsBackendGetContext, - CCSGSettingsBackendGMock::ccsGSettingsBackendConnectToValueChangedSignal, - CCSGSettingsBackendGMock::ccsGSettingsBackendGetSettingsObjectForPluginWithPath, - CCSGSettingsBackendGMock::ccsGSettingsBackendGetCurrentProfile, - CCSGSettingsBackendGMock::ccsGSettingsBackendGetExistingProfiles, - CCSGSettingsBackendGMock::ccsGSettingsBackendSetExistingProfiles, - CCSGSettingsBackendGMock::ccsGSettingsBackendSetCurrentProfile, - CCSGSettingsBackendGMock::ccsGSettingsBackendGetPluginsWithSetKeys, - CCSGSettingsBackendGMock::ccsGSettingsBackendClearPluginsWithSetKeys, - CCSGSettingsBackendGMock::ccsGSettingsBackendUnsetAllChangedPluginKeysInProfile, - CCSGSettingsBackendGMock::ccsGSettingsBackendUpdateProfile, - CCSGSettingsBackendGMock::ccsGSettingsBackendUpdateCurrentProfileName, - CCSGSettingsBackendGMock::ccsGSettingsBackendAddProfile, - CCSGSettingsBackendGMock::ccsGSettingsBackendGetIntegratedSetting, - CCSGSettingsBackendGMock::ccsGSettingsBackendReadIntegratedOption, - CCSGSettingsBackendGMock::ccsGSettingsBackendWriteIntegratedOption -}; - -CCSBackend * -ccsGSettingsBackendGMockNew () -{ - CCSBackend *backend = (CCSBackend *) calloc (1, sizeof (CCSBackend)); - - if (!backend) - return NULL; - - CCSGSettingsBackendGMock *gmock = new CCSGSettingsBackendGMock (backend); - - if (!gmock) - { - free (backend); - return NULL; - } - - ccsObjectInit (backend, &ccsDefaultObjectAllocator); - ccsObjectAddInterface (backend, (const CCSInterface *) &ccsGSettingsBackendGMockInterface, GET_INTERFACE_TYPE (CCSGSettingsBackendInterface)); - ccsObjectSetPrivate (backend, reinterpret_cast (gmock)); - - return backend; -} - -void -ccsGSettingsBackendGMockFree (CCSBackend *backend) -{ - CCSGSettingsBackendGMock *mock = reinterpret_cast (ccsObjectGetPrivate (backend)); - - delete mock; - - ccsObjectSetPrivate (backend, NULL); - ccsObjectFinalize (backend); - - free (backend); -} diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/gsettings/tests/ccs_gsettings_backend_mock.h compiz-0.9.8.4/compizconfig/gsettings/tests/ccs_gsettings_backend_mock.h --- compiz-0.9.8.2+bzr3377/compizconfig/gsettings/tests/ccs_gsettings_backend_mock.h 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/gsettings/tests/ccs_gsettings_backend_mock.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,186 +0,0 @@ -#ifndef _COMPIZCONFIG_CCS_GSETTINGS_BACKEND_MOCK -#define _COMPIZCONFIG_CCS_GSETTINGS_BACKEND_MOCK - -#include -#include - -#include -#include "ccs_gsettings_backend_interface.h" - -using ::testing::_; -using ::testing::Return; - -CCSBackend * ccsGSettingsBackendGMockNew (); -void ccsGSettingsBackendGMockFree (CCSBackend *backend); - -class CCSGSettingsBackendGMockInterface -{ - public: - - virtual ~CCSGSettingsBackendGMockInterface () {} - - virtual CCSContext * getContext () = 0; - virtual void connectToChangedSignal (CCSGSettingsWrapper *) = 0; - virtual CCSGSettingsWrapper * getSettingsObjectForPluginWithPath (const char * plugin, - const char * path, - CCSContext * context) = 0; - virtual const char * getCurrentProfile () = 0; - virtual GVariant * getExistingProfiles () = 0; - virtual void setExistingProfiles (GVariant *) = 0; - virtual void setCurrentProfile (const gchar *) = 0; - virtual GVariant * getPluginsWithSetKeys () = 0; - virtual void clearPluginsWithSetKeys () = 0; - virtual void unsetAllChangedPluginKeysInProfile (CCSContext *, GVariant *, const char *) = 0; - virtual gboolean updateProfile (CCSContext *) = 0; - virtual void updateCurrentProfileName (const char *) = 0; - virtual gboolean addProfile (const char *) = 0; - virtual CCSIntegratedSetting * getIntegratedSetting (CCSSetting *) = 0; - virtual Bool readIntegratedOption (CCSSetting *, CCSIntegratedSetting *) = 0; - virtual void writeIntegratedOption (CCSSetting *, CCSIntegratedSetting *) = 0; - -}; - -class CCSGSettingsBackendGMock : - public CCSGSettingsBackendGMockInterface -{ - public: - - CCSGSettingsBackendGMock (CCSBackend *backend) : - mBackend (backend) - { - } - - MOCK_METHOD0 (getContext, CCSContext * ()); - MOCK_METHOD1 (connectToChangedSignal, void (CCSGSettingsWrapper *)); - MOCK_METHOD3 (getSettingsObjectForPluginWithPath, CCSGSettingsWrapper * (const char * plugin, - const char * path, - CCSContext * context)); - MOCK_METHOD0 (getCurrentProfile, const char * ()); - MOCK_METHOD0 (getExistingProfiles, GVariant * ()); - MOCK_METHOD1 (setExistingProfiles, void (GVariant *)); - MOCK_METHOD1 (setCurrentProfile, void (const gchar *)); - MOCK_METHOD0 (getPluginsWithSetKeys, GVariant * ()); - MOCK_METHOD0 (clearPluginsWithSetKeys, void ()); - MOCK_METHOD3 (unsetAllChangedPluginKeysInProfile, void (CCSContext *, GVariant *, const char *)); - MOCK_METHOD1 (updateProfile, gboolean (CCSContext *)); - MOCK_METHOD1 (updateCurrentProfileName, void (const char *)); - MOCK_METHOD1 (addProfile, gboolean (const char *)); - MOCK_METHOD1 (getIntegratedSetting, CCSIntegratedSetting * (CCSSetting *)); - MOCK_METHOD2 (readIntegratedOption, Bool (CCSSetting *, CCSIntegratedSetting *)); - MOCK_METHOD2 (writeIntegratedOption, void (CCSSetting *, CCSIntegratedSetting *)); - - CCSBackend * getBackend () { return mBackend; } - - private: - - CCSBackend *mBackend; - - public: - - static CCSContext * - ccsGSettingsBackendGetContext (CCSBackend *backend) - { - return (reinterpret_cast (ccsObjectGetPrivate (backend)))->getContext (); - } - - static void - ccsGSettingsBackendConnectToValueChangedSignal (CCSBackend *backend, CCSGSettingsWrapper *object) - { - (reinterpret_cast (ccsObjectGetPrivate (backend)))->connectToChangedSignal(object); - } - - static CCSGSettingsWrapper * - ccsGSettingsBackendGetSettingsObjectForPluginWithPath (CCSBackend *backend, - const char *plugin, - const char *path, - CCSContext *context) - { - return (reinterpret_cast (ccsObjectGetPrivate (backend)))->getSettingsObjectForPluginWithPath (plugin, - path, - context); - } - - static const char * - ccsGSettingsBackendGetCurrentProfile (CCSBackend *backend) - { - return (reinterpret_cast (ccsObjectGetPrivate (backend)))->getCurrentProfile (); - } - - static GVariant * - ccsGSettingsBackendGetExistingProfiles (CCSBackend *backend) - { - return (reinterpret_cast (ccsObjectGetPrivate (backend)))->getExistingProfiles (); - } - - static void - ccsGSettingsBackendSetExistingProfiles (CCSBackend *backend, GVariant *value) - { - (reinterpret_cast (ccsObjectGetPrivate (backend)))->setExistingProfiles (value); - } - - static void - ccsGSettingsBackendSetCurrentProfile (CCSBackend *backend, const gchar *value) - { - (reinterpret_cast (ccsObjectGetPrivate (backend)))->setCurrentProfile (value); - } - - static GVariant * - ccsGSettingsBackendGetPluginsWithSetKeys (CCSBackend *backend) - { - return (reinterpret_cast (ccsObjectGetPrivate (backend)))->getPluginsWithSetKeys (); - } - - static void - ccsGSettingsBackendClearPluginsWithSetKeys (CCSBackend *backend) - { - return (reinterpret_cast (ccsObjectGetPrivate (backend)))->clearPluginsWithSetKeys (); - } - - static void - ccsGSettingsBackendUnsetAllChangedPluginKeysInProfile (CCSBackend *backend, - CCSContext *context, - GVariant *pluginKeys, - const char *profile) - { - return (reinterpret_cast (ccsObjectGetPrivate (backend)))->unsetAllChangedPluginKeysInProfile (context, pluginKeys, profile); - } - - static gboolean - ccsGSettingsBackendUpdateProfile (CCSBackend *backend, CCSContext *context) - { - return (reinterpret_cast (ccsObjectGetPrivate (backend)))->updateProfile (context); - } - - static void - ccsGSettingsBackendUpdateCurrentProfileName (CCSBackend *backend, const char *profile) - { - return (reinterpret_cast (ccsObjectGetPrivate (backend)))->updateCurrentProfileName (profile); - } - - static gboolean - ccsGSettingsBackendAddProfile (CCSBackend *backend, const char *profile) - { - return (reinterpret_cast (ccsObjectGetPrivate (backend)))->addProfile (profile); - } - - static CCSIntegratedSetting * - ccsGSettingsBackendGetIntegratedSetting (CCSBackend *backend, CCSSetting *setting) - { - return (reinterpret_cast (ccsObjectGetPrivate (backend)))->getIntegratedSetting (setting); - } - - static Bool - ccsGSettingsBackendReadIntegratedOption (CCSBackend *backend, CCSSetting *setting, CCSIntegratedSetting *integrated) - { - return (reinterpret_cast (ccsObjectGetPrivate (backend)))->readIntegratedOption (setting, integrated); - - } - - static void - ccsGSettingsBackendWriteIntegratedOption (CCSBackend *backend, CCSSetting *setting, CCSIntegratedSetting *integrated) - { - (reinterpret_cast (ccsObjectGetPrivate (backend)))->writeIntegratedOption (setting, integrated); - } -}; - -#endif diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/gsettings/tests/ccs_gsettings_wrapper_mock.cpp compiz-0.9.8.4/compizconfig/gsettings/tests/ccs_gsettings_wrapper_mock.cpp --- compiz-0.9.8.2+bzr3377/compizconfig/gsettings/tests/ccs_gsettings_wrapper_mock.cpp 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/gsettings/tests/ccs_gsettings_wrapper_mock.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,52 +0,0 @@ -#include - -const CCSGSettingsWrapperInterface mockInterface = -{ - CCSGSettingsWrapperGMock::ccsGSettingsWrapperSetValue, - CCSGSettingsWrapperGMock::ccsGSettingsWrapperGetValue, - CCSGSettingsWrapperGMock::ccsGSettingsWrapperResetKey, - CCSGSettingsWrapperGMock::ccsGSettingsWrapperListKeys, - CCSGSettingsWrapperGMock::ccsGSettingsWrapperGetGSettings, - CCSGSettingsWrapperGMock::ccsGSettingsWrapperGetSchemaName, - CCSGSettingsWrapperGMock::ccsGSettingsWrapperGetPath, - CCSGSettingsWrapperGMock::ccsGSettingsWrapperConnectToChangedSignal, - CCSGSettingsWrapperGMock::ccsFreeGSettingsWrapper -}; - -CCSGSettingsWrapper * -ccsMockGSettingsWrapperNew () -{ - CCSGSettingsWrapper *wrapper = (CCSGSettingsWrapper *) calloc (1, sizeof (CCSGSettingsWrapper)); - - if (!wrapper) - return NULL; - - CCSGSettingsWrapperGMock *gmockWrapper = new CCSGSettingsWrapperGMock (wrapper); - - if (!gmockWrapper) - { - free (wrapper); - return NULL; - } - - ccsObjectInit (wrapper, &ccsDefaultObjectAllocator); - ccsObjectAddInterface (wrapper, (const CCSInterface *) &mockInterface, GET_INTERFACE_TYPE (CCSGSettingsWrapperInterface)); - ccsObjectSetPrivate (wrapper, (CCSPrivate *) gmockWrapper); - - ccsGSettingsWrapperRef (wrapper); - - return wrapper; -} - -void -ccsMockGSettingsWrapperFree (CCSGSettingsWrapper *wrapper) -{ - CCSGSettingsWrapperGMock *gmockWrapper = reinterpret_cast (ccsObjectGetPrivate (wrapper)); - - delete gmockWrapper; - - ccsObjectSetPrivate (wrapper, NULL); - ccsObjectFinalize (wrapper); - free (wrapper); -} - diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/gsettings/tests/ccs_gsettings_wrapper_mock.h compiz-0.9.8.4/compizconfig/gsettings/tests/ccs_gsettings_wrapper_mock.h --- compiz-0.9.8.2+bzr3377/compizconfig/gsettings/tests/ccs_gsettings_wrapper_mock.h 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/gsettings/tests/ccs_gsettings_wrapper_mock.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,113 +0,0 @@ -#ifndef _COMPIZCONFIG_CCS_GSETTINGS_WRAPPER_MOCK -#define _COMPIZCONFIG_CCS_GSETTINGS_WRAPPER_MOCK - -#include -#include - -#include - -CCSGSettingsWrapper * ccsMockGSettingsWrapperNew (); -void ccsMockGSettingsWrapperFree (CCSGSettingsWrapper *); - -class CCSGSettingsWrapperMockInterface -{ - public: - - virtual ~CCSGSettingsWrapperMockInterface () {} - virtual void setValue (const char *, GVariant *) = 0; - virtual GVariant * getValue (const char *) = 0; - virtual void resetKey (const char *) = 0; - virtual char ** listKeys () = 0; - virtual GSettings * getGSettings () = 0; - virtual const char * getSchemaName () = 0; - virtual const char * getPath () = 0; - virtual void connectToChangedSignal (GCallback, gpointer) = 0; -}; - -class CCSGSettingsWrapperGMock : - public CCSGSettingsWrapperMockInterface -{ - public: - - CCSGSettingsWrapperGMock (CCSGSettingsWrapper *wrapper) : - mWrapper (wrapper) - { - } - - MOCK_METHOD2 (setValue, void (const char *, GVariant *)); - MOCK_METHOD1 (getValue, GVariant * (const char *)); - MOCK_METHOD1 (resetKey, void (const char *)); - MOCK_METHOD0 (listKeys, char ** ()); - MOCK_METHOD0 (getGSettings, GSettings * ()); - MOCK_METHOD0 (getSchemaName, const char * ()); - MOCK_METHOD0 (getPath, const char * ()); - MOCK_METHOD2 (connectToChangedSignal, void (GCallback, gpointer)); - - private: - - CCSGSettingsWrapper *mWrapper; - - public: - - static void - ccsGSettingsWrapperSetValue (CCSGSettingsWrapper *wrapper, - const char *key, - GVariant *value) - { - reinterpret_cast (ccsObjectGetPrivate (wrapper))->setValue (key, value); - } - - static GVariant * - ccsGSettingsWrapperGetValue (CCSGSettingsWrapper *wrapper, - const char *key) - { - return reinterpret_cast (ccsObjectGetPrivate (wrapper))->getValue (key); - } - - static void - ccsGSettingsWrapperResetKey (CCSGSettingsWrapper *wrapper, - const char *key) - { - reinterpret_cast (ccsObjectGetPrivate (wrapper))->resetKey (key); - } - - static char ** - ccsGSettingsWrapperListKeys (CCSGSettingsWrapper *wrapper) - { - return reinterpret_cast (ccsObjectGetPrivate (wrapper))->listKeys (); - } - - static GSettings * - ccsGSettingsWrapperGetGSettings (CCSGSettingsWrapper *wrapper) - { - return reinterpret_cast (ccsObjectGetPrivate (wrapper))->getGSettings (); - } - - static const char * - ccsGSettingsWrapperGetSchemaName (CCSGSettingsWrapper *wrapper) - { - return reinterpret_cast (ccsObjectGetPrivate (wrapper))->getSchemaName (); - } - - static const char * - ccsGSettingsWrapperGetPath (CCSGSettingsWrapper *wrapper) - { - return reinterpret_cast (ccsObjectGetPrivate (wrapper))->getPath (); - } - - static void - ccsGSettingsWrapperConnectToChangedSignal (CCSGSettingsWrapper *wrapper, - GCallback callback, - gpointer data) - { - reinterpret_cast (ccsObjectGetPrivate (wrapper))->connectToChangedSignal (callback, data); - } - - static void - ccsFreeGSettingsWrapper (CCSGSettingsWrapper *wrapper) - { - ccsMockGSettingsWrapperFree (wrapper); - } -}; - -#endif diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/gsettings/tests/compizconfig_ccs_gsettings_settings_env_test.cpp compiz-0.9.8.4/compizconfig/gsettings/tests/compizconfig_ccs_gsettings_settings_env_test.cpp --- compiz-0.9.8.2+bzr3377/compizconfig/gsettings/tests/compizconfig_ccs_gsettings_settings_env_test.cpp 1970-01-01 00:00:00.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/gsettings/tests/compizconfig_ccs_gsettings_settings_env_test.cpp 2012-09-27 11:04:02.000000000 +0000 @@ -0,0 +1,347 @@ +/* + * Compiz configuration system library + * + * Copyright (C) 2012 Canonical Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authored By: + * Sam Spilsbury + */ + +#include +#include + +#include +#include +#include + +#include +#include +#include "test_gsettings_tests.h" + +#include +#include + +#include "compizconfig_ccs_gsettings_settings_env_test.h" + +#include "backend-conformance-config.h" +#include "gsettings-mock-schemas-config.h" + +namespace cci = compiz::config::impl; +namespace cct = compizconfig::test; + +class PrivateCCSGSettingsStorageEnv +{ + public: + + PrivateCCSGSettingsStorageEnv (CCSGSettingsWrapper *settings, + const std::string &profileName); + + CCSGSettingsWrapper *mSettings; + std::string profileName; +}; + +void +CCSGSettingsStorageEnv::WriteBoolAtKey (const std::string &plugin, + const std::string &key, + const VariantTypes &value) +{ + GVariant *variant = NULL; + if (writeBoolToVariant (cct::boolToBool (boost::get (value)), &variant)) + writeVariantToKey (priv->mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant); + else + throw std::exception (); +} + +void +CCSGSettingsStorageEnv::WriteIntegerAtKey (const std::string &plugin, + const std::string &key, + const VariantTypes &value) +{ + GVariant *variant = NULL; + if (writeIntToVariant (boost::get (value), &variant)) + writeVariantToKey (priv->mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant); + else + throw std::exception (); +} + +void +CCSGSettingsStorageEnv::WriteFloatAtKey (const std::string &plugin, + const std::string &key, + const VariantTypes &value) +{ + GVariant *variant = NULL; + if (writeFloatToVariant (boost::get (value), &variant)) + writeVariantToKey (priv->mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant); + else + throw std::exception (); +} + +void +CCSGSettingsStorageEnv::WriteStringAtKey (const std::string &plugin, + const std::string &key, + const VariantTypes &value) +{ + GVariant *variant = NULL; + if (writeStringToVariant (boost::get (value), &variant)) + writeVariantToKey (priv->mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant); + else + throw std::exception (); +} + +void +CCSGSettingsStorageEnv::WriteColorAtKey (const std::string &plugin, + const std::string &key, + const VariantTypes &value) +{ + GVariant *variant = NULL; + if (writeColorToVariant (boost::get (value), &variant)) + writeVariantToKey (priv->mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant); + else + throw std::exception (); +} + +void +CCSGSettingsStorageEnv::WriteKeyAtKey (const std::string &plugin, + const std::string &key, + const VariantTypes &value) +{ + GVariant *variant = NULL; + if (writeKeyToVariant (boost::get (value), &variant)) + writeVariantToKey (priv->mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant); + else + throw std::exception (); +} + +void +CCSGSettingsStorageEnv::WriteButtonAtKey (const std::string &plugin, + const std::string &key, + const VariantTypes &value) +{ + GVariant *variant = NULL; + if (writeButtonToVariant (boost::get (value), &variant)) + writeVariantToKey (priv->mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant); + else + throw std::exception (); +} + +void +CCSGSettingsStorageEnv::WriteEdgeAtKey (const std::string &plugin, + const std::string &key, + const VariantTypes &value) +{ + GVariant *variant = NULL; + if (writeEdgeToVariant (boost::get (value), &variant)) + writeVariantToKey (priv->mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant); + else + throw std::exception (); +} + +void +CCSGSettingsStorageEnv::WriteMatchAtKey (const std::string &plugin, + const std::string &key, + const VariantTypes &value) +{ + GVariant *variant = NULL; + if (writeStringToVariant (boost::get (value), &variant)) + writeVariantToKey (priv->mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant); + else + throw std::exception (); +} + +void +CCSGSettingsStorageEnv::WriteBellAtKey (const std::string &plugin, + const std::string &key, + const VariantTypes &value) +{ + GVariant *variant = NULL; + if (writeBoolToVariant (cct::boolToBool (boost::get (value)), &variant)) + writeVariantToKey (priv->mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant); + else + throw std::exception (); +} + +void +CCSGSettingsStorageEnv::WriteListAtKey (const std::string &plugin, + const std::string &key, + const VariantTypes &value) +{ + GVariant *variant = NULL; + + const cci::SettingValueListWrapper::Ptr &lw (boost::get (value)); + + if (writeListValue (*lw, lw->type (), &variant)) + writeVariantToKey (priv->mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant); + else + throw std::exception (); +} + +Bool +CCSGSettingsStorageEnv::ReadBoolAtKey (const std::string &plugin, + const std::string &key) +{ + GVariantShared variant (ReadVariantAtKeyToShared (plugin, + key, + TypeBool)); + return readBoolFromVariant (variant.get ()); +} + + +int +CCSGSettingsStorageEnv::ReadIntegerAtKey (const std::string &plugin, + const std::string &key) +{ + GVariantShared variant (ReadVariantAtKeyToShared (plugin, + key, + TypeInt)); + return readIntFromVariant (variant.get ()); +} + +float +CCSGSettingsStorageEnv::ReadFloatAtKey (const std::string &plugin, + const std::string &key) +{ + GVariantShared variant (ReadVariantAtKeyToShared (plugin, + key, + TypeFloat)); + return readFloatFromVariant (variant.get ()); +} + +const char * +CCSGSettingsStorageEnv::ReadStringAtKey (const std::string &plugin, + const std::string &key) +{ + GVariantShared variant (ReadVariantAtKeyToShared (plugin, + key, + TypeString)); + return readStringFromVariant (variant.get ()); +} + +CCSSettingColorValue +CCSGSettingsStorageEnv::ReadColorAtKey (const std::string &plugin, + const std::string &key) +{ + Bool success = FALSE; + GVariantShared variant (ReadVariantAtKeyToShared (plugin, + key, + TypeColor)); + CCSSettingColorValue value = readColorFromVariant (variant.get (), &success); + EXPECT_TRUE (success); + return value; +} + +CCSSettingKeyValue +CCSGSettingsStorageEnv::ReadKeyAtKey (const std::string &plugin, + const std::string &key) +{ + Bool success = FALSE; + GVariantShared variant (ReadVariantAtKeyToShared (plugin, + key, + TypeKey)); + CCSSettingKeyValue value = readKeyFromVariant (variant.get (), &success); + EXPECT_TRUE (success); + return value; +} + +CCSSettingButtonValue +CCSGSettingsStorageEnv::ReadButtonAtKey (const std::string &plugin, + const std::string &key) +{ + Bool success = FALSE; + GVariantShared variant (ReadVariantAtKeyToShared (plugin, + key, + TypeButton)); + CCSSettingButtonValue value = readButtonFromVariant (variant.get (), &success); + EXPECT_TRUE (success); + return value; +} + +unsigned int +CCSGSettingsStorageEnv::ReadEdgeAtKey (const std::string &plugin, + const std::string &key) +{ + GVariantShared variant (ReadVariantAtKeyToShared (plugin, + key, + TypeEdge)); + return readEdgeFromVariant (variant.get ()); +} + +const char * +CCSGSettingsStorageEnv::ReadMatchAtKey (const std::string &plugin, + const std::string &key) +{ + GVariantShared variant (ReadVariantAtKeyToShared (plugin, + key, + TypeMatch)); + return readStringFromVariant (variant.get ()); +} + +Bool +CCSGSettingsStorageEnv::ReadBellAtKey (const std::string &plugin, + const std::string &key) +{ + GVariantShared variant (ReadVariantAtKeyToShared (plugin, + key, + TypeBell)); + return readBoolFromVariant (variant.get ()); +} + +CCSSettingValueList +CCSGSettingsStorageEnv::ReadListAtKey (const std::string &plugin, + const std::string &key, + CCSSetting *setting) +{ + GVariantShared variant (ReadVariantAtKeyToShared (plugin, + key, + TypeList)); + return readListValue (variant.get (), setting, &ccsDefaultObjectAllocator); +} + +GVariantShared +CCSGSettingsStorageEnv::ReadVariantAtKeyToShared (const std::string &plugin, + const std::string &key, + CCSSettingType type) +{ + CharacterWrapper translatedKey (translateKeyForGSettings (key.c_str ())); + CharacterWrapper pluginPath (makeCompizPluginPath (priv->profileName.c_str (), + plugin.c_str ())); + + GVariant *rawVariant = getVariantAtKey (priv->mSettings, + translatedKey, + pluginPath, + type); + + GVariantShared shared (AutoDestroy (rawVariant, g_variant_unref)); + + + + return shared; +} + +PrivateCCSGSettingsStorageEnv::PrivateCCSGSettingsStorageEnv (CCSGSettingsWrapper *settings, + const std::string &profileName) : + mSettings (settings), + profileName (profileName) + +{ +} + +CCSGSettingsStorageEnv::CCSGSettingsStorageEnv (CCSGSettingsWrapper *settings, + const std::string &profileName) : + priv (new PrivateCCSGSettingsStorageEnv (settings, + profileName)) +{ +} diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/gsettings/tests/compizconfig_ccs_gsettings_settings_env_test.h compiz-0.9.8.4/compizconfig/gsettings/tests/compizconfig_ccs_gsettings_settings_env_test.h --- compiz-0.9.8.2+bzr3377/compizconfig/gsettings/tests/compizconfig_ccs_gsettings_settings_env_test.h 1970-01-01 00:00:00.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/gsettings/tests/compizconfig_ccs_gsettings_settings_env_test.h 2012-09-27 11:04:02.000000000 +0000 @@ -0,0 +1,134 @@ +/* + * Compiz configuration system library + * + * Copyright (C) 2012 Canonical Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authored By: + * Sam Spilsbury + */ +#ifndef _COMPIZCONFIG_CCS_GSETTINGS_SETTINGS_ENV_TEST_H +#define _COMPIZCONFIG_CCS_GSETTINGS_SETTINGS_ENV_TEST_H + +#include +#include + +#include "compizconfig_ccs_settings_test_fixture.h" + +typedef boost::shared_ptr GVariantShared; +typedef struct _CCSSetting CCSSetting; +typedef struct _CCSGSettingsWrapper CCSGSettingsWrapper; +typedef enum _CCSSettingType CCSSettingType; + +class PrivateCCSGSettingsStorageEnv; + +class CCSGSettingsStorageEnv : + public CCSSettingsConceptTestEnvironmentInterface +{ + public: + + virtual void SetUp () {} + virtual void TearDown () {} + + CCSGSettingsStorageEnv (CCSGSettingsWrapper *settings, + const std::string &profileName); + + void WriteBoolAtKey (const std::string &plugin, + const std::string &key, + const VariantTypes &value); + void WriteIntegerAtKey (const std::string &plugin, + const std::string &key, + const VariantTypes &value); + + void WriteFloatAtKey (const std::string &plugin, + const std::string &key, + const VariantTypes &value); + + void WriteStringAtKey (const std::string &plugin, + const std::string &key, + const VariantTypes &value); + + void WriteColorAtKey (const std::string &plugin, + const std::string &key, + const VariantTypes &value); + + void WriteKeyAtKey (const std::string &plugin, + const std::string &key, + const VariantTypes &value); + + void WriteButtonAtKey (const std::string &plugin, + const std::string &key, + const VariantTypes &value); + + void WriteEdgeAtKey (const std::string &plugin, + const std::string &key, + const VariantTypes &value); + + void WriteMatchAtKey (const std::string &plugin, + const std::string &key, + const VariantTypes &value); + + void WriteBellAtKey (const std::string &plugin, + const std::string &key, + const VariantTypes &value); + + void WriteListAtKey (const std::string &plugin, + const std::string &key, + const VariantTypes &value); + + Bool ReadBoolAtKey (const std::string &plugin, + const std::string &key); + + int ReadIntegerAtKey (const std::string &plugin, + const std::string &key); + + float ReadFloatAtKey (const std::string &plugin, + const std::string &key); + + const char * ReadStringAtKey (const std::string &plugin, + const std::string &key); + + CCSSettingColorValue ReadColorAtKey (const std::string &plugin, + const std::string &key); + + CCSSettingKeyValue ReadKeyAtKey (const std::string &plugin, + const std::string &key); + CCSSettingButtonValue ReadButtonAtKey (const std::string &plugin, + const std::string &key); + + unsigned int ReadEdgeAtKey (const std::string &plugin, + const std::string &key); + + const char * ReadMatchAtKey (const std::string &plugin, + const std::string &key); + Bool ReadBellAtKey (const std::string &plugin, + const std::string &key); + + CCSSettingValueList ReadListAtKey (const std::string &plugin, + const std::string &key, + CCSSetting *setting); + + private: + + GVariantShared + ReadVariantAtKeyToShared (const std::string &plugin, + const std::string &key, + CCSSettingType type); + + std::auto_ptr priv; +}; + +#endif diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/gsettings/tests/gsettings-mock-schemas-config.h.in compiz-0.9.8.4/compizconfig/gsettings/tests/gsettings-mock-schemas-config.h.in --- compiz-0.9.8.2+bzr3377/compizconfig/gsettings/tests/gsettings-mock-schemas-config.h.in 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/gsettings/tests/gsettings-mock-schemas-config.h.in 2012-09-27 11:04:02.000000000 +0000 @@ -3,6 +3,8 @@ #define MOCK_SCHEMA_PATH "@CMAKE_BINARY_DIR@/generated/glib-2.0/schemas" +#include + namespace { const std::string MOCK_SCHEMA ("org.compiz.mock"); diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/gsettings/tests/gsettings_settings_test_fixture.h compiz-0.9.8.4/compizconfig/gsettings/tests/gsettings_settings_test_fixture.h --- compiz-0.9.8.2+bzr3377/compizconfig/gsettings/tests/gsettings_settings_test_fixture.h 1970-01-01 00:00:00.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/gsettings/tests/gsettings_settings_test_fixture.h 2012-09-27 11:04:02.000000000 +0000 @@ -0,0 +1,29 @@ +/* + * Compiz configuration system library + * + * Copyright (C) 2012 Canonical Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authored By: + * Sam Spilsbury + */ +#ifndef _COMPIZCONFIG_GSETTINGS_SETTINGS_TEST_FIXTURE_H +#define _COMPIZCONFIG_GSETTINGS_SETTINGS_TEST_FIXTURE_H + +#include +#include + +#endif diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/gsettings/tests/test_gsettings_conformance.cpp compiz-0.9.8.4/compizconfig/gsettings/tests/test_gsettings_conformance.cpp --- compiz-0.9.8.2+bzr3377/compizconfig/gsettings/tests/test_gsettings_conformance.cpp 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/gsettings/tests/test_gsettings_conformance.cpp 2012-09-27 11:04:02.000000000 +0000 @@ -1,3 +1,25 @@ +/* + * Compiz configuration system library + * + * Copyright (C) 2012 Canonical Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authored By: + * Sam Spilsbury + */ #include #include @@ -15,438 +37,14 @@ #include "gtest_shared_autodestroy.h" #include "test_gsettings_tests.h" +#include "compizconfig_ccs_gsettings_settings_env_test.h" +#include "compizconfig_ccs_integration_mock.h" + using ::testing::AtLeast; using ::testing::Pointee; using ::testing::ReturnNull; -CCSIntegration * -ccsMockIntegrationBackendNew (CCSObjectAllocationInterface *ai); - -void -ccsMockIntegrationBackendFree (CCSIntegration *integration); - -class CCSIntegrationGMockInterface -{ - public: - - virtual ~CCSIntegrationGMockInterface () {} - - virtual CCSIntegratedSetting * getIntegratedOptionIndex (const char *pluginName, const char *settingName) = 0; - virtual Bool readOptionIntoSetting (CCSContext *context, CCSSetting *setting, CCSIntegratedSetting *) = 0; - virtual void writeOptionFromSetting (CCSContext *context, CCSSetting *setting, CCSIntegratedSetting *) = 0; - virtual void updateIntegratedSettings (CCSContext *context, CCSIntegratedSettingList settingList) = 0; - virtual void disallowIntegratedWrites () = 0; - virtual void allowIntegratedWrites () = 0; -}; - -class CCSIntegrationGMock : - public CCSIntegrationGMockInterface -{ - public: - - MOCK_METHOD2 (getIntegratedOptionIndex, CCSIntegratedSetting * (const char *, const char *)); - MOCK_METHOD3 (readOptionIntoSetting, Bool (CCSContext *, CCSSetting *, CCSIntegratedSetting *)); - MOCK_METHOD3 (writeOptionFromSetting, void (CCSContext *, CCSSetting *, CCSIntegratedSetting *)); - MOCK_METHOD2 (updateIntegratedSettings, void (CCSContext *, CCSIntegratedSettingList)); - MOCK_METHOD0 (disallowIntegratedWrites, void ()); - MOCK_METHOD0 (allowIntegratedWrites, void ()); - - - CCSIntegrationGMock (CCSIntegration *integration) : - mIntegration (integration) - { - } - - CCSIntegration * - getIntegrationBackend () - { - return mIntegration; - } - - public: - - static - CCSIntegratedSetting * CCSIntegrationGetIntegratedOptionIndex (CCSIntegration *integration, - const char *pluginName, - const char *settingName) - { - return reinterpret_cast (ccsObjectGetPrivate (integration))->getIntegratedOptionIndex (pluginName, settingName); - } - - static - Bool CCSIntegrationReadOptionIntoSetting (CCSIntegration *integration, - CCSContext *context, - CCSSetting *setting, - CCSIntegratedSetting *integrated) - { - return reinterpret_cast (ccsObjectGetPrivate (integration))->readOptionIntoSetting (context, setting, integrated); - } - - static - void CCSIntegrationWriteSettingIntoOption (CCSIntegration *integration, - CCSContext *context, - CCSSetting *setting, - CCSIntegratedSetting *integrated) - { - return reinterpret_cast (ccsObjectGetPrivate (integration))->writeOptionFromSetting (context, setting, integrated); - } - - static void CCSIntegrationUpdateIntegratedSettings (CCSIntegration *integration, - CCSContext *context, - CCSIntegratedSettingList settingList) - { - return reinterpret_cast (ccsObjectGetPrivate (integration))->updateIntegratedSettings (context, settingList); - } - - static - void ccsFreeIntegration (CCSIntegration *integration) - { - ccsMockIntegrationBackendFree (integration); - } - - static void ccsIntegrationDisallowIntegratedWrites (CCSIntegration *integration) - { - reinterpret_cast (ccsObjectGetPrivate (integration))->disallowIntegratedWrites (); - } - - static void ccsIntegrationAllowIntegratedWrites (CCSIntegration *integration) - { - reinterpret_cast (ccsObjectGetPrivate (integration))->allowIntegratedWrites (); - } - - private: - - CCSIntegration *mIntegration; -}; - -const CCSIntegrationInterface mockIntegrationBackendInterface = -{ - CCSIntegrationGMock::CCSIntegrationGetIntegratedOptionIndex, - CCSIntegrationGMock::CCSIntegrationReadOptionIntoSetting, - CCSIntegrationGMock::CCSIntegrationWriteSettingIntoOption, - CCSIntegrationGMock::CCSIntegrationUpdateIntegratedSettings, - CCSIntegrationGMock::ccsIntegrationDisallowIntegratedWrites, - CCSIntegrationGMock::ccsIntegrationAllowIntegratedWrites, - CCSIntegrationGMock::ccsFreeIntegration -}; - -CCSIntegration * -ccsMockIntegrationBackendNew (CCSObjectAllocationInterface *ai) -{ - CCSIntegration *integration = reinterpret_cast ((*ai->calloc_) (ai->allocator, 1, sizeof (CCSIntegration))); - - if (!integration) - return NULL; - - CCSIntegrationGMock *gmockBackend = new CCSIntegrationGMock (integration); - - ccsObjectInit (integration, ai); - ccsObjectSetPrivate (integration, (CCSPrivate *) gmockBackend); - ccsObjectAddInterface (integration, (const CCSInterface *) &mockIntegrationBackendInterface, GET_INTERFACE_TYPE (CCSIntegrationInterface)); - - ccsObjectRef (integration); - - return integration; -} - -void -ccsMockIntegrationBackendFree (CCSIntegration *integration) -{ - CCSIntegrationGMock *gmockBackend = reinterpret_cast (ccsObjectGetPrivate (integration)); - - delete gmockBackend; - - ccsObjectSetPrivate (integration, NULL); - ccsObjectFinalize (integration); - (*integration->object.object_allocation->free_) (integration->object.object_allocation->allocator, integration); -} - -class CCSGSettingsStorageEnv : - public CCSSettingsConceptTestEnvironmentInterface, - public CCSGSettingsMemoryBackendTestingEnv -{ - public: - - typedef boost::shared_ptr GVariantShared; - - virtual void SetUp () - { - SetUpEnv (); - } - - virtual void TearDown () - { - TearDownEnv (); - } - - CCSGSettingsStorageEnv (CCSGSettingsWrapper *settings, - const std::string &profileName) : - mSettings (settings), - profileName (profileName) - { - } - - void WriteBoolAtKey (const std::string &plugin, - const std::string &key, - const VariantTypes &value) - { - GVariant *variant = NULL; - if (writeBoolToVariant (boolToBool (boost::get (value)), &variant)) - writeVariantToKey (mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant); - else - throw std::exception (); - } - - void WriteIntegerAtKey (const std::string &plugin, - const std::string &key, - const VariantTypes &value) - { - GVariant *variant = NULL; - if (writeIntToVariant (boost::get (value), &variant)) - writeVariantToKey (mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant); - else - throw std::exception (); - } - - void WriteFloatAtKey (const std::string &plugin, - const std::string &key, - const VariantTypes &value) - { - GVariant *variant = NULL; - if (writeFloatToVariant (boost::get (value), &variant)) - writeVariantToKey (mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant); - else - throw std::exception (); - } - - void WriteStringAtKey (const std::string &plugin, - const std::string &key, - const VariantTypes &value) - { - GVariant *variant = NULL; - if (writeStringToVariant (boost::get (value), &variant)) - writeVariantToKey (mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant); - else - throw std::exception (); - } - - void WriteColorAtKey (const std::string &plugin, - const std::string &key, - const VariantTypes &value) - { - GVariant *variant = NULL; - if (writeColorToVariant (boost::get (value), &variant)) - writeVariantToKey (mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant); - else - throw std::exception (); - } - - void WriteKeyAtKey (const std::string &plugin, - const std::string &key, - const VariantTypes &value) - { - GVariant *variant = NULL; - if (writeKeyToVariant (boost::get (value), &variant)) - writeVariantToKey (mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant); - else - throw std::exception (); - } - - void WriteButtonAtKey (const std::string &plugin, - const std::string &key, - const VariantTypes &value) - { - GVariant *variant = NULL; - if (writeButtonToVariant (boost::get (value), &variant)) - writeVariantToKey (mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant); - else - throw std::exception (); - } - - void WriteEdgeAtKey (const std::string &plugin, - const std::string &key, - const VariantTypes &value) - { - GVariant *variant = NULL; - if (writeEdgeToVariant (boost::get (value), &variant)) - writeVariantToKey (mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant); - else - throw std::exception (); - } - - void WriteMatchAtKey (const std::string &plugin, - const std::string &key, - const VariantTypes &value) - { - GVariant *variant = NULL; - if (writeStringToVariant (boost::get (value), &variant)) - writeVariantToKey (mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant); - else - throw std::exception (); - } - - void WriteBellAtKey (const std::string &plugin, - const std::string &key, - const VariantTypes &value) - { - GVariant *variant = NULL; - if (writeBoolToVariant (boolToBool (boost::get (value)), &variant)) - writeVariantToKey (mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant); - else - throw std::exception (); - } - - void WriteListAtKey (const std::string &plugin, - const std::string &key, - const VariantTypes &value) - { - GVariant *variant = NULL; - - const CCSListWrapper::Ptr &lw (boost::get (value)); - - if (writeListValue (*lw, lw->type (), &variant)) - writeVariantToKey (mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant); - else - throw std::exception (); - } - - Bool ReadBoolAtKey (const std::string &plugin, - const std::string &key) - { - GVariantShared variant (ReadVariantAtKeyToShared (plugin, - key, - TypeBool)); - return readBoolFromVariant (variant.get ()); - } - - int ReadIntegerAtKey (const std::string &plugin, - const std::string &key) - { - GVariantShared variant (ReadVariantAtKeyToShared (plugin, - key, - TypeInt)); - return readIntFromVariant (variant.get ()); - } - - float ReadFloatAtKey (const std::string &plugin, - const std::string &key) - { - GVariantShared variant (ReadVariantAtKeyToShared (plugin, - key, - TypeFloat)); - return readFloatFromVariant (variant.get ()); - } - - const char * ReadStringAtKey (const std::string &plugin, - const std::string &key) - { - GVariantShared variant (ReadVariantAtKeyToShared (plugin, - key, - TypeString)); - return readStringFromVariant (variant.get ()); - } - - CCSSettingColorValue ReadColorAtKey (const std::string &plugin, - const std::string &key) - { - Bool success = FALSE; - GVariantShared variant (ReadVariantAtKeyToShared (plugin, - key, - TypeColor)); - CCSSettingColorValue value = readColorFromVariant (variant.get (), &success); - EXPECT_TRUE (success); - return value; - } - - CCSSettingKeyValue ReadKeyAtKey (const std::string &plugin, - const std::string &key) - { - Bool success = FALSE; - GVariantShared variant (ReadVariantAtKeyToShared (plugin, - key, - TypeKey)); - CCSSettingKeyValue value = readKeyFromVariant (variant.get (), &success); - EXPECT_TRUE (success); - return value; - } - - CCSSettingButtonValue ReadButtonAtKey (const std::string &plugin, - const std::string &key) - { - Bool success = FALSE; - GVariantShared variant (ReadVariantAtKeyToShared (plugin, - key, - TypeButton)); - CCSSettingButtonValue value = readButtonFromVariant (variant.get (), &success); - EXPECT_TRUE (success); - return value; - } - - unsigned int ReadEdgeAtKey (const std::string &plugin, - const std::string &key) - { - GVariantShared variant (ReadVariantAtKeyToShared (plugin, - key, - TypeEdge)); - return readEdgeFromVariant (variant.get ()); - } - - const char * ReadMatchAtKey (const std::string &plugin, - const std::string &key) - { - GVariantShared variant (ReadVariantAtKeyToShared (plugin, - key, - TypeMatch)); - return readStringFromVariant (variant.get ()); - } - - Bool ReadBellAtKey (const std::string &plugin, - const std::string &key) - { - GVariantShared variant (ReadVariantAtKeyToShared (plugin, - key, - TypeBell)); - return readBoolFromVariant (variant.get ()); - } - - CCSSettingValueList ReadListAtKey (const std::string &plugin, - const std::string &key, - CCSSetting *setting) - { - GVariantShared variant (ReadVariantAtKeyToShared (plugin, - key, - TypeList)); - return readListValue (variant.get (), setting, &ccsDefaultObjectAllocator); - } - - private: - - GVariantShared - ReadVariantAtKeyToShared (const std::string &plugin, - const std::string &key, - CCSSettingType type) - { - CharacterWrapper translatedKey (translateKeyForGSettings (key.c_str ())); - CharacterWrapper pluginPath (makeCompizPluginPath (profileName.c_str (), - plugin.c_str ())); - - GVariant *rawVariant = getVariantAtKey (mSettings, - translatedKey, - pluginPath, - type); - - GVariantShared shared (AutoDestroy (rawVariant, g_variant_unref)); - - - - return shared; - } - - CCSGSettingsWrapper *mSettings; - std::string profileName; - - -}; +namespace cci = compiz::config::impl; class CCSGSettingsBackendEnv : public CCSBackendConceptTestEnvironmentInterface, @@ -467,7 +65,6 @@ CCSGSettingsBackendEnv () : pluginToMatch ("mock") { - g_type_init (); } /* A wrapper to prevent signals from being added */ @@ -549,7 +146,6 @@ ccsFreeDynamicBackend (mBackend); - ccsGSettingsWrapperUnref (mSettings); mStorage.reset (); g_variant_unref (pluginKeys); diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/gsettings/tests/test_gsettings_tests.h compiz-0.9.8.4/compizconfig/gsettings/tests/test_gsettings_tests.h --- compiz-0.9.8.2+bzr3377/compizconfig/gsettings/tests/test_gsettings_tests.h 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/gsettings/tests/test_gsettings_tests.h 2012-09-27 11:04:02.000000000 +0000 @@ -1,9 +1,33 @@ +/* + * Compiz configuration system library + * + * Copyright (C) 2012 Canonical Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authored By: + * Sam Spilsbury + */ #ifndef _COMPIZCONFIG_TEST_GSETTINGS_TESTS_H #define _COMPIZCONFIG_TEST_GSETTINGS_TESTS_H #include #include #include +#include +#include #include using ::testing::TestWithParam; @@ -21,13 +45,18 @@ virtual void SetUpEnv () { - setenv ("G_SLICE", "always-malloc", 1); + gsliceEnv.SetUpEnv (); + g_type_init (); } virtual void TearDownEnv () { - unsetenv ("G_SLICE"); + gsliceEnv.TearDownEnv (); } + + private: + + CompizGLibGSliceOffEnv gsliceEnv; }; class CCSGSettingsMemoryBackendTestingEnv : @@ -38,23 +67,43 @@ virtual void SetUpEnv () { CCSGSettingsTestingEnv::SetUpEnv (); - - g_setenv ("GSETTINGS_SCHEMA_DIR", MOCK_PATH.c_str (), true); - g_setenv ("GSETTINGS_BACKEND", "memory", 1); + gsettingsEnv.SetUpEnv (MOCK_PATH); } virtual void TearDownEnv () { - g_unsetenv ("GSETTINGS_BACKEND"); - g_unsetenv ("GSETTINGS_SCHEMA_DIR"); - + gsettingsEnv.TearDownEnv (); CCSGSettingsTestingEnv::TearDownEnv (); } + + private: + + CompizGLibGSettingsMemoryBackendTestingEnv gsettingsEnv; +}; + +class CCSGSettingsTestCommon : + public ::testing::Test +{ + public: + + virtual void SetUp () + { + env.SetUpEnv (); + } + + virtual void TearDown () + { + env.TearDownEnv (); + } + + private: + + CompizGLibGSliceOffEnv env; }; class CCSGSettingsTest : - public CCSGSettingsTestingEnv, - public ::testing::TestWithParam + public CCSGSettingsTestCommon, + public ::testing::WithParamInterface { public: @@ -65,13 +114,13 @@ virtual void SetUp () { - CCSGSettingsTestingEnv::SetUpEnv (); + CCSGSettingsTestCommon::SetUp (); mFuncs->SetUp (); } virtual void TearDown () { - CCSGSettingsTestingEnv::TearDownEnv (); + CCSGSettingsTestCommon::TearDown (); mFuncs->TearDown (); } @@ -81,41 +130,40 @@ }; class CCSGSettingsTestIndependent : - public CCSGSettingsTestingEnv, - public ::testing::Test + public CCSGSettingsTestCommon { public: virtual void SetUp () { + CCSGSettingsTestCommon::SetUp (); g_type_init (); - - CCSGSettingsTestingEnv::SetUpEnv (); } virtual void TearDown () { - CCSGSettingsTestingEnv::TearDownEnv (); + CCSGSettingsTestCommon::TearDown (); } }; class CCSGSettingsTestWithMemoryBackend : - public CCSGSettingsTestIndependent, - public CCSGSettingsMemoryBackendTestingEnv + public CCSGSettingsTestIndependent { public: virtual void SetUp () { CCSGSettingsTestIndependent::SetUp (); - CCSGSettingsMemoryBackendTestingEnv::SetUpEnv (); + env.SetUpEnv (MOCK_PATH); } virtual void TearDown () { - CCSGSettingsMemoryBackendTestingEnv::TearDownEnv (); - CCSGSettingsTestIndependent::TearDown (); + env.TearDownEnv (); } + private: + + CompizGLibGSettingsMemoryBackendTestingEnv env; }; #endif diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/integration/gnome/CMakeLists.txt compiz-0.9.8.4/compizconfig/integration/gnome/CMakeLists.txt --- compiz-0.9.8.2+bzr3377/compizconfig/integration/gnome/CMakeLists.txt 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/integration/gnome/CMakeLists.txt 2012-09-27 11:04:02.000000000 +0000 @@ -38,4 +38,8 @@ compizconfig ${COMPIZCONFIG_GNOME_INTEGRATION_LIBRARIES}) + if (COMPIZ_BUILD_TESTING) + add_subdirectory (tests) + endif (COMPIZ_BUILD_TESTING) + endif (COMPIZCONFIG_GNOME_INTEGRATION_FOUND) diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/integration/gnome/gconf/src/ccs_gnome_integration_gconf_integrated_setting.c compiz-0.9.8.4/compizconfig/integration/gnome/gconf/src/ccs_gnome_integration_gconf_integrated_setting.c --- compiz-0.9.8.2+bzr3377/compizconfig/integration/gnome/gconf/src/ccs_gnome_integration_gconf_integrated_setting.c 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/integration/gnome/gconf/src/ccs_gnome_integration_gconf_integrated_setting.c 2012-09-27 11:04:02.000000000 +0000 @@ -63,7 +63,8 @@ { ccsError ("NULL encountered while reading GConf setting"); free (gnomeKeyPath); - return v; + free (v); + return NULL; } if (err) @@ -71,7 +72,8 @@ ccsError ("%s", err->message); g_error_free (err); free (gnomeKeyPath); - return v; + free (v); + return NULL; } switch (type) @@ -80,6 +82,8 @@ if (gconfValue->type != GCONF_VALUE_INT) { ccsError ("Expected integer value"); + free (v); + v = NULL; break; } @@ -89,6 +93,8 @@ if (gconfValue->type != GCONF_VALUE_BOOL) { ccsError ("Expected boolean value"); + free (v); + v = NULL; break; } @@ -99,6 +105,8 @@ if (gconfValue->type != GCONF_VALUE_STRING) { ccsError ("Expected string value"); + free (v); + v = NULL; break; } @@ -220,10 +228,17 @@ ccsGConfIntegratedSettingFree ((CCSIntegratedSetting *) info); } +void +ccsGConfGNOMEIntegratedSettingInfoFree (CCSGNOMEIntegratedSettingInfo *info) +{ + ccsGConfIntegratedSettingFree ((CCSIntegratedSetting *) info); +} + const CCSGNOMEIntegratedSettingInfoInterface ccsGConfGNOMEIntegratedSettingInfoInterface = { ccsGConfIntegratedSettingGetSpecialOptionType, - ccsGConfIntegratedSettingGetGNOMEName + ccsGConfIntegratedSettingGetGNOMEName, + ccsGConfGNOMEIntegratedSettingInfoFree }; const CCSIntegratedSettingInterface ccsGConfIntegratedSettingInterface = diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/integration/gnome/gsettings/CMakeLists.txt compiz-0.9.8.4/compizconfig/integration/gnome/gsettings/CMakeLists.txt --- compiz-0.9.8.2+bzr3377/compizconfig/integration/gnome/gsettings/CMakeLists.txt 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/integration/gnome/gsettings/CMakeLists.txt 2012-09-27 11:04:02.000000000 +0000 @@ -71,6 +71,10 @@ endif (GLIB_COMPILE_SCHEMAS) + if (COMPIZ_BUILD_TESTING) + add_subdirectory (tests) + endif (COMPIZ_BUILD_TESTING) + endif (COMPIZCONFIG_GNOME_GSETTINGS_INTEGRATION_FOUND) endif (USE_GSETTINGS) diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/integration/gnome/gsettings/include/ccs_gnome_integration_gsettings_integrated_setting.h compiz-0.9.8.4/compizconfig/integration/gnome/gsettings/include/ccs_gnome_integration_gsettings_integrated_setting.h --- compiz-0.9.8.2+bzr3377/compizconfig/integration/gnome/gsettings/include/ccs_gnome_integration_gsettings_integrated_setting.h 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/integration/gnome/gsettings/include/ccs_gnome_integration_gsettings_integrated_setting.h 2012-09-27 11:04:02.000000000 +0000 @@ -26,6 +26,17 @@ CCSGSettingsWrapper *wrapper, CCSObjectAllocationInterface *ai); +/** + * @brief ccsGSettingsIntegratedSettingsTranslateOldGNOMEKeyForGSettings + * @param key the old style gnome key to translate + * @return new-style key. Caller should free + * + * This translates old style keys (eg foo_bar) to new style keys + * foo-bar and special cases a few keys + */ +char * +ccsGSettingsIntegratedSettingsTranslateOldGNOMEKeyForGSettings (const char *key); + COMPIZCONFIG_END_DECLS #endif diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/integration/gnome/gsettings/include/ccs_gnome_integration_gsettings_integrated_setting_factory.h compiz-0.9.8.4/compizconfig/integration/gnome/gsettings/include/ccs_gnome_integration_gsettings_integrated_setting_factory.h --- compiz-0.9.8.2+bzr3377/compizconfig/integration/gnome/gsettings/include/ccs_gnome_integration_gsettings_integrated_setting_factory.h 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/integration/gnome/gsettings/include/ccs_gnome_integration_gsettings_integrated_setting_factory.h 2012-09-27 11:04:02.000000000 +0000 @@ -39,6 +39,17 @@ unsigned int ccsCCSGNOMEIntegrationGSettingsWrapperFactoryInterfaceGetType (); +/** + * @brief ccsGSettingsIntegratedSettingsTranslateNewGNOMEKeyForCCS + * @param key the old style gnome key to translate + * @return new-style key. Caller should free + * + * This translates new style keys (eg foo-bar) to old style keys + * foo_bar and special cases a few keys + */ +char * +ccsGSettingsIntegratedSettingsTranslateNewGNOMEKeyForCCS (const char *key); + CCSGSettingsWrapper * ccsGNOMEIntegrationGSettingsWrapperFactoryNewGSettingsWrapper (CCSGNOMEIntegrationGSettingsWrapperFactory *factory, const gchar *schemaName, @@ -49,6 +60,9 @@ CCSGNOMEIntegrationGSettingsWrapperFactory * ccsGNOMEIntegrationGSettingsWrapperDefaultImplNew (CCSObjectAllocationInterface *ai); +void +ccsGNOMEIntegrationGSettingsWrapperDefaultImplFree (CCSGNOMEIntegrationGSettingsWrapperFactory *wrapperFactory); + CCSIntegratedSettingFactory * ccsGSettingsIntegratedSettingFactoryNew (CCSGNOMEIntegrationGSettingsWrapperFactory *wrapperFactory, CCSGNOMEValueChangeData *data, diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/integration/gnome/gsettings/org.compiz.integrated.gschema.xml compiz-0.9.8.4/compizconfig/integration/gnome/gsettings/org.compiz.integrated.gschema.xml --- compiz-0.9.8.2+bzr3377/compizconfig/integration/gnome/gsettings/org.compiz.integrated.gschema.xml 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/integration/gnome/gsettings/org.compiz.integrated.gschema.xml 2012-09-27 11:04:02.000000000 +0000 @@ -4,18 +4,12 @@ true - - "gnome-terminal" - "gnome-screenshot -w" "gnome-screenshot" - - "gnome-terminal" - ["Disabled"] @@ -88,21 +82,6 @@ "" - - ["<Control><Alt>t"] - - - ["<Alt>Print"] - - - ["Print"] - - - ["<Alt>F1"] - - - ["<Alt>F2"] - ["<Alt>"] diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/integration/gnome/gsettings/src/ccs_gnome_integration_gsettings_integrated_setting.c compiz-0.9.8.4/compizconfig/integration/gnome/gsettings/src/ccs_gnome_integration_gsettings_integrated_setting.c --- compiz-0.9.8.2+bzr3377/compizconfig/integration/gnome/gsettings/src/ccs_gnome_integration_gsettings_integrated_setting.c 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/integration/gnome/gsettings/src/ccs_gnome_integration_gsettings_integrated_setting.c 2012-09-27 11:04:02.000000000 +0000 @@ -24,6 +24,30 @@ CCSGSettingsWrapper *wrapper; }; +char * +ccsGSettingsIntegratedSettingsTranslateOldGNOMEKeyForGSettings (const char *key) +{ + char *newKey = translateKeyForGSettings (key); + + if (g_strcmp0 (newKey, "run-command-screenshot") == 0) + { + free (newKey); + newKey = strdup ("screenshot"); + } + else if (g_strcmp0 (newKey, "run-command-window-screenshot") == 0) + { + free (newKey); + newKey = strdup ("window-screenshot"); + } + else if (g_strcmp0 (newKey, "run-command-terminal") == 0) + { + free (newKey); + newKey = strdup ("terminal"); + } + + return newKey; +} + SpecialOptionType ccsGSettingsIntegratedSettingGetSpecialOptionType (CCSGNOMEIntegratedSettingInfo *setting) { @@ -46,7 +70,7 @@ CCSGSettingsIntegratedSettingPrivate *priv = (CCSGSettingsIntegratedSettingPrivate *) ccsObjectGetPrivate (setting); CCSSettingValue *v = calloc (1, sizeof (CCSSettingValue)); const char *gnomeKeyName = ccsGNOMEIntegratedSettingInfoGetGNOMEName ((CCSGNOMEIntegratedSettingInfo *) setting); - char *gsettingsTranslatedName = translateKeyForGSettings (gnomeKeyName); + char *gsettingsTranslatedName = ccsGSettingsIntegratedSettingsTranslateOldGNOMEKeyForGSettings (gnomeKeyName); v->isListChild = FALSE; v->parent = NULL; @@ -55,7 +79,11 @@ GVariant *variant = ccsGSettingsWrapperGetValue (priv->wrapper, gsettingsTranslatedName); if (!variant) + { free (gsettingsTranslatedName); + free (v); + return NULL; + } const GVariantType *variantType = G_VARIANT_TYPE (g_variant_get_type_string (variant)); @@ -65,6 +93,8 @@ if (!g_variant_type_equal (variantType, G_VARIANT_TYPE_INT32)) { ccsError ("Expected integer value"); + free (v); + v = NULL; break; } @@ -74,6 +104,8 @@ if (!g_variant_type_equal (variantType, G_VARIANT_TYPE_BOOLEAN)) { ccsError ("Expected boolean value"); + free (v); + v = NULL; break; } @@ -84,6 +116,8 @@ if (!g_variant_type_equal (variantType, G_VARIANT_TYPE_STRING)) { ccsError ("Expected string value"); + free (v); + v = NULL; break; } @@ -96,6 +130,8 @@ if (!g_variant_type_equal (variantType, G_VARIANT_TYPE ("as"))) { ccsError ("Expected array-of-string value"); + free (v); + v = NULL; break; } @@ -125,10 +161,11 @@ { CCSGSettingsIntegratedSettingPrivate *priv = (CCSGSettingsIntegratedSettingPrivate *) ccsObjectGetPrivate (setting); const char *gnomeKeyName = ccsGNOMEIntegratedSettingInfoGetGNOMEName ((CCSGNOMEIntegratedSettingInfo *) setting); - char *gsettingsTranslatedName = translateKeyForGSettings (gnomeKeyName); + char *gsettingsTranslatedName = ccsGSettingsIntegratedSettingsTranslateOldGNOMEKeyForGSettings (gnomeKeyName); - GVariant *variant = ccsGSettingsWrapperGetValue (priv->wrapper, gsettingsTranslatedName); - GVariant *newVariant = NULL; + GVariant *variant = ccsGSettingsWrapperGetValue (priv->wrapper, gsettingsTranslatedName); + const GVariantType *variantType = g_variant_get_type (variant); + GVariant *newVariant = NULL; if (!variant) { @@ -141,42 +178,62 @@ { case TypeInt: { - int currentValue = readIntFromVariant (variant); + if (!g_variant_type_equal (variantType, G_VARIANT_TYPE_INT32)) + ccsError ("Expected integer value"); + else + { + int currentValue = readIntFromVariant (variant); - if ((currentValue != v->value.asInt)) - writeIntToVariant (v->value.asInt, &newVariant); + if ((currentValue != v->value.asInt)) + writeIntToVariant (v->value.asInt, &newVariant); + } } break; case TypeBool: { - gboolean currentValue = readBoolFromVariant (variant); + if (!g_variant_type_equal (variantType, G_VARIANT_TYPE_BOOLEAN)) + ccsError ("Expected boolean value"); + else + { + gboolean currentValue = readBoolFromVariant (variant); - if ((currentValue != v->value.asBool)) - writeBoolToVariant (v->value.asBool, &newVariant); + if ((currentValue != v->value.asBool)) + writeBoolToVariant (v->value.asBool, &newVariant); + } } break; case TypeString: { - const char *defaultValue = ""; - const char *newValue = v->value.asString ? v->value.asString : defaultValue; - gsize len = 0; - const gchar *currentValue = g_variant_get_string (variant, &len); - - if (currentValue) + if (!g_variant_type_equal (variantType, G_VARIANT_TYPE_STRING)) + ccsError ("Expected string value"); + else { - if (strcmp (currentValue, newValue) != 0) - writeStringToVariant (currentValue, &newVariant); + const char *defaultValue = ""; + const char *newValue = v->value.asString ? v->value.asString : defaultValue; + gsize len = 0; + const gchar *currentValue = g_variant_get_string (variant, &len); + + if (currentValue) + { + if (strcmp (currentValue, newValue) != 0) + writeStringToVariant (newValue, &newVariant); + } } } break; case TypeKey: { - const char *defaultValue = ""; - GVariantBuilder strvBuilder; + if (!g_variant_type_equal (variantType, G_VARIANT_TYPE ("as"))) + ccsError ("Expected array-of-string value"); + else + { + const char *defaultValue = ""; + GVariantBuilder strvBuilder; - g_variant_builder_init (&strvBuilder, G_VARIANT_TYPE ("as")); - g_variant_builder_add (&strvBuilder, "s", v->value.asString ? v->value.asString : defaultValue); - newVariant = g_variant_builder_end (&strvBuilder); + g_variant_builder_init (&strvBuilder, G_VARIANT_TYPE ("as")); + g_variant_builder_add (&strvBuilder, "s", v->value.asString ? v->value.asString : defaultValue); + newVariant = g_variant_builder_end (&strvBuilder); + } } break; default: @@ -238,10 +295,17 @@ return ccsGSettingsIntegratedSettingFree ((CCSIntegratedSetting *) info); } +void +ccsGSettingsGNOMEIntegratedSettingInfoFree (CCSGNOMEIntegratedSettingInfo *info) +{ + return ccsGSettingsIntegratedSettingFree ((CCSIntegratedSetting *) info); +} + const CCSGNOMEIntegratedSettingInfoInterface ccsGSettingsGNOMEIntegratedSettingInterface = { ccsGSettingsIntegratedSettingGetSpecialOptionType, - ccsGSettingsIntegratedSettingGetGNOMEName + ccsGSettingsIntegratedSettingGetGNOMEName, + ccsGSettingsGNOMEIntegratedSettingInfoFree }; const CCSIntegratedSettingInterface ccsGSettingsIntegratedSettingInterface = diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/integration/gnome/gsettings/src/ccs_gnome_integration_gsettings_integrated_setting_factory.c compiz-0.9.8.4/compizconfig/integration/gnome/gsettings/src/ccs_gnome_integration_gsettings_integrated_setting_factory.c --- compiz-0.9.8.2+bzr3377/compizconfig/integration/gnome/gsettings/src/ccs_gnome_integration_gsettings_integrated_setting_factory.c 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/integration/gnome/gsettings/src/ccs_gnome_integration_gsettings_integrated_setting_factory.c 2012-09-27 11:04:02.000000000 +0000 @@ -21,6 +21,30 @@ INTERFACE_TYPE (CCSGNOMEIntegrationGSettingsWrapperFactoryInterface); +char * +ccsGSettingsIntegratedSettingsTranslateNewGNOMEKeyForCCS (const char *key) +{ + char *newKey = translateKeyForCCS (key); + + if (g_strcmp0 (newKey, "screenshot") == 0) + { + free (newKey); + newKey = strdup ("run_command_screenshot"); + } + else if (g_strcmp0 (newKey, "window_screenshot") == 0) + { + free (newKey); + newKey = strdup ("run_command_window_screenshot"); + } + else if (g_strcmp0 (newKey, "terminal") == 0) + { + free (newKey); + newKey = strdup ("run_command_terminal"); + } + + return newKey; +} + CCSGSettingsWrapper * ccsGNOMEIntegrationGSettingsWrapperFactoryNewGSettingsWrapper (CCSGNOMEIntegrationGSettingsWrapperFactory *factory, const gchar *schemaName, @@ -55,6 +79,14 @@ ccsGNOMEIntegrationGSettingsWrapperFactoryNewGSettingsWrapperDefault }; +void +ccsGNOMEIntegrationGSettingsWrapperDefaultImplFree (CCSGNOMEIntegrationGSettingsWrapperFactory *wrapperFactory) +{ + ccsObjectFinalize (wrapperFactory); + (*wrapperFactory->object.object_allocation->free_) (wrapperFactory->object.object_allocation->allocator, + wrapperFactory); +} + CCSGNOMEIntegrationGSettingsWrapperFactory * ccsGNOMEIntegrationGSettingsWrapperDefaultImplNew (CCSObjectAllocationInterface *ai) { @@ -103,7 +135,7 @@ gpointer user_data) { CCSGNOMEValueChangeData *data = (CCSGNOMEValueChangeData *) user_data; - char *baseName = translateKeyForCCS (key); + char *baseName = ccsGSettingsIntegratedSettingsTranslateNewGNOMEKeyForCCS (key); /* We don't care if integration is not enabled */ if (!ccsGetIntegrationEnabled (data->context)) @@ -185,6 +217,18 @@ gnomeGSettingsValueChanged, data, factory->object.object_allocation)); + g_hash_table_insert (quarksToGSettingsWrappers, GINT_TO_POINTER (quarks->ORG_GNOME_DESKTOP_DEFAULT_APPLICATIONS_TERMINAL), + ccsGNOMEIntegrationGSettingsWrapperFactoryNewGSettingsWrapper (factory, + g_quark_to_string (quarks->ORG_GNOME_DESKTOP_DEFAULT_APPLICATIONS_TERMINAL), + gnomeGSettingsValueChanged, + data, + factory->object.object_allocation)); + g_hash_table_insert (quarksToGSettingsWrappers, GINT_TO_POINTER (quarks->ORG_GNOME_SETTINGS_DAEMON_PLUGINS_MEDIA_KEYS), + ccsGNOMEIntegrationGSettingsWrapperFactoryNewGSettingsWrapper (factory, + g_quark_to_string (quarks->ORG_GNOME_SETTINGS_DAEMON_PLUGINS_MEDIA_KEYS), + gnomeGSettingsValueChanged, + data, + factory->object.object_allocation)); return quarksToGSettingsWrappers; } @@ -243,6 +287,8 @@ if (priv->pluginsToSettingNameGNOMENameHashTable) g_hash_table_unref (priv->pluginsToSettingNameGNOMENameHashTable); + ccsGNOMEIntegrationGSettingsWrapperDefaultImplFree (priv->wrapperFactory); + ccsObjectFinalize (factory); (*factory->object.object_allocation->free_) (factory->object.object_allocation->allocator, factory); } @@ -282,6 +328,8 @@ ccsObjectSetPrivate (factory, (CCSPrivate *) priv); ccsObjectAddInterface (factory, (const CCSInterface *) &ccsGSettingsIntegratedSettingFactoryInterface, GET_INTERFACE_TYPE (CCSIntegratedSettingFactoryInterface)); + ccsObjectRef (factory); + return factory; } diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/integration/gnome/gsettings/tests/CMakeLists.txt compiz-0.9.8.4/compizconfig/integration/gnome/gsettings/tests/CMakeLists.txt --- compiz-0.9.8.2+bzr3377/compizconfig/integration/gnome/gsettings/tests/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/integration/gnome/gsettings/tests/CMakeLists.txt 2012-09-27 11:04:02.000000000 +0000 @@ -0,0 +1,31 @@ +include_directories (${GTEST_INCLUDE_DIRS}) +include_directories (${CMAKE_SOURCE_DIR}/include) +include_directories (${CMAKE_SOURCE_DIR}/tests/shared) +include_directories (${CMAKE_SOURCE_DIR}/tests/shared/glib) +include_directories (${CMAKE_CURRENT_SOURCE_DIR}/../../../../mocks/libcompizconfig) +include_directories (${CMAKE_CURRENT_SOURCE_DIR}/../../../../gsettings/tests) +include_directories (${CMAKE_CURRENT_SOURCE_DIR}/../../../../gsettings/mocks) +include_directories (${CMAKE_SOURCE_DIR}/compizconfig/tests) +link_directories (${CMAKE_INSTALL_PREFIX}/lib) +link_directories (${CMAKE_CURRENT_BINARY_DIR}/../../mocks/libcompizconfig) +link_directories (${CMAKE_CURRENT_BINARY_DIR}/../../tests/) +link_directories (${CMAKE_CURRENT_BINARY_DIR}/../src/) + +set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") + +add_executable (compizconfig_test_ccs_gnome_gsettings_integrated_setting + ${CMAKE_CURRENT_SOURCE_DIR}/compizconfig_test_ccs_gnome_gsettings_integrated_setting.cpp) + +target_link_libraries (compizconfig_test_ccs_gnome_gsettings_integrated_setting + ${GTEST_BOTH_LIBRARIES} + ${GMOCK_LIBRARY} + ${GMOCK_MAIN_LIBRARY} + ${CMAKE_THREAD_LIBS_INIT} + ${LIBCOMPIZCONFIG_LIBRARIES} + compizconfig + compizconfig_gsettings_settings_test_env + compizconfig_ccs_gsettings_wrapper_mock + compizconfig_gnome_integration_gsettings_integrated_setting + compizconfig_gsettings_backend_interface) + +compiz_discover_tests (compizconfig_test_ccs_gnome_gsettings_integrated_setting COVERAGE compizconfig_gnome_gsettings_integrated_setting) diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/integration/gnome/gsettings/tests/compizconfig_test_ccs_gnome_gsettings_integrated_setting.cpp compiz-0.9.8.4/compizconfig/integration/gnome/gsettings/tests/compizconfig_test_ccs_gnome_gsettings_integrated_setting.cpp --- compiz-0.9.8.2+bzr3377/compizconfig/integration/gnome/gsettings/tests/compizconfig_test_ccs_gnome_gsettings_integrated_setting.cpp 1970-01-01 00:00:00.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/integration/gnome/gsettings/tests/compizconfig_test_ccs_gnome_gsettings_integrated_setting.cpp 2012-09-27 11:04:02.000000000 +0000 @@ -0,0 +1,444 @@ +/* + * Compiz configuration system library + * + * Copyright (C) 2012 Canonical Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authored By: + * Sam Spilsbury + */ +#include +#include + +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include + +using ::testing::Combine; +using ::testing::Return; +using ::testing::IsNull; +using ::testing::ValuesIn; +using ::testing::Values; +using ::testing::Eq; +using ::testing::WithArgs; +using ::testing::_; + +namespace compiz +{ + namespace config + { + namespace integration + { + namespace test + { + const std::string KEYBINDING_ONE = "keybinding_one"; + const std::string KEYBINDING_TWO = "keybinding_two"; + const std::string STRING = "string"; + const Bool BOOLEAN = TRUE; + const int INTEGER = 2; + + const std::string STRING_ALT = "string_alt"; + const Bool BOOLEAN_ALT = FALSE; + const int INTEGER_ALT = 1; + + namespace variant_generators + { + GVariant * i (); + GVariant * s (); + GVariant * b (); + GVariant * as (); + GVariant * fromValue (CCSSettingValue *v, CCSSettingType type); + } + + namespace value_generators + { + CCSSettingValue * integer (); + CCSSettingValue * string (); + CCSSettingValue * key (); + CCSSettingValue * boolean (); + } + + namespace expectations + { + void integer (CCSSettingValue *); + void string (CCSSettingValue *); + void boolean (CCSSettingValue *); + void key (CCSSettingValue *); + + void integerVariant (GVariant *, int); + void stringVariant (GVariant *, const std::string &); + void booleanVariant (GVariant *, bool); + void keyVariant (GVariant *, const std::string &); + } + + typedef GVariant * (*VariantGenerator) (); + typedef CCSSettingValue * (*ValueGenerator) (); + typedef void (*Expectation) (CCSSettingValue *); + + struct GSettingsIntegratedSettingInfo + { + VariantGenerator variantGenerator; + ValueGenerator valueGenerator; + Expectation expectation; + CCSSettingType settingType; + CCSSettingType returnType; + }; + + namespace impl + { + namespace ccit = compiz::config::integration::test; + namespace vg = compiz::config::integration::test::variant_generators; + namespace cvg = compiz::config::integration::test::value_generators; + namespace ex = compiz::config::integration::test::expectations; + + ccit::GSettingsIntegratedSettingInfo settingsInfo[] = + { + { vg::i, cvg::integer, ex::integer, TypeInt, TypeInt }, + { vg::b, cvg::boolean, ex::boolean, TypeBool, TypeBool }, + { vg::s, cvg::string, ex::string, TypeString, TypeString }, + { vg::as, cvg::key, ex::key, TypeKey, TypeString } + }; + } + } + } + } +} + +MATCHER_P (VariantEqual, lhs, "Variants Equal") +{ + return g_variant_equal (lhs, arg); +} + +namespace +{ + std::map & + ccsTypeToSpecialType () + { + static std::map types; + static bool initialized = false; + + if (!initialized) + { + types[TypeInt] = OptionInt; + types[TypeBool] = OptionBool; + types[TypeString] = OptionString; + types[TypeKey] = OptionKey; + } + + return types; + } +} + +namespace ccit = compiz::config::integration::test; +namespace cciti = compiz::config::integration::test::impl; +namespace ccvg = compiz::config::integration::test::variant_generators; +namespace ccvalg = compiz::config::integration::test::value_generators; +namespace ccex = compiz::config::integration::test::expectations; + +typedef std::tr1::tuple CCSGSettingsIntegratedSettingTestInfo; + +class CCSGSettingsIntegratedSettingTest : + public ::testing::TestWithParam +{ + public: + + virtual void SetUp (); + virtual void TearDown (); + + protected: + + CompizGLibGSliceOffEnv env; + boost::shared_ptr mWrapper; + CCSGSettingsWrapperGMock *mWrapperMock; +}; + +GVariant * +ccvg::fromValue (CCSSettingValue *v, + CCSSettingType type) +{ + switch (type) + { + case TypeInt: + return g_variant_new ("i", v->value.asInt); + break; + case TypeBool: + return g_variant_new ("b", v->value.asBool); + break; + case TypeString: + return g_variant_new ("s", v->value.asString); + break; + case TypeKey: + { + GVariantBuilder builder; + g_variant_builder_init (&builder, G_VARIANT_TYPE ("as")); + + /* Represented internally as strings */ + std::string kb (v->value.asString); + if (kb == "Disabled") + kb[0] = 'd'; + + g_variant_builder_add (&builder, "s", kb.c_str ()); + return g_variant_builder_end (&builder); + } + default: + break; + } + + return NULL; +} + +GVariant * +ccvg::as () +{ + GVariantBuilder builder; + g_variant_builder_init (&builder, G_VARIANT_TYPE ("as")); + g_variant_builder_add (&builder, "s", ccit::KEYBINDING_ONE.c_str ()); + g_variant_builder_add (&builder, "s", ccit::KEYBINDING_TWO.c_str ()); + + return g_variant_builder_end (&builder); +} + +GVariant * +ccvg::i () +{ + return g_variant_new ("i", ccit::INTEGER); +} + +GVariant * +ccvg::b () +{ + return g_variant_new ("b", ccit::BOOLEAN); +} + +GVariant * +ccvg::s () +{ + return g_variant_new ("s", ccit::STRING.c_str ()); +} + +namespace +{ + CCSSettingValue * createSettingValue () + { + CCSSettingValue *v = reinterpret_cast (calloc (1, sizeof (CCSSettingValue))); + + v->isListChild = FALSE; + v->parent = NULL; + v->refCount = 1; + + return v; + } +} + +CCSSettingValue * +ccvalg::integer () +{ + CCSSettingValue *v = createSettingValue (); + v->value.asInt = ccit::INTEGER_ALT; + return v; +} + +CCSSettingValue * +ccvalg::string () +{ + CCSSettingValue *v = createSettingValue (); + v->value.asString = strdup (ccit::STRING_ALT.c_str ()); + return v; +} + +CCSSettingValue * +ccvalg::key () +{ + CCSSettingValue *v = createSettingValue (); + v->value.asString = strdup (ccit::KEYBINDING_TWO.c_str ()); + return v; +} + +CCSSettingValue * +ccvalg::boolean () +{ + CCSSettingValue *v = createSettingValue (); + v->value.asBool = ccit::BOOLEAN_ALT; + return v; +} + +void +ccex::boolean (CCSSettingValue *v) +{ + EXPECT_EQ (v->value.asBool, ccit::BOOLEAN); +} + +void +ccex::integer (CCSSettingValue *v) +{ + EXPECT_EQ (v->value.asInt, ccit::INTEGER); +} + +void +ccex::string (CCSSettingValue *v) +{ + EXPECT_EQ (v->value.asString, ccit::STRING); +} + +void +ccex::key (CCSSettingValue *v) +{ + EXPECT_EQ (v->value.asString, ccit::KEYBINDING_ONE); +} + +void +ccex::integerVariant (GVariant *v , int i) +{ + EXPECT_EQ (g_variant_get_int32 (v), i); +} + +void +ccex::stringVariant (GVariant *v, const std::string &s) +{ + gsize len; + EXPECT_EQ (g_variant_get_string (v, &len), s); +} + +void +ccex::booleanVariant (GVariant *v, bool b) +{ + EXPECT_EQ (g_variant_get_boolean (v), b); +} + +void +ccex::keyVariant (GVariant *v, const std::string &s) +{ + gsize len; + const gchar * const *strv = g_variant_get_strv (v, &len); + EXPECT_EQ (strv[0], s); +} + +void +CCSGSettingsIntegratedSettingTest::SetUp () +{ + env.SetUpEnv (); + mWrapper.reset (ccsMockGSettingsWrapperNew (), + boost::bind (ccsMockGSettingsWrapperFree, _1)); + mWrapperMock = reinterpret_cast ( + ccsObjectGetPrivate (mWrapper.get ())); +} + +void +CCSGSettingsIntegratedSettingTest::TearDown () +{ + mWrapper.reset (); + mWrapperMock = NULL; + env.TearDownEnv (); +} + +TEST_P (CCSGSettingsIntegratedSettingTest, MatchedTypesReturnValueMismatchedTypesReturnNull) +{ + const std::string keyName ("mock"); + const ccit::GSettingsIntegratedSettingInfo &integratedSettingInfo = + std::tr1::get <1> (GetParam ()); + const CCSSettingType createSettingType = + std::tr1::get <0> (GetParam ()); + + /* The GSettings Integrated setting takes ownership of these */ + CCSIntegratedSettingInfo *integratedSetting = ccsSharedIntegratedSettingInfoNew (keyName.c_str (), + keyName.c_str (), + integratedSettingInfo.settingType, + &ccsDefaultObjectAllocator); + SpecialOptionType specialType = ccsTypeToSpecialType ()[integratedSettingInfo.settingType]; + CCSGNOMEIntegratedSettingInfo *gnomeIntegratedSetting = ccsGNOMEIntegratedSettingInfoNew (integratedSetting, + specialType, + keyName.c_str (), + &ccsDefaultObjectAllocator); + boost::shared_ptr gsettingsIntegrated (AutoDestroy (ccsGSettingsIntegratedSettingNew (gnomeIntegratedSetting, + mWrapper.get (), + &ccsDefaultObjectAllocator), + ccsIntegratedSettingUnref)); + + GVariant *variant = (*integratedSettingInfo.variantGenerator) (); + EXPECT_CALL (*mWrapperMock, getValue (Eq (keyName))).WillOnce (Return (variant)); + + CCSSettingValue *value = ccsIntegratedSettingReadValue (gsettingsIntegrated.get (), createSettingType); + + if (createSettingType == integratedSettingInfo.settingType) + (*integratedSettingInfo.expectation) (value); + else + EXPECT_THAT (value, IsNull ()); + + if (value) + ccsFreeSettingValueWithType (value, integratedSettingInfo.returnType); +} + +ACTION (FreeVariant) +{ + g_variant_unref (arg0); +} + +TEST_P (CCSGSettingsIntegratedSettingTest, MatchedTypesReturnValueMismatchedTypesResetOrWrite) +{ + const std::string keyName ("mock"); + const ccit::GSettingsIntegratedSettingInfo &integratedSettingInfo = + std::tr1::get <1> (GetParam ()); + const CCSSettingType createSettingType = + std::tr1::get <0> (GetParam ()); + + CCSIntegratedSettingInfo *integratedSetting = ccsSharedIntegratedSettingInfoNew (keyName.c_str (), + keyName.c_str (), + integratedSettingInfo.settingType, + &ccsDefaultObjectAllocator); + SpecialOptionType specialType = ccsTypeToSpecialType ()[integratedSettingInfo.settingType]; + CCSGNOMEIntegratedSettingInfo *gnomeIntegratedSetting = ccsGNOMEIntegratedSettingInfoNew (integratedSetting, + specialType, + keyName.c_str (), + &ccsDefaultObjectAllocator); + boost::shared_ptr gsettingsIntegrated (AutoDestroy (ccsGSettingsIntegratedSettingNew (gnomeIntegratedSetting, + mWrapper.get (), + &ccsDefaultObjectAllocator), + ccsIntegratedSettingUnref)); + + boost::shared_ptr value ((*integratedSettingInfo.valueGenerator) (), + boost::bind (ccsFreeSettingValueWithType, + _1, + integratedSettingInfo.returnType)); + boost::shared_ptr variant = AutoDestroy (g_variant_ref ((*integratedSettingInfo.variantGenerator) ()), + g_variant_unref); + boost::shared_ptr newVariant = AutoDestroy (ccvg::fromValue (value.get (), + integratedSettingInfo.settingType), + g_variant_unref); + EXPECT_CALL (*mWrapperMock, getValue (Eq (keyName))).WillOnce (Return (variant.get ())); + + if (createSettingType == integratedSettingInfo.settingType) + EXPECT_CALL (*mWrapperMock, setValue (Eq (keyName), VariantEqual (newVariant.get ()))) + .WillOnce (WithArgs <1> (FreeVariant ())); + else + EXPECT_CALL (*mWrapperMock, resetKey (Eq (keyName))); + + ccsIntegratedSettingWriteValue (gsettingsIntegrated.get (), value.get (), createSettingType); +} + +INSTANTIATE_TEST_CASE_P (CCSGSettingsIntegratedSettingTestMismatchedValues, CCSGSettingsIntegratedSettingTest, + Combine (Values (TypeInt, TypeString, TypeBool, TypeKey), + ValuesIn (cciti::settingsInfo))); diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/integration/gnome/include/ccs_gnome_integrated_setting.h compiz-0.9.8.4/compizconfig/integration/gnome/include/ccs_gnome_integrated_setting.h --- compiz-0.9.8.2+bzr3377/compizconfig/integration/gnome/include/ccs_gnome_integrated_setting.h 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/integration/gnome/include/ccs_gnome_integrated_setting.h 2012-09-27 11:04:02.000000000 +0000 @@ -15,11 +15,13 @@ typedef SpecialOptionType (*CCSGNOMEIntegratedSettingInfoGetSpecialOptionType) (CCSGNOMEIntegratedSettingInfo *); typedef const char * (*CCSGNOMEIntegratedSettingInfoGetGNOMEName) (CCSGNOMEIntegratedSettingInfo *); +typedef void (*CCSGNOMEIntegratedSettingInfoFree) (CCSGNOMEIntegratedSettingInfo *); struct _CCSGNOMEIntegratedSettingInfoInterface { CCSGNOMEIntegratedSettingInfoGetSpecialOptionType getSpecialOptionType; - CCSGNOMEIntegratedSettingInfoGetGNOMEName getGNOMEName; + CCSGNOMEIntegratedSettingInfoGetGNOMEName getGNOMEName; + CCSGNOMEIntegratedSettingInfoFree free; }; /** @@ -53,6 +55,12 @@ const char *gnomeName, CCSObjectAllocationInterface *ai); +void +ccsFreeGNOMEIntegratedSettingInfo (CCSGNOMEIntegratedSettingInfo *); + +CCSREF_HDR (GNOMEIntegratedSettingInfo, CCSGNOMEIntegratedSettingInfo); +CCSLIST_HDR (GNOMEIntegratedSettingInfo, CCSGNOMEIntegratedSettingInfo); + COMPIZCONFIG_END_DECLS #endif diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/integration/gnome/include/ccs_gnome_integration_constants.h compiz-0.9.8.4/compizconfig/integration/gnome/include/ccs_gnome_integration_constants.h --- compiz-0.9.8.2+bzr3377/compizconfig/integration/gnome/include/ccs_gnome_integration_constants.h 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/integration/gnome/include/ccs_gnome_integration_constants.h 2012-09-27 11:04:02.000000000 +0000 @@ -2,6 +2,7 @@ #define _CCS_GNOME_INTEGRATION_CONSTANTS_H #include +#include COMPIZCONFIG_BEGIN_DECLS @@ -187,6 +188,8 @@ { GQuark ORG_GNOME_DESKTOP_WM_PREFERENCES; GQuark ORG_GNOME_DESKTOP_WM_KEYBINDINGS; + GQuark ORG_GNOME_SETTINGS_DAEMON_PLUGINS_MEDIA_KEYS; + GQuark ORG_GNOME_DESKTOP_DEFAULT_APPLICATIONS_TERMINAL; GQuark ORG_COMPIZ_INTEGRATED; } CCSGSettingsWrapperIntegratedSchemasQuarks; diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/integration/gnome/include/ccs_gnome_integration_types.h compiz-0.9.8.4/compizconfig/integration/gnome/include/ccs_gnome_integration_types.h --- compiz-0.9.8.2+bzr3377/compizconfig/integration/gnome/include/ccs_gnome_integration_types.h 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/integration/gnome/include/ccs_gnome_integration_types.h 2012-09-27 11:04:02.000000000 +0000 @@ -22,5 +22,7 @@ OptionSpecial, } SpecialOptionType; +COMPIZCONFIG_END_DECLS + #endif diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/integration/gnome/include/ccs_gnome_integration_types.h~ compiz-0.9.8.4/compizconfig/integration/gnome/include/ccs_gnome_integration_types.h~ --- compiz-0.9.8.2+bzr3377/compizconfig/integration/gnome/include/ccs_gnome_integration_types.h~ 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/integration/gnome/include/ccs_gnome_integration_types.h~ 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -#ifndef _CCS_GNOME_INTEGRATION_TYPES_H -#define _CCS_GNOME_INTEGRATION_TYPES_H - -#include - -COMPIZCONFIG_BEGIN_DECLS - -typedef struct _CCSBackend CCSBackend; -typedef struct _CCSContext CCSContext; -typedef struct _CCSObjectAllocationInterface CCSObjectAllocationInterface; -typedef struct _CCSIntegration CCSIntegration; -typedef struct _CCSIntegratedSetting CCSIntegratedSetting; -typedef struct _CCSIntegratedSettingFactory CCSIntegratedSettingFactory; -typedef struct _CCSIntegratedSettingsStorage CCSIntegratedSettingsStorage; -typedef struct _GConfClient GConfClient; - -typedef enum { - OptionInt, - OptionBool, - OptionKey, - OptionString, - OptionSpecial, -} SpecialOptionType; - -#endif - diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/integration/gnome/src/ccs_gnome_integrated_setting.c compiz-0.9.8.4/compizconfig/integration/gnome/src/ccs_gnome_integrated_setting.c --- compiz-0.9.8.2+bzr3377/compizconfig/integration/gnome/src/ccs_gnome_integrated_setting.c 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/integration/gnome/src/ccs_gnome_integrated_setting.c 2012-09-27 11:04:02.000000000 +0000 @@ -12,6 +12,8 @@ INTERFACE_TYPE (CCSGNOMEIntegratedSettingInfoInterface); +CCSREF_OBJ (GNOMEIntegratedSettingInfo, CCSGNOMEIntegratedSettingInfo); + SpecialOptionType ccsGNOMEIntegratedSettingInfoGetSpecialOptionType (CCSGNOMEIntegratedSettingInfo *info) { @@ -89,7 +91,7 @@ } void -ccsGNOMEIntegratedSettingInfoFree (CCSIntegratedSettingInfo *info) +ccsGNOMESharedIntegratedSettingInfoFree (CCSIntegratedSettingInfo *info) { CCSGNOMEIntegratedSettingInfoDefaultImplPrivate *priv = (CCSGNOMEIntegratedSettingInfoDefaultImplPrivate *) ccsObjectGetPrivate (info); @@ -99,10 +101,17 @@ (*info->object.object_allocation->free_) (info->object.object_allocation->allocator, info); } +static void +ccsGNOMEIntegratedSettingInfoFree (CCSGNOMEIntegratedSettingInfo *info) +{ + ccsGNOMESharedIntegratedSettingInfoFree ((CCSIntegratedSettingInfo *) info); +} + CCSGNOMEIntegratedSettingInfoInterface ccsGNOMEIntegratedSettingInfoDefaultImplInterface = { ccsGNOMEIntegratedSettingGetSpecialOptionDefault, - ccsGNOMEIntegratedSettingGetGNOMENameDefault + ccsGNOMEIntegratedSettingGetGNOMENameDefault, + ccsGNOMEIntegratedSettingInfoFree }; const CCSIntegratedSettingInfoInterface ccsGNOMEIntegratedSettingInfoInterface = @@ -110,9 +119,15 @@ ccsGNOMEIntegratedSettingInfoPluginName, ccsGNOMEIntegratedSettingInfoSettingName, ccsGNOMEIntegratedSettingInfoGetType, - ccsGNOMEIntegratedSettingInfoFree + ccsGNOMESharedIntegratedSettingInfoFree }; +void +ccsFreeGNOMEIntegratedSettingInfo (CCSGNOMEIntegratedSettingInfo *info) +{ + (*(GET_INTERFACE (CCSGNOMEIntegratedSettingInfoInterface, info))->free) (info); +} + CCSGNOMEIntegratedSettingInfo * ccsGNOMEIntegratedSettingInfoNew (CCSIntegratedSettingInfo *base, SpecialOptionType type, diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/integration/gnome/src/ccs_gnome_integration.c compiz-0.9.8.4/compizconfig/integration/gnome/src/ccs_gnome_integration.c --- compiz-0.9.8.2+bzr3377/compizconfig/integration/gnome/src/ccs_gnome_integration.c 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/integration/gnome/src/ccs_gnome_integration.c 2012-09-27 11:04:02.000000000 +0000 @@ -132,9 +132,12 @@ CCSSettingType type = TypeString; CCSSettingValue *v = ccsIntegratedSettingReadValue (mouseButtonModifierSetting, type); - modMask = ccsStringToModifiers (v->value.asString); + if (v) + { + modMask = ccsStringToModifiers (v->value.asString); - ccsFreeSettingValueWithType (v, type); + ccsFreeSettingValueWithType (v, type); + } return modMask; } @@ -157,6 +160,29 @@ } static Bool +ccsGNOMEIntegrationBackendReadISAndSetSettingForType (CCSIntegratedSetting *integratedSetting, + CCSSetting *setting, + CCSSettingValue **v, + CCSSettingType type) +{ + *v = ccsIntegratedSettingReadValue (integratedSetting, type); + + if ((*v)->value.asString) + { + CCSSettingKeyValue key; + + memset (&key, 0, sizeof (CCSSettingKeyValue)); + if (ccsStringToKeyBinding ((*v)->value.asString, &key)) + { + ccsSetKey (setting, key, TRUE); + return TRUE; + } + } + + return FALSE; +} + +static Bool ccsGNOMEIntegrationBackendReadOptionIntoSetting (CCSIntegration *integration, CCSContext *context, CCSSetting *setting, @@ -206,20 +232,11 @@ case OptionKey: { type = TypeKey; - v = ccsIntegratedSettingReadValue (integratedSetting, type); - - if (v->value.asString) - { - CCSSettingKeyValue key; - - memset (&key, 0, sizeof (CCSSettingKeyValue)); - ccsGetKey (setting, &key); - if (ccsStringToKeyBinding (v->value.asString, &key)) - { - ccsSetKey (setting, key, TRUE); - ret = TRUE; - } - } + if (ccsGNOMEIntegrationBackendReadISAndSetSettingForType (integratedSetting, + setting, + &v, + type)) + ret = TRUE; } break; case OptionSpecial: @@ -265,6 +282,17 @@ ret = TRUE; } } + else if ((strcmp (settingName, "run_command_screenshot_key") == 0 || + strcmp (settingName, "run_command_window_screenshot_key") == 0 || + strcmp (settingName, "run_command_terminal_key") == 0)) + { + type = TypeString; + if (ccsGNOMEIntegrationBackendReadISAndSetSettingForType (integratedSetting, + setting, + &v, + type)) + ret = TRUE; + } else if (((strcmp (settingName, "initiate_button") == 0) && ((strcmp (pluginName, "move") == 0) || (strcmp (pluginName, "resize") == 0))) || @@ -370,6 +398,29 @@ } } +static Bool +ccsGNOMEIntegrationBackendKeyValueToStringValue (CCSSettingValue *keyValue, + CCSSettingValue *stringValue) +{ + char *newValue; + + newValue = ccsKeyBindingToString (&keyValue->value.asKey); + if (newValue) + { + if (strcmp (newValue, "Disabled") == 0) + { + /* Metacity doesn't like "Disabled", it wants "disabled" */ + newValue[0] = 'd'; + } + + stringValue->value.asString = newValue; + + return TRUE; + } + + return FALSE; +} + static void ccsGNOMEIntegrationBackendWriteOptionFromSetting (CCSIntegration *integration, CCSContext *context, @@ -390,7 +441,14 @@ /* Do not allow recursing back into writeIntegratedSetting */ ccsIntegrationDisallowIntegratedWrites (integration); - CCSSettingValue *v = ccsSettingGetValue (setting); + CCSSettingType sType = ccsSettingGetType (setting); + CCSSettingInfo *sInfo = ccsSettingGetInfo (setting); + + CCSSettingValue *vSetting = ccsSettingGetValue (setting); + CCSSettingValue *v = ccsCopyValue (vSetting, sType, sInfo); + + if (!v) + return; switch (ccsGNOMEIntegratedSettingInfoGetSpecialOptionType ((CCSGNOMEIntegratedSettingInfo *) integratedSetting)) { @@ -405,25 +463,22 @@ break; case OptionKey: { - char *newValue; + CCSSettingValue *newValue = calloc (1, sizeof (CCSSettingValue)); - newValue = ccsKeyBindingToString (&(ccsSettingGetValue (setting)->value.asKey)); - if (newValue) - { - if (strcmp (newValue, "Disabled") == 0) - { - /* Metacity doesn't like "Disabled", it wants "disabled" */ - newValue[0] = 'd'; - } + newValue->isListChild = FALSE; + newValue->parent = NULL; + newValue->refCount = 1; + if (ccsGNOMEIntegrationBackendKeyValueToStringValue (v, newValue)) + { /* Really this is a lie - the writer expects a string * but it needs to know if its a key or a string */ type = TypeKey; - v->value.asString = newValue; - - ccsIntegratedSettingWriteValue (integratedSetting, v, type); - free (newValue); + ccsIntegratedSettingWriteValue (integratedSetting, newValue, type); } + + if (newValue) + ccsFreeSettingValueWithType (newValue, TypeString); } break; case OptionSpecial: @@ -445,7 +500,7 @@ } else if (strcmp (settingName, "fullscreen_visual_bell") == 0) { - const char *newValueString = v->value.asString ? "fullscreen" : "frame_flash"; + const char *newValueString = v->value.asBool ? "fullscreen" : "frame_flash"; newValue->value.asString = strdup (newValueString); type = TypeString; @@ -453,12 +508,24 @@ } else if (strcmp (settingName, "click_to_focus") == 0) { - const char *newValueString = v->value.asString ? "click" : "sloppy"; + const char *newValueString = v->value.asBool ? "click" : "sloppy"; newValue->value.asString = strdup (newValueString); type = TypeString; ccsIntegratedSettingWriteValue (integratedSetting, newValue, type); } + else if ((strcmp (settingName, "run_command_screenshot_key") == 0 || + strcmp (settingName, "run_command_window_screenshot_key") == 0 || + strcmp (settingName, "run_command_terminal_key") == 0)) + { + if (ccsGNOMEIntegrationBackendKeyValueToStringValue (v, newValue)) + { + /* These are actually stored as strings in the schemas */ + type = TypeString; + ccsIntegratedSettingWriteValue (integratedSetting, newValue, type); + } + + } else if (((strcmp (settingName, "initiate_button") == 0) && ((strcmp (pluginName, "move") == 0) || (strcmp (pluginName, "resize") == 0))) || @@ -468,9 +535,9 @@ unsigned int modMask; Bool resizeWithRightButton = FALSE; - if ((getButtonBindingForSetting (context, "resize", + if ((getButtonBindingForSetting (priv->context, "resize", "initiate_button") == 3) || - (getButtonBindingForSetting (context, "core", + (getButtonBindingForSetting (priv->context, "core", "window_menu_button") == 2)) { resizeWithRightButton = TRUE; @@ -489,16 +556,16 @@ ccsGNOMEIntegratedPluginNames.SPECIAL, ccsGNOMEIntegratedSettingNames.NULL_MOUSE_BUTTON_MODIFIER.compizName); - modMask = ccsSettingGetValue (setting)->value.asButton.buttonModMask; + modMask = v->value.asButton.buttonModMask; if (setGnomeMouseButtonModifier (integratedSettingsMBM->data, modMask)) { - setButtonBindingForSetting (context, "move", + setButtonBindingForSetting (priv->context, "move", "initiate_button", 1, modMask); - setButtonBindingForSetting (context, "resize", + setButtonBindingForSetting (priv->context, "resize", "initiate_button", resizeWithRightButton ? 3 : 2, modMask); - setButtonBindingForSetting (context, "core", + setButtonBindingForSetting (priv->context, "core", "window_menu_button", resizeWithRightButton ? 2 : 3, modMask); @@ -517,6 +584,9 @@ g_error_free (err); } + if (v) + ccsFreeSettingValueWithType (v, sType); + /* we should immediately write changed settings */ ccsWriteChangedSettings (priv->context); ccsIntegrationAllowIntegratedWrites (integration); diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/integration/gnome/src/ccs_gnome_integration_constants.c compiz-0.9.8.4/compizconfig/integration/gnome/src/ccs_gnome_integration_constants.c --- compiz-0.9.8.2+bzr3377/compizconfig/integration/gnome/src/ccs_gnome_integration_constants.c 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/integration/gnome/src/ccs_gnome_integration_constants.c 2012-09-27 11:04:02.000000000 +0000 @@ -431,10 +431,14 @@ static const char *org_compiz_integrated = "org.compiz.integrated"; static const char *org_gnome_desktop_wm_keybindings = "org.gnome.desktop.wm.keybindings"; static const char *org_gnome_desktop_wm_preferences = "org.gnome.desktop.wm.preferences"; + static const char *org_gnome_settings_daemon_plugins_media_keys = "org.gnome.settings-daemon.plugins.media-keys"; + static const char *org_gnome_desktop_default_applications_terminal = "org.gnome.desktop.default-applications.terminal"; quarks->ORG_COMPIZ_INTEGRATED = g_quark_from_string (org_compiz_integrated); quarks->ORG_GNOME_DESKTOP_WM_KEYBINDINGS = g_quark_from_string (org_gnome_desktop_wm_keybindings); quarks->ORG_GNOME_DESKTOP_WM_PREFERENCES = g_quark_from_string (org_gnome_desktop_wm_preferences); + quarks->ORG_GNOME_SETTINGS_DAEMON_PLUGINS_MEDIA_KEYS = g_quark_from_string (org_gnome_settings_daemon_plugins_media_keys); + quarks->ORG_GNOME_DESKTOP_DEFAULT_APPLICATIONS_TERMINAL = g_quark_from_string (org_gnome_desktop_default_applications_terminal); return NULL; } @@ -501,7 +505,7 @@ g_hash_table_insert (coreHashTable, (gpointer) names->CORE_AUTORAISE_DELAY.compizName, GINT_TO_POINTER (quarks->ORG_GNOME_DESKTOP_WM_PREFERENCES)); g_hash_table_insert (coreHashTable, (gpointer) names->CORE_AUTORAISE.compizName, GINT_TO_POINTER (quarks->ORG_GNOME_DESKTOP_WM_PREFERENCES)); g_hash_table_insert (thumbnailHashTable, (gpointer) names->THUMBNAIL_CURRENT_VIEWPORT.compizName, GINT_TO_POINTER (quarks->ORG_COMPIZ_INTEGRATED)); - g_hash_table_insert (gnomecompatHashTable, (gpointer) names->GNOMECOMPAT_COMMAND_TERMINAL.compizName, GINT_TO_POINTER (quarks->ORG_COMPIZ_INTEGRATED)); + g_hash_table_insert (gnomecompatHashTable, (gpointer) names->GNOMECOMPAT_COMMAND_TERMINAL.compizName, GINT_TO_POINTER (quarks->ORG_GNOME_DESKTOP_DEFAULT_APPLICATIONS_TERMINAL)); g_hash_table_insert (gnomecompatHashTable, (gpointer) names->GNOMECOMPAT_COMMAND_WINDOW_SCREENSHOT.compizName, GINT_TO_POINTER (quarks->ORG_COMPIZ_INTEGRATED)); g_hash_table_insert (gnomecompatHashTable, (gpointer) names->GNOMECOMPAT_COMMAND_SCREENSHOT.compizName, GINT_TO_POINTER (quarks->ORG_COMPIZ_INTEGRATED)); g_hash_table_insert (rotateHashTable, (gpointer) names->ROTATE_ROTATE_RIGHT_WINDOW_KEY.compizName, GINT_TO_POINTER (quarks->ORG_GNOME_DESKTOP_WM_KEYBINDINGS)); @@ -609,11 +613,11 @@ g_hash_table_insert (coreHashTable, (gpointer) names->CORE_MAXIMIZE_WINDOW_KEY.compizName, GINT_TO_POINTER (quarks->ORG_GNOME_DESKTOP_WM_KEYBINDINGS)); g_hash_table_insert (coreHashTable, (gpointer) names->CORE_MINIMIZE_WINDOW_KEY.compizName, GINT_TO_POINTER (quarks->ORG_GNOME_DESKTOP_WM_KEYBINDINGS)); g_hash_table_insert (coreHashTable, (gpointer) names->CORE_TOGGLE_WINDOW_MAXIMIZED_KEY.compizName, GINT_TO_POINTER (quarks->ORG_GNOME_DESKTOP_WM_KEYBINDINGS)); - g_hash_table_insert (gnomecompatHashTable, (gpointer) names->GNOMECOMPAT_RUN_COMMAND_TERMINAL_KEY.compizName, GINT_TO_POINTER (quarks->ORG_COMPIZ_INTEGRATED)); - g_hash_table_insert (gnomecompatHashTable, (gpointer) names->GNOMECOMPAT_RUN_COMMAND_WINDOW_SCREENSHOT_KEY.compizName, GINT_TO_POINTER (quarks->ORG_COMPIZ_INTEGRATED)); - g_hash_table_insert (gnomecompatHashTable, (gpointer) names->GNOMECOMPAT_RUN_COMMAND_SCREENSHOT_KEY.compizName, GINT_TO_POINTER (quarks->ORG_COMPIZ_INTEGRATED)); - g_hash_table_insert (gnomecompatHashTable, (gpointer) names->GNOMECOMPAT_MAIN_MENU_KEY.compizName, GINT_TO_POINTER (quarks->ORG_COMPIZ_INTEGRATED)); - g_hash_table_insert (gnomecompatHashTable, (gpointer) names->GNOMECOMPAT_RUN_KEY.compizName, GINT_TO_POINTER (quarks->ORG_COMPIZ_INTEGRATED)); + g_hash_table_insert (gnomecompatHashTable, (gpointer) names->GNOMECOMPAT_RUN_COMMAND_TERMINAL_KEY.compizName, GINT_TO_POINTER (quarks->ORG_GNOME_SETTINGS_DAEMON_PLUGINS_MEDIA_KEYS)); + g_hash_table_insert (gnomecompatHashTable, (gpointer) names->GNOMECOMPAT_RUN_COMMAND_WINDOW_SCREENSHOT_KEY.compizName, GINT_TO_POINTER (quarks->ORG_GNOME_SETTINGS_DAEMON_PLUGINS_MEDIA_KEYS)); + g_hash_table_insert (gnomecompatHashTable, (gpointer) names->GNOMECOMPAT_RUN_COMMAND_SCREENSHOT_KEY.compizName, GINT_TO_POINTER (quarks->ORG_GNOME_SETTINGS_DAEMON_PLUGINS_MEDIA_KEYS)); + g_hash_table_insert (gnomecompatHashTable, (gpointer) names->GNOMECOMPAT_MAIN_MENU_KEY.compizName, GINT_TO_POINTER (quarks->ORG_GNOME_DESKTOP_WM_KEYBINDINGS)); + g_hash_table_insert (gnomecompatHashTable, (gpointer) names->GNOMECOMPAT_RUN_KEY.compizName, GINT_TO_POINTER (quarks->ORG_GNOME_DESKTOP_WM_KEYBINDINGS)); g_hash_table_insert (unityshellHashTable, (gpointer) names->UNITYSHELL_SHOW_HUD.compizName, GINT_TO_POINTER (quarks->ORG_COMPIZ_INTEGRATED)); return masterHashTable; @@ -937,9 +941,9 @@ g_hash_table_insert (coreHashTable, (gpointer) names->CORE_MAXIMIZE_WINDOW_KEY.compizName, GINT_TO_POINTER (OptionKey)); g_hash_table_insert (coreHashTable, (gpointer) names->CORE_MINIMIZE_WINDOW_KEY.compizName, GINT_TO_POINTER (OptionKey)); g_hash_table_insert (coreHashTable, (gpointer) names->CORE_TOGGLE_WINDOW_MAXIMIZED_KEY.compizName, GINT_TO_POINTER (OptionKey)); - g_hash_table_insert (gnomecompatHashTable, (gpointer) names->GNOMECOMPAT_RUN_COMMAND_TERMINAL_KEY.compizName, GINT_TO_POINTER (OptionKey)); - g_hash_table_insert (gnomecompatHashTable, (gpointer) names->GNOMECOMPAT_RUN_COMMAND_WINDOW_SCREENSHOT_KEY.compizName, GINT_TO_POINTER (OptionKey)); - g_hash_table_insert (gnomecompatHashTable, (gpointer) names->GNOMECOMPAT_RUN_COMMAND_SCREENSHOT_KEY.compizName, GINT_TO_POINTER (OptionKey)); + g_hash_table_insert (gnomecompatHashTable, (gpointer) names->GNOMECOMPAT_RUN_COMMAND_TERMINAL_KEY.compizName, GINT_TO_POINTER (OptionSpecial)); + g_hash_table_insert (gnomecompatHashTable, (gpointer) names->GNOMECOMPAT_RUN_COMMAND_WINDOW_SCREENSHOT_KEY.compizName, GINT_TO_POINTER (OptionSpecial)); + g_hash_table_insert (gnomecompatHashTable, (gpointer) names->GNOMECOMPAT_RUN_COMMAND_SCREENSHOT_KEY.compizName, GINT_TO_POINTER (OptionSpecial)); g_hash_table_insert (gnomecompatHashTable, (gpointer) names->GNOMECOMPAT_MAIN_MENU_KEY.compizName, GINT_TO_POINTER (OptionKey)); g_hash_table_insert (gnomecompatHashTable, (gpointer) names->GNOMECOMPAT_RUN_KEY.compizName, GINT_TO_POINTER (OptionKey)); g_hash_table_insert (unityshellHashTable, (gpointer) names->UNITYSHELL_SHOW_HUD.compizName, GINT_TO_POINTER (OptionKey)); diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/integration/gnome/tests/CMakeLists.txt compiz-0.9.8.4/compizconfig/integration/gnome/tests/CMakeLists.txt --- compiz-0.9.8.2+bzr3377/compizconfig/integration/gnome/tests/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/integration/gnome/tests/CMakeLists.txt 2012-09-27 11:04:02.000000000 +0000 @@ -0,0 +1,47 @@ +include_directories (${GTEST_INCLUDE_DIRS}) +include_directories (${CMAKE_SOURCE_DIR}/include) +include_directories (${CMAKE_SOURCE_DIR}/tests/shared) +include_directories (${CMAKE_SOURCE_DIR}/tests/shared/glib) +include_directories (${CMAKE_CURRENT_SOURCE_DIR}/../../../mocks/libcompizconfig) +include_directories (${CMAKE_CURRENT_SOURCE_DIR}/../../../gsettings/tests) +include_directories (${CMAKE_CURRENT_SOURCE_DIR}/../../../gsettings/mocks) +include_directories (${CMAKE_SOURCE_DIR}/compizconfig/tests) +link_directories (${CMAKE_INSTALL_PREFIX}/lib) + +set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") + +add_library (compizconfig_ccs_mock_gnome_integrated_setting_composition + ${CMAKE_CURRENT_SOURCE_DIR}/compizconfig_ccs_mock_gnome_integrated_setting_composition.c) + +target_link_libraries (compizconfig_ccs_mock_gnome_integrated_setting_composition + compizconfig_ccs_integrated_setting_mock + compizconfig_gnome_integrated_setting + compizconfig) + +add_executable (compizconfig_test_ccs_gnome_integration + ${CMAKE_CURRENT_SOURCE_DIR}/compizconfig_test_ccs_gnome_integration.cpp) + +target_link_libraries (compizconfig_test_ccs_gnome_integration + ${GTEST_BOTH_LIBRARIES} + ${GMOCK_LIBRARY} + ${GMOCK_MAIN_LIBRARY} + ${CMAKE_THREAD_LIBS_INIT} + ${LIBCOMPIZCONFIG_LIBRARIES} + compizconfig + compizconfig_ccs_context_mock + compizconfig_ccs_backend_mock + compizconfig_ccs_setting_mock + compizconfig_ccs_plugin_mock + compizconfig_ccs_list_wrapper + compizconfig_ccs_setting_value_operators + compizconfig_ccs_setting_value_matcher + compizconfig_ccs_integrated_setting_mock + compizconfig_ccs_integrated_setting_factory_mock + compizconfig_ccs_integrated_setting_storage_mock + compizconfig_ccs_mock_gnome_integrated_setting_composition + compizconfig_gnome_integration) + +compiz_discover_tests (compizconfig_test_ccs_gnome_integration + COVERAGE + compizconfig_gnome_integration + compizconfig_gnome_integration_constants) diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/integration/gnome/tests/compizconfig_ccs_mock_gnome_integrated_setting_composition.c compiz-0.9.8.4/compizconfig/integration/gnome/tests/compizconfig_ccs_mock_gnome_integrated_setting_composition.c --- compiz-0.9.8.2+bzr3377/compizconfig/integration/gnome/tests/compizconfig_ccs_mock_gnome_integrated_setting_composition.c 1970-01-01 00:00:00.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/integration/gnome/tests/compizconfig_ccs_mock_gnome_integrated_setting_composition.c 2012-09-27 11:04:02.000000000 +0000 @@ -0,0 +1,220 @@ +/* + * Compiz configuration system library + * + * Copyright (C) 2012 Canonical Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authored By: + * Sam Spilsbury + */ + +#include +#include +#include +#include "compizconfig_ccs_mock_gnome_integrated_setting_composition.h" + +typedef struct _CCSMockGNOMEIntegratedSettingCompositionPrivate +{ + CCSIntegratedSetting *integratedSetting; + CCSGNOMEIntegratedSettingInfo *gnomeIntegratedSettingInfo; + CCSIntegratedSettingInfo *integratedSettingInfo; +} CCSMockGNOMEIntegratedSettingCompositionPrivate; + +static CCSIntegratedSetting * +allocateCCSIntegratedSetting (CCSObjectAllocationInterface *allocator) +{ + CCSIntegratedSetting *setting = + (*allocator->calloc_) (allocator->allocator, + 1, + sizeof (CCSIntegratedSetting)); + + ccsObjectInit (setting, allocator); + + return setting; +} + +static CCSMockGNOMEIntegratedSettingCompositionPrivate * +allocatePrivate (CCSIntegratedSetting *integratedSetting, + CCSObjectAllocationInterface *allocator) +{ + CCSMockGNOMEIntegratedSettingCompositionPrivate *priv = + (*allocator->calloc_) (allocator->allocator, + 1, + sizeof (CCSMockGNOMEIntegratedSettingCompositionPrivate)); + + if (!priv) + { + ccsObjectFinalize (integratedSetting); + (*allocator->free_) (allocator->allocator, integratedSetting); + return NULL; + } + + return priv; +} + +static SpecialOptionType +ccsMockCompositionIntegratedSettingGetSpecialOptionType (CCSGNOMEIntegratedSettingInfo *setting) +{ + CCSMockGNOMEIntegratedSettingCompositionPrivate *priv = GET_PRIVATE (CCSMockGNOMEIntegratedSettingCompositionPrivate, setting); + + return ccsGNOMEIntegratedSettingInfoGetSpecialOptionType (priv->gnomeIntegratedSettingInfo); +} + +static const char * +ccsMockCompositionIntegratedSettingGetGNOMEName (CCSGNOMEIntegratedSettingInfo *setting) +{ + CCSMockGNOMEIntegratedSettingCompositionPrivate *priv = GET_PRIVATE (CCSMockGNOMEIntegratedSettingCompositionPrivate, setting); + + return ccsGNOMEIntegratedSettingInfoGetGNOMEName (priv->gnomeIntegratedSettingInfo); +} + +static CCSSettingValue * +ccsMockCompositionIntegratedSettingReadValue (CCSIntegratedSetting *setting, CCSSettingType type) +{ + CCSMockGNOMEIntegratedSettingCompositionPrivate *priv = + GET_PRIVATE (CCSMockGNOMEIntegratedSettingCompositionPrivate, setting); + + return ccsIntegratedSettingReadValue (priv->integratedSetting, type); +} + +static void +ccsMockCompositionIntegratedSettingWriteValue (CCSIntegratedSetting *setting, CCSSettingValue *v, CCSSettingType type) +{ + CCSMockGNOMEIntegratedSettingCompositionPrivate *priv = + GET_PRIVATE (CCSMockGNOMEIntegratedSettingCompositionPrivate, setting); + + ccsIntegratedSettingWriteValue (priv->integratedSetting, v, type); +} + +static const char * +ccsMockCompositionIntegratedSettingInfoPluginName (CCSIntegratedSettingInfo *setting) +{ + CCSMockGNOMEIntegratedSettingCompositionPrivate *priv = GET_PRIVATE (CCSMockGNOMEIntegratedSettingCompositionPrivate, setting); + + return ccsIntegratedSettingInfoPluginName (priv->integratedSettingInfo); +} + +static const char * +ccsMockCompositionIntegratedSettingInfoSettingName (CCSIntegratedSettingInfo *setting) +{ + CCSMockGNOMEIntegratedSettingCompositionPrivate *priv = GET_PRIVATE (CCSMockGNOMEIntegratedSettingCompositionPrivate, setting); + + return ccsIntegratedSettingInfoSettingName (priv->integratedSettingInfo); +} + +static CCSSettingType +ccsMockCompositionIntegratedSettingInfoGetType (CCSIntegratedSettingInfo *setting) +{ + CCSMockGNOMEIntegratedSettingCompositionPrivate *priv = GET_PRIVATE (CCSMockGNOMEIntegratedSettingCompositionPrivate, setting); + + return ccsIntegratedSettingInfoGetType (priv->integratedSettingInfo); +} + +static void +ccsMockCompositionIntegratedSettingFree (CCSIntegratedSetting *integratedSetting) +{ + CCSMockGNOMEIntegratedSettingCompositionPrivate *priv = + GET_PRIVATE (CCSMockGNOMEIntegratedSettingCompositionPrivate, integratedSetting); + + ccsIntegratedSettingUnref (priv->integratedSetting); + ccsGNOMEIntegratedSettingInfoUnref (priv->gnomeIntegratedSettingInfo); + + ccsObjectFinalize (integratedSetting); + (*integratedSetting->object.object_allocation->free_) + (integratedSetting->object.object_allocation->allocator, integratedSetting); +} + +static void +ccsMockCompositionIntegratedSettingInfoFree (CCSIntegratedSettingInfo *info) +{ + return ccsMockCompositionIntegratedSettingFree ((CCSIntegratedSetting *) info); +} + +static void +ccsMockCompositionGNOMEIntegratedSettingInfoFree (CCSGNOMEIntegratedSettingInfo *info) +{ + return ccsMockCompositionIntegratedSettingFree ((CCSIntegratedSetting *) info); +} + +const CCSGNOMEIntegratedSettingInfoInterface ccsMockCompositionGNOMEIntegratedSettingInfo = +{ + ccsMockCompositionIntegratedSettingGetSpecialOptionType, + ccsMockCompositionIntegratedSettingGetGNOMEName, + ccsMockCompositionGNOMEIntegratedSettingInfoFree +}; + +const CCSIntegratedSettingInterface ccsMockCompositionIntegratedSetting = +{ + ccsMockCompositionIntegratedSettingReadValue, + ccsMockCompositionIntegratedSettingWriteValue, + ccsMockCompositionIntegratedSettingFree +}; + +const CCSIntegratedSettingInfoInterface ccsMockCompositionIntegratedSettingInfo = +{ + ccsMockCompositionIntegratedSettingInfoPluginName, + ccsMockCompositionIntegratedSettingInfoSettingName, + ccsMockCompositionIntegratedSettingInfoGetType, + ccsMockCompositionIntegratedSettingInfoFree +}; + +CCSIntegratedSetting * +ccsMockCompositionIntegratedSettingNew (CCSIntegratedSetting *integratedSetting, + CCSGNOMEIntegratedSettingInfo *gnomeInfo, + CCSIntegratedSettingInfo *settingInfo, + CCSObjectAllocationInterface *allocator) +{ + CCSIntegratedSetting *composition = allocateCCSIntegratedSetting (allocator); + + if (!composition) + return NULL; + + CCSMockGNOMEIntegratedSettingCompositionPrivate *priv = allocatePrivate (composition, + allocator); + + if (!priv) + return NULL; + + const CCSInterface *integratedSettingImpl = + (const CCSInterface *) (&ccsMockCompositionIntegratedSetting); + const CCSInterface *integratedSettingInfoImpl = + (const CCSInterface *) (&ccsMockCompositionIntegratedSettingInfo); + const CCSInterface *gnomeSettingImpl = + (const CCSInterface *) (&ccsMockCompositionGNOMEIntegratedSettingInfo); + + priv->integratedSetting = integratedSetting; + priv->gnomeIntegratedSettingInfo = gnomeInfo; + priv->integratedSettingInfo = settingInfo; + + ccsIntegratedSettingRef (priv->integratedSetting); + ccsGNOMEIntegratedSettingInfoRef (priv->gnomeIntegratedSettingInfo); + + ccsObjectSetPrivate (composition, (CCSPrivate *) (priv)); + ccsObjectAddInterface (composition, + integratedSettingImpl, + GET_INTERFACE_TYPE (CCSIntegratedSettingInterface)); + ccsObjectAddInterface (composition, + integratedSettingInfoImpl, + GET_INTERFACE_TYPE (CCSIntegratedSettingInfoInterface)); + ccsObjectAddInterface (composition, + gnomeSettingImpl, + GET_INTERFACE_TYPE (CCSGNOMEIntegratedSettingInfoInterface)); + + ccsObjectRef (composition); + + return composition; +} + diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/integration/gnome/tests/compizconfig_ccs_mock_gnome_integrated_setting_composition.h compiz-0.9.8.4/compizconfig/integration/gnome/tests/compizconfig_ccs_mock_gnome_integrated_setting_composition.h --- compiz-0.9.8.2+bzr3377/compizconfig/integration/gnome/tests/compizconfig_ccs_mock_gnome_integrated_setting_composition.h 1970-01-01 00:00:00.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/integration/gnome/tests/compizconfig_ccs_mock_gnome_integrated_setting_composition.h 2012-09-27 11:04:02.000000000 +0000 @@ -0,0 +1,42 @@ +/* + * Compiz configuration system library + * + * Copyright (C) 2012 Canonical Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authored By: + * Sam Spilsbury + */ +#ifndef _COMPIZCONFIG_CCS_MOCK_GNOME_INTEGRATED_SETTING_COMPOSITION_H +#define _COMPIZCONFIG_CCS_MOCK_GNOME_INTEGRATED_SETTING_COMPOSITION_H + +COMPIZCONFIG_BEGIN_DECLS + +typedef struct _CCSIntegratedSetting CCSIntegratedSetting; +typedef struct _CCSGNOMEIntegratedSettingInfo CCSGNOMEIntegratedSettingInfo; +typedef struct _CCSIntegratedSettingInfo CCSIntegratedSettingInfo; +typedef struct _CCSObjectAllocationInterface CCSObjectAllocationInterface; + +CCSIntegratedSetting * +ccsMockCompositionIntegratedSettingNew (CCSIntegratedSetting *integratedSetting, + CCSGNOMEIntegratedSettingInfo *gnomeInfo, + CCSIntegratedSettingInfo *settingInfo, + CCSObjectAllocationInterface *allocator); + +COMPIZCONFIG_END_DECLS + +#endif + diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/integration/gnome/tests/compizconfig_test_ccs_gnome_integration.cpp compiz-0.9.8.4/compizconfig/integration/gnome/tests/compizconfig_test_ccs_gnome_integration.cpp --- compiz-0.9.8.2+bzr3377/compizconfig/integration/gnome/tests/compizconfig_test_ccs_gnome_integration.cpp 1970-01-01 00:00:00.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/integration/gnome/tests/compizconfig_test_ccs_gnome_integration.cpp 2012-09-27 11:04:02.000000000 +0000 @@ -0,0 +1,959 @@ +/* + * Compiz configuration system library + * + * Copyright (C) 2012 Canonical Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authored By: + * Sam Spilsbury + */ +#include + +#include +#include + +#include +#include + +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "compizconfig_ccs_mock_gnome_integrated_setting_composition.h" +#include "compizconfig_ccs_setting_value_matcher.h" + +namespace cc = compiz::config; +namespace cci = compiz::config::impl; + +using ::testing::Pointee; +using ::testing::Eq; +using ::testing::Return; +using ::testing::ReturnNull; +using ::testing::SetArgPointee; +using ::testing::DoAll; +using ::testing::Values; +using ::testing::WithParamInterface; +using ::testing::_; + +namespace +{ + typedef std::tr1::tuple > IntegratedSettingWithMock; + + typedef boost::shared_ptr IntegratedSettingWithMockPtr; + + IntegratedSettingWithMockPtr + createIntegratedSettingCompositionFromMock (const std::string &plugin, + const std::string &setting, + CCSSettingType type, + SpecialOptionType gnomeType, + const std::string &gnomeName, + CCSObjectAllocationInterface *allocator) + { + CCSIntegratedSettingInfo *integratedSettingInfo = + ccsSharedIntegratedSettingInfoNew (plugin.c_str (), + setting.c_str (), + type, + allocator); + /* This takes ownership of integratedSettingInfo */ + CCSGNOMEIntegratedSettingInfo *gnomeIntegratedSettingInfo = + ccsGNOMEIntegratedSettingInfoNew (integratedSettingInfo, + gnomeType, + gnomeName.c_str (), + allocator); + CCSIntegratedSetting *integratedSetting = + ccsMockIntegratedSettingNew (allocator); + + CCSIntegratedSettingGMock *mockPtr = GET_PRIVATE (CCSIntegratedSettingGMock, integratedSetting) + CCSIntegratedSettingGMock &mock (*mockPtr); + + boost::shared_ptr composition = + AutoDestroy (ccsMockCompositionIntegratedSettingNew (integratedSetting, + gnomeIntegratedSettingInfo, + integratedSettingInfo, + allocator), + ccsIntegratedSettingUnref); + + /* We want the composition to take ownership here, so unref the + * original members of the composition */ + ccsGNOMEIntegratedSettingInfoUnref (gnomeIntegratedSettingInfo); + ccsIntegratedSettingUnref (integratedSetting); + + return boost::make_shared (mock, composition); + } + + CCSIntegratedSettingGMock & + Mock (IntegratedSettingWithMock &integratedSettingWithMocks) + { + return std::tr1::get <0> (integratedSettingWithMocks); + } + + CCSIntegratedSetting * + Real (IntegratedSettingWithMock &integratedSettingWithMocks) + { + return std::tr1::get <1> (integratedSettingWithMocks).get (); + } + + typedef std::tr1::tuple , + boost::shared_ptr , + CCSIntegratedSettingsStorage *, + CCSIntegratedSettingFactory *, + boost::shared_ptr > CCSGNOMEIntegrationWithMocks; + + CCSGNOMEIntegrationWithMocks + createIntegrationWithMocks (CCSObjectAllocationInterface *ai) + { + boost::shared_ptr context (AutoDestroy (ccsMockContextNew (), + ccsFreeContext)); + boost::shared_ptr backend (AutoDestroy (ccsMockBackendNew (), + ccsFreeMockBackend)); + /* The GNOME Integration backend takes ownership of these two */ + CCSIntegratedSettingsStorage *storage (ccsMockIntegratedSettingsStorageNew (ai)); + CCSIntegratedSettingFactory *factory (ccsMockIntegratedSettingFactoryNew (ai)); + boost::shared_ptr integration (AutoDestroy (ccsGNOMEIntegrationBackendNew (backend.get (), + context.get (), + factory, + storage, + ai), + ccsIntegrationUnref)); + + CCSContextGMock &gmockContext = *(reinterpret_cast (ccsObjectGetPrivate (context.get ()))); + CCSBackendGMock &gmockBackend = *(reinterpret_cast (ccsObjectGetPrivate (backend.get ()))); + CCSIntegratedSettingsStorageGMock &gmockStorage = *(reinterpret_cast (ccsObjectGetPrivate (storage))); + CCSIntegratedSettingFactoryGMock &gmockFactory = *(reinterpret_cast (ccsObjectGetPrivate (factory))); + + return CCSGNOMEIntegrationWithMocks (gmockContext, + gmockBackend, + gmockStorage, + gmockFactory, + context, + backend, + storage, + factory, + integration); + } + + CCSIntegration * + Real (CCSGNOMEIntegrationWithMocks &integrationWithMocks) + { + return std::tr1::get <8> (integrationWithMocks).get (); + } + + CCSContextGMock & + MockContext (CCSGNOMEIntegrationWithMocks &integrationWithMocks) + { + return std::tr1::get <0> (integrationWithMocks); + } + + CCSBackendGMock & + MockBackend (CCSGNOMEIntegrationWithMocks &integrationWithMocks) + { + return std::tr1::get <1> (integrationWithMocks); + } + + CCSIntegratedSettingsStorageGMock & + MockStorage (CCSGNOMEIntegrationWithMocks &integrationWithMocks) + { + return std::tr1::get <2> (integrationWithMocks); + } + + CCSIntegratedSettingFactoryGMock & + MockFactory (CCSGNOMEIntegrationWithMocks &integrationWithMocks) + { + return std::tr1::get <3> (integrationWithMocks); + } + + void + IgnoreRegistration (CCSIntegratedSettingsStorageGMock &storage) + { + EXPECT_CALL (storage, empty ()).WillOnce (Return (FALSE)); + } + + void + AllowReadability (CCSSettingGMock &setting) + { + EXPECT_CALL (setting, isReadableByBackend ()).WillOnce (Return (TRUE)); + } + + void + ExpectWriteSettings (CCSContextGMock &context) + { + EXPECT_CALL (context, writeChangedSettings ()); + } + + void + SetNames (CCSSettingGMock &setting, + CCSPluginGMock &plugin, + const std::string &settingName, + const std::string &pluginName) + { + EXPECT_CALL (setting, getName ()).WillOnce (Return (settingName.c_str ())); + EXPECT_CALL (setting, getParent ()); + EXPECT_CALL (plugin, getName ()).WillOnce (Return (pluginName.c_str ())); + } + + void + SetTypeInfo (CCSSettingGMock &setting, + CCSSettingType type, + CCSSettingInfo *info) + { + EXPECT_CALL (setting, getType ()).WillOnce (Return (type)); + EXPECT_CALL (setting, getInfo ()).WillOnce (Return (info)); + } + + CCSSettingValue * + MakeSettingValue () + { + CCSSettingValue *v = reinterpret_cast (calloc (1, sizeof (CCSSettingValue))); + v->parent = NULL; + v->isListChild = FALSE; + v->refCount = 1; + + return v; + } + + boost::shared_ptr + MakeAutoDestroySettingValue (CCSSettingType type) + { + CCSSettingValue *v = reinterpret_cast (calloc (1, sizeof (CCSSettingValue))); + v->parent = NULL; + v->isListChild = FALSE; + v->refCount = 1; + + return boost::shared_ptr (v, + boost::bind (ccsFreeSettingValueWithType, _1, type)); + } + + const std::string MOCK_PLUGIN ("mock"); + const std::string MOCK_SETTING ("mock"); + const std::string MOCK_GNOME_NAME ("mock"); + const CCSSettingType MOCK_SETTING_TYPE = TypeInt; + const SpecialOptionType MOCK_GNOME_SETTING_TYPE = OptionInt; +} + +TEST (CCSGNOMEIntegrationTest, TestConstructComposition) +{ + IntegratedSettingWithMockPtr settingWithMock ( + createIntegratedSettingCompositionFromMock (MOCK_PLUGIN, + MOCK_SETTING, + MOCK_SETTING_TYPE, + MOCK_GNOME_SETTING_TYPE, + MOCK_GNOME_NAME, + &ccsDefaultObjectAllocator)); +} + +class CCSGNOMEIntegrationTestWithMocks : + public ::testing::Test +{ + public: + + CCSGNOMEIntegrationTestWithMocks () : + mIntegration (createIntegrationWithMocks (&ccsDefaultObjectAllocator)), + mSetting (AutoDestroy (ccsMockSettingNew (), + ccsSettingUnref)), + mSettingMock ((*(reinterpret_cast (ccsObjectGetPrivate (mSetting.get ()))))), + mIntegratedSetting (), + mPlugin (AutoDestroy (ccsMockPluginNew (), + ccsPluginUnref)), + mPluginMock ((*(reinterpret_cast (ccsObjectGetPrivate (mPlugin.get ()))))) + { + ON_CALL (mSettingMock, getParent ()).WillByDefault (Return (mPlugin.get ())); + } + + protected: + + CCSGNOMEIntegrationWithMocks mIntegration; + boost::shared_ptr mSetting; + CCSSettingGMock &mSettingMock; + IntegratedSettingWithMockPtr mIntegratedSetting; + boost::shared_ptr mPlugin; + CCSPluginGMock &mPluginMock; +}; + +class CCSGNOMEIntegrationTestReadIntegrated : + public CCSGNOMEIntegrationTestWithMocks +{ + public: + + virtual void SetUp () + { + IgnoreRegistration (MockStorage (mIntegration)); + AllowReadability (mSettingMock); + } +}; + +class CCSGNOMEIntegrationTestWriteIntegrated : + public CCSGNOMEIntegrationTestWithMocks +{ + public: + + virtual void SetUp () + { + IgnoreRegistration (MockStorage (mIntegration)); + ExpectWriteSettings (MockContext (mIntegration)); + } +}; + +TEST_F (CCSGNOMEIntegrationTestWithMocks, TestConstructGNOMEIntegration) +{ +} + +TEST_F (CCSGNOMEIntegrationTestReadIntegrated, TestReadInSpecialOptionCurrentViewport) +{ + const std::string settingName ("current_viewport"); + CCSSettingValue *v = MakeSettingValue (); + v->value.asBool = FALSE; + + mIntegratedSetting = createIntegratedSettingCompositionFromMock (MOCK_PLUGIN, + settingName, + TypeBool, + OptionSpecial, + MOCK_GNOME_NAME, + &ccsDefaultObjectAllocator); + SetNames (mSettingMock, mPluginMock, settingName, MOCK_PLUGIN); + EXPECT_CALL (Mock (*mIntegratedSetting), readValue (TypeBool)).WillOnce (Return (v)); + EXPECT_CALL (mSettingMock, setBool (IsTrue (), IsTrue ())); + + EXPECT_THAT (ccsIntegrationReadOptionIntoSetting (Real (mIntegration), + NULL, + mSetting.get (), + Real (*mIntegratedSetting)), IsTrue ()); +} + +TEST_F (CCSGNOMEIntegrationTestReadIntegrated, TestReadInSpecialOptionFullscreenVisualBell) +{ + const std::string settingName ("fullscreen_visual_bell"); + CCSSettingValue *v = MakeSettingValue (); + v->value.asString = strdup ("fullscreen"); + + mIntegratedSetting = createIntegratedSettingCompositionFromMock (MOCK_PLUGIN, + settingName, + TypeString, + OptionSpecial, + MOCK_GNOME_NAME, + &ccsDefaultObjectAllocator); + SetNames (mSettingMock, mPluginMock, settingName, MOCK_PLUGIN); + EXPECT_CALL (Mock (*mIntegratedSetting), readValue (TypeString)).WillOnce (Return (v)); + EXPECT_CALL (mSettingMock, setBool (IsTrue (), IsTrue ())); + + EXPECT_THAT (ccsIntegrationReadOptionIntoSetting (Real (mIntegration), + NULL, + mSetting.get (), + Real (*mIntegratedSetting)), IsTrue ()); +} + +TEST_F (CCSGNOMEIntegrationTestReadIntegrated, TestReadInSpecialOptionClickToFocus) +{ + const std::string settingName ("click_to_focus"); + CCSSettingValue *v = MakeSettingValue (); + v->value.asString = strdup ("click"); + + mIntegratedSetting = createIntegratedSettingCompositionFromMock (MOCK_PLUGIN, + settingName, + TypeString, + OptionSpecial, + MOCK_GNOME_NAME, + &ccsDefaultObjectAllocator); + SetNames (mSettingMock, mPluginMock, settingName, MOCK_PLUGIN); + EXPECT_CALL (Mock (*mIntegratedSetting), readValue (TypeString)).WillOnce (Return (v)); + EXPECT_CALL (mSettingMock, setBool (IsTrue (), IsTrue ())); + + EXPECT_THAT (ccsIntegrationReadOptionIntoSetting (Real (mIntegration), + NULL, + mSetting.get (), + Real (*mIntegratedSetting)), IsTrue ()); +} + +namespace +{ + struct IntegratedMediaKeysParam + { + public: + + IntegratedMediaKeysParam (const std::string &settingName, + const std::string &integratedName, + const std::string &keyValueString) : + settingName (settingName), + integratedName (integratedName), + keyValueString (keyValueString) + { + EXPECT_TRUE (ccsStringToKeyBinding (keyValueString.c_str (), + &keyValue)); + } + + const std::string settingName; + const std::string integratedName; + const std::string keyValueString; + CCSSettingKeyValue keyValue; + }; +} + +namespace +{ + std::string RUN_COMMAND_SCREENSHOT_KEY ("run_command_screenshot_key"); + std::string SCREENSHOT ("screenshot"); + std::string SCREENSHOT_BINDING ("Print"); + std::string RUN_COMMAND_WINDOW_SCREENSHOT_KEY ("run_command_window_screenshot_key"); + std::string WINDOW_SCREENSHOT ("window_screenshot"); + std::string WINDOW_SCREENSHOT_BINDING ("Print"); + std::string RUN_COMMAND_TERMINAL_KEY ("run_command_terminal_key"); + std::string TERMINAL ("terminal"); + std::string TERMINAL_BINDING ("t"); +} + +class CCSGNOMEIntegrationTestReadIntegratedMediaKeys : + public CCSGNOMEIntegrationTestReadIntegrated, + public WithParamInterface +{ +}; + +TEST_P (CCSGNOMEIntegrationTestReadIntegratedMediaKeys, TestReadIntegratedMediaKey) +{ + const std::string settingName (GetParam ().settingName); + CCSSettingValue *v = MakeSettingValue (); + v->value.asString = strdup (GetParam ().keyValueString.c_str ()); + + mIntegratedSetting = createIntegratedSettingCompositionFromMock (MOCK_PLUGIN, + settingName, + TypeString, + OptionSpecial, + MOCK_GNOME_NAME, + &ccsDefaultObjectAllocator); + SetNames (mSettingMock, mPluginMock, settingName, MOCK_PLUGIN); + EXPECT_CALL (Mock (*mIntegratedSetting), readValue (TypeString)).WillOnce (Return (v)); + EXPECT_CALL (mSettingMock, setKey (Eq (GetParam ().keyValue), IsTrue ())); + + EXPECT_THAT (ccsIntegrationReadOptionIntoSetting (Real (mIntegration), + NULL, + mSetting.get (), + Real (*mIntegratedSetting)), IsTrue ()); +} + +INSTANTIATE_TEST_CASE_P (CCSGNOMEMediaKeys, CCSGNOMEIntegrationTestReadIntegratedMediaKeys, + Values (IntegratedMediaKeysParam (RUN_COMMAND_SCREENSHOT_KEY, + SCREENSHOT, + SCREENSHOT_BINDING), + IntegratedMediaKeysParam (RUN_COMMAND_WINDOW_SCREENSHOT_KEY, + WINDOW_SCREENSHOT, + WINDOW_SCREENSHOT_BINDING), + IntegratedMediaKeysParam (RUN_COMMAND_TERMINAL_KEY, + TERMINAL, + TERMINAL_BINDING))); + +namespace +{ + const std::string DEFAULT_MOUSE_BUTTON_MODIFIERS_STRING (""); + const std::string GNOME_MOUSE_BUTTON_MODIFIERS_STRING (""); + const unsigned int DEFAULT_MOUSE_BUTTON_MODIFIERS = + ccsStringToModifiers (DEFAULT_MOUSE_BUTTON_MODIFIERS_STRING.c_str ()); + const unsigned int GNOME_MOUSE_BUTTON_MODIFIERS = + ccsStringToModifiers (GNOME_MOUSE_BUTTON_MODIFIERS_STRING.c_str ()); + + const unsigned int LEFT_BUTTON = 1; + const unsigned int MIDDLE_BUTTON = 2; + const unsigned int RIGHT_BUTTON = 3; + + typedef cci::ListWrapper CCSIntegratedSettingListWrapper; + typedef boost::shared_ptr CCSIntegratedSettingListWrapperPtr; + + CCSIntegratedSettingListWrapperPtr + constructCCSIntegratedSettingListWrapper (CCSIntegratedSetting *setting) + { + return boost::make_shared (ccsIntegratedSettingListAppend (NULL, setting), + ccsIntegratedSettingListFree, + ccsIntegratedSettingListAppend, + ccsIntegratedSettingListRemove, + cci::Shallow); + } +} + +class CCSGNOMEIntegrationTestWithMocksIntegratedMouseButtonModifiers +{ + public: + + CCSGNOMEIntegrationTestWithMocksIntegratedMouseButtonModifiers () : + mIntegratedSettingMBM (AutoDestroy (ccsMockIntegratedSettingNew (&ccsDefaultObjectAllocator), + ccsIntegratedSettingUnref)), + mIntegratedSettingMBMMock (*(reinterpret_cast (ccsObjectGetPrivate (mIntegratedSettingMBM.get ())))), + mIntegratedSettingsMBM (constructCCSIntegratedSettingListWrapper (mIntegratedSettingMBM.get ())), + mIntegratedSettingResizeWithRB (AutoDestroy (ccsMockIntegratedSettingNew (&ccsDefaultObjectAllocator), + ccsIntegratedSettingUnref)), + mIntegratedSettingResizeWithRBMock (*(reinterpret_cast (ccsObjectGetPrivate (mIntegratedSettingResizeWithRB.get ())))), + mIntegratedSettingsResizeWithRB (constructCCSIntegratedSettingListWrapper (mIntegratedSettingResizeWithRB.get ())) + { + memset (&mButtonValue, 0, sizeof (CCSSettingButtonValue)); + + mButtonValue.button = MIDDLE_BUTTON; + mButtonValue.buttonModMask = DEFAULT_MOUSE_BUTTON_MODIFIERS; + mButtonValue.edgeMask = 0; + } + + virtual void SetUp (CCSGNOMEIntegrationWithMocks &integration) + { + CCSIntegratedSettingList integratedSettingsMBM = + *mIntegratedSettingsMBM; + CCSIntegratedSettingList integratedSettingsResizeWithRB = + *mIntegratedSettingsResizeWithRB; + + EXPECT_CALL (MockStorage (integration), + findMatchingSettingsByPluginAndSettingName (Eq (std::string (ccsGNOMEIntegratedPluginNames.SPECIAL)), + Eq (std::string (ccsGNOMEIntegratedSettingNames.NULL_MOUSE_BUTTON_MODIFIER.compizName)))) + .WillOnce (Return (integratedSettingsMBM)); + EXPECT_CALL (MockStorage (integration), + findMatchingSettingsByPluginAndSettingName (Eq (std::string (ccsGNOMEIntegratedPluginNames.SPECIAL)), + Eq (std::string (ccsGNOMEIntegratedSettingNames.NULL_RESIZE_WITH_RIGHT_BUTTON.compizName)))) + .WillOnce (Return (integratedSettingsResizeWithRB)); + } + + + protected: + + boost::shared_ptr mIntegratedSettingMBM; + CCSIntegratedSettingGMock &mIntegratedSettingMBMMock; + CCSIntegratedSettingListWrapperPtr mIntegratedSettingsMBM; + boost::shared_ptr mIntegratedSettingResizeWithRB; + CCSIntegratedSettingGMock &mIntegratedSettingResizeWithRBMock; + CCSIntegratedSettingListWrapperPtr mIntegratedSettingsResizeWithRB; + CCSSettingButtonValue mButtonValue; +}; + +class CCSGNOMEIntegrationTestWithMocksReadIntegratedMouseButtonModifiers : + public CCSGNOMEIntegrationTestReadIntegrated, + public CCSGNOMEIntegrationTestWithMocksIntegratedMouseButtonModifiers +{ + public: + + virtual void SetUp () + { + CCSSettingValue *vRB = MakeSettingValue (); + CCSSettingValue *vMBM = MakeSettingValue (); + vRB->value.asBool = TRUE; + vMBM->value.asString = strdup (GNOME_MOUSE_BUTTON_MODIFIERS_STRING.c_str ()); + + CCSGNOMEIntegrationTestReadIntegrated::SetUp (); + CCSGNOMEIntegrationTestWithMocksIntegratedMouseButtonModifiers::SetUp (mIntegration); + + EXPECT_CALL (mSettingMock, getButton (_)) + .WillOnce (DoAll ( + SetArgPointee <0> ( + mButtonValue), + Return (TRUE))); + + /* Get the GNOME Mouse button modifier */ + EXPECT_CALL (mIntegratedSettingMBMMock, readValue (TypeString)).WillOnce (Return (vMBM)); + EXPECT_CALL (mIntegratedSettingResizeWithRBMock, readValue (TypeBool)).WillOnce (Return (vRB)); + } +}; + +class CCSGNOMEIntegrationTestWithMocksWriteIntegratedMouseButtonModifiers : + public CCSGNOMEIntegrationTestWriteIntegrated, + public CCSGNOMEIntegrationTestWithMocksIntegratedMouseButtonModifiers +{ + public: + + CCSGNOMEIntegrationTestWithMocksWriteIntegratedMouseButtonModifiers () : + corePlugin (AutoDestroy (ccsMockPluginNew (), + ccsPluginUnref)), + corePluginMock (*(reinterpret_cast (ccsObjectGetPrivate (corePlugin.get ())))), + resizePlugin (AutoDestroy (ccsMockPluginNew (), + ccsPluginUnref)), + resizePluginMock (*(reinterpret_cast (ccsObjectGetPrivate (resizePlugin.get ())))), + movePlugin (AutoDestroy (ccsMockPluginNew (), + ccsPluginUnref)), + movePluginMock (*(reinterpret_cast (ccsObjectGetPrivate (movePlugin.get ())))), + resizeInitiateButtonSetting (AutoDestroy (ccsMockSettingNew (), + ccsSettingUnref)), + resizeInitiateButtonSettingMock (*(reinterpret_cast (ccsObjectGetPrivate (resizeInitiateButtonSetting.get ())))), + moveInitiateButtonSetting (AutoDestroy (ccsMockSettingNew (), + ccsSettingUnref)), + moveInitiateButtonSettingMock (*(reinterpret_cast (ccsObjectGetPrivate (moveInitiateButtonSetting.get ())))), + coreWindowMenuSetting (AutoDestroy (ccsMockSettingNew (), + ccsSettingUnref)), + coreWindowMenuSettingMock (*(reinterpret_cast (ccsObjectGetPrivate (coreWindowMenuSetting.get ())))), + resizeInitiateButton (MakeAutoDestroySettingValue (TypeButton)), + moveInitiateButton (MakeAutoDestroySettingValue (TypeButton)), + coreWindowMenuButton (MakeAutoDestroySettingValue (TypeButton)) + { + resizeInitiateButton->value.asButton.button = LEFT_BUTTON; + resizeInitiateButton->value.asButton.buttonModMask = 0; + resizeInitiateButton->value.asButton.edgeMask = 0; + moveInitiateButton->value.asButton.button = LEFT_BUTTON; + moveInitiateButton->value.asButton.buttonModMask = DEFAULT_MOUSE_BUTTON_MODIFIERS; + moveInitiateButton->value.asButton.edgeMask = 0; + coreWindowMenuButton->value.asButton.button = MIDDLE_BUTTON; + coreWindowMenuButton->value.asButton.buttonModMask = 0; + coreWindowMenuButton->value.asButton.edgeMask = 0; + } + + virtual void SetUp () + { + CCSGNOMEIntegrationTestWriteIntegrated::SetUp (); + CCSGNOMEIntegrationTestWithMocksIntegratedMouseButtonModifiers::SetUp (mIntegration); + } + + protected: + + boost::shared_ptr corePlugin; + CCSPluginGMock &corePluginMock; + boost::shared_ptr resizePlugin; + CCSPluginGMock &resizePluginMock; + boost::shared_ptr movePlugin; + CCSPluginGMock &movePluginMock; + + boost::shared_ptr resizeInitiateButtonSetting; + CCSSettingGMock &resizeInitiateButtonSettingMock; + boost::shared_ptr moveInitiateButtonSetting; + CCSSettingGMock &moveInitiateButtonSettingMock; + boost::shared_ptr coreWindowMenuSetting; + CCSSettingGMock &coreWindowMenuSettingMock; + + boost::shared_ptr resizeInitiateButton; + boost::shared_ptr moveInitiateButton; + boost::shared_ptr coreWindowMenuButton; +}; + +TEST_F (CCSGNOMEIntegrationTestWithMocksReadIntegratedMouseButtonModifiers, TestReadInSpecialOptionMoveInitiateButton) +{ + const std::string settingName ("initiate_button"); + const std::string pluginName ("move"); + + CCSSettingButtonValue newButtonValue = mButtonValue; + newButtonValue.button = LEFT_BUTTON; + newButtonValue.buttonModMask = GNOME_MOUSE_BUTTON_MODIFIERS; + + mIntegratedSetting = createIntegratedSettingCompositionFromMock (pluginName, + settingName, + TypeBool, + OptionSpecial, + MOCK_GNOME_NAME, + &ccsDefaultObjectAllocator); + SetNames (mSettingMock, mPluginMock, settingName, pluginName); + + /* Set the new mouse button modifier */ + EXPECT_CALL (mSettingMock, setButton (Eq (newButtonValue), + IsTrue ())); + + EXPECT_THAT (ccsIntegrationReadOptionIntoSetting (Real (mIntegration), + NULL, + mSetting.get (), + Real (*mIntegratedSetting)), IsTrue ()); +} + +TEST_F (CCSGNOMEIntegrationTestWithMocksReadIntegratedMouseButtonModifiers, TestReadInSpecialOptionResizeInitiateButton) +{ + const std::string settingName ("initiate_button"); + const std::string pluginName ("resize"); + + CCSSettingButtonValue newButtonValue = mButtonValue; + newButtonValue.button = RIGHT_BUTTON; + newButtonValue.buttonModMask = GNOME_MOUSE_BUTTON_MODIFIERS; + + mIntegratedSetting = createIntegratedSettingCompositionFromMock (pluginName, + settingName, + TypeBool, + OptionSpecial, + MOCK_GNOME_NAME, + &ccsDefaultObjectAllocator); + SetNames (mSettingMock, mPluginMock, settingName, pluginName); + + /* Set the new mouse button modifier */ + EXPECT_CALL (mSettingMock, setButton (Eq (newButtonValue), + IsTrue ())); + + EXPECT_THAT (ccsIntegrationReadOptionIntoSetting (Real (mIntegration), + NULL, + mSetting.get (), + Real (*mIntegratedSetting)), IsTrue ()); +} + +TEST_F (CCSGNOMEIntegrationTestWithMocksReadIntegratedMouseButtonModifiers, TestReadInSpecialOptionWhereIntegratedOptionReturnsNull) +{ + const std::string settingName ("initiate_button"); + const std::string pluginName ("move"); + + CCSSettingButtonValue newButtonValue = mButtonValue; + newButtonValue.button = LEFT_BUTTON; + /* Reading the gnome mouse button modifiers failed, so default to zero */ + newButtonValue.buttonModMask = 0; + + /* Clear the old expectation */ + ccsFreeSettingValueWithType (ccsIntegratedSettingReadValue (mIntegratedSettingMBM.get (), TypeString), + TypeString); + /* Now return null */ + EXPECT_CALL (mIntegratedSettingMBMMock, readValue (TypeString)).WillOnce (ReturnNull ()); + + mIntegratedSetting = createIntegratedSettingCompositionFromMock (pluginName, + settingName, + TypeBool, + OptionSpecial, + MOCK_GNOME_NAME, + &ccsDefaultObjectAllocator); + SetNames (mSettingMock, mPluginMock, settingName, pluginName); + + /* Set the new mouse button modifier */ + EXPECT_CALL (mSettingMock, setButton (Eq (newButtonValue), + IsTrue ())); + + EXPECT_THAT (ccsIntegrationReadOptionIntoSetting (Real (mIntegration), + NULL, + mSetting.get (), + Real (*mIntegratedSetting)), IsTrue ()); +} + +TEST_F (CCSGNOMEIntegrationTestWriteIntegrated, TestWriteCurrentViewport) +{ + const std::string settingName ("current_viewport"); + boost::shared_ptr compizValue (MakeAutoDestroySettingValue (TypeBool)); + boost::shared_ptr gnomeValue (MakeAutoDestroySettingValue (TypeBool)); + CCSSettingInfo info; + + compizValue->value.asBool = TRUE; + gnomeValue->value.asBool = FALSE; + + mIntegratedSetting = createIntegratedSettingCompositionFromMock (MOCK_PLUGIN, + settingName, + TypeBool, + OptionSpecial, + MOCK_GNOME_NAME, + &ccsDefaultObjectAllocator); + SetNames (mSettingMock, mPluginMock, settingName, MOCK_PLUGIN); + SetTypeInfo (mSettingMock, TypeBool, &info); + + EXPECT_CALL (mSettingMock, getValue ()).WillOnce (Return (compizValue.get ())); + EXPECT_CALL (Mock (*mIntegratedSetting), writeValue (Pointee (SettingValueMatch (*gnomeValue, + TypeBool, + &info)), + TypeBool)); + ccsIntegrationWriteSettingIntoOption (Real (mIntegration), + NULL, + mSetting.get (), + Real (*mIntegratedSetting)); +} + +TEST_F (CCSGNOMEIntegrationTestWriteIntegrated, TestWriteFullscreenVisualBell) +{ + const std::string settingName ("fullscreen_visual_bell"); + boost::shared_ptr compizValue (MakeAutoDestroySettingValue (TypeBool)); + boost::shared_ptr gnomeValue (MakeAutoDestroySettingValue (TypeString)); + CCSSettingInfo info; + + compizValue->value.asBool = TRUE; + gnomeValue->value.asString = strdup ("fullscreen"); + + mIntegratedSetting = createIntegratedSettingCompositionFromMock (MOCK_PLUGIN, + settingName, + TypeBool, + OptionSpecial, + MOCK_GNOME_NAME, + &ccsDefaultObjectAllocator); + SetNames (mSettingMock, mPluginMock, settingName, MOCK_PLUGIN); + SetTypeInfo (mSettingMock, TypeBool, &info); + + EXPECT_CALL (mSettingMock, getValue ()).WillOnce (Return (compizValue.get ())); + EXPECT_CALL (Mock (*mIntegratedSetting), writeValue (Pointee (SettingValueMatch (*gnomeValue, + TypeString, + &info)), + TypeString)); + ccsIntegrationWriteSettingIntoOption (Real (mIntegration), + NULL, + mSetting.get (), + Real (*mIntegratedSetting)); +} + +TEST_F (CCSGNOMEIntegrationTestWriteIntegrated, TestWriteClickToFocus) +{ + const std::string settingName ("click_to_focus"); + boost::shared_ptr compizValue (MakeAutoDestroySettingValue (TypeBool)); + boost::shared_ptr gnomeValue (MakeAutoDestroySettingValue (TypeString)); + CCSSettingInfo info; + + compizValue->value.asBool = TRUE; + gnomeValue->value.asString = strdup ("click"); + + mIntegratedSetting = createIntegratedSettingCompositionFromMock (MOCK_PLUGIN, + settingName, + TypeBool, + OptionSpecial, + MOCK_GNOME_NAME, + &ccsDefaultObjectAllocator); + SetNames (mSettingMock, mPluginMock, settingName, MOCK_PLUGIN); + SetTypeInfo (mSettingMock, TypeBool, &info); + + EXPECT_CALL (mSettingMock, getValue ()).WillOnce (Return (compizValue.get ())); + EXPECT_CALL (Mock (*mIntegratedSetting), writeValue (Pointee (SettingValueMatch (*gnomeValue, + TypeString, + &info)), + TypeString)); + ccsIntegrationWriteSettingIntoOption (Real (mIntegration), + NULL, + mSetting.get (), + Real (*mIntegratedSetting)); +} + +class CCSGNOMEIntegrationTestWriteIntegratedMediaKeys : + public CCSGNOMEIntegrationTestWriteIntegrated, + public WithParamInterface +{ +}; + +TEST_P (CCSGNOMEIntegrationTestWriteIntegratedMediaKeys, TestWriteIntegratedMediaKey) +{ + const std::string settingName (GetParam ().settingName); + boost::shared_ptr compizValue (MakeAutoDestroySettingValue (TypeKey)); + boost::shared_ptr gnomeValue (MakeAutoDestroySettingValue (TypeString)); + CCSSettingInfo info; + + compizValue->value.asKey = GetParam ().keyValue; + gnomeValue->value.asString = strdup (GetParam ().keyValueString.c_str ()); + + mIntegratedSetting = createIntegratedSettingCompositionFromMock (MOCK_PLUGIN, + settingName, + TypeString, + OptionSpecial, + MOCK_GNOME_NAME, + &ccsDefaultObjectAllocator); + SetNames (mSettingMock, mPluginMock, settingName, MOCK_PLUGIN); + SetTypeInfo (mSettingMock, TypeKey, &info); + + EXPECT_CALL (mSettingMock, getValue ()).WillOnce (Return (compizValue.get ())); + EXPECT_CALL (Mock (*mIntegratedSetting), writeValue (Pointee (SettingValueMatch (*gnomeValue, + TypeString, + &info)), + TypeString)); + ccsIntegrationWriteSettingIntoOption (Real (mIntegration), + NULL, + mSetting.get (), + Real (*mIntegratedSetting)); +} + +INSTANTIATE_TEST_CASE_P (CCSGNOMEMediaKeys, CCSGNOMEIntegrationTestWriteIntegratedMediaKeys, + Values (IntegratedMediaKeysParam (RUN_COMMAND_SCREENSHOT_KEY, + SCREENSHOT, + SCREENSHOT_BINDING), + IntegratedMediaKeysParam (RUN_COMMAND_WINDOW_SCREENSHOT_KEY, + WINDOW_SCREENSHOT, + WINDOW_SCREENSHOT_BINDING), + IntegratedMediaKeysParam (RUN_COMMAND_TERMINAL_KEY, + TERMINAL, + TERMINAL_BINDING))); + +/* + * TODO: Break up the function that this test covers. Its way too complicated + */ +TEST_F (CCSGNOMEIntegrationTestWithMocksWriteIntegratedMouseButtonModifiers, TestWriteMouseButtonModifier) +{ + const std::string moveSettingName ("initiate_button"); + const std::string movePluginName ("move"); + const std::string resizeSettingName ("initiate_button"); + const std::string resizePluginName ("resize"); + const std::string coreSettingName ("window_menu_button"); + const std::string corePluginName ("core"); + + const std::string settingName (moveSettingName); + const std::string pluginName (movePluginName); + + CCSSettingInfo info; + + mIntegratedSetting = createIntegratedSettingCompositionFromMock (pluginName, + settingName, + TypeBool, + OptionSpecial, + MOCK_GNOME_NAME, + &ccsDefaultObjectAllocator); + SetNames (mSettingMock, mPluginMock, settingName, pluginName); + SetTypeInfo (mSettingMock, TypeButton, &info); + + EXPECT_CALL (MockContext (mIntegration), findPlugin (Eq (movePluginName))).WillRepeatedly (Return (movePlugin.get ())); + EXPECT_CALL (movePluginMock, findSetting (Eq (moveSettingName))).WillRepeatedly (Return (moveInitiateButtonSetting.get ())); + EXPECT_CALL (moveInitiateButtonSettingMock, getType ()).WillRepeatedly (Return (TypeButton)); + EXPECT_CALL (moveInitiateButtonSettingMock, getValue ()).WillRepeatedly (Return (moveInitiateButton.get ())); + + EXPECT_CALL (MockContext (mIntegration), findPlugin (Eq (resizePluginName))).WillRepeatedly (Return (resizePlugin.get ())); + EXPECT_CALL (resizePluginMock, findSetting (Eq (resizeSettingName))).WillRepeatedly (Return (resizeInitiateButtonSetting.get ())); + EXPECT_CALL (resizeInitiateButtonSettingMock, getType ()).WillRepeatedly (Return (TypeButton)); + EXPECT_CALL (resizeInitiateButtonSettingMock, getValue ()).WillRepeatedly (Return (resizeInitiateButton.get ())); + + EXPECT_CALL (MockContext (mIntegration), findPlugin (Eq (corePluginName))).WillRepeatedly (Return (corePlugin.get ())); + EXPECT_CALL (corePluginMock, findSetting (Eq (coreSettingName))).WillRepeatedly (Return (coreWindowMenuSetting.get ())); + EXPECT_CALL (coreWindowMenuSettingMock, getType ()).WillRepeatedly (Return (TypeButton)); + EXPECT_CALL (coreWindowMenuSettingMock, getValue ()).WillRepeatedly (Return (coreWindowMenuButton.get ())); + + boost::shared_ptr newResizeWithRBValue (MakeAutoDestroySettingValue (TypeBool)); + newResizeWithRBValue->value.asBool = TRUE; + + EXPECT_CALL (mIntegratedSettingResizeWithRBMock, writeValue (Pointee (SettingValueMatch (*newResizeWithRBValue, + TypeBool, + &info)), + TypeBool)); + + boost::shared_ptr newMBMValue (MakeAutoDestroySettingValue (TypeString)); + newMBMValue->value.asString = strdup (DEFAULT_MOUSE_BUTTON_MODIFIERS_STRING.c_str ()); + + EXPECT_CALL (mSettingMock, getValue ()).WillOnce (Return (moveInitiateButton.get ())); + + EXPECT_CALL (mIntegratedSettingMBMMock, writeValue (Pointee (SettingValueMatch (*newMBMValue, + TypeString, + &info)), + TypeString)); + + unsigned int modifiers = moveInitiateButton->value.asButton.buttonModMask; + + CCSSettingButtonValue newResizeInitiateButton; + CCSSettingButtonValue newMoveInitiateButton; + CCSSettingButtonValue newWindowMenuButton; + + memset (&newResizeInitiateButton, 0, sizeof (CCSSettingButtonValue)); + memset (&newMoveInitiateButton, 0, sizeof (CCSSettingButtonValue)); + memset (&newWindowMenuButton, 0, sizeof (CCSSettingButtonValue)); + + newResizeInitiateButton.button = RIGHT_BUTTON; + newResizeInitiateButton.buttonModMask = modifiers; + newMoveInitiateButton.button = LEFT_BUTTON; + newMoveInitiateButton.buttonModMask = modifiers; + newWindowMenuButton.button = MIDDLE_BUTTON; + newWindowMenuButton.buttonModMask = modifiers; + + EXPECT_CALL (resizeInitiateButtonSettingMock, setButton (Eq (newResizeInitiateButton), + IsTrue ())); + /* The move button is exactly the same, so it is not updated */ + EXPECT_CALL (moveInitiateButtonSettingMock, setButton (Eq (newMoveInitiateButton), + IsTrue ())).Times (0); + EXPECT_CALL (coreWindowMenuSettingMock, setButton (Eq (newWindowMenuButton), + IsTrue ())); + + ccsIntegrationWriteSettingIntoOption (Real (mIntegration), + NULL, + mSetting.get (), + Real (*mIntegratedSetting)); +} diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/libcompizconfig/include/ccs-defs.h compiz-0.9.8.4/compizconfig/libcompizconfig/include/ccs-defs.h --- compiz-0.9.8.2+bzr3377/compizconfig/libcompizconfig/include/ccs-defs.h 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/libcompizconfig/include/ccs-defs.h 2012-09-27 11:04:02.000000000 +0000 @@ -88,6 +88,9 @@ ccsFree##type (d); \ } \ +#define GET_PRIVATE(Private, obj) \ + (Private *) ccsObjectGetPrivate (obj); + COMPIZCONFIG_END_DECLS #endif diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/libcompizconfig/include/ccs.h compiz-0.9.8.4/compizconfig/libcompizconfig/include/ccs.h --- compiz-0.9.8.2+bzr3377/compizconfig/libcompizconfig/include/ccs.h 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/libcompizconfig/include/ccs.h 2012-09-27 11:04:02.000000000 +0000 @@ -135,7 +135,7 @@ typedef void (*CCSContextSetPrivatePtr) (CCSContext *context, void *ptr); typedef Bool (*CCSContextLoadPlugin) (CCSContext *context, char *name); typedef CCSPlugin * (*CCSContextFindPlugin) (CCSContext *context, const char *name); -typedef Bool (*CCSContextPluginIsActive) (CCSContext *context, char *name); +typedef Bool (*CCSContextPluginIsActive) (CCSContext *context, const char *name); typedef CCSPluginList (*CCSContextGetActivePluginList) (CCSContext *context); typedef CCSStringList (*CCSContextGetSortedPluginStringList) (CCSContext *context); typedef Bool (*CCSContextSetBackend) (CCSContext *context, char *name); @@ -223,11 +223,11 @@ }; /* CCSPluginInterface */ -typedef char * (*CCSPluginGetName) (CCSPlugin *plugin); -typedef char * (*CCSPluginGetShortDesc) (CCSPlugin *plugin); -typedef char * (*CCSPluginGetLongDesc) (CCSPlugin *plugin); -typedef char * (*CCSPluginGetHints) (CCSPlugin *plugin); -typedef char * (*CCSPluginGetCategory) (CCSPlugin *plugin); +typedef const char * (*CCSPluginGetName) (CCSPlugin *plugin); +typedef const char * (*CCSPluginGetShortDesc) (CCSPlugin *plugin); +typedef const char * (*CCSPluginGetLongDesc) (CCSPlugin *plugin); +typedef const char * (*CCSPluginGetHints) (CCSPlugin *plugin); +typedef const char * (*CCSPluginGetCategory) (CCSPlugin *plugin); typedef CCSStringList (*CCSPluginGetLoadAfter) (CCSPlugin *plugin); typedef CCSStringList (*CCSPluginGetLoadBefore) (CCSPlugin *plugin); @@ -276,11 +276,11 @@ }; /* CCSPlugin accessor functions */ -char * ccsPluginGetName (CCSPlugin *plugin); -char * ccsPluginGetShortDesc (CCSPlugin *plugin); -char * ccsPluginGetLongDesc (CCSPlugin *plugin); -char * ccsPluginGetHints (CCSPlugin *plugin); -char * ccsPluginGetCategory (CCSPlugin *plugin); +const char * ccsPluginGetName (CCSPlugin *plugin); +const char * ccsPluginGetShortDesc (CCSPlugin *plugin); +const char * ccsPluginGetLongDesc (CCSPlugin *plugin); +const char * ccsPluginGetHints (CCSPlugin *plugin); +const char * ccsPluginGetCategory (CCSPlugin *plugin); CCSStringList ccsPluginGetLoadAfter (CCSPlugin *plugin); CCSStringList ccsPluginGetLoadBefore (CCSPlugin *plugin); @@ -465,14 +465,14 @@ }; /* Interface for CCSSetting */ -char * ccsSettingGetName (CCSSetting *setting); -char * ccsSettingGetShortDesc (CCSSetting *setting); -char * ccsSettingGetLongDesc (CCSSetting *setting); +const char * ccsSettingGetName (CCSSetting *setting); +const char * ccsSettingGetShortDesc (CCSSetting *setting); +const char * ccsSettingGetLongDesc (CCSSetting *setting); CCSSettingType ccsSettingGetType (CCSSetting *setting); CCSSettingInfo * ccsSettingGetInfo (CCSSetting *setting); -char * ccsSettingGetGroup (CCSSetting *setting); -char * ccsSettingGetSubGroup (CCSSetting *setting); -char * ccsSettingGetHints (CCSSetting *setting); +const char * ccsSettingGetGroup (CCSSetting *setting); +const char * ccsSettingGetSubGroup (CCSSetting *setting); +const char * ccsSettingGetHints (CCSSetting *setting); CCSSettingValue * ccsSettingGetDefaultValue (CCSSetting *setting); CCSSettingValue *ccsSettingGetValue (CCSSetting *setting); Bool ccsSettingGetIsDefault (CCSSetting *setting); @@ -558,14 +558,14 @@ /* Checks if a setting is readable by backends */ Bool ccsSettingIsReadableByBackend (CCSSetting *setting); -typedef char * (*CCSSettingGetName) (CCSSetting *); -typedef char * (*CCSSettingGetShortDesc) (CCSSetting *); -typedef char * (*CCSSettingGetLongDesc) (CCSSetting *); +typedef const char * (*CCSSettingGetName) (CCSSetting *); +typedef const char * (*CCSSettingGetShortDesc) (CCSSetting *); +typedef const char * (*CCSSettingGetLongDesc) (CCSSetting *); typedef CCSSettingType (*CCSSettingGetType) (CCSSetting *); typedef CCSSettingInfo * (*CCSSettingGetInfo) (CCSSetting *); -typedef char * (*CCSSettingGetGroup) (CCSSetting *); -typedef char * (*CCSSettingGetSubGroup) (CCSSetting *); -typedef char * (*CCSSettingGetHints) (CCSSetting *); +typedef const char * (*CCSSettingGetGroup) (CCSSetting *); +typedef const char * (*CCSSettingGetSubGroup) (CCSSetting *); +typedef const char * (*CCSSettingGetHints) (CCSSetting *); typedef CCSSettingValue * (*CCSSettingGetDefaultValue) (CCSSetting *setting); typedef CCSSettingValue * (*CCSSettingGetValue) (CCSSetting *setting); typedef Bool (*CCSSettingGetIsDefault) (CCSSetting *); @@ -697,8 +697,7 @@ /* Returns TRUE if the named plugin is in the context and marked as currently active in Compiz, FALSE otherwise. */ -Bool ccsPluginIsActive (CCSContext *context, - char *name); +Bool ccsPluginIsActive(CCSContext *context, const char *name); void ccsFreeContext (CCSContext *context); void ccsFreePlugin (CCSPlugin *plugin); @@ -773,6 +772,12 @@ CCSSettingValueList ccsCopyList (CCSSettingValueList l1, CCSSetting * setting); +/* Deep copy setting value */ +CCSSettingValue * +ccsCopyValue (CCSSettingValue *orig, + CCSSettingType type, + CCSSettingInfo *info); + /* Converts an array of data items to a setting value list. Behaves similar to ccsGetListFromStringArray */ CCSSettingValueList ccsGetValueListFromStringArray (const char **array, @@ -1080,6 +1085,14 @@ CCSStrExtensionList ccsGetPluginStrExtensions (CCSPlugin *plugin); +Bool +ccsCheckValueEq (const CCSSettingValue *rhs, + CCSSettingType rhsType, + CCSSettingInfo *rhsInfo, + const CCSSettingValue *lhs, + CCSSettingType lhsType, + CCSSettingInfo *lhsInfo); + COMPIZCONFIG_END_DECLS #endif diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/libcompizconfig/src/CMakeLists.txt compiz-0.9.8.4/compizconfig/libcompizconfig/src/CMakeLists.txt --- compiz-0.9.8.2+bzr3377/compizconfig/libcompizconfig/src/CMakeLists.txt 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/libcompizconfig/src/CMakeLists.txt 2012-09-27 11:04:02.000000000 +0000 @@ -51,6 +51,21 @@ endif (HAVE_INOTIFY) add_library ( + ccs_text_file_interface STATIC + ccs_text_file_interface.c +) + +add_library ( + ccs_text_file STATIC + ccs_text_file.c +) + +target_link_libraries ( + ccs_text_file + ccs_text_file_interface +) + +add_library ( ccs_settings_upgrade_internal STATIC ccs_settings_upgrade_internal.c ) @@ -75,6 +90,7 @@ m dl ccs_settings_upgrade_internal + ccs_text_file ) # diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/libcompizconfig/src/bindings.c compiz-0.9.8.4/compizconfig/libcompizconfig/src/bindings.c --- compiz-0.9.8.2+bzr3377/compizconfig/libcompizconfig/src/bindings.c 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/libcompizconfig/src/bindings.c 2012-09-27 11:04:02.000000000 +0000 @@ -219,9 +219,9 @@ if (button->button) { - char buttonStr[256]; + char buttonStr[256]; snprintf (buttonStr, 256, "Button%d", button->button); - binding = stringAppend (binding, buttonStr); + binding = stringAppend (binding, buttonStr); } if (!binding) diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/libcompizconfig/src/ccs-private.h compiz-0.9.8.4/compizconfig/libcompizconfig/src/ccs-private.h --- compiz-0.9.8.2+bzr3377/compizconfig/libcompizconfig/src/ccs-private.h 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/libcompizconfig/src/ccs-private.h 2012-09-27 11:04:02.000000000 +0000 @@ -25,9 +25,6 @@ #include #include -#define GET_PRIVATE(Private, obj) \ - (Private *) ccsObjectGetPrivate (obj); - extern Bool basicMetadata; typedef struct _CCSContextPrivate diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/libcompizconfig/src/ccs_settings_upgrade_internal.c compiz-0.9.8.4/compizconfig/libcompizconfig/src/ccs_settings_upgrade_internal.c --- compiz-0.9.8.2+bzr3377/compizconfig/libcompizconfig/src/ccs_settings_upgrade_internal.c 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/libcompizconfig/src/ccs_settings_upgrade_internal.c 2012-09-27 11:04:02.000000000 +0000 @@ -20,8 +20,8 @@ * Authored By: * Sam Spilsbury */ - #include "ccs_settings_upgrade_internal.h" +#include #include #include #include @@ -44,13 +44,10 @@ int foundNumber, void *userData) { - static const char *UPGRADE = "upgrade"; - static const unsigned int UPGRADE_STR_LEN = 7; - - if (strncmp (tokenThree, UPGRADE, UPGRADE_STR_LEN)) - return FALSE; + static const char *upgrade = "upgrade"; + static const unsigned int upgrade_str_len = 7; - return TRUE; + return strncmp (tokenThree, upgrade, upgrade_str_len) == 0; } typedef struct _FillDomainNumAndProfileData @@ -121,8 +118,6 @@ userData)) success = TRUE; } - else if (errno) - perror ("sscanf"); tok = nexttok; free (bit); @@ -166,3 +161,239 @@ return 0; } + +void +ccsUpgradeClearValues (CCSSettingList clearSettings) +{ + CCSSettingList sl = clearSettings; + + while (sl) + { + CCSSetting *tempSetting = (CCSSetting *) sl->data; + CCSSetting *setting; + CCSPlugin *plugin = ccsSettingGetParent (tempSetting); + const char *name = ccsSettingGetName (tempSetting); + + setting = ccsFindSetting (plugin, name); + + if (setting) + { + CCSSettingInfo *tempInfo = ccsSettingGetInfo (tempSetting); + CCSSettingType tType = ccsSettingGetType (tempSetting); + CCSSettingType sType = ccsSettingGetType (setting); + CCSSettingInfo *info = ccsSettingGetInfo (setting); + + if (sType != tType) + { + ccsWarning ("Attempted to upgrade setting %s with wrong type", name); + sl = sl->next; + continue; + } + + if (sType != TypeList) + { + if (ccsCheckValueEq (ccsSettingGetValue (setting), + sType, + info, + ccsSettingGetValue (tempSetting), + tType, + tempInfo)) + { + ccsDebug ("Resetting %s to default", name); + ccsResetToDefault (setting, TRUE); + } + else + { + ccsDebug ("Skipping processing of %s", name); + } + } + else + { + unsigned int count = 0; + /* Try and remove any specified items from the list */ + CCSSettingValueList l = ccsSettingGetValue (tempSetting)->value.asList; + CCSSettingValueList nl = ccsCopyList (ccsSettingGetValue (setting)->value.asList, setting); + CCSSettingInfo *info = ccsSettingGetInfo (setting); + + while (l) + { + CCSSettingValueList olv = nl; + + while (olv) + { + CCSSettingValue *lv = (CCSSettingValue *) l->data; + CCSSettingValue *olvv = (CCSSettingValue *) olv->data; + + /* Break if we found a matching value, so that we can + * remove it from the list */ + if (ccsCheckValueEq (lv, + info->forList.listType, + info, + olvv, + info->forList.listType, + info)) + break; + + olv = olv->next; + } + + /* We found a matching value, remove it */ + if (olv) + { + count++; + nl = ccsSettingValueListRemove (nl, olv->data, TRUE); + } + + l = l->next; + } + + ccsDebug ("Removed %i items from %s", count, name); + ccsSetList (setting, nl, TRUE); + ccsSettingValueListFree (nl, TRUE); + } + } + + sl = sl->next; + } +} + +void +ccsUpgradeAddValues (CCSSettingList addSettings) +{ + CCSSettingList sl = addSettings; + + while (sl) + { + CCSSetting *tempSetting = (CCSSetting *) sl->data; + CCSSetting *setting; + CCSPlugin *plugin = ccsSettingGetParent (tempSetting); + const char *name = ccsSettingGetName (tempSetting); + + setting = ccsFindSetting (plugin, name); + + if (setting) + { + const CCSSettingType tempSettingType = ccsSettingGetType (tempSetting); + const CCSSettingType actualSettingType = ccsSettingGetType (setting); + + if (tempSettingType != actualSettingType) + { + ccsWarning ("Attempted to upgrade setting %s with wrong type", name); + sl = sl->next; + continue; + } + + ccsDebug ("Overriding value %s", name); + if (tempSettingType != TypeList) + ccsSetValue (setting, ccsSettingGetValue (tempSetting), TRUE); + else + { + unsigned int count = 0; + /* Try and apppend any new items to the list */ + CCSSettingValueList l = ccsSettingGetValue (tempSetting)->value.asList; + CCSSettingValueList nl = ccsCopyList (ccsSettingGetValue (setting)->value.asList, setting); + CCSSettingInfo *info = ccsSettingGetInfo (setting); + + while (l) + { + CCSSettingValueList olv = nl; + + while (olv) + { + CCSSettingValue *lv = (CCSSettingValue *) l->data; + CCSSettingValue *olvv = (CCSSettingValue *) olv->data; + + /* Break if we find the same value, as it was in the list + * already */ + if (ccsCheckValueEq (lv, + info->forList.listType, + info, + olvv, + info->forList.listType, + info)) + break; + + olv = olv->next; + } + + /* If olv is NULL then the value was not in the original + * list and we should append the value to nl */ + if (!olv) + { + count++; + nl = ccsSettingValueListAppend (nl, l->data); + } + + l = l->next; + } + + ccsDebug ("Appending %i items to %s", count, name); + ccsSetList (setting, nl, TRUE); + } + } + else + { + ccsDebug ("Value %s not found!", name); + } + + sl = sl->next; + } +} + +void +ccsUpgradeReplaceValues (CCSSettingList replaceFromValueSettings, + CCSSettingList replaceToValueSettings) +{ + CCSSettingList sl = replaceFromValueSettings; + + while (sl) + { + CCSSetting *tempSetting = (CCSSetting *) sl->data; + CCSSetting *setting; + CCSPlugin *plugin = ccsSettingGetParent (tempSetting); + const char *name = ccsSettingGetName (tempSetting); + + setting = ccsFindSetting (plugin, name); + + if (setting) + { + CCSSettingValue *value = ccsSettingGetValue (setting); + CCSSettingType realType = ccsSettingGetType (setting); + CCSSettingInfo *realInfo = ccsSettingGetInfo (setting); + CCSSettingValue *tempValue = ccsSettingGetValue (tempSetting); + CCSSettingType tempType = ccsSettingGetType (tempSetting); + CCSSettingInfo *tempInfo = ccsSettingGetInfo (tempSetting); + + if (ccsCheckValueEq (value, + realType, + realInfo, + tempValue, + tempType, + tempInfo)) + { + CCSSettingList rl = replaceToValueSettings; + + while (rl) + { + CCSSetting *rsetting = (CCSSetting *) rl->data; + const char *replaceToSettingName = ccsSettingGetName (rsetting); + + if (strcmp (replaceToSettingName, name) == 0) + { + ccsDebug ("Matched and replaced %s", name); + ccsSetValue (setting, ccsSettingGetValue (rsetting), TRUE); + break; + } + + rl = rl->next; + } + } + else + { + ccsDebug ("Skipping processing of %s", name); + } + } + + sl = sl->next; + } +} diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/libcompizconfig/src/ccs_settings_upgrade_internal.h compiz-0.9.8.4/compizconfig/libcompizconfig/src/ccs_settings_upgrade_internal.h --- compiz-0.9.8.2+bzr3377/compizconfig/libcompizconfig/src/ccs_settings_upgrade_internal.h 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/libcompizconfig/src/ccs_settings_upgrade_internal.h 2012-09-27 11:04:02.000000000 +0000 @@ -27,6 +27,8 @@ COMPIZCONFIG_BEGIN_DECLS +typedef struct _CCSSettingList * CCSSettingList; + Bool ccsUpgradeGetDomainNumAndProfile (const char *name, char **domain, @@ -36,6 +38,16 @@ int ccsUpgradeNameFilter (const char *name); +void +ccsUpgradeClearValues (CCSSettingList clearSettings); + +void +ccsUpgradeAddValues (CCSSettingList addSettings); + +void +ccsUpgradeReplaceValues (CCSSettingList replaceFromValueSettings, + CCSSettingList replaceToValueSettings); + COMPIZCONFIG_END_DECLS #endif diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/libcompizconfig/src/ccs_text_file.c compiz-0.9.8.4/compizconfig/libcompizconfig/src/ccs_text_file.c --- compiz-0.9.8.2+bzr3377/compizconfig/libcompizconfig/src/ccs_text_file.c 1970-01-01 00:00:00.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/libcompizconfig/src/ccs_text_file.c 2012-09-27 11:04:02.000000000 +0000 @@ -0,0 +1,212 @@ +/* + * Compiz configuration system library + * + * ccs_text_file.c + * + * Copyright (C) 2012 Canonical Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authored By: + * Sam Spilsbury + */ + +#include +#include +#include + +#include +#include +#include +#include + +typedef struct _CCSUnixTextFilePrivate CCSUnixTextFilePrivate; + +struct _CCSUnixTextFilePrivate +{ + FILE *unixFile; +}; + +static void +freeAndFinalizeCCSTextFile (CCSTextFile *file, + CCSObjectAllocationInterface *ai) +{ + ccsObjectFinalize (file); + (*ai->free_) (ai->allocator, file); +} + +static char * +ccsUnixTextFileReadFromStart (CCSTextFile *textFile) +{ + CCSUnixTextFilePrivate *priv = GET_PRIVATE (CCSUnixTextFilePrivate, textFile); + FILE *completedUpgrades = priv->unixFile; + + char *cuBuffer; + unsigned int cuSize; + size_t cuReadSize; + + fseek (completedUpgrades, 0, SEEK_END); + cuSize = ftell (completedUpgrades); + rewind (completedUpgrades); + + cuBuffer = calloc (cuSize + 1, sizeof (char)); + + if (!cuBuffer) + return NULL; + + cuReadSize = fread (cuBuffer, 1, cuSize, completedUpgrades); + + /* + ccsWarning ("Couldn't read completed upgrades file!"); + */ + if (cuReadSize != cuSize) + { + free (cuBuffer); + return NULL; + } + + cuBuffer[cuSize] = '\0'; + + return cuBuffer; +} + +static Bool +ccsUnixTextFileAppendString (CCSTextFile *textFile, const char *str) +{ + CCSUnixTextFilePrivate *priv = GET_PRIVATE (CCSUnixTextFilePrivate, textFile); + FILE *completedUpgrades = priv->unixFile; + + fprintf (completedUpgrades, "%s\n", str); + return TRUE; +} + +static void +ccsUnixFreeTextFile (CCSTextFile *textFile) +{ + CCSUnixTextFilePrivate *priv = GET_PRIVATE (CCSUnixTextFilePrivate, textFile); + + fclose (priv->unixFile); + priv->unixFile = NULL; + + freeAndFinalizeCCSTextFile (textFile, + textFile->object.object_allocation); +} + +CCSTextFileInterface ccsUnixTextFileInterface = +{ + ccsUnixTextFileReadFromStart, + ccsUnixTextFileAppendString, + ccsUnixFreeTextFile +}; + +const char * CCS_UNIX_TEXT_FILE_OPEN_MODE_READONLY = "r"; +const char * CCS_UNIX_TEXT_FILE_OPEN_MODE_READWRITE = "r+"; +const char * CCS_UNIX_TEXT_FILE_OPEN_MODE_READWRITECREATE = "a+"; + +static FILE * +openUnixFile (CCSTextFile *textFile, + CCSObjectAllocationInterface *ai, + const char *path, + const char *openMode) +{ + FILE *file = fopen (path, openMode); + + if (!file) + { + ccsObjectFinalize (textFile); + (*ai->free_) (ai->allocator, textFile); + return NULL; + } + + return file; +} + + +static CCSUnixTextFilePrivate * +allocateCCSUnixTextFilePrivate (CCSTextFile *file, + CCSObjectAllocationInterface *ai) +{ + CCSUnixTextFilePrivate *priv = (*ai->calloc_) (ai->allocator, 1, sizeof (CCSUnixTextFilePrivate)); + + if (!priv) + { + freeAndFinalizeCCSTextFile (file, ai); + return NULL; + } + + return priv; +} + +static CCSTextFile * +allocateCCSTextFile (CCSObjectAllocationInterface *ai) +{ + CCSTextFile *textFile = (*ai->calloc_) (ai->allocator, 1, sizeof (CCSTextFile)); + + if (!textFile) + return NULL; + + ccsObjectInit (textFile, ai); + + return textFile; +} + +CCSTextFile * +ccsUnixTextFileNew (const char *path, + CCSTextFileOpenMode openMode, + CCSObjectAllocationInterface *ai) +{ + const char *fopenMode = NULL; + + switch (openMode) + { + case ReadOnly: + fopenMode = CCS_UNIX_TEXT_FILE_OPEN_MODE_READONLY; + break; + case ReadWrite: + fopenMode = CCS_UNIX_TEXT_FILE_OPEN_MODE_READWRITE; + break; + case ReadWriteCreate: + fopenMode = CCS_UNIX_TEXT_FILE_OPEN_MODE_READWRITECREATE; + break; + } + + CCSTextFile *textFile = allocateCCSTextFile (ai); + + if (!textFile) + return NULL; + + CCSUnixTextFilePrivate *priv = allocateCCSUnixTextFilePrivate (textFile, ai); + + if (!priv) + return NULL; + + ccsObjectSetPrivate (textFile, (CCSPrivate *) priv); + + FILE *unixFile = openUnixFile (textFile, + ai, + path, + fopenMode); + + if (!unixFile) + return NULL; + + priv->unixFile = unixFile; + + ccsObjectAddInterface (textFile, (const CCSInterface *) &ccsUnixTextFileInterface, + GET_INTERFACE_TYPE (CCSTextFileInterface)); + ccsObjectRef (textFile); + + return textFile; +} diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/libcompizconfig/src/ccs_text_file.h compiz-0.9.8.4/compizconfig/libcompizconfig/src/ccs_text_file.h --- compiz-0.9.8.2+bzr3377/compizconfig/libcompizconfig/src/ccs_text_file.h 1970-01-01 00:00:00.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/libcompizconfig/src/ccs_text_file.h 2012-09-27 11:04:02.000000000 +0000 @@ -0,0 +1,49 @@ +/* + * Compiz configuration system library + * + * ccs_text_file.h + * + * Copyright (C) 2012 Canonical Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authored By: + * Sam Spilsbury + */ +#ifndef CCS_TEXT_FILE_H +#define CCS_TEXT_FILE_H + +#include + +COMPIZCONFIG_BEGIN_DECLS + +typedef struct _CCSTextFile CCSTextFile; +typedef struct _CCSObjectAllocationInterface CCSObjectAllocationInterface; + +typedef enum _CCSTextFileOpenMode +{ + ReadOnly = 1, + ReadWrite = 2, + ReadWriteCreate = 3 +} CCSTextFileOpenMode; + +CCSTextFile * +ccsUnixTextFileNew (const char *path, + CCSTextFileOpenMode openMode, + CCSObjectAllocationInterface *ai); + +COMPIZCONFIG_END_DECLS + +#endif diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/libcompizconfig/src/ccs_text_file_interface.c compiz-0.9.8.4/compizconfig/libcompizconfig/src/ccs_text_file_interface.c --- compiz-0.9.8.2+bzr3377/compizconfig/libcompizconfig/src/ccs_text_file_interface.c 1970-01-01 00:00:00.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/libcompizconfig/src/ccs_text_file_interface.c 2012-09-27 11:04:02.000000000 +0000 @@ -0,0 +1,50 @@ +/* + * Compiz configuration system library + * + * ccs_text_file_interface.c + * + * Copyright (C) 2012 Canonical Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authored By: + * Sam Spilsbury + */ + +#include +#include +#include +#include + +INTERFACE_TYPE (CCSTextFileInterface); +CCSREF_OBJ (TextFile, CCSTextFile); + +char * +ccsTextFileReadFromStart (CCSTextFile *file) +{ + return (*(GET_INTERFACE (CCSTextFileInterface, file))->readFromStart) (file); +} + +Bool +ccsTextFileAppendString (CCSTextFile *file, const char *str) +{ + return (*(GET_INTERFACE (CCSTextFileInterface, file))->appendString) (file, str); +} + +void +ccsFreeTextFile (CCSTextFile *file) +{ + return (*(GET_INTERFACE (CCSTextFileInterface, file))->free) (file); +} diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/libcompizconfig/src/ccs_text_file_interface.h compiz-0.9.8.4/compizconfig/libcompizconfig/src/ccs_text_file_interface.h --- compiz-0.9.8.2+bzr3377/compizconfig/libcompizconfig/src/ccs_text_file_interface.h 1970-01-01 00:00:00.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/libcompizconfig/src/ccs_text_file_interface.h 2012-09-27 11:04:02.000000000 +0000 @@ -0,0 +1,67 @@ +/* + * Compiz configuration system library + * + * ccs_text_file_interface.h + * + * Copyright (C) 2012 Canonical Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authored By: + * Sam Spilsbury + */ +#ifndef CCS_TEXT_FILE_INTERFACE_H +#define CCS_TEXT_FILE_INTERFACE_H + +#include +#include + +COMPIZCONFIG_BEGIN_DECLS + +typedef struct _CCSTextFile CCSTextFile; +typedef struct _CCSTextFileInterface CCSTextFileInterface; + +typedef char * (*CCSReadTextFileFromStart) (CCSTextFile *file); +typedef Bool (*CCSAppendStringToTextFile) (CCSTextFile *file, const char *str); +typedef void (*CCSFreeTextFile) (CCSTextFile *file); + +struct _CCSTextFileInterface +{ + CCSReadTextFileFromStart readFromStart; + CCSAppendStringToTextFile appendString; + CCSFreeTextFile free; +}; + +struct _CCSTextFile +{ + CCSObject object; +}; + +CCSREF_HDR (TextFile, CCSTextFile); + +char * +ccsTextFileReadFromStart (CCSTextFile *); + +Bool +ccsTextFileAppendString (CCSTextFile *, const char *); + +void +ccsFreeTextFile (CCSTextFile *); + +unsigned int ccsCCSTextFileInterfaceGetType (); + +COMPIZCONFIG_END_DECLS + +#endif diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/libcompizconfig/src/main.c compiz-0.9.8.4/compizconfig/libcompizconfig/src/main.c --- compiz-0.9.8.2+bzr3377/compizconfig/libcompizconfig/src/main.c 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/libcompizconfig/src/main.c 2012-09-27 11:04:02.000000000 +0000 @@ -39,6 +39,8 @@ #include "ccs-private.h" #include "iniparser.h" #include "ccs_settings_upgrade_internal.h" +#include "ccs_text_file_interface.h" +#include "ccs_text_file.h" static void * wrapRealloc (void *o, void *a , size_t b) { @@ -622,7 +624,7 @@ } Bool -ccsPluginIsActiveDefault (CCSContext * context, char *name) +ccsPluginIsActiveDefault (CCSContext * context, const char *name) { CCSPlugin *plugin; @@ -636,7 +638,7 @@ } Bool -ccsPluginIsActive (CCSContext *context, char *name) +ccsPluginIsActive (CCSContext *context, const char *name) { return (*(GET_INTERFACE (CCSContextInterface, context))->contextPluginIsActive) (context, name); } @@ -904,7 +906,9 @@ ccsFreeSettingValueCommon (v, type); - if (v != ccsSettingGetDefaultValue (v->parent)) + /* List children cannot be a default value */ + if (v->isListChild || + v != ccsSettingGetDefaultValue (v->parent)) free (v); } @@ -1105,7 +1109,6 @@ void ccsFreeBackend (CCSBackend *backend) { - ccsBackendFini (backend); ccsObjectFinalize (backend); free (backend); } @@ -1115,6 +1118,7 @@ { CCSDynamicBackendPrivate *dbPrivate = GET_PRIVATE (CCSDynamicBackendPrivate, backend); + ccsBackendFini (dbPrivate->backend); ccsBackendUnref (dbPrivate->backend); if (dbPrivate->dlhand) @@ -2037,20 +2041,25 @@ } Bool -ccsCheckValueEq (CCSSettingValue *rhs, CCSSettingValue *lhs) +ccsCheckValueEq (const CCSSettingValue *rhs, + CCSSettingType rhsType, + CCSSettingInfo *rhsInfo, + const CCSSettingValue *lhs, + CCSSettingType lhsType, + CCSSettingInfo *lhsInfo) { CCSSettingType type; - if (ccsSettingGetType (rhs->parent) != ccsSettingGetType (lhs->parent)) + if (rhsType != lhsType) { ccsWarning ("Attempted to check equality between mismatched types!"); return FALSE; } if (rhs->isListChild) - type = ccsSettingGetInfo (rhs->parent)->forList.listType; + type = rhsInfo->forList.listType; else - type = ccsSettingGetType (rhs->parent); + type = rhsType; switch (type) { @@ -2080,14 +2089,14 @@ case TypeList: { return ccsCompareLists (lhs->value.asList, rhs->value.asList, - ccsSettingGetInfo (lhs->parent)->forList); + lhsInfo->forList); } default: break; } - ccsWarning ("Failed to process type %i", ccsSettingGetType (lhs->parent)); + ccsWarning ("Failed to check equality for value with type %i", lhsType); return FALSE; } @@ -2452,62 +2461,82 @@ return TRUE; } -CCSSettingValueList -ccsCopyList (CCSSettingValueList l1, CCSSetting * setting) +CCSSettingValue * +ccsCopyValue (CCSSettingValue *orig, + CCSSettingType type, + CCSSettingInfo *info) { - CCSSettingValueList l2 = NULL; + CCSSettingValue *value = calloc (1, sizeof (CCSSettingValue)); - while (l1) - { - CCSSettingValue *value = calloc (1, sizeof (CCSSettingValue)); - if (!value) - return l2; + if (!value) + return NULL; - value->refCount = 1; - value->parent = setting; - value->isListChild = TRUE; + value->refCount = 1; + value->parent = orig->parent; + value->isListChild = orig->isListChild; - switch (ccsSettingGetInfo (setting)->forList.listType) - { + CCSSettingType vType = value->isListChild ? info->forList.listType : type; + + switch (vType) + { case TypeInt: - value->value.asInt = l1->data->value.asInt; + value->value.asInt = orig->value.asInt; break; case TypeBool: - value->value.asBool = l1->data->value.asBool; + value->value.asBool = orig->value.asBool; break; case TypeFloat: - value->value.asFloat = l1->data->value.asFloat; + value->value.asFloat = orig->value.asFloat; break; case TypeString: - value->value.asString = strdup (l1->data->value.asString); + value->value.asString = strdup (orig->value.asString); break; case TypeMatch: - value->value.asMatch = strdup (l1->data->value.asMatch); + value->value.asMatch = strdup (orig->value.asMatch); break; case TypeKey: - memcpy (&value->value.asKey, &l1->data->value.asKey, + memcpy (&value->value.asKey, &orig->value.asKey, sizeof (CCSSettingKeyValue)); break; case TypeButton: - memcpy (&value->value.asButton, &l1->data->value.asButton, + memcpy (&value->value.asButton, &orig->value.asButton, sizeof (CCSSettingButtonValue)); break; case TypeEdge: - value->value.asEdge = l1->data->value.asEdge; + value->value.asEdge = orig->value.asEdge; break; case TypeBell: - value->value.asBell = l1->data->value.asBell; + value->value.asBell = orig->value.asBell; break; case TypeColor: - memcpy (&value->value.asColor, &l1->data->value.asColor, + memcpy (&value->value.asColor, &orig->value.asColor, sizeof (CCSSettingColorValue)); break; default: - /* FIXME If l2 != NULL, we leak l2 */ free (value); return NULL; break; - } + } + + return value; +} + +CCSSettingValueList +ccsCopyList (CCSSettingValueList l1, CCSSetting * setting) +{ + CCSSettingInfo *info = ccsSettingGetInfo (setting); + CCSSettingType type = ccsSettingGetType (setting); + CCSSettingValueList l2 = NULL; + + while (l1) + { + CCSSettingValue *value = ccsCopyValue (l1->data, + type, + info); + + /* FIXME If l2 != NULL, we leak l2 */ + if (!value) + return l2; l2 = ccsSettingValueListAppend (l2, value); l1 = l1->next; @@ -4572,21 +4601,17 @@ return FALSE; } -Bool -ccsProcessUpgrade (CCSContext *context, - CCSSettingsUpgrade *upgrade) +void +ccsCollectSettingsToUpgrade (CCSContext *context, + IniDictionary *dict, + CCSSettingsUpgrade *upgrade) { - CCSContextPrivate *cPrivate = GET_PRIVATE (CCSContextPrivate, context); - - IniDictionary *dict = ccsIniOpen (upgrade->file); - CCSPluginList pl = cPrivate->plugins; - CCSSettingList sl; - - ccsSetProfile (context, upgrade->profile); + CCSPluginList pl = ccsContextGetPlugins (context); while (pl) { - sl = ccsGetPluginSettings ((CCSPlugin *) pl->data); + CCSPlugin *plugin = (CCSPlugin *) pl->data; + CCSSettingList sl = ccsGetPluginSettings (plugin); while (sl) { @@ -4600,170 +4625,21 @@ pl = pl->next; } - - sl = upgrade->clearValueSettings; - - while (sl) - { - CCSSetting *tempSetting = (CCSSetting *) sl->data; - CCSSetting *setting; - CCSPlugin *plugin = ccsSettingGetParent (tempSetting); - const char *name = ccsSettingGetName (tempSetting); - - setting = ccsFindSetting (plugin, name); - - if (setting) - { - if (ccsSettingGetType (setting) != TypeList) - { - if (ccsSettingGetValue (setting) == ccsSettingGetValue (tempSetting)) - { - ccsDebug ("Resetting %s to default", ccsSettingGetName ((CCSSetting *) sl->data)); - ccsResetToDefault (setting, TRUE); - } - else - { - ccsDebug ("Skipping processing of %s", ccsSettingGetName ((CCSSetting *) sl->data)); - } - } - else - { - unsigned int count = 0; - /* Try and remove any specified items from the list */ - CCSSettingValueList l = ccsSettingGetValue (tempSetting)->value.asList; - CCSSettingValueList nl = ccsCopyList (ccsSettingGetValue (setting)->value.asList, setting); - - while (l) - { - CCSSettingValueList olv = nl; - - while (olv) - { - CCSSettingValue *lv = (CCSSettingValue *) l->data; - CCSSettingValue *olvv = (CCSSettingValue *) olv->data; - - if (ccsCheckValueEq (lv, olvv)) - break; - - olv = olv->next; - } - - if (olv) - { - count++; - nl = ccsSettingValueListRemove (nl, olv->data, TRUE); - } - - l = l->next; - } - - ccsDebug ("Removed %i items from %s", count, ccsSettingGetName (setting)); - ccsSetList (setting, nl, TRUE); - - } - } - - sl = sl->next; - } - - sl = upgrade->addValueSettings; - - while (sl) - { - CCSSetting *tempSetting = (CCSSetting *) sl->data; - CCSSetting *setting; - CCSPlugin *plugin = ccsSettingGetParent (tempSetting); - const char *name = ccsSettingGetName (tempSetting); - - setting = ccsFindSetting (plugin, name); - - if (setting) - { - ccsDebug ("Overriding value %s", ccsSettingGetName ((CCSSetting *) sl->data)); - if (ccsSettingGetType (setting) != TypeList) - ccsSetValue (setting, ccsSettingGetValue (tempSetting), TRUE); - else - { - unsigned int count = 0; - /* Try and apppend any new items to the list */ - CCSSettingValueList l = ccsSettingGetValue (tempSetting)->value.asList; - CCSSettingValueList nl = ccsCopyList (ccsSettingGetValue (setting)->value.asList, setting); - - while (l) - { - CCSSettingValueList olv = nl; - - while (olv) - { - CCSSettingValue *lv = (CCSSettingValue *) l->data; - CCSSettingValue *olvv = (CCSSettingValue *) olv->data; - - if (ccsCheckValueEq (lv, olvv)) - break; - - olv = olv->next; - } - - if (!olv) - { - count++; - nl = ccsSettingValueListAppend (nl, l->data); - } - - l = l->next; - } - - ccsDebug ("Appending %i items to %s", count, ccsSettingGetName (setting)); - ccsSetList (setting, nl, TRUE); - } - } - else - { - ccsDebug ("Value %s not found!", ccsSettingGetName ((CCSSetting *) sl->data)); - } - - sl = sl->next; - } +} - sl = upgrade->replaceFromValueSettings; - - while (sl) - { - CCSSetting *tempSetting = (CCSSetting *) sl->data; - CCSSetting *setting; - CCSPlugin *plugin = ccsSettingGetParent (tempSetting); - const char *name = ccsSettingGetName (tempSetting); +Bool +ccsProcessUpgrade (CCSContext *context, + CCSSettingsUpgrade *upgrade) +{ + IniDictionary *dict = ccsIniOpen (upgrade->file); - setting = ccsFindSetting (plugin, name); - - if (setting) - { - if (ccsSettingGetValue (setting) == ccsSettingGetValue (tempSetting)) - { - CCSSettingList rl = upgrade->replaceToValueSettings; - - while (rl) - { - CCSSetting *rsetting = (CCSSetting *) rl->data; - - if (strcmp (ccsSettingGetName (rsetting), ccsSettingGetName (setting)) == 0) - { - ccsDebug ("Matched and replaced %s", ccsSettingGetName (setting)); - ccsSetValue (setting, ccsSettingGetValue (rsetting), TRUE); - break; - } - - rl = rl->next; - } - } - else - { - ccsDebug ("Skipping processing of %s", ccsSettingGetName ((CCSSetting *) sl->data)); - } - } + ccsSetProfile (context, upgrade->profile); - sl = sl->next; - } + ccsCollectSettingsToUpgrade (context, dict, upgrade); + ccsUpgradeClearValues (upgrade->clearValueSettings); + ccsUpgradeAddValues (upgrade->addValueSettings); + ccsUpgradeReplaceValues (upgrade->replaceFromValueSettings, + upgrade->replaceToValueSettings); upgrade->clearValueSettings = ccsSettingListFree (upgrade->clearValueSettings, TRUE); upgrade->addValueSettings = ccsSettingListFree (upgrade->addValueSettings, TRUE); @@ -4810,7 +4686,7 @@ * */ CCSSettingsUpgrade * -ccsSettingsUpgradeNew (char *path, const char *name) +ccsSettingsUpgradeNew (const char *path, const char *name) { CCSSettingsUpgrade *upgrade = calloc (1, sizeof (CCSSettingsUpgrade)); char *upgradeName = strdup (name); @@ -4822,9 +4698,9 @@ upgradeName = strdup (name); if (!ccsUpgradeGetDomainNumAndProfile (upgradeName, - &upgrade->domain, - &upgrade->num, - &upgrade->profile)) + &upgrade->domain, + &upgrade->num, + &upgrade->profile)) { ccsFreeUpgrade (upgrade); upgrade = NULL; @@ -4835,41 +4711,35 @@ return upgrade; } -static FILE * +static CCSTextFile * +ccsUnixOpenDoneSettingsUpgradeFile (const char *path) +{ + return ccsUnixTextFileNew (path, + ReadWriteCreate, + &ccsDefaultObjectAllocator); +} + + + +static CCSTextFile * ccsGetDoneSettingsUpgradeFile (const char *home) { char *dupath = NULL; - FILE *completedUpgrades = NULL; + CCSTextFile *completedUpgrades = NULL; if (asprintf (&dupath, "%s/.config/compiz-1/compizconfig/done_upgrades", home) == -1) return NULL; - completedUpgrades = fopen (dupath, "a+"); + completedUpgrades = ccsUnixOpenDoneSettingsUpgradeFile (dupath); free (dupath); return completedUpgrades; } static char * -ccsReadCompletedUpgradesIntoString (FILE *completedUpgrades) +ccsReadCompletedUpgradesIntoString (CCSTextFile *completedUpgrades) { - char *cuBuffer; - unsigned int cuSize; - size_t cuReadSize; - - fseek (completedUpgrades, 0, SEEK_END); - cuSize = ftell (completedUpgrades); - rewind (completedUpgrades); - - cuBuffer = calloc (cuSize + 1, sizeof (char)); - cuReadSize = fread (cuBuffer, 1, cuSize, completedUpgrades); - - if (cuReadSize != cuSize) - ccsWarning ("Couldn't read completed upgrades file!"); - - cuBuffer[cuSize] = '\0'; - - return cuBuffer; + return ccsTextFileReadFromStart (completedUpgrades); } static unsigned int @@ -4906,7 +4776,7 @@ ccsProcessUpgradeOnce (CCSContext *context, CCSSettingsUpgrade *upgrade, const char *upgradeName, - FILE *completedUpgrades) + CCSTextFile *completedUpgrades) { ccsDebug ("Processing upgrade %s\n profile: %s\n number: %i\n domain: %s", upgradeName, @@ -4919,17 +4789,46 @@ ccsWriteAutoSortedPluginList (context); ccsDebug ("Completed upgrade %s", upgradeName); - fprintf (completedUpgrades, "%s\n", upgradeName); + ccsTextFileAppendString (completedUpgrades, upgradeName); ccsFreeUpgrade (upgrade); } +static const char * CCS_UPGRADE_PATH = DATADIR "/compizconfig/upgrades"; + +static void +ccsApplyUnappliedUpgrades (CCSContext *context, + struct dirent **nameList, + unsigned int nFile, + const char *completedUpradesContents, + CCSTextFile *completedUpgrades) +{ + int i = 0; + const char *path = CCS_UPGRADE_PATH; + + for (i = 0; i < nFile; i++) + { + CCSSettingsUpgrade *upgrade = NULL; + const char *upgradeName = nameList[i]->d_name; + + if (ccsShouldSkipUpgrade (upgradeName, + completedUpradesContents)) + continue; + + upgrade = ccsSettingsUpgradeNew (path, upgradeName); + + ccsProcessUpgradeOnce (context, upgrade, upgradeName, completedUpgrades); + + free (nameList[i]); + } +} + Bool ccsCheckForSettingsUpgradeDefault (CCSContext *context) { struct dirent **nameList = NULL; - int nFile, i; - char *path = DATADIR "/compizconfig/upgrades/"; - FILE *completedUpgrades; + int nFile; + const char *path = CCS_UPGRADE_PATH; + CCSTextFile *completedUpgrades; char *cuBuffer = NULL; char *home = getenv ("HOME"); @@ -4945,7 +4844,7 @@ if (!cuBuffer) { - fclose (completedUpgrades); + ccsTextFileUnref (completedUpgrades); ccsWarning ("Error opening done_upgrades"); return FALSE; } @@ -4955,27 +4854,13 @@ if (!nFile || !nameList) { free (cuBuffer); - fclose (completedUpgrades); + ccsTextFileUnref (completedUpgrades); return FALSE; } - for (i = 0; i < nFile; i++) - { - CCSSettingsUpgrade *upgrade = NULL; - const char *upgradeName = nameList[i]->d_name; - - if (ccsShouldSkipUpgrade (upgradeName, - cuBuffer)) - continue; - - upgrade = ccsSettingsUpgradeNew (path, upgradeName); - - ccsProcessUpgradeOnce (context, upgrade, upgradeName, completedUpgrades); - - free (nameList[i]); - } + ccsApplyUnappliedUpgrades (context, nameList, nFile, cuBuffer, completedUpgrades); - fclose (completedUpgrades); + ccsTextFileUnref (completedUpgrades); free (cuBuffer); if (nameList != NULL) @@ -5165,7 +5050,7 @@ return (*(GET_INTERFACE (CCSContextInterface, context))->contextImportFromFile) (context, fileName, overwriteNonDefault); } -char * +const char * ccsPluginGetNameDefault (CCSPlugin *plugin) { CCSPluginPrivate *pPrivate = GET_PRIVATE (CCSPluginPrivate, plugin); @@ -5173,28 +5058,28 @@ return pPrivate->name; } -char * ccsPluginGetShortDescDefault (CCSPlugin *plugin) +const char * ccsPluginGetShortDescDefault (CCSPlugin *plugin) { CCSPluginPrivate *pPrivate = GET_PRIVATE (CCSPluginPrivate, plugin); return pPrivate->shortDesc; } -char * ccsPluginGetLongDescDefault (CCSPlugin *plugin) +const char * ccsPluginGetLongDescDefault (CCSPlugin *plugin) { CCSPluginPrivate *pPrivate = GET_PRIVATE (CCSPluginPrivate, plugin); return pPrivate->longDesc; } -char * ccsPluginGetHintsDefault (CCSPlugin *plugin) +const char * ccsPluginGetHintsDefault (CCSPlugin *plugin) { CCSPluginPrivate *pPrivate = GET_PRIVATE (CCSPluginPrivate, plugin); return pPrivate->hints; } -char * ccsPluginGetCategoryDefault (CCSPlugin *plugin) +const char * ccsPluginGetCategoryDefault (CCSPlugin *plugin) { CCSPluginPrivate *pPrivate = GET_PRIVATE (CCSPluginPrivate, plugin); @@ -5270,27 +5155,27 @@ } /* CCSPlugin accessor functions */ -char * ccsPluginGetName (CCSPlugin *plugin) +const char * ccsPluginGetName (CCSPlugin *plugin) { return (*(GET_INTERFACE (CCSPluginInterface, plugin))->pluginGetName) (plugin); } -char * ccsPluginGetShortDesc (CCSPlugin *plugin) +const char * ccsPluginGetShortDesc (CCSPlugin *plugin) { return (*(GET_INTERFACE (CCSPluginInterface, plugin))->pluginGetShortDesc) (plugin); } -char * ccsPluginGetLongDesc (CCSPlugin *plugin) +const char * ccsPluginGetLongDesc (CCSPlugin *plugin) { return (*(GET_INTERFACE (CCSPluginInterface, plugin))->pluginGetLongDesc) (plugin); } -char * ccsPluginGetHints (CCSPlugin *plugin) +const char * ccsPluginGetHints (CCSPlugin *plugin) { return (*(GET_INTERFACE (CCSPluginInterface, plugin))->pluginGetHints) (plugin); } -char * ccsPluginGetCategory (CCSPlugin *plugin) +const char * ccsPluginGetCategory (CCSPlugin *plugin) { return (*(GET_INTERFACE (CCSPluginInterface, plugin))->pluginGetCategory) (plugin); } @@ -5370,18 +5255,18 @@ return (*(GET_INTERFACE (CCSPluginInterface, plugin))->pluginGetPluginGroups) (plugin); } -char * ccsSettingGetName (CCSSetting *setting) +const char * ccsSettingGetName (CCSSetting *setting) { return (*(GET_INTERFACE (CCSSettingInterface, setting))->settingGetName) (setting); } -char * ccsSettingGetShortDesc (CCSSetting *setting) +const char * ccsSettingGetShortDesc (CCSSetting *setting) { return (*(GET_INTERFACE (CCSSettingInterface, setting))->settingGetShortDesc) (setting); } -char * ccsSettingGetLongDesc (CCSSetting *setting) +const char * ccsSettingGetLongDesc (CCSSetting *setting) { return (*(GET_INTERFACE (CCSSettingInterface, setting))->settingGetLongDesc) (setting); } @@ -5396,17 +5281,17 @@ return (*(GET_INTERFACE (CCSSettingInterface, setting))->settingGetInfo) (setting); } -char * ccsSettingGetGroup (CCSSetting *setting) +const char * ccsSettingGetGroup (CCSSetting *setting) { return (*(GET_INTERFACE (CCSSettingInterface, setting))->settingGetGroup) (setting); } -char * ccsSettingGetSubGroup (CCSSetting *setting) +const char * ccsSettingGetSubGroup (CCSSetting *setting) { return (*(GET_INTERFACE (CCSSettingInterface, setting))->settingGetSubGroup) (setting); } -char * ccsSettingGetHints (CCSSetting *setting) +const char * ccsSettingGetHints (CCSSetting *setting) { return (*(GET_INTERFACE (CCSSettingInterface, setting))->settingGetHints) (setting); } @@ -5527,7 +5412,7 @@ } /* Interface for CCSSetting */ -char * +const char * ccsSettingGetNameDefault (CCSSetting *setting) { CCSSettingPrivate *sPrivate = GET_PRIVATE (CCSSettingPrivate, setting); @@ -5535,14 +5420,14 @@ return sPrivate->name; } -char * ccsSettingGetShortDescDefault (CCSSetting *setting) +const char * ccsSettingGetShortDescDefault (CCSSetting *setting) { CCSSettingPrivate *sPrivate = GET_PRIVATE (CCSSettingPrivate, setting); return sPrivate->shortDesc; } -char * ccsSettingGetLongDescDefault (CCSSetting *setting) +const char * ccsSettingGetLongDescDefault (CCSSetting *setting) { CCSSettingPrivate *sPrivate = GET_PRIVATE (CCSSettingPrivate, setting); @@ -5563,21 +5448,21 @@ return &sPrivate->info; } -char * ccsSettingGetGroupDefault (CCSSetting *setting) +const char * ccsSettingGetGroupDefault (CCSSetting *setting) { CCSSettingPrivate *sPrivate = GET_PRIVATE (CCSSettingPrivate, setting); return sPrivate->group; } -char * ccsSettingGetSubGroupDefault (CCSSetting *setting) +const char * ccsSettingGetSubGroupDefault (CCSSetting *setting) { CCSSettingPrivate *sPrivate = GET_PRIVATE (CCSSettingPrivate, setting); return sPrivate->subGroup; } -char * ccsSettingGetHintsDefault (CCSSetting *setting) +const char * ccsSettingGetHintsDefault (CCSSetting *setting) { CCSSettingPrivate *sPrivate = GET_PRIVATE (CCSSettingPrivate, setting); @@ -5789,7 +5674,7 @@ void ccsFreeIntegratedSettingsStorage (CCSIntegratedSettingsStorage *storage) { - (*(GET_INTERFACE (CCSIntegratedSettingsStorageInterface, storage))->empty) (storage); + (*(GET_INTERFACE (CCSIntegratedSettingsStorageInterface, storage))->free) (storage); } /* CCSIntegratedSettingsStorageDefault implementation */ diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/libcompizconfig/tests/CMakeLists.txt compiz-0.9.8.4/compizconfig/libcompizconfig/tests/CMakeLists.txt --- compiz-0.9.8.2+bzr3377/compizconfig/libcompizconfig/tests/CMakeLists.txt 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/libcompizconfig/tests/CMakeLists.txt 2012-09-27 11:04:02.000000000 +0000 @@ -7,6 +7,7 @@ link_directories (${CMAKE_INSTALL_PREFIX}/lib) link_directories (${CMAKE_CURRENT_BINARY_DIR}/../../mocks/libcompizconfig) link_directories (${CMAKE_CURRENT_BINARY_DIR}/../../tests/) +link_directories (${CMAKE_CURRENT_BINARY_DIR}/../src/) set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") @@ -25,6 +26,9 @@ add_executable (compizconfig_test_ccs_backend ${CMAKE_CURRENT_SOURCE_DIR}/compizconfig_test_ccs_backend.cpp) +add_executable (compizconfig_test_ccs_text_file + ${CMAKE_CURRENT_SOURCE_DIR}/compizconfig_test_ccs_text_file.cpp) + add_executable (compizconfig_test_ccs_mock_backend_conformance ${CMAKE_CURRENT_SOURCE_DIR}/compizconfig_test_ccs_mock_backend_conformance.cpp) @@ -89,7 +93,13 @@ compizconfig_ccs_context_mock compizconfig_ccs_plugin_mock compizconfig_ccs_setting_mock - compizconfig_ccs_backend_mock) + compizconfig_ccs_backend_mock + compizconfig_ccs_backend_conformance_test + compizconfig_ccs_item_in_list_matcher + compizconfig_ccs_list_equality + compizconfig_ccs_list_wrapper + compizconfig_ccs_setting_value_operators + compizconfig_ccs_test_value_combinations) target_link_libraries (compizconfig_test_ccs_setting ${GTEST_BOTH_LIBRARIES} @@ -102,12 +112,28 @@ compizconfig_ccs_plugin_mock compizconfig_ccs_setting_mock) +target_link_libraries (compizconfig_test_ccs_text_file + ${GTEST_BOTH_LIBRARIES} + ${GMOCK_LIBRARY} + ${GMOCK_MAIN_LIBRARY} + ${CMAKE_THREAD_LIBS_INIT} + ${LIBCOMPIZCONFIG_LIBRARIES} + ccs_text_file_interface + compizconfig_ccs_text_file_mock + compizconfig) + target_link_libraries (compizconfig_test_ccs_upgrade_internal ${GTEST_BOTH_LIBRARIES} ${GMOCK_LIBRARY} ${GMOCK_MAIN_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} - ccs_settings_upgrade_internal + ccs_settings_upgrade_internal + compizconfig + compizconfig_ccs_context_mock + compizconfig_ccs_plugin_mock + compizconfig_ccs_setting_mock + compizconfig_ccs_item_in_list_matcher + compizconfig_ccs_setting_value_matcher ) compiz_discover_tests (compizconfig_test_ccs_object COVERAGE compizconfig) @@ -115,4 +141,5 @@ compiz_discover_tests (compizconfig_test_ccs_plugin COVERAGE compizconfig_ccs_plugin_mock) compiz_discover_tests (compizconfig_test_ccs_setting COVERAGE compizconfig_ccs_setting_mock) compiz_discover_tests (compizconfig_test_ccs_mock_backend_conformance COVERAGE compizconfig_ccs_backend_mock) +compiz_discover_tests (compizconfig_test_ccs_text_file COVERAGE ccs_text_file_interface compizconfig_ccs_text_file_mock) compiz_discover_tests (compizconfig_test_ccs_upgrade_internal COVERAGE ccs_settings_upgrade_internal) diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/libcompizconfig/tests/compizconfig_test_ccs_mock_backend_conformance.cpp compiz-0.9.8.4/compizconfig/libcompizconfig/tests/compizconfig_test_ccs_mock_backend_conformance.cpp --- compiz-0.9.8.2+bzr3377/compizconfig/libcompizconfig/tests/compizconfig_test_ccs_mock_backend_conformance.cpp 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/libcompizconfig/tests/compizconfig_test_ccs_mock_backend_conformance.cpp 2012-09-27 11:04:02.000000000 +0000 @@ -151,68 +151,80 @@ virtual Bool ReadBoolAtKey (const std::string &plugin, const std::string &key) { - return boolToBool (ValueForKeyRetreival ().GetValueForKey (keynameFromPluginKey (plugin, key), mValues)); + return compizconfig::test::boolToBool ( + ValueForKeyRetreival ().GetValueForKey ( + keynameFromPluginKey (plugin, key), mValues)); } virtual int ReadIntegerAtKey (const std::string &plugin, const std::string &key) { - return ValueForKeyRetreival ().GetValueForKey (keynameFromPluginKey (plugin, key), mValues); + return ValueForKeyRetreival ().GetValueForKey ( + keynameFromPluginKey (plugin, key), mValues); } virtual float ReadFloatAtKey (const std::string &plugin, const std::string &key) { - return ValueForKeyRetreival ().GetValueForKey (keynameFromPluginKey (plugin, key), mValues); + return ValueForKeyRetreival ().GetValueForKey ( + keynameFromPluginKey (plugin, key), mValues); } virtual const char * ReadStringAtKey (const std::string &plugin, const std::string &key) { - return ValueForKeyRetreival ().GetValueForKey (keynameFromPluginKey (plugin, key), mValues); + return ValueForKeyRetreival ().GetValueForKey ( + keynameFromPluginKey (plugin, key), mValues); } virtual CCSSettingColorValue ReadColorAtKey (const std::string &plugin, const std::string &key) { - return ValueForKeyRetreival ().GetValueForKey (keynameFromPluginKey (plugin, key), mValues); + return ValueForKeyRetreival ().GetValueForKey ( + keynameFromPluginKey (plugin, key), mValues); } virtual CCSSettingKeyValue ReadKeyAtKey (const std::string &plugin, const std::string &key) { - return ValueForKeyRetreival ().GetValueForKey (keynameFromPluginKey (plugin, key), mValues); + return ValueForKeyRetreival ().GetValueForKey ( + keynameFromPluginKey (plugin, key), mValues); } virtual CCSSettingButtonValue ReadButtonAtKey (const std::string &plugin, const std::string &key) { - return ValueForKeyRetreival ().GetValueForKey (keynameFromPluginKey (plugin, key), mValues); + return ValueForKeyRetreival ().GetValueForKey ( + keynameFromPluginKey (plugin, key), mValues); } virtual unsigned int ReadEdgeAtKey (const std::string &plugin, const std::string &key) { - return ValueForKeyRetreival ().GetValueForKey (keynameFromPluginKey (plugin, key), mValues); + return ValueForKeyRetreival ().GetValueForKey ( + keynameFromPluginKey (plugin, key), mValues); } virtual const char * ReadMatchAtKey (const std::string &plugin, const std::string &key) { - return ValueForKeyRetreival ().GetValueForKey (keynameFromPluginKey (plugin, key), mValues); + return ValueForKeyRetreival ().GetValueForKey ( + keynameFromPluginKey (plugin, key), mValues); } virtual Bool ReadBellAtKey (const std::string &plugin, const std::string &key) { - return boolToBool (ValueForKeyRetreival ().GetValueForKey (keynameFromPluginKey (plugin, key), mValues)); + return compizconfig::test::boolToBool ( + ValueForKeyRetreival ().GetValueForKey ( + keynameFromPluginKey (plugin, key), mValues)); } virtual CCSSettingValueList ReadListAtKey (const std::string &plugin, const std::string &key, CCSSetting *setting) { - CCSListWrapper::Ptr lw (ValueForKeyRetreival > ().GetValueForKey (keynameFromPluginKey (plugin, key), mValues)); + cci::SettingValueListWrapper::Ptr lw (ValueForKeyRetreival > ().GetValueForKey (keynameFromPluginKey (plugin, key), mValues)); return ccsCopyList (*lw, lw->setting ().get ()); } @@ -373,15 +385,14 @@ EXPECT_CALL (*gmockSetting, getName ()); EXPECT_CALL (*gmockSetting, getParent ()); + testing::Cardinality cardinality; + if (type == TypeList) - { - EXPECT_CALL (*gmockSetting, getType ()).Times (AtLeast (1)); - EXPECT_CALL (*gmockSetting, getDefaultValue ()).Times (AtLeast (1)); - } + cardinality = ::testing::AtLeast (1); else - { - EXPECT_CALL (*gmockSetting, getType ()); - } + cardinality = ::testing::AtMost (1); + + EXPECT_CALL (*gmockSetting, getType ()).Times (cardinality); } void PostWrite (CCSContextGMock *gmockContext, @@ -688,12 +699,15 @@ break; case TypeList: - ccsSetList (setting, CCSListWrapper (ReadListAtKey (plugin, key, setting), - true, - ccsSettingGetInfo (setting)->forList.listType, - boost::shared_ptr (), - boost::shared_ptr (setting, boost::bind (doNothingWithCCSSetting, _1))), FALSE); - break; + ccsSetList (setting, + cci::SettingValueListWrapper (ReadListAtKey (plugin, key, setting), + cci::Deep, + ccsSettingGetInfo (setting)->forList.listType, + boost::shared_ptr (), + boost::shared_ptr (setting, + boost::bind (doNothingWithCCSSetting, _1))), + FALSE); + break; default: @@ -785,10 +799,11 @@ ccsGetList (setting, &vList); listCopy = ccsCopyList (vList, setting); - WriteListAtKey (plugin, key, VariantTypes (boost::make_shared (listCopy, true, - ccsSettingGetInfo (setting)->forList.listType, - boost::shared_ptr (), - boost::shared_ptr (setting, boost::bind (doNothingWithCCSSetting, _1))))); + WriteListAtKey (plugin, key, VariantTypes (boost::make_shared (listCopy, + cci::Deep, + ccsSettingGetInfo (setting)->forList.listType, + boost::shared_ptr (), + boost::shared_ptr (setting, boost::bind (doNothingWithCCSSetting, _1))))); break; } default: diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/libcompizconfig/tests/compizconfig_test_ccs_settings_upgrade_internal.cpp compiz-0.9.8.4/compizconfig/libcompizconfig/tests/compizconfig_test_ccs_settings_upgrade_internal.cpp --- compiz-0.9.8.2+bzr3377/compizconfig/libcompizconfig/tests/compizconfig_test_ccs_settings_upgrade_internal.cpp 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/libcompizconfig/tests/compizconfig_test_ccs_settings_upgrade_internal.cpp 2012-09-27 11:04:02.000000000 +0000 @@ -1,10 +1,64 @@ +/* + * Compiz configuration system library + * + * Copyright (C) 2012 Canonical Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authored By: + * Sam Spilsbury + */ +#include + #include #include +#include +#include +#include + +#include + +#include "compizconfig_ccs_context_mock.h" +#include "compizconfig_ccs_plugin_mock.h" +#include "compizconfig_ccs_setting_mock.h" + #include "ccs_settings_upgrade_internal.h" #include "gtest_shared_characterwrapper.h" +#include "gtest_shared_autodestroy.h" +#include "gtest_unspecified_bool_type_matcher.h" +#include "compizconfig_ccs_list_equality.h" +#include "compizconfig_ccs_item_in_list_matcher.h" +#include "compizconfig_ccs_list_wrapper.h" +#include "compizconfig_ccs_setting_value_operators.h" +#include "compizconfig_ccs_setting_value_matcher.h" using ::testing::IsNull; +using ::testing::Eq; +using ::testing::Return; +using ::testing::AtLeast; +using ::testing::_; +using ::testing::AllOf; +using ::testing::Not; +using ::testing::Matcher; +using ::testing::MakeMatcher; +using ::testing::MatcherInterface; +using ::testing::Pointee; + +namespace cc = compiz::config; +namespace cci = compiz::config::impl; class CCSSettingsUpgradeInternalTest : public ::testing::Test @@ -15,15 +69,13 @@ { static const std::string CCS_SETTINGS_UPGRADE_TEST_CORRECT_FILENAME = "org.compiz.general.1.upgrade"; static const std::string CCS_SETTINGS_UPGRADE_TEST_INCORRECT_FILENAME = "1.upgra"; + static const std::string CCS_SETTINGS_UPGRADE_TEST_VERY_INCORRECT_FILENAME = "1"; static const std::string CCS_SETTINGS_UPGRADE_TEST_CORRECT_DOMAIN = "org.compiz"; static const std::string CCS_SETTINGS_UPGRADE_TEST_CORRECT_PROFILE = "general"; static const unsigned int CCS_SETTINGS_UPGRADE_TEST_CORRECT_NUM = 1; } -MATCHER(BoolTrue, "Bool True") { if (arg) return true; else return false; } -MATCHER(BoolFalse, "Bool False") { if (!arg) return true; else return false; } - -TEST_F (CCSSettingsUpgradeInternalTest, TestDetokenizeAndSetValues) +TEST (CCSSettingsUpgradeInternalTest, TestDetokenizeAndSetValues) { char *profileName = NULL; char *domainName = NULL; @@ -33,7 +85,7 @@ EXPECT_THAT (ccsUpgradeGetDomainNumAndProfile (CCS_SETTINGS_UPGRADE_TEST_CORRECT_FILENAME.c_str (), &domainName, &num, - &profileName), BoolTrue ()); + &profileName), IsTrue ()); CharacterWrapper profileNameC (profileName); CharacterWrapper domainNameC (domainName); @@ -43,7 +95,7 @@ EXPECT_EQ (num, CCS_SETTINGS_UPGRADE_TEST_CORRECT_NUM); } -TEST_F (CCSSettingsUpgradeInternalTest, TestDetokenizeAndSetValuesReturnsFalseIfInvalid) +TEST (CCSSettingsUpgradeInternalTest, TestDetokenizeAndSetValuesReturnsFalseIfInvalid) { char *profileName = NULL; char *domainName = NULL; @@ -53,18 +105,627 @@ EXPECT_THAT (ccsUpgradeGetDomainNumAndProfile (CCS_SETTINGS_UPGRADE_TEST_INCORRECT_FILENAME.c_str (), &domainName, &num, - &profileName), BoolFalse ()); + &profileName), IsFalse ()); + + EXPECT_THAT (profileName, IsNull ()); + EXPECT_THAT (domainName, IsNull ()); + + EXPECT_THAT (ccsUpgradeGetDomainNumAndProfile (CCS_SETTINGS_UPGRADE_TEST_VERY_INCORRECT_FILENAME.c_str (), + &domainName, + &num, + &profileName), IsFalse ()); EXPECT_THAT (profileName, IsNull ()); EXPECT_THAT (domainName, IsNull ()); } -TEST_F (CCSSettingsUpgradeInternalTest, TestDetokenizeAndReturnTrueForUpgradeFileName) +TEST (CCSSettingsUpgradeInternalTest, TestDetokenizeAndReturnTrueForUpgradeFileName) +{ + EXPECT_THAT (ccsUpgradeNameFilter (CCS_SETTINGS_UPGRADE_TEST_CORRECT_FILENAME.c_str ()), IsTrue ()); +} + +TEST (CCSSettingsUpgradeInternalTest, TestDetokenizeAndReturnFalseForNoUpgradeFileName) +{ + EXPECT_THAT (ccsUpgradeNameFilter (CCS_SETTINGS_UPGRADE_TEST_INCORRECT_FILENAME.c_str ()), IsFalse ()); + EXPECT_THAT (ccsUpgradeNameFilter (CCS_SETTINGS_UPGRADE_TEST_VERY_INCORRECT_FILENAME.c_str ()), IsFalse ()); +} + +namespace +{ + const std::string CCS_SETTINGS_UPGRADE_TEST_MOCK_PLUGIN_NAME = "mock"; + const std::string CCS_SETTINGS_UPGRADE_TEST_MOCK_SETTING_NAME_ONE = "setting_one"; + const std::string CCS_SETTINGS_UPGRADE_TEST_MOCK_SETTING_NAME_TWO = "setting_two"; + + typedef std::tr1::tuple , + CCSSettingGMock *> MockedSetting; + + inline CCSSetting * Real (MockedSetting &ms) { return (std::tr1::get <0> (ms)).get (); } + inline CCSSettingGMock & Mock (MockedSetting &ms) { return *(std::tr1::get <1> (ms)); } +} + +class CCSSettingsUpgradeTestWithMockContext : + public ::testing::Test +{ + public: + + typedef enum _AddMode + { + DoNotAddSettingToPlugin, + AddSettingToPlugin + } AddMode; + + virtual void SetUp () + { + context = AutoDestroy (ccsMockContextNew (), + ccsFreeMockContext); + plugin = AutoDestroy (ccsMockPluginNew (), + ccsFreeMockPlugin); + + ON_CALL (MockPlugin (), getName ()) + .WillByDefault ( + Return ( + + CCS_SETTINGS_UPGRADE_TEST_MOCK_PLUGIN_NAME.c_str ())); + + ON_CALL (MockPlugin (), getContext ()) + .WillByDefault ( + Return ( + context.get ())); + } + + CCSPluginGMock & MockPlugin () + { + return *(reinterpret_cast (ccsObjectGetPrivate (plugin.get ()))); + } + + CCSContextGMock & MockContext () + { + return *(reinterpret_cast (ccsObjectGetPrivate (context.get ()))); + } + + void InitializeValueCommon (CCSSettingValue &value, + CCSSetting *setting) + { + value.parent = setting; + value.refCount = 1; + } + + void InitializeValueForSetting (CCSSettingValue &value, + CCSSetting *setting) + { + InitializeValueCommon (value, setting); + value.isListChild = FALSE; + } + + + MockedSetting + SpawnSetting (const std::string &name, + CCSSettingType type, + AddMode addMode = AddSettingToPlugin) + { + boost::shared_ptr setting (ccsMockSettingNew (), + ccsSettingUnref); + + CCSSettingGMock *gmockSetting = reinterpret_cast (ccsObjectGetPrivate (setting.get ())); + + ON_CALL (*gmockSetting, getName ()) + .WillByDefault ( + Return ( + name.c_str ())); + ON_CALL (*gmockSetting, getType ()) + .WillByDefault ( + Return ( + type)); + + ON_CALL (*gmockSetting, getParent ()) + .WillByDefault ( + Return ( + plugin.get ())); + + if (addMode == AddSettingToPlugin) + { + ON_CALL (MockPlugin (), findSetting (Eq (name.c_str ()))) + .WillByDefault ( + Return ( + setting.get ())); + } + + return MockedSetting (setting, gmockSetting); + } + + private: + + boost::shared_ptr context; + boost::shared_ptr plugin; +}; + +namespace +{ + typedef boost::shared_ptr > CCSSettingListWrapperPtr; + + CCSSettingListWrapperPtr + constructSettingListWrapper (CCSSettingList list, + cci::ListStorageType storageType) + { + return boost::make_shared > (list, + ccsSettingListFree, + ccsSettingListAppend, + ccsSettingListRemove, + storageType); + } +} + +TEST_F (CCSSettingsUpgradeTestWithMockContext, TestNoClearValuesSettingNotFound) +{ + MockedSetting settingOne (SpawnSetting (CCS_SETTINGS_UPGRADE_TEST_MOCK_SETTING_NAME_ONE, + TypeInt, + DoNotAddSettingToPlugin)); + + EXPECT_CALL (MockPlugin (), findSetting (Eq (CCS_SETTINGS_UPGRADE_TEST_MOCK_SETTING_NAME_ONE))); + EXPECT_CALL (Mock (settingOne), getParent ()); + EXPECT_CALL (Mock (settingOne), getName ()); + + CCSSettingListWrapperPtr list (constructSettingListWrapper (ccsSettingListAppend (NULL, Real (settingOne)), + cci::Shallow)); + + ccsUpgradeClearValues (*list); +} + +TEST_F (CCSSettingsUpgradeTestWithMockContext, TestClearValuesInListNonListType) +{ + MockedSetting resetSettingIdentifier (SpawnSetting (CCS_SETTINGS_UPGRADE_TEST_MOCK_SETTING_NAME_ONE, + TypeInt, + DoNotAddSettingToPlugin)); + MockedSetting settingToReset (SpawnSetting (CCS_SETTINGS_UPGRADE_TEST_MOCK_SETTING_NAME_ONE, + TypeInt)); + CCSSettingValue valueToReset; + CCSSettingValue valueResetIdentifier; + + InitializeValueForSetting (valueToReset, Real (settingToReset)); + InitializeValueForSetting (valueResetIdentifier, Real (resetSettingIdentifier)); + + valueToReset.value.asInt = 7; + valueResetIdentifier.value.asInt = 7; + + CCSSettingListWrapperPtr list (constructSettingListWrapper (ccsSettingListAppend (NULL, Real (resetSettingIdentifier)), + cci::Shallow)); + + EXPECT_CALL (MockPlugin (), findSetting (Eq (CCS_SETTINGS_UPGRADE_TEST_MOCK_SETTING_NAME_ONE))) + .WillOnce (Return (Real (settingToReset))); + EXPECT_CALL (Mock (resetSettingIdentifier), getParent ()); + EXPECT_CALL (Mock (resetSettingIdentifier), getName ()); + + CCSSettingInfo info; + + info.forInt.max = 0; + info.forInt.min = 10; + + /* ccsCheckValueEq needs to know the type and info about this type */ + EXPECT_CALL (Mock (settingToReset), getType ()).Times (AtLeast (1)); + EXPECT_CALL (Mock (resetSettingIdentifier), getType ()).Times (AtLeast (1)); + + EXPECT_CALL (Mock (settingToReset), getInfo ()).WillRepeatedly (Return (&info)); + EXPECT_CALL (Mock (resetSettingIdentifier), getInfo ()).WillRepeatedly (Return (&info)); + + EXPECT_CALL (Mock (resetSettingIdentifier), getValue ()).WillOnce (Return (&valueResetIdentifier)); + EXPECT_CALL (Mock (settingToReset), getValue ()).WillOnce (Return (&valueToReset)); + + EXPECT_CALL (Mock (settingToReset), resetToDefault (IsTrue ())); + + ccsUpgradeClearValues (*list); +} + +TEST_F (CCSSettingsUpgradeTestWithMockContext, TestClearValuesInListNonListTypeNotMatched) +{ + MockedSetting resetSettingIdentifier (SpawnSetting (CCS_SETTINGS_UPGRADE_TEST_MOCK_SETTING_NAME_ONE, + TypeInt, + DoNotAddSettingToPlugin)); + MockedSetting settingToReset (SpawnSetting (CCS_SETTINGS_UPGRADE_TEST_MOCK_SETTING_NAME_ONE, + TypeInt)); + CCSSettingValue valueToReset; + CCSSettingValue valueResetIdentifier; + + InitializeValueForSetting (valueToReset, Real (settingToReset)); + InitializeValueForSetting (valueResetIdentifier, Real (resetSettingIdentifier)); + + valueToReset.value.asInt = 2; + valueResetIdentifier.value.asInt = 7; + + CCSSettingListWrapperPtr list (constructSettingListWrapper (ccsSettingListAppend (NULL, Real (resetSettingIdentifier)), + cci::Shallow)); + + EXPECT_CALL (MockPlugin (), findSetting (Eq (CCS_SETTINGS_UPGRADE_TEST_MOCK_SETTING_NAME_ONE))) + .WillOnce (Return (Real (settingToReset))); + EXPECT_CALL (Mock (resetSettingIdentifier), getParent ()); + EXPECT_CALL (Mock (resetSettingIdentifier), getName ()); + + CCSSettingInfo info; + + info.forInt.max = 0; + info.forInt.min = 10; + + /* ccsCheckValueEq needs to know the type and info about this type */ + EXPECT_CALL (Mock (settingToReset), getType ()).Times (AtLeast (1)); + EXPECT_CALL (Mock (resetSettingIdentifier), getType ()).Times (AtLeast (1)); + + EXPECT_CALL (Mock (settingToReset), getInfo ()).WillRepeatedly (Return (&info)); + EXPECT_CALL (Mock (resetSettingIdentifier), getInfo ()).WillRepeatedly (Return (&info)); + + EXPECT_CALL (Mock (resetSettingIdentifier), getValue ()).WillOnce (Return (&valueResetIdentifier)); + EXPECT_CALL (Mock (settingToReset), getValue ()).WillOnce (Return (&valueToReset)); + + ccsUpgradeClearValues (*list); +} + +TEST_F (CCSSettingsUpgradeTestWithMockContext, TestNoAddValuesSettingNotFound) +{ + MockedSetting settingOne (SpawnSetting (CCS_SETTINGS_UPGRADE_TEST_MOCK_SETTING_NAME_ONE, + TypeInt, + DoNotAddSettingToPlugin)); + + EXPECT_CALL (MockPlugin (), findSetting (Eq (CCS_SETTINGS_UPGRADE_TEST_MOCK_SETTING_NAME_ONE))); + EXPECT_CALL (Mock (settingOne), getParent ()); + EXPECT_CALL (Mock (settingOne), getName ()); + + CCSSettingListWrapperPtr list (constructSettingListWrapper (ccsSettingListAppend (NULL, Real (settingOne)), + cci::Shallow)); + + ccsUpgradeAddValues (*list); +} + +TEST_F (CCSSettingsUpgradeTestWithMockContext, TestAddValuesInListNonListType) { - EXPECT_THAT (ccsUpgradeNameFilter (CCS_SETTINGS_UPGRADE_TEST_CORRECT_FILENAME.c_str ()), BoolTrue ()); + MockedSetting addSettingIdentifier (SpawnSetting (CCS_SETTINGS_UPGRADE_TEST_MOCK_SETTING_NAME_ONE, + TypeInt, + DoNotAddSettingToPlugin)); + MockedSetting settingToBeChanged (SpawnSetting (CCS_SETTINGS_UPGRADE_TEST_MOCK_SETTING_NAME_ONE, + TypeInt)); + CCSSettingValue valueToReset; + CCSSettingValue valueResetIdentifier; + + InitializeValueForSetting (valueToReset, Real (settingToBeChanged)); + InitializeValueForSetting (valueResetIdentifier, Real (addSettingIdentifier)); + + valueToReset.value.asInt = 7; + valueResetIdentifier.value.asInt = 7; + + CCSSettingListWrapperPtr list (constructSettingListWrapper (ccsSettingListAppend (NULL, Real (addSettingIdentifier)), + cci::Shallow)); + + EXPECT_CALL (MockPlugin (), findSetting (Eq (CCS_SETTINGS_UPGRADE_TEST_MOCK_SETTING_NAME_ONE))) + .WillOnce (Return (Real (settingToBeChanged))); + EXPECT_CALL (Mock (addSettingIdentifier), getParent ()); + EXPECT_CALL (Mock (addSettingIdentifier), getName ()); + + CCSSettingInfo info; + + info.forInt.max = 0; + info.forInt.min = 10; + + /* ccsCheckValueEq needs to know the type and info about this type */ + EXPECT_CALL (Mock (settingToBeChanged), getType ()).Times (AtLeast (1)); + EXPECT_CALL (Mock (addSettingIdentifier), getType ()).Times (AtLeast (1)); + + EXPECT_CALL (Mock (settingToBeChanged), getInfo ()).WillRepeatedly (Return (&info)); + EXPECT_CALL (Mock (addSettingIdentifier), getInfo ()).WillRepeatedly (Return (&info)); + + EXPECT_CALL (Mock (addSettingIdentifier), getValue ()).WillOnce (Return (&valueResetIdentifier)); + + EXPECT_CALL (Mock (settingToBeChanged), setValue (Pointee (SettingValueMatch (valueResetIdentifier, + TypeInt, + &info)), IsTrue ())); + + ccsUpgradeAddValues (*list); +} + +TEST_F (CCSSettingsUpgradeTestWithMockContext, TestNoReplaceValuesSettingNotFound) +{ + MockedSetting fromSettingIdentifier (SpawnSetting (CCS_SETTINGS_UPGRADE_TEST_MOCK_SETTING_NAME_ONE, + TypeInt, + DoNotAddSettingToPlugin)); + MockedSetting toSettingIdentifier (SpawnSetting (CCS_SETTINGS_UPGRADE_TEST_MOCK_SETTING_NAME_ONE, + TypeInt, + DoNotAddSettingToPlugin)); + + EXPECT_CALL (MockPlugin (), findSetting (Eq (CCS_SETTINGS_UPGRADE_TEST_MOCK_SETTING_NAME_ONE))); + EXPECT_CALL (Mock (fromSettingIdentifier), getParent ()); + EXPECT_CALL (Mock (fromSettingIdentifier), getName ()); + + CCSSettingListWrapperPtr replaceFromValueSettings (constructSettingListWrapper (ccsSettingListAppend (NULL, Real (fromSettingIdentifier)), + cci::Shallow)); + CCSSettingListWrapperPtr replaceToValueSettings (constructSettingListWrapper (ccsSettingListAppend (NULL, Real (toSettingIdentifier)), + cci::Shallow)); + + + ccsUpgradeReplaceValues (*replaceFromValueSettings, + *replaceToValueSettings); +} + +TEST_F (CCSSettingsUpgradeTestWithMockContext, TestReplaceValuesInListNonListType) +{ + MockedSetting fromSettingIdentifier (SpawnSetting (CCS_SETTINGS_UPGRADE_TEST_MOCK_SETTING_NAME_ONE, + TypeInt, + DoNotAddSettingToPlugin)); + MockedSetting toSettingIdentifier (SpawnSetting (CCS_SETTINGS_UPGRADE_TEST_MOCK_SETTING_NAME_ONE, + TypeInt, + DoNotAddSettingToPlugin)); + MockedSetting settingToBeChanged (SpawnSetting (CCS_SETTINGS_UPGRADE_TEST_MOCK_SETTING_NAME_ONE, + TypeInt)); + CCSSettingValue settingToBeChangedValue; + CCSSettingValue fromSettingIdentifierValue; + CCSSettingValue toSettingIdentifierValue; + + InitializeValueForSetting (settingToBeChangedValue, Real (settingToBeChanged)); + InitializeValueForSetting (fromSettingIdentifierValue, Real (fromSettingIdentifier)); + InitializeValueForSetting (toSettingIdentifierValue, Real (toSettingIdentifier)); + + settingToBeChangedValue.value.asInt = 7; + fromSettingIdentifierValue.value.asInt = 7; + toSettingIdentifierValue.value.asInt = 8; + + CCSSettingListWrapperPtr replaceFromValueSettings (constructSettingListWrapper (ccsSettingListAppend (NULL, Real (fromSettingIdentifier)), + cci::Shallow)); + CCSSettingListWrapperPtr replaceToValueSettings (constructSettingListWrapper (ccsSettingListAppend (NULL, Real (toSettingIdentifier)), + cci::Shallow)); + + + EXPECT_CALL (MockPlugin (), findSetting (Eq (CCS_SETTINGS_UPGRADE_TEST_MOCK_SETTING_NAME_ONE))) + .WillOnce (Return (Real (settingToBeChanged))); + EXPECT_CALL (Mock (fromSettingIdentifier), getParent ()); + EXPECT_CALL (Mock (fromSettingIdentifier), getName ()); + EXPECT_CALL (Mock (toSettingIdentifier), getName ()); + + CCSSettingInfo info; + + info.forInt.max = 0; + info.forInt.min = 10; + + /* ccsCheckValueEq needs to know the type and info about this type */ + EXPECT_CALL (Mock (settingToBeChanged), getType ()).Times (AtLeast (1)); + EXPECT_CALL (Mock (fromSettingIdentifier), getType ()).Times (AtLeast (1)); + + EXPECT_CALL (Mock (settingToBeChanged), getInfo ()).WillRepeatedly (Return (&info)); + EXPECT_CALL (Mock (fromSettingIdentifier), getInfo ()).WillRepeatedly (Return (&info)); + EXPECT_CALL (Mock (toSettingIdentifier), getInfo ()).WillRepeatedly (Return (&info)); + + EXPECT_CALL (Mock (settingToBeChanged), getValue ()).WillOnce (Return (&settingToBeChangedValue)); + EXPECT_CALL (Mock (fromSettingIdentifier), getValue ()).WillOnce (Return (&fromSettingIdentifierValue)); + EXPECT_CALL (Mock (toSettingIdentifier), getValue ()).WillOnce (Return (&toSettingIdentifierValue)); + + + EXPECT_CALL (Mock (settingToBeChanged), setValue (Pointee (SettingValueMatch (toSettingIdentifierValue, + TypeInt, + &info)), IsTrue ())); + + ccsUpgradeReplaceValues (*replaceFromValueSettings, + *replaceToValueSettings); } -TEST_F (CCSSettingsUpgradeInternalTest, TestDetokenizeAndReturnFalseForNoUpgradeFileName) +TEST_F (CCSSettingsUpgradeTestWithMockContext, TestReplaceValuesInListNonListTypeNoMatch) { - EXPECT_THAT (ccsUpgradeNameFilter (CCS_SETTINGS_UPGRADE_TEST_CORRECT_FILENAME.c_str ()), BoolTrue ()); + MockedSetting fromSettingIdentifier (SpawnSetting (CCS_SETTINGS_UPGRADE_TEST_MOCK_SETTING_NAME_ONE, + TypeInt, + DoNotAddSettingToPlugin)); + MockedSetting toSettingIdentifier (SpawnSetting (CCS_SETTINGS_UPGRADE_TEST_MOCK_SETTING_NAME_ONE, + TypeInt, + DoNotAddSettingToPlugin)); + MockedSetting settingToBeChanged (SpawnSetting (CCS_SETTINGS_UPGRADE_TEST_MOCK_SETTING_NAME_ONE, + TypeInt)); + CCSSettingValue settingToBeChangedValue; + CCSSettingValue fromSettingIdentifierValue; + CCSSettingValue toSettingIdentifierValue; + + InitializeValueForSetting (settingToBeChangedValue, Real (settingToBeChanged)); + InitializeValueForSetting (fromSettingIdentifierValue, Real (fromSettingIdentifier)); + InitializeValueForSetting (toSettingIdentifierValue, Real (toSettingIdentifier)); + + settingToBeChangedValue.value.asInt = 6; + fromSettingIdentifierValue.value.asInt = 7; + toSettingIdentifierValue.value.asInt = 8; + + CCSSettingListWrapperPtr replaceFromValueSettings (constructSettingListWrapper (ccsSettingListAppend (NULL, Real (fromSettingIdentifier)), + cci::Shallow)); + CCSSettingListWrapperPtr replaceToValueSettings (constructSettingListWrapper (ccsSettingListAppend (NULL, Real (toSettingIdentifier)), + cci::Shallow)); + + EXPECT_CALL (MockPlugin (), findSetting (Eq (CCS_SETTINGS_UPGRADE_TEST_MOCK_SETTING_NAME_ONE))) + .WillOnce (Return (Real (settingToBeChanged))); + EXPECT_CALL (Mock (fromSettingIdentifier), getParent ()); + EXPECT_CALL (Mock (fromSettingIdentifier), getName ()); + + CCSSettingInfo info; + + info.forInt.max = 0; + info.forInt.min = 10; + + /* ccsCheckValueEq needs to know the type and info about this type */ + EXPECT_CALL (Mock (settingToBeChanged), getType ()).Times (AtLeast (1)); + EXPECT_CALL (Mock (fromSettingIdentifier), getType ()).Times (AtLeast (1)); + + EXPECT_CALL (Mock (settingToBeChanged), getInfo ()).WillRepeatedly (Return (&info)); + EXPECT_CALL (Mock (fromSettingIdentifier), getInfo ()).WillRepeatedly (Return (&info)); + EXPECT_CALL (Mock (toSettingIdentifier), getInfo ()).WillRepeatedly (Return (&info)); + + EXPECT_CALL (Mock (settingToBeChanged), getValue ()).WillOnce (Return (&settingToBeChangedValue)); + EXPECT_CALL (Mock (fromSettingIdentifier), getValue ()).WillOnce (Return (&fromSettingIdentifierValue)); + + ccsUpgradeReplaceValues (*replaceFromValueSettings, + *replaceToValueSettings); +} + +namespace +{ + boost::shared_ptr + newOwnedCCSStringFromStaticCharArray (const char *cStr) + { + CCSString *string = reinterpret_cast (calloc (1, sizeof (CCSString))); + boost::shared_ptr str (string, + ccsStringUnref); + + str->value = strdup (cStr); + ccsStringRef (str.get ()); + return str; + } + + void + ccsStringListDeepFree (CCSStringList list) + { + ccsStringListFree (list, TRUE); + } + + void + ccsSettingValueListDeepFree (CCSSettingValueList list) + { + ccsSettingValueListFree (list, TRUE); + } + + void + ccsSettingValueListShallowFree (CCSSettingValueList list) + { + ccsSettingValueListFree (list, FALSE); + } + + typedef boost::shared_ptr > CCSStringListWrapperPtr; + + CCSStringListWrapperPtr + constructStrListWrapper (CCSStringList list, + cci::ListStorageType storageType) + { + return boost::make_shared > (list, + ccsStringListFree, + ccsStringListAppend, + ccsStringListRemove, + storageType); + } +} + +TEST_F (CCSSettingsUpgradeTestWithMockContext, TestAddValuesInListAppendsValuesToListFromList) +{ + const std::string valueOne ("value_one"); + const std::string valueThree ("value_three"); + MockedSetting appendSettingIdentifier (SpawnSetting (CCS_SETTINGS_UPGRADE_TEST_MOCK_SETTING_NAME_ONE, + TypeList, + DoNotAddSettingToPlugin)); + MockedSetting settingToAppendValuesTo (SpawnSetting (CCS_SETTINGS_UPGRADE_TEST_MOCK_SETTING_NAME_ONE, + TypeList)); + + boost::shared_ptr stringToAppendOne (newOwnedCCSStringFromStaticCharArray (valueOne.c_str ())); + boost::shared_ptr stringInBothLists (newOwnedCCSStringFromStaticCharArray (valueThree.c_str ())); + + CCSStringListWrapperPtr settingsStrList (constructStrListWrapper (ccsStringListAppend (NULL, stringInBothLists.get ()), + cci::Shallow)); + + + boost::shared_ptr <_CCSSettingValueList> settingStrValueList (AutoDestroy (ccsGetValueListFromStringList (*settingsStrList, + Real (settingToAppendValuesTo)), + ccsSettingValueListDeepFree)); + + CCSStringListWrapperPtr appendStrList (constructStrListWrapper (ccsStringListAppend (NULL, stringInBothLists.get ()), + cci::Shallow)); + appendStrList->append (stringToAppendOne.get ()); + + boost::shared_ptr <_CCSSettingValueList> appendStrValueList (AutoDestroy (ccsGetValueListFromStringList (*appendStrList, + Real (appendSettingIdentifier)), + ccsSettingValueListDeepFree)); + + + CCSSettingListWrapperPtr list (constructSettingListWrapper (ccsSettingListAppend (NULL, Real (appendSettingIdentifier)), + cci::Shallow)); + + CCSSettingValue valueToHaveSubValuesAdded; + CCSSettingValue valueSubValuesAddIdentifiers; + + InitializeValueForSetting (valueToHaveSubValuesAdded, Real (settingToAppendValuesTo)); + InitializeValueForSetting (valueSubValuesAddIdentifiers, Real (appendSettingIdentifier)); + + valueToHaveSubValuesAdded.value.asList = settingStrValueList.get (); + valueSubValuesAddIdentifiers.value.asList = appendStrValueList.get (); + + CCSSettingInfo info; + + info.forList.listType = TypeString; + + EXPECT_CALL (MockPlugin (), findSetting (Eq (CCS_SETTINGS_UPGRADE_TEST_MOCK_SETTING_NAME_ONE))) + .WillOnce (Return (Real (settingToAppendValuesTo))); + EXPECT_CALL (Mock (appendSettingIdentifier), getParent ()); + EXPECT_CALL (Mock (appendSettingIdentifier), getName ()); + EXPECT_CALL (Mock (appendSettingIdentifier), getType ()).Times (AtLeast (1)); + EXPECT_CALL (Mock (settingToAppendValuesTo), getType ()).Times (AtLeast (1)); + EXPECT_CALL (Mock (appendSettingIdentifier), getValue ()).WillOnce (Return (&valueSubValuesAddIdentifiers)); + EXPECT_CALL (Mock (settingToAppendValuesTo), getValue ()).WillOnce (Return (&valueToHaveSubValuesAdded)); + EXPECT_CALL (Mock (settingToAppendValuesTo), getInfo ()).WillRepeatedly (Return (&info)); + EXPECT_CALL (Mock (appendSettingIdentifier), getInfo ()).WillRepeatedly (Return (&info)); + + const CCSSettingValue &appendedStringInListValue = *appendStrValueList->next->data; + + EXPECT_CALL (Mock (settingToAppendValuesTo), setList ( + IsSettingValueInSettingValueCCSList ( + SettingValueMatch (appendedStringInListValue, TypeString, &info)), IsTrue ())); + + ccsUpgradeAddValues (*list); +} + +TEST_F (CCSSettingsUpgradeTestWithMockContext, TestClearValuesInListRemovesValuesFromList) +{ + const std::string valueOne ("value_one"); + const std::string valueThree ("value_three"); + MockedSetting resetSettingIdentifier (SpawnSetting (CCS_SETTINGS_UPGRADE_TEST_MOCK_SETTING_NAME_ONE, + TypeList, + DoNotAddSettingToPlugin)); + MockedSetting settingToRemoveValuesFrom (SpawnSetting (CCS_SETTINGS_UPGRADE_TEST_MOCK_SETTING_NAME_ONE, + TypeList)); + + boost::shared_ptr stringForRemovalOne (newOwnedCCSStringFromStaticCharArray (valueOne.c_str ())); + boost::shared_ptr stringNotRemoved (newOwnedCCSStringFromStaticCharArray (valueThree.c_str ())); + + CCSStringListWrapperPtr settingsStrList (constructStrListWrapper (ccsStringListAppend (NULL, stringForRemovalOne.get ()), + cci::Shallow)); + settingsStrList->append (stringNotRemoved.get ()); + + boost::shared_ptr <_CCSSettingValueList> settingStrValueList (AutoDestroy (ccsGetValueListFromStringList (*settingsStrList, + Real (settingToRemoveValuesFrom)), + ccsSettingValueListDeepFree)); + + CCSStringListWrapperPtr removeStrList (constructStrListWrapper (ccsStringListAppend (NULL, stringForRemovalOne.get ()), + cci::Shallow)); + + boost::shared_ptr <_CCSSettingValueList> removeStrValueList (AutoDestroy (ccsGetValueListFromStringList (*removeStrList, + Real (resetSettingIdentifier)), + ccsSettingValueListDeepFree)); + + CCSSettingListWrapperPtr list (constructSettingListWrapper (ccsSettingListAppend (NULL, Real (resetSettingIdentifier)), + cci::Shallow)); + + CCSSettingValue valueToHaveSubValuesRemoved; + CCSSettingValue valueSubValuesResetIdentifiers; + + InitializeValueForSetting (valueToHaveSubValuesRemoved, Real (settingToRemoveValuesFrom)); + InitializeValueForSetting (valueSubValuesResetIdentifiers, Real (resetSettingIdentifier)); + + valueToHaveSubValuesRemoved.value.asList = settingStrValueList.get (); + valueSubValuesResetIdentifiers.value.asList = removeStrValueList.get (); + + CCSSettingInfo info; + + info.forList.listType = TypeString; + + EXPECT_CALL (MockPlugin (), findSetting (Eq (CCS_SETTINGS_UPGRADE_TEST_MOCK_SETTING_NAME_ONE))) + .WillOnce (Return (Real (settingToRemoveValuesFrom))); + EXPECT_CALL (Mock (resetSettingIdentifier), getParent ()); + EXPECT_CALL (Mock (resetSettingIdentifier), getName ()); + EXPECT_CALL (Mock (resetSettingIdentifier), getType ()).Times (AtLeast (1)); + EXPECT_CALL (Mock (settingToRemoveValuesFrom), getType ()).Times (AtLeast (1)); + EXPECT_CALL (Mock (resetSettingIdentifier), getValue ()).WillOnce (Return (&valueSubValuesResetIdentifiers)); + EXPECT_CALL (Mock (settingToRemoveValuesFrom), getValue ()).WillOnce (Return (&valueToHaveSubValuesRemoved)); + EXPECT_CALL (Mock (settingToRemoveValuesFrom), getInfo ()).WillRepeatedly (Return (&info)); + EXPECT_CALL (Mock (resetSettingIdentifier), getInfo ()).WillRepeatedly (Return (&info)); + + const CCSSettingValue &removedStringInListValue = *removeStrValueList->data; + + EXPECT_CALL (Mock (settingToRemoveValuesFrom), setList ( + Not ( + IsSettingValueInSettingValueCCSList ( + SettingValueMatch (removedStringInListValue, TypeString, &info))), IsTrue ())); + + ccsUpgradeClearValues (*list); } diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/libcompizconfig/tests/compizconfig_test_ccs_text_file.cpp compiz-0.9.8.4/compizconfig/libcompizconfig/tests/compizconfig_test_ccs_text_file.cpp --- compiz-0.9.8.2+bzr3377/compizconfig/libcompizconfig/tests/compizconfig_test_ccs_text_file.cpp 1970-01-01 00:00:00.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/libcompizconfig/tests/compizconfig_test_ccs_text_file.cpp 2012-09-27 11:04:02.000000000 +0000 @@ -0,0 +1,49 @@ +#include + +#include +#include + +#include +#include + +#include + +#include "ccs_text_file_interface.h" +#include "compizconfig_ccs_text_file_mock.h" + +#include +#include + +using ::testing::_; +using ::testing::Return; +using ::testing::Eq; + +class CCSTextFileTest : + public ::testing::Test +{ +}; + +namespace +{ + const std::string CCS_TEXT_FILE_TESTING_CONTENTS; + const std::string CCS_TEXT_FILE_APPEND_CONTENTS; +} + +MATCHER(BoolTrue, "Boolean True") { if (arg) return true; else return false; } + +TEST(CCSTextFileTest, TestMock) +{ + boost::shared_ptr textFile (AutoDestroy (ccsMockTextFileNew (&ccsDefaultObjectAllocator), + ccsTextFileUnref)); + CCSTextFileGMock *mock = reinterpret_cast (ccsObjectGetPrivate (textFile)); + + CharacterWrapper temporaryFileContents (strdup (CCS_TEXT_FILE_TESTING_CONTENTS.c_str ())); + char *temporaryFileContentsC = temporaryFileContents; + + EXPECT_CALL (*mock, readFromStart ()).WillOnce (Return (temporaryFileContentsC)); + EXPECT_CALL (*mock, appendString (Eq (CCS_TEXT_FILE_APPEND_CONTENTS))).WillOnce (Return (TRUE)); + EXPECT_CALL (*mock, free ()); + + EXPECT_THAT (ccsTextFileReadFromStart (textFile.get ()), Eq (CCS_TEXT_FILE_TESTING_CONTENTS)); + EXPECT_THAT (ccsTextFileAppendString (textFile.get (), CCS_TEXT_FILE_APPEND_CONTENTS.c_str ()), BoolTrue ()); +} diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/mocks/libcompizconfig/CMakeLists.txt compiz-0.9.8.4/compizconfig/mocks/libcompizconfig/CMakeLists.txt --- compiz-0.9.8.2+bzr3377/compizconfig/mocks/libcompizconfig/CMakeLists.txt 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/mocks/libcompizconfig/CMakeLists.txt 2012-09-27 11:04:02.000000000 +0000 @@ -1,6 +1,8 @@ include_directories (${GTEST_INCLUDE_DIRS}) include_directories (${CMAKE_CURRENT_SOURCE_DIR}/../../libcompizconfig/include) +include_directories (${CMAKE_CURRENT_SOURCE_DIR}/../../libcompizconfig/src) link_directories (${CMAKE_INSTALL_PREFIX}/lib) +link_directories (${CMAKE_CURRENT_BINARY_DIR}/../../libcompizconfig/src) if (HAVE_PROTOBUF) set (LIBCOMPIZCONFIG_LIBRARIES @@ -20,6 +22,21 @@ add_library (compizconfig_ccs_backend_mock ${CMAKE_CURRENT_SOURCE_DIR}/compizconfig_ccs_backend_mock.cpp) +add_library (compizconfig_ccs_text_file_mock + ${CMAKE_CURRENT_SOURCE_DIR}/compizconfig_ccs_text_file_mock.cpp) + +add_library (compizconfig_ccs_integration_mock + ${CMAKE_CURRENT_SOURCE_DIR}/compizconfig_ccs_integration_mock.cpp) + +add_library (compizconfig_ccs_integrated_setting_mock + ${CMAKE_CURRENT_SOURCE_DIR}/compizconfig_ccs_integrated_setting_mock.cpp) + +add_library (compizconfig_ccs_integrated_setting_storage_mock + ${CMAKE_CURRENT_SOURCE_DIR}/compizconfig_ccs_integrated_setting_storage_mock.cpp) + +add_library (compizconfig_ccs_integrated_setting_factory_mock + ${CMAKE_CURRENT_SOURCE_DIR}/compizconfig_ccs_integrated_setting_factory_mock.cpp) + target_link_libraries (compizconfig_ccs_context_mock ${GTEST_BOTH_LIBRARIES} ${GMOCK_LIBRARY} @@ -51,3 +68,37 @@ ${CMAKE_THREAD_LIBS_INIT} ${LIBCOMPIZCONFIG_LIBRARIES} compizconfig) + +target_link_libraries (compizconfig_ccs_text_file_mock + ${GTEST_BOTH_LIBRARIES} + ${GMOCK_LIBRARY} + ${GMOCK_MAIN_LIBRARY} + ${CMAKE_THREAD_LIBS_INIT}) + +target_link_libraries (compizconfig_ccs_integration_mock + ${GTEST_BOTH_LIBRARIES} + ${GMOCK_LIBRARY} + ${GMOCK_MAIN_LIBRARY} + ${CMAKE_THREAD_LIBS_INIT} + compizconfig) + +target_link_libraries (compizconfig_ccs_integrated_setting_mock + ${GTEST_BOTH_LIBRARIES} + ${GMOCK_LIBRARY} + ${GMOCK_MAIN_LIBRARY} + ${CMAKE_THREAD_LIBS_INIT} + compizconfig) + +target_link_libraries (compizconfig_ccs_integrated_setting_factory_mock + ${GTEST_BOTH_LIBRARIES} + ${GMOCK_LIBRARY} + ${GMOCK_MAIN_LIBRARY} + ${CMAKE_THREAD_LIBS_INIT} + compizconfig) + +target_link_libraries (compizconfig_ccs_integrated_setting_storage_mock + ${GTEST_BOTH_LIBRARIES} + ${GMOCK_LIBRARY} + ${GMOCK_MAIN_LIBRARY} + ${CMAKE_THREAD_LIBS_INIT} + compizconfig) diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/mocks/libcompizconfig/compizconfig_ccs_context_mock.h compiz-0.9.8.4/compizconfig/mocks/libcompizconfig/compizconfig_ccs_context_mock.h --- compiz-0.9.8.2+bzr3377/compizconfig/mocks/libcompizconfig/compizconfig_ccs_context_mock.h 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/mocks/libcompizconfig/compizconfig_ccs_context_mock.h 2012-09-27 11:04:02.000000000 +0000 @@ -23,7 +23,7 @@ virtual void setPrivatePtr (void *) = 0; virtual Bool loadPlugin (char *name) = 0; virtual CCSPlugin * findPlugin (const char *name) = 0; - virtual Bool pluginIsActive (char *name) = 0; + virtual Bool pluginIsActive (const char *name) = 0; virtual CCSPluginList getActivePluginList () = 0; virtual CCSStringList getSortedPluginStringList () = 0; virtual const char * getBackend () = 0; @@ -71,7 +71,7 @@ MOCK_METHOD1 (setPrivatePtr, void (void *)); MOCK_METHOD1 (loadPlugin, Bool (char *)); MOCK_METHOD1 (findPlugin, CCSPlugin * (const char *)); - MOCK_METHOD1 (pluginIsActive, Bool (char *)); + MOCK_METHOD1 (pluginIsActive, Bool (const char *)); MOCK_METHOD0 (getActivePluginList, CCSPluginList ()); MOCK_METHOD0 (getSortedPluginStringList, CCSStringList ()); MOCK_METHOD0 (getBackend, const char * ()); @@ -163,7 +163,7 @@ } static Bool - ccsPluginIsActive (CCSContext *context, char *name) + ccsPluginIsActive (CCSContext *context, const char *name) { return ((CCSContextGMock *) ccsObjectGetPrivate (context))->pluginIsActive (name); } diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/mocks/libcompizconfig/compizconfig_ccs_integrated_setting_factory_mock.cpp compiz-0.9.8.4/compizconfig/mocks/libcompizconfig/compizconfig_ccs_integrated_setting_factory_mock.cpp --- compiz-0.9.8.2+bzr3377/compizconfig/mocks/libcompizconfig/compizconfig_ccs_integrated_setting_factory_mock.cpp 1970-01-01 00:00:00.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/mocks/libcompizconfig/compizconfig_ccs_integrated_setting_factory_mock.cpp 2012-09-27 11:04:02.000000000 +0000 @@ -0,0 +1,70 @@ +/* + * Compiz configuration system library + * + * Copyright (C) 2012 Canonical Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authored By: + * Sam Spilsbury + */ +#include +#include + +#include + +#include "compizconfig_ccs_integrated_setting_factory_mock.h" + +const CCSIntegratedSettingFactoryInterface mockIntegratedSettingFactoryInterface = +{ + CCSIntegratedSettingFactoryGMock::ccsIntegratedSettingFactoryCreateIntegratedSettingForCCSSettingNameAndType, + CCSIntegratedSettingFactoryGMock::ccsIntegratedSettingFactoryFree +}; + +CCSIntegratedSettingFactory * +ccsMockIntegratedSettingFactoryNew (CCSObjectAllocationInterface *ai) +{ + CCSIntegratedSettingFactory *integratedSettingFactory = + reinterpret_cast ((*ai->calloc_) (ai->allocator, 1, sizeof (CCSIntegratedSettingFactory))); + + if (!integratedSettingFactory) + return NULL; + + CCSIntegratedSettingFactoryGMock *gmockFactory = new CCSIntegratedSettingFactoryGMock (integratedSettingFactory); + + ccsObjectInit (integratedSettingFactory, ai); + ccsObjectSetPrivate (integratedSettingFactory, (CCSPrivate *) gmockFactory); + ccsObjectAddInterface (integratedSettingFactory, + reinterpret_cast (&mockIntegratedSettingFactoryInterface), + GET_INTERFACE_TYPE (CCSIntegratedSettingFactoryInterface)); + + ccsObjectRef (integratedSettingFactory); + + return integratedSettingFactory; +} + +void +ccsMockIntegratedSettingFactoryFree (CCSIntegratedSettingFactory *integratedSettingFactory) +{ + CCSIntegratedSettingFactoryGMock *gmockFactory = + GET_PRIVATE (CCSIntegratedSettingFactoryGMock, integratedSettingFactory); + + delete gmockFactory; + + ccsObjectSetPrivate (integratedSettingFactory, NULL); + ccsObjectFinalize (integratedSettingFactory); + (*integratedSettingFactory->object.object_allocation->free_) + (integratedSettingFactory->object.object_allocation->allocator, integratedSettingFactory); +} diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/mocks/libcompizconfig/compizconfig_ccs_integrated_setting_factory_mock.h compiz-0.9.8.4/compizconfig/mocks/libcompizconfig/compizconfig_ccs_integrated_setting_factory_mock.h --- compiz-0.9.8.2+bzr3377/compizconfig/mocks/libcompizconfig/compizconfig_ccs_integrated_setting_factory_mock.h 1970-01-01 00:00:00.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/mocks/libcompizconfig/compizconfig_ccs_integrated_setting_factory_mock.h 2012-09-27 11:04:02.000000000 +0000 @@ -0,0 +1,99 @@ +/* + * Compiz configuration system library + * + * Copyright (C) 2012 Canonical Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authored By: + * Sam Spilsbury + */ +#ifndef _COMPIZCONFIG_CCS_INTEGRATED_SETTING_FACTORY_MOCK_H +#define _COMPIZCONFIG_CCS_INTEGRATED_SETTING_FACTORY_MOCK_H + +#include +#include + +#include +#include + +CCSIntegratedSettingFactory * +ccsMockIntegratedSettingFactoryNew (CCSObjectAllocationInterface *ai); + +void +ccsMockIntegratedSettingFactoryFree (CCSIntegratedSettingFactory *); + +class CCSIntegratedSettingFactoryGMockInterface +{ + public: + + virtual ~CCSIntegratedSettingFactoryGMockInterface () {} + + virtual CCSIntegratedSetting * createIntegratedSettingForCCSNameAndType (CCSIntegration *integration, + const char *pluginName, + const char *settingName, + CCSSettingType type) = 0; +}; + +class CCSIntegratedSettingFactoryGMock : + public CCSIntegratedSettingFactoryGMockInterface +{ + public: + + MOCK_METHOD4 (createIntegratedSettingForCCSNameAndType, CCSIntegratedSetting * (CCSIntegration *, + const char *, + const char *, + CCSSettingType )); + + CCSIntegratedSettingFactoryGMock (CCSIntegratedSettingFactory *integratedSettingFactory) : + mIntegratedSettingFactory (integratedSettingFactory) + { + } + + CCSIntegratedSettingFactory * + getIntegratedSettingFactory () + { + return mIntegratedSettingFactory; + } + + public: + + static CCSIntegratedSetting * + ccsIntegratedSettingFactoryCreateIntegratedSettingForCCSSettingNameAndType (CCSIntegratedSettingFactory *factory, + CCSIntegration *integration, + const char *pluginName, + const char *settingName, + CCSSettingType type) + { + return reinterpret_cast (factory)->createIntegratedSettingForCCSNameAndType (integration, + pluginName, + settingName, + type); + } + + static void + ccsIntegratedSettingFactoryFree (CCSIntegratedSettingFactory *integratedSettingFactory) + { + ccsMockIntegratedSettingFactoryFree (integratedSettingFactory); + } + + private: + + CCSIntegratedSettingFactory *mIntegratedSettingFactory; +}; + +extern const CCSIntegratedSettingFactoryInterface mockIntegratedSettingFactoryInterface; + +#endif diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/mocks/libcompizconfig/compizconfig_ccs_integrated_setting_mock.cpp compiz-0.9.8.4/compizconfig/mocks/libcompizconfig/compizconfig_ccs_integrated_setting_mock.cpp --- compiz-0.9.8.2+bzr3377/compizconfig/mocks/libcompizconfig/compizconfig_ccs_integrated_setting_mock.cpp 1970-01-01 00:00:00.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/mocks/libcompizconfig/compizconfig_ccs_integrated_setting_mock.cpp 2012-09-27 11:04:02.000000000 +0000 @@ -0,0 +1,71 @@ +/* + * Compiz configuration system library + * + * Copyright (C) 2012 Canonical Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authored By: + * Sam Spilsbury + */ +#include +#include + +#include + +#include "compizconfig_ccs_integrated_setting_mock.h" + +const CCSIntegratedSettingInterface mockIntegratedSettingInterface = +{ + CCSIntegratedSettingGMock::ccsIntegratedSettingReadValue, + CCSIntegratedSettingGMock::ccsIntegratedSettingWriteValue, + CCSIntegratedSettingGMock::ccsIntegratedSettingFree +}; + +CCSIntegratedSetting * +ccsMockIntegratedSettingNew (CCSObjectAllocationInterface *ai) +{ + CCSIntegratedSetting *integratedSetting = + reinterpret_cast ((*ai->calloc_) (ai->allocator, 1, sizeof (CCSIntegratedSetting))); + + if (!integratedSetting) + return NULL; + + CCSIntegratedSettingGMock *gmockBackend = new CCSIntegratedSettingGMock (integratedSetting); + + ccsObjectInit (integratedSetting, ai); + ccsObjectSetPrivate (integratedSetting, (CCSPrivate *) gmockBackend); + ccsObjectAddInterface (integratedSetting, + reinterpret_cast (&mockIntegratedSettingInterface), + GET_INTERFACE_TYPE (CCSIntegratedSettingInterface)); + + ccsObjectRef (integratedSetting); + + return integratedSetting; +} + +void +ccsMockIntegratedSettingFree (CCSIntegratedSetting *integration) +{ + CCSIntegratedSettingGMock *gmockIntegration = + GET_PRIVATE (CCSIntegratedSettingGMock, integration); + + delete gmockIntegration; + + ccsObjectSetPrivate (integration, NULL); + ccsObjectFinalize (integration); + (*integration->object.object_allocation->free_) + (integration->object.object_allocation->allocator, integration); +} diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/mocks/libcompizconfig/compizconfig_ccs_integrated_setting_mock.h compiz-0.9.8.4/compizconfig/mocks/libcompizconfig/compizconfig_ccs_integrated_setting_mock.h --- compiz-0.9.8.2+bzr3377/compizconfig/mocks/libcompizconfig/compizconfig_ccs_integrated_setting_mock.h 1970-01-01 00:00:00.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/mocks/libcompizconfig/compizconfig_ccs_integrated_setting_mock.h 2012-09-27 11:04:02.000000000 +0000 @@ -0,0 +1,97 @@ +/* + * Compiz configuration system library + * + * Copyright (C) 2012 Canonical Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authored By: + * Sam Spilsbury + */ +#ifndef _COMPIZCONFIG_CCS_INTEGRATED_SETTING_MOCK_H +#define _COMPIZCONFIG_CCS_INTEGRATED_SETTING_MOCK_H + +#include +#include + +#include +#include + +CCSIntegratedSetting * +ccsMockIntegratedSettingNew (CCSObjectAllocationInterface *ai); + +void +ccsMockIntegratedSettingFree (CCSIntegratedSetting *); + +class CCSIntegratedSettingGMockInterface +{ + public: + + virtual ~CCSIntegratedSettingGMockInterface () {} + + virtual CCSSettingValue * readValue (CCSSettingType) = 0; + virtual void writeValue (CCSSettingValue *, CCSSettingType) = 0; +}; + +class CCSIntegratedSettingGMock : + public CCSIntegratedSettingGMockInterface +{ + public: + + MOCK_METHOD1 (readValue, CCSSettingValue * (CCSSettingType)); + MOCK_METHOD2 (writeValue, void (CCSSettingValue *, CCSSettingType)); + + CCSIntegratedSettingGMock (CCSIntegratedSetting *integratedSetting) : + mIntegrationSetting (integratedSetting) + { + } + + CCSIntegratedSetting * + getIntegratedSetting () + { + return mIntegrationSetting; + } + + public: + + static CCSSettingValue * + ccsIntegratedSettingReadValue (CCSIntegratedSetting *integratedSetting, + CCSSettingType type) + { + return reinterpret_cast (ccsObjectGetPrivate (integratedSetting))->readValue (type); + } + + static void + ccsIntegratedSettingWriteValue (CCSIntegratedSetting *integratedSetting, + CCSSettingValue *value, + CCSSettingType type) + { + reinterpret_cast (ccsObjectGetPrivate (integratedSetting))->writeValue (value, type); + } + + static void + ccsIntegratedSettingFree (CCSIntegratedSetting *integratedSetting) + { + ccsMockIntegratedSettingFree (integratedSetting); + } + + private: + + CCSIntegratedSetting *mIntegrationSetting; +}; + +extern const CCSIntegratedSettingInterface mockIntegratedSettingInterface; + +#endif diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/mocks/libcompizconfig/compizconfig_ccs_integrated_setting_storage_mock.cpp compiz-0.9.8.4/compizconfig/mocks/libcompizconfig/compizconfig_ccs_integrated_setting_storage_mock.cpp --- compiz-0.9.8.2+bzr3377/compizconfig/mocks/libcompizconfig/compizconfig_ccs_integrated_setting_storage_mock.cpp 1970-01-01 00:00:00.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/mocks/libcompizconfig/compizconfig_ccs_integrated_setting_storage_mock.cpp 2012-09-27 11:04:02.000000000 +0000 @@ -0,0 +1,73 @@ +/* + * Compiz configuration system library + * + * Copyright (C) 2012 Canonical Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authored By: + * Sam Spilsbury + */ +#include +#include + +#include + +#include "compizconfig_ccs_integrated_setting_storage_mock.h" + +const CCSIntegratedSettingsStorageInterface mockIntegratedSettingsStorageInterface = +{ + CCSIntegratedSettingsStorageGMock::ccsIntegratedSettingsStorageFindMatchingSettingsByPredicate, + CCSIntegratedSettingsStorageGMock::ccsIntegratedSettingsStorageFindMatchingSettingsByPluginAndSettingName, + CCSIntegratedSettingsStorageGMock::ccsIntegratedSettingsStorageAddSetting, + CCSIntegratedSettingsStorageGMock::ccsIntegratedSettingsStorageEmpty, + CCSIntegratedSettingsStorageGMock::ccsIntegratedSettingsStorageFree +}; + +CCSIntegratedSettingsStorage * +ccsMockIntegratedSettingsStorageNew (CCSObjectAllocationInterface *ai) +{ + CCSIntegratedSettingsStorage *storage = + reinterpret_cast ((*ai->calloc_) (ai->allocator, 1, sizeof (CCSIntegratedSettingsStorage))); + + if (!storage) + return NULL; + + CCSIntegratedSettingsStorageGMock *gmockBackend = new CCSIntegratedSettingsStorageGMock (storage); + + ccsObjectInit (storage, ai); + ccsObjectSetPrivate (storage, (CCSPrivate *) gmockBackend); + ccsObjectAddInterface (storage, + reinterpret_cast (&mockIntegratedSettingsStorageInterface), + GET_INTERFACE_TYPE (CCSIntegratedSettingsStorageInterface)); + + ccsObjectRef (storage); + + return storage; +} + +void +ccsMockIntegratedSettingsStorageFree (CCSIntegratedSettingsStorage *storage) +{ + CCSIntegratedSettingsStorageGMock *gmockStorage = + GET_PRIVATE (CCSIntegratedSettingsStorageGMock, storage); + + delete gmockStorage; + + ccsObjectSetPrivate (storage, NULL); + ccsObjectFinalize (storage); + (*storage->object.object_allocation->free_) + (storage->object.object_allocation->allocator, storage); +} diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/mocks/libcompizconfig/compizconfig_ccs_integrated_setting_storage_mock.h compiz-0.9.8.4/compizconfig/mocks/libcompizconfig/compizconfig_ccs_integrated_setting_storage_mock.h --- compiz-0.9.8.2+bzr3377/compizconfig/mocks/libcompizconfig/compizconfig_ccs_integrated_setting_storage_mock.h 1970-01-01 00:00:00.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/mocks/libcompizconfig/compizconfig_ccs_integrated_setting_storage_mock.h 2012-09-27 11:04:02.000000000 +0000 @@ -0,0 +1,119 @@ +/* + * Compiz configuration system library + * + * Copyright (C) 2012 Canonical Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authored By: + * Sam Spilsbury + */ +#ifndef _COMPIZCONFIG_CCS_INTEGRATED_SETTING_STORAGE_MOCK_H +#define _COMPIZCONFIG_CCS_INTEGRATED_SETTING_STORAGE_MOCK_H + +#include +#include + +#include +#include + +CCSIntegratedSettingsStorage * +ccsMockIntegratedSettingsStorageNew (CCSObjectAllocationInterface *ai); + +void +ccsMockIntegratedSettingsStorageFree (CCSIntegratedSettingsStorage *); + +class CCSIntegratedSettingsStorageGMockInterface +{ + public: + + virtual ~CCSIntegratedSettingsStorageGMockInterface () {} + + virtual CCSIntegratedSettingList findMatchingSettingsByPluginAndSettingName (const char *pluginName, + const char *settingName) = 0; + virtual void addSetting (CCSIntegratedSetting *setting) = 0; + virtual CCSIntegratedSettingList findMatchingSettingsByPredicate (CCSIntegratedSettingsStorageFindPredicate pred, + void *data) = 0; + virtual Bool empty () = 0; +}; + +class CCSIntegratedSettingsStorageGMock : + public CCSIntegratedSettingsStorageGMockInterface +{ + public: + + MOCK_METHOD2 (findMatchingSettingsByPluginAndSettingName, CCSIntegratedSettingList (const char *, + const char *)); + MOCK_METHOD1 (addSetting, void (CCSIntegratedSetting *)); + MOCK_METHOD2 (findMatchingSettingsByPredicate, CCSIntegratedSettingList (CCSIntegratedSettingsStorageFindPredicate , + void *)); + MOCK_METHOD0 (empty, Bool ()); + + CCSIntegratedSettingsStorageGMock (CCSIntegratedSettingsStorage *integratedSetting) : + mIntegrationSetting (integratedSetting) + { + } + + CCSIntegratedSettingsStorage * + getIntegratedSettingsStorage () + { + return mIntegrationSetting; + } + + public: + + static CCSIntegratedSettingList + ccsIntegratedSettingsStorageFindMatchingSettingsByPredicate (CCSIntegratedSettingsStorage *storage, + CCSIntegratedSettingsStorageFindPredicate pred, + void *data) + { + return reinterpret_cast (ccsObjectGetPrivate (storage))->findMatchingSettingsByPredicate (pred, data); + } + + static CCSIntegratedSettingList + ccsIntegratedSettingsStorageFindMatchingSettingsByPluginAndSettingName (CCSIntegratedSettingsStorage *storage, + const char *pluginName, + const char *settingName) + { + return reinterpret_cast (ccsObjectGetPrivate (storage))->findMatchingSettingsByPluginAndSettingName (pluginName, settingName); + } + + static void + ccsIntegratedSettingsStorageAddSetting (CCSIntegratedSettingsStorage *storage, + CCSIntegratedSetting *setting) + { + return reinterpret_cast (ccsObjectGetPrivate (storage))->addSetting (setting); + } + + static Bool + ccsIntegratedSettingsStorageEmpty (CCSIntegratedSettingsStorage *storage) + { + return reinterpret_cast (ccsObjectGetPrivate (storage))->empty (); + } + + static void + ccsIntegratedSettingsStorageFree (CCSIntegratedSettingsStorage *integratedSetting) + { + ccsMockIntegratedSettingsStorageFree (integratedSetting); + } + + private: + + CCSIntegratedSettingsStorage *mIntegrationSetting; +}; + +extern const CCSIntegratedSettingsStorageInterface mockIntegratedSettingsStorageInterface; + +#endif diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/mocks/libcompizconfig/compizconfig_ccs_integration_mock.cpp compiz-0.9.8.4/compizconfig/mocks/libcompizconfig/compizconfig_ccs_integration_mock.cpp --- compiz-0.9.8.2+bzr3377/compizconfig/mocks/libcompizconfig/compizconfig_ccs_integration_mock.cpp 1970-01-01 00:00:00.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/mocks/libcompizconfig/compizconfig_ccs_integration_mock.cpp 2012-09-27 11:04:02.000000000 +0000 @@ -0,0 +1,70 @@ +/* + * Compiz configuration system library + * + * Copyright (C) 2012 Canonical Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authored By: + * Sam Spilsbury + */ +#include +#include + +#include + +#include "compizconfig_ccs_integration_mock.h" + +const CCSIntegrationInterface mockIntegrationBackendInterface = +{ + CCSIntegrationGMock::ccsIntegrationGetIntegratedOptionIndex, + CCSIntegrationGMock::ccsIntegrationReadOptionIntoSetting, + CCSIntegrationGMock::ccsIntegrationWriteSettingIntoOption, + CCSIntegrationGMock::ccsIntegrationUpdateIntegratedSettings, + CCSIntegrationGMock::ccsIntegrationDisallowIntegratedWrites, + CCSIntegrationGMock::ccsIntegrationAllowIntegratedWrites, + CCSIntegrationGMock::ccsFreeIntegration +}; + +CCSIntegration * +ccsMockIntegrationBackendNew (CCSObjectAllocationInterface *ai) +{ + CCSIntegration *integration = reinterpret_cast ((*ai->calloc_) (ai->allocator, 1, sizeof (CCSIntegration))); + + if (!integration) + return NULL; + + CCSIntegrationGMock *gmockBackend = new CCSIntegrationGMock (integration); + + ccsObjectInit (integration, ai); + ccsObjectSetPrivate (integration, (CCSPrivate *) gmockBackend); + ccsObjectAddInterface (integration, (const CCSInterface *) &mockIntegrationBackendInterface, GET_INTERFACE_TYPE (CCSIntegrationInterface)); + + ccsObjectRef (integration); + + return integration; +} + +void +ccsMockIntegrationBackendFree (CCSIntegration *integration) +{ + CCSIntegrationGMock *gmockBackend = reinterpret_cast (ccsObjectGetPrivate (integration)); + + delete gmockBackend; + + ccsObjectSetPrivate (integration, NULL); + ccsObjectFinalize (integration); + (*integration->object.object_allocation->free_) (integration->object.object_allocation->allocator, integration); +} diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/mocks/libcompizconfig/compizconfig_ccs_integration_mock.h compiz-0.9.8.4/compizconfig/mocks/libcompizconfig/compizconfig_ccs_integration_mock.h --- compiz-0.9.8.2+bzr3377/compizconfig/mocks/libcompizconfig/compizconfig_ccs_integration_mock.h 1970-01-01 00:00:00.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/mocks/libcompizconfig/compizconfig_ccs_integration_mock.h 2012-09-27 11:04:02.000000000 +0000 @@ -0,0 +1,129 @@ +/* + * Compiz configuration system library + * + * Copyright (C) 2012 Canonical Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authored By: + * Sam Spilsbury + */ +#ifndef _COMPIZCONFIG_CCS_INTEGRATION_MOCK_H +#define _COMPIZCONFIG_CCS_INTEGRATION_MOCK_H + +#include +#include + +#include + +CCSIntegration * +ccsMockIntegrationBackendNew (CCSObjectAllocationInterface *ai); + +void +ccsMockIntegrationBackendFree (CCSIntegration *integration); + +class CCSIntegrationGMockInterface +{ + public: + + virtual ~CCSIntegrationGMockInterface () {} + + virtual CCSIntegratedSetting * getIntegratedOptionIndex (const char *pluginName, const char *settingName) = 0; + virtual Bool readOptionIntoSetting (CCSContext *context, CCSSetting *setting, CCSIntegratedSetting *) = 0; + virtual void writeOptionFromSetting (CCSContext *context, CCSSetting *setting, CCSIntegratedSetting *) = 0; + virtual void updateIntegratedSettings (CCSContext *context, CCSIntegratedSettingList settingList) = 0; + virtual void disallowIntegratedWrites () = 0; + virtual void allowIntegratedWrites () = 0; +}; + +class CCSIntegrationGMock : + public CCSIntegrationGMockInterface +{ + public: + + MOCK_METHOD2 (getIntegratedOptionIndex, CCSIntegratedSetting * (const char *, const char *)); + MOCK_METHOD3 (readOptionIntoSetting, Bool (CCSContext *, CCSSetting *, CCSIntegratedSetting *)); + MOCK_METHOD3 (writeOptionFromSetting, void (CCSContext *, CCSSetting *, CCSIntegratedSetting *)); + MOCK_METHOD2 (updateIntegratedSettings, void (CCSContext *, CCSIntegratedSettingList)); + MOCK_METHOD0 (disallowIntegratedWrites, void ()); + MOCK_METHOD0 (allowIntegratedWrites, void ()); + + + CCSIntegrationGMock (CCSIntegration *integration) : + mIntegration (integration) + { + } + + CCSIntegration * + getIntegrationBackend () + { + return mIntegration; + } + + public: + + static CCSIntegratedSetting * ccsIntegrationGetIntegratedOptionIndex (CCSIntegration *integration, + const char *pluginName, + const char *settingName) + { + return reinterpret_cast (ccsObjectGetPrivate (integration))->getIntegratedOptionIndex (pluginName, settingName); + } + + static Bool ccsIntegrationReadOptionIntoSetting (CCSIntegration *integration, + CCSContext *context, + CCSSetting *setting, + CCSIntegratedSetting *integrated) + { + return reinterpret_cast (ccsObjectGetPrivate (integration))->readOptionIntoSetting (context, setting, integrated); + } + + static void ccsIntegrationWriteSettingIntoOption (CCSIntegration *integration, + CCSContext *context, + CCSSetting *setting, + CCSIntegratedSetting *integrated) + { + return reinterpret_cast (ccsObjectGetPrivate (integration))->writeOptionFromSetting (context, setting, integrated); + } + + static void ccsIntegrationUpdateIntegratedSettings (CCSIntegration *integration, + CCSContext *context, + CCSIntegratedSettingList settingList) + { + return reinterpret_cast (ccsObjectGetPrivate (integration))->updateIntegratedSettings (context, settingList); + } + + static void ccsFreeIntegration (CCSIntegration *integration) + { + ccsMockIntegrationBackendFree (integration); + } + + static void ccsIntegrationDisallowIntegratedWrites (CCSIntegration *integration) + { + reinterpret_cast (ccsObjectGetPrivate (integration))->disallowIntegratedWrites (); + } + + static void ccsIntegrationAllowIntegratedWrites (CCSIntegration *integration) + { + reinterpret_cast (ccsObjectGetPrivate (integration))->allowIntegratedWrites (); + } + + private: + + CCSIntegration *mIntegration; +}; + +extern const CCSIntegrationInterface mockIntegrationBackendInterface; + +#endif diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/mocks/libcompizconfig/compizconfig_ccs_plugin_mock.h compiz-0.9.8.4/compizconfig/mocks/libcompizconfig/compizconfig_ccs_plugin_mock.h --- compiz-0.9.8.2+bzr3377/compizconfig/mocks/libcompizconfig/compizconfig_ccs_plugin_mock.h 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/mocks/libcompizconfig/compizconfig_ccs_plugin_mock.h 2012-09-27 11:04:02.000000000 +0000 @@ -12,11 +12,11 @@ virtual ~CCSPluginGMockInterface () {}; - virtual char * getName () = 0; - virtual char * getShortDesc () = 0; - virtual char * getLongDesc () = 0; - virtual char * getHints () = 0; - virtual char * getCategory () = 0; + virtual const char * getName () = 0; + virtual const char * getShortDesc () = 0; + virtual const char * getLongDesc () = 0; + virtual const char * getHints () = 0; + virtual const char * getCategory () = 0; virtual CCSStringList getLoadAfter () = 0; virtual CCSStringList getLoadBefore () = 0; virtual CCSStringList getRequiresPlugins () = 0; @@ -47,11 +47,11 @@ plugin () { return mPlugin; } /* Mock implementations */ - MOCK_METHOD0 (getName, char * ()); - MOCK_METHOD0 (getShortDesc, char * ()); - MOCK_METHOD0 (getLongDesc, char * ()); - MOCK_METHOD0 (getHints, char * ()); - MOCK_METHOD0 (getCategory, char * ()); + MOCK_METHOD0 (getName, const char * ()); + MOCK_METHOD0 (getShortDesc, const char * ()); + MOCK_METHOD0 (getLongDesc, const char * ()); + MOCK_METHOD0 (getHints, const char * ()); + MOCK_METHOD0 (getCategory, const char * ()); MOCK_METHOD0 (getLoadAfter, CCSStringList ()); MOCK_METHOD0 (getLoadBefore, CCSStringList ()); MOCK_METHOD0 (getRequiresPlugins, CCSStringList ()); @@ -74,27 +74,27 @@ public: /* Thunking C to C++ */ - static char * ccsPluginGetName (CCSPlugin *plugin) + static const char * ccsPluginGetName (CCSPlugin *plugin) { return ((CCSPluginGMock *) ccsObjectGetPrivate (plugin))->getName (); } - static char * ccsPluginGetShortDesc (CCSPlugin *plugin) + static const char * ccsPluginGetShortDesc (CCSPlugin *plugin) { return ((CCSPluginGMock *) ccsObjectGetPrivate (plugin))->getShortDesc (); } - static char * ccsPluginGetLongDesc (CCSPlugin *plugin) + static const char * ccsPluginGetLongDesc (CCSPlugin *plugin) { return ((CCSPluginGMock *) ccsObjectGetPrivate (plugin))->getLongDesc (); } - static char * ccsPluginGetHints (CCSPlugin *plugin) + static const char * ccsPluginGetHints (CCSPlugin *plugin) { return ((CCSPluginGMock *) ccsObjectGetPrivate (plugin))->getHints (); } - static char * ccsPluginGetCategory (CCSPlugin *plugin) + static const char * ccsPluginGetCategory (CCSPlugin *plugin) { return ((CCSPluginGMock *) ccsObjectGetPrivate (plugin))->getCategory (); } diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/mocks/libcompizconfig/compizconfig_ccs_setting_mock.h compiz-0.9.8.4/compizconfig/mocks/libcompizconfig/compizconfig_ccs_setting_mock.h --- compiz-0.9.8.2+bzr3377/compizconfig/mocks/libcompizconfig/compizconfig_ccs_setting_mock.h 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/mocks/libcompizconfig/compizconfig_ccs_setting_mock.h 2012-09-27 11:04:02.000000000 +0000 @@ -19,14 +19,14 @@ virtual ~CCSSettingGMockInterface () {}; - virtual char * getName () = 0; - virtual char * getShortDesc () = 0; - virtual char * getLongDesc () = 0; + virtual const char * getName () = 0; + virtual const char * getShortDesc () = 0; + virtual const char * getLongDesc () = 0; virtual CCSSettingType getType () = 0; virtual CCSSettingInfo * getInfo () = 0; - virtual char * getGroup () = 0; - virtual char * getSubGroup () = 0; - virtual char * getHints () = 0; + virtual const char * getGroup () = 0; + virtual const char * getSubGroup () = 0; + virtual const char * getHints () = 0; virtual CCSSettingValue * getDefaultValue () = 0; virtual CCSSettingValue * getValue () = 0; virtual Bool getIsDefault () = 0; @@ -78,14 +78,14 @@ CCSSetting * setting () { return mSetting; } - MOCK_METHOD0 (getName, char * ()); - MOCK_METHOD0 (getShortDesc, char * ()); - MOCK_METHOD0 (getLongDesc, char * ()); + MOCK_METHOD0 (getName, const char * ()); + MOCK_METHOD0 (getShortDesc, const char * ()); + MOCK_METHOD0 (getLongDesc, const char * ()); MOCK_METHOD0 (getType, CCSSettingType ()); MOCK_METHOD0 (getInfo, CCSSettingInfo * ()); - MOCK_METHOD0 (getGroup, char * ()); - MOCK_METHOD0 (getSubGroup, char * ()); - MOCK_METHOD0 (getHints, char * ()); + MOCK_METHOD0 (getGroup, const char * ()); + MOCK_METHOD0 (getSubGroup, const char * ()); + MOCK_METHOD0 (getHints, const char * ()); MOCK_METHOD0 (getDefaultValue, CCSSettingValue * ()); MOCK_METHOD0 (getValue, CCSSettingValue * ()); MOCK_METHOD0 (getIsDefault, Bool ()); @@ -291,18 +291,18 @@ return ((CCSSettingGMock *) ccsObjectGetPrivate (setting))->isReadOnly (); } - static char * ccsSettingGetName (CCSSetting *setting) + static const char * ccsSettingGetName (CCSSetting *setting) { return ((CCSSettingGMock *) ccsObjectGetPrivate (setting))->getName (); } - static char * ccsSettingGetShortDesc (CCSSetting *setting) + static const char * ccsSettingGetShortDesc (CCSSetting *setting) { return ((CCSSettingGMock *) ccsObjectGetPrivate (setting))->getShortDesc (); } - static char * ccsSettingGetLongDesc (CCSSetting *setting) + static const char * ccsSettingGetLongDesc (CCSSetting *setting) { return ((CCSSettingGMock *) ccsObjectGetPrivate (setting))->getLongDesc (); } @@ -317,17 +317,17 @@ return ((CCSSettingGMock *) ccsObjectGetPrivate (setting))->getInfo (); } - static char * ccsSettingGetGroup (CCSSetting *setting) + static const char * ccsSettingGetGroup (CCSSetting *setting) { return ((CCSSettingGMock *) ccsObjectGetPrivate (setting))->getGroup (); } - static char * ccsSettingGetSubGroup (CCSSetting *setting) + static const char * ccsSettingGetSubGroup (CCSSetting *setting) { return ((CCSSettingGMock *) ccsObjectGetPrivate (setting))->getSubGroup (); } - static char * ccsSettingGetHints (CCSSetting *setting) + static const char * ccsSettingGetHints (CCSSetting *setting) { return ((CCSSettingGMock *) ccsObjectGetPrivate (setting))->getHints (); } diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/mocks/libcompizconfig/compizconfig_ccs_text_file_mock.cpp compiz-0.9.8.4/compizconfig/mocks/libcompizconfig/compizconfig_ccs_text_file_mock.cpp --- compiz-0.9.8.2+bzr3377/compizconfig/mocks/libcompizconfig/compizconfig_ccs_text_file_mock.cpp 1970-01-01 00:00:00.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/mocks/libcompizconfig/compizconfig_ccs_text_file_mock.cpp 2012-09-27 11:04:02.000000000 +0000 @@ -0,0 +1,104 @@ +/* + * Compiz configuration system library + * + * Copyright (C) 2012 Canonical Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authored By: + * Sam Spilsbury + */ +#include +#include + +#include +#include +#include "compizconfig_ccs_text_file_mock.h" + +const CCSTextFileInterface ccsMockTextFileInterface = +{ + CCSTextFileGMock::ccsTextFileReadFromStart, + CCSTextFileGMock::ccsTextFileAppendString, + CCSTextFileGMock::ccsFreeTextFile +}; + +static void +finalizeAndFreeTextFile (CCSTextFile *textFile) +{ + CCSObjectAllocationInterface *ai = textFile->object.object_allocation; + + ccsObjectFinalize (textFile); + (*ai->free_) (ai->allocator, textFile); +} + +void +ccsFreeMockTextFile (CCSTextFile *textFile) +{ + CCSTextFileGMock *gmock = reinterpret_cast (ccsObjectGetPrivate (textFile)); + delete gmock; + + ccsObjectSetPrivate (textFile, NULL); + finalizeAndFreeTextFile (textFile); + +} + +static CCSTextFileGMock * +newCCSTextFileGMockInterface (CCSTextFile *textFile) +{ + CCSTextFileGMock *gmock = new CCSTextFileGMock (); + + if (!gmock) + { + finalizeAndFreeTextFile (textFile); + return NULL; + } + + return gmock; +} + +static CCSTextFile * +allocateCCSTextFile (CCSObjectAllocationInterface *ai) +{ + CCSTextFile *textFile = reinterpret_cast ((*ai->calloc_) (ai->allocator, 1, sizeof (CCSTextFile))); + + if (!textFile) + return NULL; + + ccsObjectInit (textFile, ai); + + return textFile; +} + +CCSTextFile * +ccsMockTextFileNew (CCSObjectAllocationInterface *ai) +{ + CCSTextFile *textFile = allocateCCSTextFile (ai); + + if (!textFile) + return NULL; + + CCSTextFileGMock *gmock = newCCSTextFileGMockInterface (textFile); + + if (!gmock) + return NULL; + + ccsObjectSetPrivate (textFile, (CCSPrivate *) gmock); + ccsObjectAddInterface (textFile, + (const CCSInterface *) &ccsMockTextFileInterface, + GET_INTERFACE_TYPE (CCSTextFileInterface)); + ccsObjectRef (textFile); + + return textFile; +} diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/mocks/libcompizconfig/compizconfig_ccs_text_file_mock.h compiz-0.9.8.4/compizconfig/mocks/libcompizconfig/compizconfig_ccs_text_file_mock.h --- compiz-0.9.8.2+bzr3377/compizconfig/mocks/libcompizconfig/compizconfig_ccs_text_file_mock.h 1970-01-01 00:00:00.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/mocks/libcompizconfig/compizconfig_ccs_text_file_mock.h 2012-09-27 11:04:02.000000000 +0000 @@ -0,0 +1,84 @@ +/* + * Compiz configuration system library + * + * Copyright (C) 2012 Canonical Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authored By: + * Sam Spilsbury + */ +#ifndef COMPIZCONFIG_CCS_TEST_FILE_MOCK_H +#define COMPIZCONFIG_CCS_TEST_FILE_MOCK_H + +#include +#include + +#include +#include + +COMPIZCONFIG_BEGIN_DECLS + +typedef struct _CCSTextFile CCSTextFile; +typedef struct _CCSObjectAllocationInterface CCSObjectAllocationInterface; + +CCSTextFile * ccsMockTextFileNew (CCSObjectAllocationInterface *ai); +void ccsFreeMockTextFile (CCSTextFile *); + +COMPIZCONFIG_END_DECLS + +class CCSTextFileGMockInterface +{ + public: + + virtual ~CCSTextFileGMockInterface () {} + virtual char * readFromStart () = 0; + virtual Bool appendString (const char *) = 0; + virtual void free () = 0; +}; + +class CCSTextFileGMock : + public CCSTextFileGMockInterface +{ + public: + + MOCK_METHOD0 (readFromStart, char * ()); + MOCK_METHOD1 (appendString, Bool (const char *)); + MOCK_METHOD0 (free, void ()); + + public: + + static char * + ccsTextFileReadFromStart (CCSTextFile *file) + { + return reinterpret_cast (ccsObjectGetPrivate (file))->readFromStart (); + } + + static Bool + ccsTextFileAppendString (CCSTextFile *file, const char *str) + { + return reinterpret_cast (ccsObjectGetPrivate (file))->appendString (str); + } + + static void + ccsFreeTextFile (CCSTextFile *file) + { + reinterpret_cast (ccsObjectGetPrivate (file))->free (); + ccsFreeMockTextFile (file); + } + +}; + +#endif diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/tests/CMakeLists.txt compiz-0.9.8.4/compizconfig/tests/CMakeLists.txt --- compiz-0.9.8.2+bzr3377/compizconfig/tests/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/tests/CMakeLists.txt 2012-09-27 11:04:02.000000000 +0000 @@ -0,0 +1,71 @@ +include_directories (${CMAKE_CURRENT_SOURCE_DIR}/../libcompizconfig/include + ${CMAKE_CURRENT_SOURCE_DIR}/../mocks/libcompizconfig + ${CMAKE_SOURCE_DIR}/tests/shared + ${CMAKE_CURRENT_SOURCE_DIR}) + +add_library (compizconfig_ccs_item_in_list_matcher STATIC + ${CMAKE_CURRENT_SOURCE_DIR}/compizconfig_ccs_item_in_list_matcher.cpp) + +target_link_libraries (compizconfig_ccs_item_in_list_matcher + ${GTEST_BOTH_LIBRARIES} + ${GMOCK_MAIN_LIBRARY} + ${GMOCK_LIBRARY} + compizconfig) + +add_library (compizconfig_ccs_list_equality STATIC + ${CMAKE_CURRENT_SOURCE_DIR}/compizconfig_ccs_list_equality.cpp) + +target_link_libraries (compizconfig_ccs_list_equality + ${GTEST_BOTH_LIBRARIES} + ${GMOCK_MAIN_LIBRARY} + ${GMOCK_LIBRARY} + compizconfig) + +add_library (compizconfig_ccs_setting_value_matcher STATIC + ${CMAKE_CURRENT_SOURCE_DIR}/compizconfig_ccs_setting_value_matcher.cpp) + +target_link_libraries (compizconfig_ccs_setting_value_matcher + ${GTEST_BOTH_LIBRARIES} + ${GMOCK_MAIN_LIBRARY} + ${GMOCK_LIBRARY} + compizconfig) + +add_library (compizconfig_ccs_list_wrapper STATIC + ${CMAKE_CURRENT_SOURCE_DIR}/compizconfig_ccs_list_wrapper.cpp) + +target_link_libraries (compizconfig_ccs_list_wrapper + ${GTEST_BOTH_LIBRARIES} + ${GMOCK_MAIN_LIBRARY} + ${GMOCK_LIBRARY} + compizconfig) + +add_library (compizconfig_ccs_setting_value_operators STATIC + ${CMAKE_CURRENT_SOURCE_DIR}/compizconfig_ccs_setting_value_operators.cpp) + +target_link_libraries (compizconfig_ccs_setting_value_operators + ${GTEST_BOTH_LIBRARIES} + ${GMOCK_MAIN_LIBRARY} + ${GMOCK_LIBRARY} + compizconfig) + +add_library (compizconfig_ccs_test_value_combinations STATIC + ${CMAKE_CURRENT_SOURCE_DIR}/compizconfig_test_value_combiners.cpp) + +target_link_libraries (compizconfig_ccs_test_value_combinations + ${GTEST_BOTH_LIBRARIES} + ${GMOCK_MAIN_LIBRARY} + ${GMOCK_LIBRARY} + compizconfig) + +add_library (compizconfig_ccs_backend_conformance_test STATIC + ${CMAKE_CURRENT_SOURCE_DIR}/compizconfig_backend_concept_test.cpp) + +target_link_libraries (compizconfig_ccs_backend_conformance_test + ${GTEST_BOTH_LIBRARIES} + ${GMOCK_MAIN_LIBRARY} + ${GMOCK_LIBRARY} + compizconfig + compizconfig_ccs_test_value_combinations + compizconfig_ccs_setting_value_operators + compizconfig_ccs_list_equality + compizconfig_ccs_item_in_list_matcher) diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/tests/compizconfig_backend_concept_test.cpp compiz-0.9.8.4/compizconfig/tests/compizconfig_backend_concept_test.cpp --- compiz-0.9.8.2+bzr3377/compizconfig/tests/compizconfig_backend_concept_test.cpp 1970-01-01 00:00:00.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/tests/compizconfig_backend_concept_test.cpp 2012-09-27 11:04:02.000000000 +0000 @@ -0,0 +1,381 @@ +/* + * Compiz configuration system library + * + * Copyright (C) 2012 Canonical Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authored By: + * Sam Spilsbury + */ +#include +#include + +#include + +#include + +#include +#include +#include +#include + +#include +#include + +using ::testing::NiceMock; +using ::testing::Return; +using ::testing::ReturnNull; +using ::testing::SetArgPointee; +using ::testing::DoAll; +using ::testing::AtLeast; +using ::testing::Eq; + + +namespace cct = compizconfig::test; + +Bool cct::boolToBool (bool v) +{ + return v ? TRUE : FALSE; +} + +cci::SettingValueListWrapper::Ptr +cct::CCSListConstructionExpectationsSetter (const cct::ConstructorFunc &c, + CCSSettingType type, + cci::ListStorageType storageType) +{ + boost::function f (boost::bind (ccsSettingUnref, _1)); + boost::shared_ptr mockSetting (ccsNiceMockSettingNew (), f); + NiceMock *gmockSetting = reinterpret_cast *> (ccsObjectGetPrivate (mockSetting.get ())); + + ON_CALL (*gmockSetting, getType ()).WillByDefault (Return (TypeList)); + + boost::shared_ptr listInfo (new CCSSettingInfo); + + listInfo->forList.listType = type; + + ON_CALL (*gmockSetting, getInfo ()).WillByDefault (Return (listInfo.get ())); + ON_CALL (*gmockSetting, getDefaultValue ()).WillByDefault (ReturnNull ()); + return boost::make_shared (c (mockSetting.get ()), storageType, type, listInfo, mockSetting); +} + +CCSSettingGMock * +cct::getSettingGMockFromSetting (const boost::shared_ptr &setting) +{ + return reinterpret_cast (ccsObjectGetPrivate (setting.get ())); +} + +void +cct::SetIntWriteExpectation (const std::string &plugin, + const std::string &key, + const VariantTypes &value, + const boost::shared_ptr &setting, + const WriteFunc &write, + const CCSBackendConceptTestEnvironmentInterface::Ptr &env) +{ + CCSSettingGMock *gmock (getSettingGMockFromSetting (setting)); + EXPECT_CALL (*gmock, getInt (_)).WillRepeatedly (DoAll ( + SetArgPointee <0> ( + boost::get (value)), + Return (TRUE))); + write (); + EXPECT_EQ (env->ReadIntegerAtKey (plugin, key), boost::get (value)); +} + +void +cct::SetBoolWriteExpectation (const std::string &plugin, + const std::string &key, + const VariantTypes &value, + const boost::shared_ptr &setting, + const WriteFunc &write, + const CCSBackendConceptTestEnvironmentInterface::Ptr &env) +{ + CCSSettingGMock *gmock (getSettingGMockFromSetting (setting)); + EXPECT_CALL (*gmock, getBool (_)).WillRepeatedly (DoAll ( + SetArgPointee <0> ( + boolToBool (boost::get (value))), + Return (TRUE))); + write (); + + bool v (boost::get (value)); + + if (v) + EXPECT_THAT (env->ReadBoolAtKey (plugin, key), IsTrue ()); + else + EXPECT_THAT (env->ReadBoolAtKey (plugin, key), IsFalse ()); +} + +void +cct::SetFloatWriteExpectation (const std::string &plugin, + const std::string &key, + const VariantTypes &value, + const boost::shared_ptr &setting, + const WriteFunc &write, + const CCSBackendConceptTestEnvironmentInterface::Ptr &env) +{ + CCSSettingGMock *gmock (getSettingGMockFromSetting (setting)); + EXPECT_CALL (*gmock, getFloat (_)).WillRepeatedly (DoAll ( + SetArgPointee <0> ( + boost::get (value)), + Return (TRUE))); + write (); + EXPECT_EQ (env->ReadFloatAtKey (plugin, key), boost::get (value)); +} + +void +cct::SetStringWriteExpectation (const std::string &plugin, + const std::string &key, + const VariantTypes &value, + const boost::shared_ptr &setting, + const WriteFunc &write, + const CCSBackendConceptTestEnvironmentInterface::Ptr &env) +{ + CCSSettingGMock *gmock (getSettingGMockFromSetting (setting)); + EXPECT_CALL (*gmock, getString (_)).WillRepeatedly (DoAll ( + SetArgPointee <0> ( + const_cast (boost::get (value))), + Return (TRUE))); + write (); + EXPECT_EQ (std::string (env->ReadStringAtKey (plugin, key)), std::string (boost::get (value))); +} + +void +cct::SetColorWriteExpectation (const std::string &plugin, + const std::string &key, + const VariantTypes &value, + const boost::shared_ptr &setting, + const WriteFunc &write, + const CCSBackendConceptTestEnvironmentInterface::Ptr &env) +{ + CCSSettingGMock *gmock (getSettingGMockFromSetting (setting)); + EXPECT_CALL (*gmock, getColor (_)).WillRepeatedly (DoAll ( + SetArgPointee <0> ( + boost::get (value)), + Return (TRUE))); + write (); + + EXPECT_EQ (env->ReadColorAtKey (plugin, key), boost::get (value)); +} + +void +cct::SetKeyWriteExpectation (const std::string &plugin, + const std::string &key, + const VariantTypes &value, + const boost::shared_ptr &setting, + const WriteFunc &write, + const CCSBackendConceptTestEnvironmentInterface::Ptr &env) +{ + CCSSettingGMock *gmock (getSettingGMockFromSetting (setting)); + EXPECT_CALL (*gmock, getKey (_)).WillRepeatedly (DoAll ( + SetArgPointee <0> ( + boost::get (value)), + Return (TRUE))); + write (); + EXPECT_EQ (env->ReadKeyAtKey (plugin, key), boost::get (value)); +} + +void +cct::SetButtonWriteExpectation (const std::string &plugin, + const std::string &key, + const VariantTypes &value, + const boost::shared_ptr &setting, + const WriteFunc &write, + const CCSBackendConceptTestEnvironmentInterface::Ptr &env) +{ + CCSSettingGMock *gmock (getSettingGMockFromSetting (setting)); + EXPECT_CALL (*gmock, getButton (_)).WillRepeatedly (DoAll ( + SetArgPointee <0> ( + boost::get (value)), + Return (TRUE))); + write (); + EXPECT_EQ (env->ReadButtonAtKey (plugin, key), boost::get (value)); +} + +void +cct::SetEdgeWriteExpectation (const std::string &plugin, + const std::string &key, + const VariantTypes &value, + const boost::shared_ptr &setting, + const WriteFunc &write, + const CCSBackendConceptTestEnvironmentInterface::Ptr &env) +{ + CCSSettingGMock *gmock (getSettingGMockFromSetting (setting)); + EXPECT_CALL (*gmock, getEdge (_)).WillRepeatedly (DoAll ( + SetArgPointee <0> ( + boost::get (value)), + Return (TRUE))); + write (); + EXPECT_EQ (env->ReadEdgeAtKey (plugin, key), boost::get (value)); +} + +void +cct::SetBellWriteExpectation (const std::string &plugin, + const std::string &key, + const VariantTypes &value, + const boost::shared_ptr &setting, + const WriteFunc &write, + const CCSBackendConceptTestEnvironmentInterface::Ptr &env) +{ + CCSSettingGMock *gmock (getSettingGMockFromSetting (setting)); + EXPECT_CALL (*gmock, getBell (_)).WillRepeatedly (DoAll ( + SetArgPointee <0> ( + boolToBool (boost::get (value))), + Return (TRUE))); + write (); + bool v (boost::get (value)); + + if (v) + EXPECT_THAT (env->ReadBellAtKey (plugin, key), IsTrue ()); + else + EXPECT_THAT (env->ReadBellAtKey (plugin, key), IsFalse ()); +} + +void +cct::SetMatchWriteExpectation (const std::string &plugin, + const std::string &key, + const VariantTypes &value, + const boost::shared_ptr &setting, + const WriteFunc &write, + const CCSBackendConceptTestEnvironmentInterface::Ptr &env) +{ + CCSSettingGMock *gmock (getSettingGMockFromSetting (setting)); + EXPECT_CALL (*gmock, getMatch (_)).WillRepeatedly (DoAll ( + SetArgPointee <0> ( + const_cast ( + boost::get ( + value))), + Return (TRUE))); + write (); + EXPECT_EQ (std::string (env->ReadMatchAtKey (plugin, key)), + std::string (boost::get (value))); +} + +void +cct::SetListWriteExpectation (const std::string &plugin, + const std::string &key, + const VariantTypes &value, + const boost::shared_ptr &setting, + const WriteFunc &write, + const CCSBackendConceptTestEnvironmentInterface::Ptr &env) +{ + CCSSettingGMock *gmock (getSettingGMockFromSetting (setting)); + CCSSettingValueList list = *(boost::get > (value)); + + EXPECT_CALL (*gmock, getInfo ()); + + CCSSettingInfo *info = ccsSettingGetInfo (setting.get ()); + info->forList.listType = + (boost::get > (value))->type (); + + EXPECT_CALL (*gmock, getInfo ()).Times (AtLeast (1)); + EXPECT_CALL (*gmock, getList (_)).WillRepeatedly (DoAll ( + SetArgPointee <0> ( + list), + Return (TRUE))); + write (); + + EXPECT_THAT (cci::SettingValueListWrapper (env->ReadListAtKey (plugin, key, setting.get ()), + cci::Deep, + info->forList.listType, + boost::shared_ptr (), + setting), + ListEqual (&info->forList, list)); +} + +void +cct::SetIntReadExpectation (CCSSettingGMock *gmock, const VariantTypes &value) +{ + EXPECT_CALL (*gmock, setInt (boost::get (value), _)); +} + +void +cct::SetBoolReadExpectation (CCSSettingGMock *gmock, const VariantTypes &value) +{ + bool v (boost::get (value)); + + if (v) + EXPECT_CALL (*gmock, setBool (IsTrue (), _)); + else + EXPECT_CALL (*gmock, setBool (IsFalse (), _)); +} + +void +cct::SetBellReadExpectation (CCSSettingGMock *gmock, const VariantTypes &value) +{ + bool v (boost::get (value)); + + if (v) + EXPECT_CALL (*gmock, setBell (IsTrue (), _)); + else + EXPECT_CALL (*gmock, setBell (IsFalse (), _)); +} + +void +cct::SetFloatReadExpectation (CCSSettingGMock *gmock, const VariantTypes &value) +{ + EXPECT_CALL (*gmock, setFloat (boost::get (value), _)); +} + +void +cct::SetStringReadExpectation (CCSSettingGMock *gmock, const VariantTypes &value) +{ + EXPECT_CALL (*gmock, setString (Eq (std::string (boost::get (value))), _)); +} + +void +cct::SetMatchReadExpectation (CCSSettingGMock *gmock, const VariantTypes &value) +{ + EXPECT_CALL (*gmock, setMatch (Eq (std::string (boost::get (value))), _)); +} + +void +cct::SetColorReadExpectation (CCSSettingGMock *gmock, const VariantTypes &value) +{ + EXPECT_CALL (*gmock, setColor (boost::get (value), _)); +} + +void +cct::SetKeyReadExpectation (CCSSettingGMock *gmock, const VariantTypes &value) +{ + EXPECT_CALL (*gmock, setKey (boost::get (value), _)); +} + +void +cct::SetButtonReadExpectation (CCSSettingGMock *gmock, const VariantTypes &value) +{ + EXPECT_CALL (*gmock, setButton (boost::get (value), _)); +} + +void +cct::SetEdgeReadExpectation (CCSSettingGMock *gmock, const VariantTypes &value) +{ + EXPECT_CALL (*gmock, setEdge (boost::get (value), _)); +} + +void +cct::SetListReadExpectation (CCSSettingGMock *gmock, const VariantTypes &value) +{ + static CCSSettingInfo globalListInfo; + + globalListInfo.forList.listType = + (boost::get > (value))->type (); + globalListInfo.forList.listInfo = NULL; + + ON_CALL (*gmock, getInfo ()).WillByDefault (Return (&globalListInfo)); + EXPECT_CALL (*gmock, setList ( + ListEqual ( + &globalListInfo.forList, + *(boost::get > (value))), _)); +} diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/tests/compizconfig_backend_concept_test.h compiz-0.9.8.4/compizconfig/tests/compizconfig_backend_concept_test.h --- compiz-0.9.8.2+bzr3377/compizconfig/tests/compizconfig_backend_concept_test.h 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/tests/compizconfig_backend_concept_test.h 2012-09-27 11:04:02.000000000 +0000 @@ -1,3 +1,25 @@ +/* + * Compiz configuration system library + * + * Copyright (C) 2012 Canonical Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authored By: + * Sam Spilsbury + */ #ifndef _COMPIZCONFIG_CCS_BACKEND_CONCEPT_TEST #define _COMPIZCONFIG_CCS_BACKEND_CONCEPT_TEST @@ -23,239 +45,149 @@ #include #include "gtest_shared_characterwrapper.h" +#include "gtest_unspecified_bool_type_matcher.h" #include "compizconfig_test_value_combiners.h" +#include "compizconfig_ccs_setting_value_operators.h" +#include "compizconfig_ccs_item_in_list_matcher.h" +#include "compizconfig_ccs_list_equality.h" +#include "compizconfig_ccs_list_wrapper.h" +#include "compizconfig_ccs_variant_types.h" +#include "compizconfig_backend_concept_test_internal.h" +#include "compizconfig_backend_concept_test_environment_interface.h" -using ::testing::Eq; -using ::testing::IsNull; -using ::testing::SetArgPointee; -using ::testing::DoAll; -using ::testing::Return; -using ::testing::ReturnNull; -using ::testing::MakeMatcher; -using ::testing::Matcher; -using ::testing::MatcherInterface; -using ::testing::MatchResultListener; -using ::testing::AtLeast; -using ::testing::NiceMock; - -MATCHER(IsTrue, "Is True") { if (arg) return true; else return false; } -MATCHER(IsFalse, "Is False") { if (!arg) return true; else return false; } +namespace cci = compiz::config::impl; +namespace cc = compiz::config; -class ListEqualityMatcher : - public MatcherInterface +class CCSBackendConceptTestEnvironmentFactoryInterface { public: - ListEqualityMatcher (CCSSettingListInfo info, - CCSSettingValueList cmp) : - mInfo (info), - mCmp (cmp) - { - } - - virtual bool MatchAndExplain (CCSSettingValueList x, MatchResultListener *listener) const - { - return ccsCompareLists (x, mCmp, mInfo); - } - - virtual void DescribeTo (std::ostream *os) const - { - *os << "lists are equal"; - } - - virtual void DescribeNegationTo (std::ostream *os) const - { - *os << "lists are not equal"; - } + typedef boost::shared_ptr Ptr; - private: + virtual ~CCSBackendConceptTestEnvironmentFactoryInterface () {} - CCSSettingListInfo mInfo; - CCSSettingValueList mCmp; + virtual CCSBackendConceptTestEnvironmentInterface::Ptr ConstructTestEnv () = 0; }; -Matcher ListEqual (CCSSettingListInfo info, - CCSSettingValueList cmp) -{ - return MakeMatcher (new ListEqualityMatcher (info, cmp)); -} - -bool -operator== (const CCSSettingColorValue &lhs, - const CCSSettingColorValue &rhs) -{ - if (ccsIsEqualColor (lhs, rhs)) - return true; - return false; -} - -::std::ostream & -operator<< (::std::ostream &os, const CCSSettingColorValue &v) -{ - return os << "Red: " << std::hex << v.color.red << "Blue: " << std::hex << v.color.blue << "Green: " << v.color.green << "Alpha: " << v.color.alpha - << std::dec << std::endl; -} - -bool -operator== (const CCSSettingKeyValue &lhs, - const CCSSettingKeyValue &rhs) -{ - if (ccsIsEqualKey (lhs, rhs)) - return true; - return false; -} - -::std::ostream & -operator<< (::std::ostream &os, const CCSSettingKeyValue &v) -{ - return os << "Keysym: " << v.keysym << " KeyModMask " << std::hex << v.keyModMask << std::dec << std::endl; -} - -bool -operator== (const CCSSettingButtonValue &lhs, - const CCSSettingButtonValue &rhs) -{ - if (ccsIsEqualButton (lhs, rhs)) - return true; - return false; -} - -::std::ostream & -operator<< (::std::ostream &os, const CCSSettingButtonValue &v) -{ - return os << "Button " << v.button << "Button Key Mask: " << std::hex << v.buttonModMask << "Edge Mask: " << v.edgeMask << std::dec << std::endl; -} - -bool -operator== (const CCSString &lhs, - const std::string &rhs) -{ - if (rhs == lhs.value) - return true; - - return false; -} - -bool -operator== (const std::string &lhs, - const CCSString &rhs) -{ - if (lhs == rhs.value) - return true; - - return false; -} - -::std::ostream & -operator<< (::std::ostream &os, CCSString &string) -{ - os << string.value << std::endl; - return os; -} - -class CCSListWrapper : - boost::noncopyable +template +class CCSBackendConceptTestEnvironmentFactory : + public CCSBackendConceptTestEnvironmentFactoryInterface { public: - typedef boost::shared_ptr Ptr; - - CCSListWrapper (CCSSettingValueList list, - bool freeItems, - CCSSettingType type, - const boost::shared_ptr &listInfo, - const boost::shared_ptr &settingReference) : - mList (list), - mFreeItems (freeItems), - mType (type), - mListInfo (listInfo), - mSettingReference (settingReference) - { - } - - CCSSettingType type () { return mType; } - - operator CCSSettingValueList () - { - return mList; - } - - operator CCSSettingValueList () const - { - return mList; - } - - ~CCSListWrapper () - { - ccsSettingValueListFree (mList, mFreeItems ? TRUE : FALSE); - } - - const boost::shared_ptr & - setting () + CCSBackendConceptTestEnvironmentInterface::Ptr + ConstructTestEnv () { - return mSettingReference; + return boost::shared_static_cast (boost::make_shared ()); } - - private: - - CCSSettingValueList mList; - bool mFreeItems; - CCSSettingType mType; - boost::shared_ptr mListInfo; - boost::shared_ptr mSettingReference; }; -template -class ItemInCCSListMatcher : - public ::testing::MatcherInterface +namespace compizconfig { - public: - - ItemInCCSListMatcher (const Matcher &matcher) : - mMatcher (matcher) - { - } - - virtual bool MatchAndExplain (L list, MatchResultListener *listener) const - { - L iter = list; - - while (iter) - { - if (mMatcher.MatchAndExplain ((*(reinterpret_cast (iter->data))), listener)) - return true; - - iter = iter->next; - } - - return false; - } - - virtual void DescribeTo (std::ostream *os) const - { - *os << "found in list ("; - mMatcher.DescribeTo (os); - *os << ")"; - } - - virtual void DescribeNegationTo (std::ostream *os) const - { - *os << "not found in list ("; - mMatcher.DescribeNegationTo (os); - *os << ")"; - } - - private: - - const Matcher & mMatcher; -}; + namespace test + { + typedef boost::function WriteFunc; + typedef boost::function ConstructorFunc; -template -Matcher IsItemInCCSList (const Matcher &matcher) -{ - return MakeMatcher (new ItemInCCSListMatcher (matcher)); + cci::SettingValueListWrapper::Ptr + CCSListConstructionExpectationsSetter (const ConstructorFunc &c, + CCSSettingType type, + cci::ListStorageType storageType); + + CCSSettingGMock * getSettingGMockFromSetting (const boost::shared_ptr &setting); + void SetIntWriteExpectation (const std::string &plugin, + const std::string &key, + const VariantTypes &value, + const boost::shared_ptr &setting, + const WriteFunc &write, + const CCSBackendConceptTestEnvironmentInterface::Ptr &env); + void SetBoolWriteExpectation (const std::string &plugin, + const std::string &key, + const VariantTypes &value, + const boost::shared_ptr &setting, + const WriteFunc &write, + const CCSBackendConceptTestEnvironmentInterface::Ptr &env); + void SetFloatWriteExpectation (const std::string &plugin, + const std::string &key, + const VariantTypes &value, + const boost::shared_ptr &setting, + const WriteFunc &write, + const CCSBackendConceptTestEnvironmentInterface::Ptr &env); + void SetStringWriteExpectation (const std::string &plugin, + const std::string &key, + const VariantTypes &value, + const boost::shared_ptr &setting, + const WriteFunc &write, + const CCSBackendConceptTestEnvironmentInterface::Ptr &env); + void SetColorWriteExpectation (const std::string &plugin, + const std::string &key, + const VariantTypes &value, + const boost::shared_ptr &setting, + const WriteFunc &write, + const CCSBackendConceptTestEnvironmentInterface::Ptr &env); + void SetKeyWriteExpectation (const std::string &plugin, + const std::string &key, + const VariantTypes &value, + const boost::shared_ptr &setting, + const WriteFunc &write, + const CCSBackendConceptTestEnvironmentInterface::Ptr &env); + void SetButtonWriteExpectation (const std::string &plugin, + const std::string &key, + const VariantTypes &value, + const boost::shared_ptr &setting, + const WriteFunc &write, + const CCSBackendConceptTestEnvironmentInterface::Ptr &env); + void SetEdgeWriteExpectation (const std::string &plugin, + const std::string &key, + const VariantTypes &value, + const boost::shared_ptr &setting, + const WriteFunc &write, + const CCSBackendConceptTestEnvironmentInterface::Ptr &env); + void SetBellWriteExpectation (const std::string &plugin, + const std::string &key, + const VariantTypes &value, + const boost::shared_ptr &setting, + const WriteFunc &write, + const CCSBackendConceptTestEnvironmentInterface::Ptr &env); + void SetMatchWriteExpectation (const std::string &plugin, + const std::string &key, + const VariantTypes &value, + const boost::shared_ptr &setting, + const WriteFunc &write, + const CCSBackendConceptTestEnvironmentInterface::Ptr &env); + void SetListWriteExpectation (const std::string &plugin, + const std::string &key, + const VariantTypes &value, + const boost::shared_ptr &setting, + const WriteFunc &write, + const CCSBackendConceptTestEnvironmentInterface::Ptr &env); + void SetIntReadExpectation (CCSSettingGMock *gmock, const VariantTypes &value); + void SetBoolReadExpectation (CCSSettingGMock *gmock, const VariantTypes &value); + void SetBellReadExpectation (CCSSettingGMock *gmock, const VariantTypes &value); + void SetFloatReadExpectation (CCSSettingGMock *gmock, const VariantTypes &value); + void SetStringReadExpectation (CCSSettingGMock *gmock, const VariantTypes &value); + void SetMatchReadExpectation (CCSSettingGMock *gmock, const VariantTypes &value); + void SetColorReadExpectation (CCSSettingGMock *gmock, const VariantTypes &value); + void SetKeyReadExpectation (CCSSettingGMock *gmock, const VariantTypes &value); + void SetButtonReadExpectation (CCSSettingGMock *gmock, const VariantTypes &value); + void SetEdgeReadExpectation (CCSSettingGMock *gmock, const VariantTypes &value); + void SetListReadExpectation (CCSSettingGMock *gmock, const VariantTypes &value); + } } +using ::testing::Eq; +using ::testing::IsNull; +using ::testing::SetArgPointee; +using ::testing::DoAll; +using ::testing::Return; +using ::testing::ReturnNull; +using ::testing::MakeMatcher; +using ::testing::Matcher; +using ::testing::MatcherInterface; +using ::testing::MatchResultListener; +using ::testing::AtLeast; +using ::testing::NiceMock; + namespace { bool ccsStringCmp (const CCSString &a, const CCSString &b) @@ -264,6 +196,9 @@ } } +namespace cci = compiz::config::impl; +namespace cc = compiz::config; + typedef boost::variant VariantTypes; - -class CCSSettingsConceptTestEnvironmentInterface -{ - public: - - virtual void SetUp () = 0; - virtual void TearDown () = 0; - - virtual void WriteBoolAtKey (const std::string &plugin, - const std::string &key, - const VariantTypes &value) = 0; - virtual void WriteIntegerAtKey (const std::string &plugin, - const std::string &key, - const VariantTypes &value) = 0; - virtual void WriteFloatAtKey (const std::string &plugin, - const std::string &key, - const VariantTypes &value) = 0; - virtual void WriteStringAtKey (const std::string &plugin, - const std::string &key, - const VariantTypes &value) = 0; - virtual void WriteColorAtKey (const std::string &plugin, - const std::string &key, - const VariantTypes &value) = 0; - virtual void WriteKeyAtKey (const std::string &plugin, - const std::string &key, - const VariantTypes &value) = 0; - virtual void WriteButtonAtKey (const std::string &plugin, - const std::string &key, - const VariantTypes &value) = 0; - virtual void WriteEdgeAtKey (const std::string &plugin, - const std::string &key, - const VariantTypes &value) = 0; - virtual void WriteMatchAtKey (const std::string &plugin, - const std::string &key, - const VariantTypes &value) = 0; - virtual void WriteBellAtKey (const std::string &plugin, - const std::string &key, - const VariantTypes &value) = 0; - virtual void WriteListAtKey (const std::string &plugin, - const std::string &key, - const VariantTypes &value) = 0; - - virtual Bool ReadBoolAtKey (const std::string &plugin, - const std::string &key) = 0; - virtual int ReadIntegerAtKey (const std::string &plugin, - const std::string &key) = 0; - virtual float ReadFloatAtKey (const std::string &plugin, - const std::string &key) = 0; - virtual const char * ReadStringAtKey (const std::string &plugin, - const std::string &key) = 0; - virtual CCSSettingColorValue ReadColorAtKey (const std::string &plugin, - const std::string &key) = 0; - virtual CCSSettingKeyValue ReadKeyAtKey (const std::string &plugin, - const std::string &key) = 0; - virtual CCSSettingButtonValue ReadButtonAtKey (const std::string &plugin, - const std::string &key) = 0; - virtual unsigned int ReadEdgeAtKey (const std::string &plugin, - const std::string &key) = 0; - virtual const char * ReadMatchAtKey (const std::string &plugin, - const std::string &key) = 0; - virtual Bool ReadBellAtKey (const std::string &plugin, - const std::string &key) = 0; - virtual CCSSettingValueList ReadListAtKey (const std::string &plugin, - const std::string &key, - CCSSetting *setting) = 0; -}; - -class CCSBackendConceptTestEnvironmentInterface : - public CCSSettingsConceptTestEnvironmentInterface -{ - public: - - typedef boost::shared_ptr Ptr; - - virtual ~CCSBackendConceptTestEnvironmentInterface () {}; - virtual CCSBackend * SetUp (CCSContext *context, - CCSContextGMock *gmockContext) = 0; - virtual void TearDown (CCSBackend *) = 0; - - virtual void AddProfile (const std::string &profile) = 0; - virtual void SetGetExistingProfilesExpectation (CCSContext *, - CCSContextGMock *) = 0; - virtual void SetDeleteProfileExpectation (const std::string &, - CCSContext *, - CCSContextGMock *) = 0; - - virtual void SetReadInitExpectation (CCSContext *, - CCSContextGMock *) = 0; - - virtual void SetReadDoneExpectation (CCSContext *, - CCSContextGMock *) = 0; - - virtual void SetWriteInitExpectation (CCSContext *, - CCSContextGMock *) = 0; - - virtual void SetWriteDoneExpectation (CCSContext *, - CCSContextGMock *) = 0; - - virtual const CCSBackendInfo * GetInfo () = 0; - - virtual void PreWrite (CCSContextGMock *, - CCSPluginGMock *, - CCSSettingGMock *, - CCSSettingType) = 0; - virtual void PostWrite (CCSContextGMock *, - CCSPluginGMock *, - CCSSettingGMock *, - CCSSettingType) = 0; - - virtual void PreRead (CCSContextGMock *, - CCSPluginGMock *, - CCSSettingGMock *, - CCSSettingType) = 0; - virtual void PostRead (CCSContextGMock *, - CCSPluginGMock *, - CCSSettingGMock *, - CCSSettingType) = 0; - - virtual void PreUpdate (CCSContextGMock *, - CCSPluginGMock *, - CCSSettingGMock *, - CCSSettingType) = 0; - virtual void PostUpdate (CCSContextGMock *, - CCSPluginGMock *, - CCSSettingGMock *, - CCSSettingType) = 0; - - virtual bool UpdateSettingAtKey (const std::string &plugin, - const std::string &setting) = 0; -}; - -class CCSBackendConceptTestEnvironmentFactoryInterface -{ - public: - - typedef boost::shared_ptr Ptr; - - virtual ~CCSBackendConceptTestEnvironmentFactoryInterface () {} - - virtual CCSBackendConceptTestEnvironmentInterface::Ptr ConstructTestEnv () = 0; -}; - -template -class CCSBackendConceptTestEnvironmentFactory : - public CCSBackendConceptTestEnvironmentFactoryInterface -{ - public: - - CCSBackendConceptTestEnvironmentInterface::Ptr - ConstructTestEnv () - { - return boost::shared_static_cast (boost::make_shared ()); - } -}; + cci::SettingValueListWrapper::Ptr> VariantTypes; namespace { @@ -617,13 +398,13 @@ const CCSBackendConceptTestEnvironmentInterface::Ptr &env) { CCSSettingGMock *gmock (getSettingGMockFromSetting (setting)); - CCSSettingValueList list = *(boost::get > (value)); + CCSSettingValueList list = *(boost::get > (value)); EXPECT_CALL (*gmock, getInfo ()); CCSSettingInfo *info = ccsSettingGetInfo (setting.get ()); - info->forList.listType = (boost::get > (value))->type (); + info->forList.listType = (boost::get > (value))->type (); EXPECT_CALL (*gmock, getInfo ()).Times (AtLeast (1)); EXPECT_CALL (*gmock, getList (_)).WillRepeatedly (DoAll ( @@ -632,12 +413,12 @@ Return (TRUE))); write (); - EXPECT_THAT (CCSListWrapper (env->ReadListAtKey (plugin, key, setting.get ()), - true, - info->forList.listType, - boost::shared_ptr (), - setting), - ListEqual (info->forList, list)); + EXPECT_THAT (cci::SettingValueListWrapper (env->ReadListAtKey (plugin, key, setting.get ()), + cci::Deep, + info->forList.listType, + boost::shared_ptr (), + setting), + ListEqual (&info->forList, list)); } void SetIntReadExpectation (CCSSettingGMock *gmock, const VariantTypes &value) @@ -704,11 +485,14 @@ void SetListReadExpectation (CCSSettingGMock *gmock, const VariantTypes &value) { - globalListInfo.forList.listType = (boost::get > (value))->type (); + globalListInfo.forList.listType = (boost::get > (value))->type (); globalListInfo.forList.listInfo = NULL; ON_CALL (*gmock, getInfo ()).WillByDefault (Return (&globalListInfo)); - EXPECT_CALL (*gmock, setList (ListEqual (globalListInfo.forList, *(boost::get > (value))), _)); + EXPECT_CALL (*gmock, setList ( + ListEqual ( + &globalListInfo.forList, + *(boost::get > (value))), _)); } } @@ -725,21 +509,21 @@ typedef boost::function SetReadExpectation; - typedef boost::function &, - const WriteFunc &, - const CCSBackendConceptTestEnvironmentInterface::Ptr & )> SetWriteExpectation; + typedef boost::function &, + const compizconfig::test::WriteFunc &, + const CCSBackendConceptTestEnvironmentInterface::Ptr &)> SetWriteExpectation; virtual void TearDown (CCSBackend *) = 0; virtual CCSBackendConceptTestEnvironmentInterface::Ptr testEnv () = 0; virtual VariantTypes & value () = 0; - virtual void nativeWrite (const CCSBackendConceptTestEnvironmentInterface::Ptr & iface, - const std::string &plugin, - const std::string &keyname, - const VariantTypes &value) = 0; + virtual void nativeWrite (const CCSBackendConceptTestEnvironmentInterface::Ptr &iface, + const std::string &plugin, + const std::string &keyname, + const VariantTypes &value) = 0; virtual CCSSettingType & type () = 0; virtual std::string & keyname () = 0; virtual SetWriteExpectation & setWriteExpectationAndWrite () = 0; @@ -960,25 +744,10 @@ typedef boost::function ConstructorFunc; -CCSListWrapper::Ptr +cci::SettingValueListWrapper::Ptr CCSListConstructionExpectationsSetter (const ConstructorFunc &c, CCSSettingType type, - bool freeItems) -{ - boost::function f (boost::bind (ccsFreeMockSetting, _1)); - boost::shared_ptr mockSetting (ccsNiceMockSettingNew (), f); - NiceMock *gmockSetting = reinterpret_cast *> (ccsObjectGetPrivate (mockSetting.get ())); - - ON_CALL (*gmockSetting, getType ()).WillByDefault (Return (TypeList)); - - boost::shared_ptr listInfo (new CCSSettingInfo); - - listInfo->forList.listType = type; - - ON_CALL (*gmockSetting, getInfo ()).WillByDefault (Return (listInfo.get ())); - ON_CALL (*gmockSetting, getDefaultValue ()).WillByDefault (ReturnNull ()); - return boost::make_shared (c (mockSetting.get ()), freeItems, type, listInfo, mockSetting); -} + cci::ListStorageType storageType); template ::testing::internal::ParamGenerator @@ -1073,7 +842,7 @@ "TestEdge"), boost::make_shared (backendEnvFactory, VariantTypes (CCSListConstructionExpectationsSetter (boost::bind (list_populators::integer, _1), - TypeInt, true)), + TypeInt, cci::Deep)), &CCSBackendConceptTestEnvironmentInterface::WriteListAtKey, TypeList, "int_list_setting", @@ -1082,7 +851,7 @@ "TestListInt"), boost::make_shared (backendEnvFactory, VariantTypes (CCSListConstructionExpectationsSetter (boost::bind (list_populators::doubleprecision, _1), - TypeFloat, true)), + TypeFloat, cci::Deep)), &CCSBackendConceptTestEnvironmentInterface::WriteListAtKey, TypeList, "float_list_setting", @@ -1091,7 +860,7 @@ "TestListFloat"), boost::make_shared (backendEnvFactory, VariantTypes (CCSListConstructionExpectationsSetter (boost::bind (list_populators::boolean, _1), - TypeBool, true)), + TypeBool, cci::Deep)), &CCSBackendConceptTestEnvironmentInterface::WriteListAtKey, TypeList, "bool_list_setting", @@ -1100,7 +869,7 @@ "TestListBool"), boost::make_shared (backendEnvFactory, VariantTypes (CCSListConstructionExpectationsSetter (boost::bind (list_populators::string, _1), - TypeString, true)), + TypeString, cci::Deep)), &CCSBackendConceptTestEnvironmentInterface::WriteListAtKey, TypeList, "string_list_setting", @@ -1109,7 +878,7 @@ "TestListString"), boost::make_shared (backendEnvFactory, VariantTypes (CCSListConstructionExpectationsSetter (boost::bind (list_populators::match, _1), - TypeMatch, true)), + TypeMatch, cci::Deep)), &CCSBackendConceptTestEnvironmentInterface::WriteListAtKey, TypeList, "match_list_setting", @@ -1118,7 +887,7 @@ "TestListMatch"), boost::make_shared (backendEnvFactory, VariantTypes (CCSListConstructionExpectationsSetter (boost::bind (list_populators::color, _1), - TypeColor, true)), + TypeColor, cci::Deep)), &CCSBackendConceptTestEnvironmentInterface::WriteListAtKey, TypeList, "color_list_setting", @@ -1336,17 +1105,6 @@ const std::string CCSBackendConformanceTestProfileHandling::PROFILE_BAR ("bar"); const std::string CCSBackendConformanceTestProfileHandling::PROFILE_BAZ ("baz"); -/* A workaround for templates inside of macros not - * expanding correctly */ -namespace -{ - Matcher - IsStringItemInStringCCSList (const Matcher &matcher) - { - return IsItemInCCSList (matcher); - } -} - TEST_P (CCSBackendConformanceTestProfileHandling, TestGetExistingProfiles) { CCSBackend *backend = GetBackend (); diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/tests/compizconfig_backend_concept_test_environment_interface.h compiz-0.9.8.4/compizconfig/tests/compizconfig_backend_concept_test_environment_interface.h --- compiz-0.9.8.2+bzr3377/compizconfig/tests/compizconfig_backend_concept_test_environment_interface.h 1970-01-01 00:00:00.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/tests/compizconfig_backend_concept_test_environment_interface.h 2012-09-27 11:04:02.000000000 +0000 @@ -0,0 +1,101 @@ +/* + * Compiz configuration system library + * + * Copyright (C) 2012 Canonical Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authored By: + * Sam Spilsbury + */ +#ifndef _COMPIZCONFIG_CCS_BACKEND_CONCEPT_TEST_ENVIRONMENT_INTERFACE_H +#define _COMPIZCONFIG_CCS_BACKEND_CONCEPT_TEST_ENVIRONMENT_INTERFACE_H + +#include +#include +#include "compizconfig_ccs_settings_test_fixture.h" + +typedef struct _CCSContext CCSContext; +typedef struct _CCSBackendInfo CCSBackendInfo; + +class CCSContextGMock; +class CCSPluginGMock; +class CCSSettingGMock; + +class CCSBackendConceptTestEnvironmentInterface : + public CCSSettingsConceptTestEnvironmentInterface +{ + public: + + typedef boost::shared_ptr Ptr; + + virtual ~CCSBackendConceptTestEnvironmentInterface () {}; + virtual CCSBackend * SetUp (CCSContext *context, + CCSContextGMock *gmockContext) = 0; + virtual void TearDown (CCSBackend *) = 0; + + virtual void AddProfile (const std::string &profile) = 0; + virtual void SetGetExistingProfilesExpectation (CCSContext *, + CCSContextGMock *) = 0; + virtual void SetDeleteProfileExpectation (const std::string &, + CCSContext *, + CCSContextGMock *) = 0; + + virtual void SetReadInitExpectation (CCSContext *, + CCSContextGMock *) = 0; + + virtual void SetReadDoneExpectation (CCSContext *, + CCSContextGMock *) = 0; + + virtual void SetWriteInitExpectation (CCSContext *, + CCSContextGMock *) = 0; + + virtual void SetWriteDoneExpectation (CCSContext *, + CCSContextGMock *) = 0; + + virtual const CCSBackendInfo * GetInfo () = 0; + + virtual void PreWrite (CCSContextGMock *, + CCSPluginGMock *, + CCSSettingGMock *, + CCSSettingType) = 0; + virtual void PostWrite (CCSContextGMock *, + CCSPluginGMock *, + CCSSettingGMock *, + CCSSettingType) = 0; + + virtual void PreRead (CCSContextGMock *, + CCSPluginGMock *, + CCSSettingGMock *, + CCSSettingType) = 0; + virtual void PostRead (CCSContextGMock *, + CCSPluginGMock *, + CCSSettingGMock *, + CCSSettingType) = 0; + + virtual void PreUpdate (CCSContextGMock *, + CCSPluginGMock *, + CCSSettingGMock *, + CCSSettingType) = 0; + virtual void PostUpdate (CCSContextGMock *, + CCSPluginGMock *, + CCSSettingGMock *, + CCSSettingType) = 0; + + virtual bool UpdateSettingAtKey (const std::string &plugin, + const std::string &setting) = 0; +}; + +#endif diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/tests/compizconfig_backend_concept_test_internal.h compiz-0.9.8.4/compizconfig/tests/compizconfig_backend_concept_test_internal.h --- compiz-0.9.8.2+bzr3377/compizconfig/tests/compizconfig_backend_concept_test_internal.h 1970-01-01 00:00:00.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/tests/compizconfig_backend_concept_test_internal.h 2012-09-27 11:04:02.000000000 +0000 @@ -0,0 +1,146 @@ +/* + * Compiz configuration system library + * + * Copyright (C) 2012 Canonical Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authored By: + * Sam Spilsbury + */ +#ifndef _COMPIZCONFIG_CCS_BACKEND_CONCEPT_TEST_INTERNAL_H +#define _COMPIZCONFIG_CCS_BACKEND_CONCEPT_TEST_INTERNAL_H + +#include + +#include +#include +#include + +#include +#include +#include + +#include "gtest_shared_characterwrapper.h" +#include "compizconfig_test_value_combiners.h" +#include "compizconfig_ccs_setting_value_operators.h" +#include "compizconfig_ccs_item_in_list_matcher.h" +#include "compizconfig_ccs_list_equality.h" +#include "compizconfig_ccs_list_wrapper.h" +#include "compizconfig_ccs_variant_types.h" +#include "compizconfig_ccs_settings_test_fixture.h" + +namespace cci = compiz::config::impl; +namespace cc = compiz::config; + +class CCSBackendConceptTestEnvironmentInterface; +class CCSSettingGMock; + +namespace compizconfig +{ + namespace test + { + typedef boost::function WriteFunc; + typedef boost::function ConstructorFunc; + + cci::SettingValueListWrapper::Ptr + CCSListConstructionExpectationsSetter (const ConstructorFunc &c, + CCSSettingType type, + cci::ListStorageType storageType); + + Bool boolToBool (bool v); + CCSSettingGMock * getSettingGMockFromSetting (const boost::shared_ptr &setting); + void SetIntWriteExpectation (const std::string &plugin, + const std::string &key, + const VariantTypes &value, + const boost::shared_ptr &setting, + const WriteFunc &write, + const boost::shared_ptr &env); + void SetBoolWriteExpectation (const std::string &plugin, + const std::string &key, + const VariantTypes &value, + const boost::shared_ptr &setting, + const WriteFunc &write, + const boost::shared_ptr &env); + void SetFloatWriteExpectation (const std::string &plugin, + const std::string &key, + const VariantTypes &value, + const boost::shared_ptr &setting, + const WriteFunc &write, + const boost::shared_ptr &env); + void SetStringWriteExpectation (const std::string &plugin, + const std::string &key, + const VariantTypes &value, + const boost::shared_ptr &setting, + const WriteFunc &write, + const boost::shared_ptr &env); + void SetColorWriteExpectation (const std::string &plugin, + const std::string &key, + const VariantTypes &value, + const boost::shared_ptr &setting, + const WriteFunc &write, + const boost::shared_ptr &env); + void SetKeyWriteExpectation (const std::string &plugin, + const std::string &key, + const VariantTypes &value, + const boost::shared_ptr &setting, + const WriteFunc &write, + const boost::shared_ptr &env); + void SetButtonWriteExpectation (const std::string &plugin, + const std::string &key, + const VariantTypes &value, + const boost::shared_ptr &setting, + const WriteFunc &write, + const boost::shared_ptr &env); + void SetEdgeWriteExpectation (const std::string &plugin, + const std::string &key, + const VariantTypes &value, + const boost::shared_ptr &setting, + const WriteFunc &write, + const boost::shared_ptr &env); + void SetBellWriteExpectation (const std::string &plugin, + const std::string &key, + const VariantTypes &value, + const boost::shared_ptr &setting, + const WriteFunc &write, + const boost::shared_ptr &env); + void SetMatchWriteExpectation (const std::string &plugin, + const std::string &key, + const VariantTypes &value, + const boost::shared_ptr &setting, + const WriteFunc &write, + const boost::shared_ptr &env); + void SetListWriteExpectation (const std::string &plugin, + const std::string &key, + const VariantTypes &value, + const boost::shared_ptr &setting, + const WriteFunc &write, + const boost::shared_ptr &env); + void SetIntReadExpectation (CCSSettingGMock *gmock, const VariantTypes &value); + void SetBoolReadExpectation (CCSSettingGMock *gmock, const VariantTypes &value); + void SetBellReadExpectation (CCSSettingGMock *gmock, const VariantTypes &value); + void SetFloatReadExpectation (CCSSettingGMock *gmock, const VariantTypes &value); + void SetStringReadExpectation (CCSSettingGMock *gmock, const VariantTypes &value); + void SetMatchReadExpectation (CCSSettingGMock *gmock, const VariantTypes &value); + void SetColorReadExpectation (CCSSettingGMock *gmock, const VariantTypes &value); + void SetKeyReadExpectation (CCSSettingGMock *gmock, const VariantTypes &value); + void SetButtonReadExpectation (CCSSettingGMock *gmock, const VariantTypes &value); + void SetEdgeReadExpectation (CCSSettingGMock *gmock, const VariantTypes &value); + void SetListReadExpectation (CCSSettingGMock *gmock, const VariantTypes &value); + } +} + +#endif + diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/tests/compizconfig_ccs_item_in_list_matcher.cpp compiz-0.9.8.4/compizconfig/tests/compizconfig_ccs_item_in_list_matcher.cpp --- compiz-0.9.8.2+bzr3377/compizconfig/tests/compizconfig_ccs_item_in_list_matcher.cpp 1970-01-01 00:00:00.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/tests/compizconfig_ccs_item_in_list_matcher.cpp 2012-09-27 11:04:02.000000000 +0000 @@ -0,0 +1,36 @@ +/* + * Compiz configuration system library + * + * Copyright (C) 2012 Canonical Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authored By: + * Sam Spilsbury + */ + +#include + +Matcher +IsStringItemInStringCCSList (const Matcher &matcher) +{ + return IsItemInCCSList (matcher); +} + +Matcher +IsSettingValueInSettingValueCCSList (const Matcher &matcher) +{ + return IsItemInCCSList (matcher); +} diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/tests/compizconfig_ccs_item_in_list_matcher.h compiz-0.9.8.4/compizconfig/tests/compizconfig_ccs_item_in_list_matcher.h --- compiz-0.9.8.2+bzr3377/compizconfig/tests/compizconfig_ccs_item_in_list_matcher.h 1970-01-01 00:00:00.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/tests/compizconfig_ccs_item_in_list_matcher.h 2012-09-27 11:04:02.000000000 +0000 @@ -0,0 +1,101 @@ +/* + * Compiz configuration system library + * + * Copyright (C) 2012 Canonical Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authored By: + * Sam Spilsbury + */ +#ifndef _COMPIZCONFIG_CCS_ITEM_IN_LIST_MATCHER_H +#define _COMPIZCONFIG_CCS_ITEM_IN_LIST_MATCHER_H + +#include +#include +#include + +using ::testing::Matcher; +using ::testing::MatcherInterface; +using ::testing::MatchResultListener; +using ::testing::MakeMatcher; + +template +class ItemInCCSListMatcher : + public ::testing::MatcherInterface +{ + public: + + ItemInCCSListMatcher (const Matcher &matcher) : + mMatcher (matcher) + { + } + + virtual bool MatchAndExplain (L list, MatchResultListener *listener) const + { + L iter = list; + + while (iter) + { + const I &i = *(reinterpret_cast (iter->data)); + + if (mMatcher.MatchAndExplain (i, listener)) + return true; + + iter = iter->next; + } + + return false; + } + + virtual void DescribeTo (std::ostream *os) const + { + *os << "found in list ("; + mMatcher.DescribeTo (os); + *os << ")"; + } + + virtual void DescribeNegationTo (std::ostream *os) const + { + *os << "not found in list ("; + mMatcher.DescribeNegationTo (os); + *os << ")"; + } + + private: + + Matcher mMatcher; +}; + +template +Matcher IsItemInCCSList (const Matcher &matcher) +{ + return MakeMatcher (new ItemInCCSListMatcher (matcher)); +} + +typedef struct _CCSString CCSString; +typedef struct _CCSStringList * CCSStringList; +typedef struct _CCSSettingValue CCSSettingValue; +typedef struct _CCSSettingValueList * CCSSettingValueList; + +/* A workaround for templates inside of macros not + * expanding correctly */ +Matcher +IsStringItemInStringCCSList (const Matcher &matcher); + +Matcher +IsSettingValueInSettingValueCCSList (const Matcher &matcher); + +#endif diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/tests/compizconfig_ccs_list_equality.cpp compiz-0.9.8.4/compizconfig/tests/compizconfig_ccs_list_equality.cpp --- compiz-0.9.8.2+bzr3377/compizconfig/tests/compizconfig_ccs_list_equality.cpp 1970-01-01 00:00:00.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/tests/compizconfig_ccs_list_equality.cpp 2012-09-27 11:04:02.000000000 +0000 @@ -0,0 +1,74 @@ +/* + * Compiz configuration system library + * + * Copyright (C) 2012 Canonical Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authored By: + * Sam Spilsbury + */ +#include +#include +#include + +using ::testing::MakeMatcher; + +class PrivateListEqualityMatcher +{ + public: + + PrivateListEqualityMatcher (CCSSettingListInfo *info, + CCSSettingValueList cmp) : + mInfo (info), + mCmp (cmp) + { + } + + CCSSettingListInfo *mInfo; + CCSSettingValueList mCmp; +}; + +ListEqualityMatcher::ListEqualityMatcher (CCSSettingListInfo *info, + CCSSettingValueList cmp) : + priv (new PrivateListEqualityMatcher (info, cmp)) +{ +} + +bool +ListEqualityMatcher::MatchAndExplain (CCSSettingValueList x, + MatchResultListener *listener) const +{ + return ccsCompareLists (x, priv->mCmp, *priv->mInfo); +} + +void +ListEqualityMatcher::DescribeTo (std::ostream *os) const +{ + *os << "lists are equal"; +} + +void +ListEqualityMatcher::DescribeNegationTo (std::ostream *os) const +{ + *os << "lists are not equal"; +} + +Matcher ListEqual (CCSSettingListInfo *info, + CCSSettingValueList cmp) +{ + return MakeMatcher (new ListEqualityMatcher (info, cmp)); +} + diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/tests/compizconfig_ccs_list_equality.h compiz-0.9.8.4/compizconfig/tests/compizconfig_ccs_list_equality.h --- compiz-0.9.8.2+bzr3377/compizconfig/tests/compizconfig_ccs_list_equality.h 1970-01-01 00:00:00.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/tests/compizconfig_ccs_list_equality.h 2012-09-27 11:04:02.000000000 +0000 @@ -0,0 +1,60 @@ +/* + * Compiz configuration system library + * + * Copyright (C) 2012 Canonical Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authored By: + * Sam Spilsbury + */ +#ifndef _COMPIZCONFIG_CCS_LIST_EQUALITY_H +#define _COMPIZCONFIG_CCS_LIST_EQUALITY_H + +#include +#include +#include +#include + +using ::testing::MatcherInterface; +using ::testing::MatchResultListener; +using ::testing::Matcher; + +typedef struct _CCSSettingValueList * CCSSettingValueList; +typedef struct _CCSSettingListInfo CCSSettingListInfo; + +class PrivateListEqualityMatcher; + +class ListEqualityMatcher : + public MatcherInterface +{ + public: + + ListEqualityMatcher (CCSSettingListInfo *info, + CCSSettingValueList cmp); + + virtual bool MatchAndExplain (CCSSettingValueList x, MatchResultListener *listener) const; + virtual void DescribeTo (std::ostream *os) const; + virtual void DescribeNegationTo (std::ostream *os) const; + + private: + + std::auto_ptr priv; +}; + +Matcher ListEqual (CCSSettingListInfo *info, + CCSSettingValueList cmp); + +#endif diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/tests/compizconfig_ccs_list_wrapper.cpp compiz-0.9.8.4/compizconfig/tests/compizconfig_ccs_list_wrapper.cpp --- compiz-0.9.8.2+bzr3377/compizconfig/tests/compizconfig_ccs_list_wrapper.cpp 1970-01-01 00:00:00.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/tests/compizconfig_ccs_list_wrapper.cpp 2012-09-27 11:04:02.000000000 +0000 @@ -0,0 +1,109 @@ +/* + * Compiz configuration system library + * + * Copyright (C) 2012 Canonical Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authored By: + * Sam Spilsbury + */ +#include +#include + +namespace cci = compiz::config::impl; +namespace cc = compiz::config; + +namespace compiz +{ + namespace config + { + namespace impl + { + class PrivateSettingValueListWrapper + { + public: + + PrivateSettingValueListWrapper (CCSSettingValueList list, + cci::ListStorageType storageType, + CCSSettingType type, + const boost::shared_ptr &listInfo, + const boost::shared_ptr &settingReference) : + mType (type), + mListInfo (listInfo), + mSettingReference (settingReference), + mListWrapper (list, + ccsSettingValueListFree, + ccsSettingValueListAppend, + ccsSettingValueListRemove, + storageType) + { + } + + CCSSettingType mType; + boost::shared_ptr mListInfo; + boost::shared_ptr mSettingReference; + SettingValueListWrapper::InternalWrapperImpl mListWrapper; + }; + } + } +} + +cci::SettingValueListWrapper::SettingValueListWrapper (CCSSettingValueList list, + cci::ListStorageType storageType, + CCSSettingType type, + const boost::shared_ptr &listInfo, + const boost::shared_ptr &settingReference) : + priv (new cci::PrivateSettingValueListWrapper (list, + storageType, + type, + listInfo, + settingReference)) +{ +} + +CCSSettingType +cci::SettingValueListWrapper::type () +{ + return priv->mType; +} + +cci::SettingValueListWrapper::InternalWrapper & +cci::SettingValueListWrapper::append (CCSSettingValue * const &value) +{ + return priv->mListWrapper.append (value); +} + +cci::SettingValueListWrapper::InternalWrapper & +cci::SettingValueListWrapper::remove (CCSSettingValue * const &value) +{ + return priv->mListWrapper.remove (value); +} + +cci::SettingValueListWrapper::operator const CCSSettingValueList & () const +{ + return priv->mListWrapper; +} + +cci::SettingValueListWrapper::operator CCSSettingValueList & () +{ + return priv->mListWrapper; +} + +const boost::shared_ptr & +cci::SettingValueListWrapper::setting () +{ + return priv->mSettingReference; +} diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/tests/compizconfig_ccs_list_wrapper.h compiz-0.9.8.4/compizconfig/tests/compizconfig_ccs_list_wrapper.h --- compiz-0.9.8.2+bzr3377/compizconfig/tests/compizconfig_ccs_list_wrapper.h 1970-01-01 00:00:00.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/tests/compizconfig_ccs_list_wrapper.h 2012-09-27 11:04:02.000000000 +0000 @@ -0,0 +1,163 @@ +/* + * Compiz configuration system library + * + * Copyright (C) 2012 Canonical Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authored By: + * Sam Spilsbury + */ +#ifndef _COMPIZCONFIG_CCS_LIST_WRAPPER_H +#define _COMPIZCONFIG_CCS_LIST_WRAPPER_H + +#include +#include + +#include +#include + +typedef struct _CCSSettingValueList * CCSSettingValueList; +typedef struct _CCSSetting CCSSetting; +typedef union _CCSSettingInfo CCSSettingInfo; +typedef struct _CCSSettingValue CCSSettingValue; + +namespace compiz +{ + namespace config + { + template + class ListWrapper : + boost::noncopyable + { + public: + + virtual ~ListWrapper () {} + + virtual ListWrapper & append (const DataType &) = 0; + virtual ListWrapper & remove (const DataType &) = 0; + + virtual operator const ListType & () const = 0; + virtual operator ListType & () = 0; + }; + + namespace impl + { + namespace cc = compiz::config; + namespace cci = compiz::config::impl; + + typedef enum _ListStorageType + { + Shallow = 0, + Deep = 1 + } ListStorageType; + + template + class ListWrapper : + public cc::ListWrapper + { + public: + + typedef ListType (*ListTypeFreeFunc) (ListType, Bool); + typedef ListType (*ListTypeAppendFunc) (ListType, DataType); + typedef ListType (*ListTypeRemoveFunc) (ListType, DataType, Bool); + + ListWrapper (const ListType &list, + ListTypeFreeFunc freeFunc, + ListTypeAppendFunc appendFunc, + ListTypeRemoveFunc removeFunc, + ListStorageType storageType) : + mList (list), + mFree (freeFunc), + mAppend (appendFunc), + mRemove (removeFunc), + mStorageType (storageType) + { + }; + + cc::ListWrapper & append (DataType const &data) + { + mList = (*mAppend) (mList, data); + return *this; + } + + cc::ListWrapper & remove (DataType const &data) + { + Bool freeObj = (mStorageType == Deep); + mList = (*mRemove) (mList, data, freeObj); + return *this; + } + + operator const ListType & () const + { + return mList; + } + + operator ListType & () + { + return mList; + } + + ~ListWrapper () + { + Bool freeObj = (mStorageType == Deep); + + (*mFree) (mList, freeObj); + } + + private: + + ListType mList; + ListTypeFreeFunc mFree; + ListTypeAppendFunc mAppend; + ListTypeRemoveFunc mRemove; + ListStorageType mStorageType; + }; + + class PrivateSettingValueListWrapper; + class SettingValueListWrapper : + public compiz::config::ListWrapper + { + public: + + typedef boost::shared_ptr Ptr; + typedef compiz::config::ListWrapper InternalWrapper; + typedef compiz::config::impl::ListWrapper InternalWrapperImpl; + + SettingValueListWrapper (CCSSettingValueList list, + ListStorageType storageType, + CCSSettingType type, + const boost::shared_ptr &listInfo, + const boost::shared_ptr &settingReference); + + CCSSettingType type (); + + InternalWrapper & append (CCSSettingValue * const &value); + InternalWrapper & remove (CCSSettingValue * const &value); + operator const CCSSettingValueList & () const; + operator CCSSettingValueList & (); + const boost::shared_ptr & setting (); + + private: + + boost::shared_ptr priv; + }; + } + } +} + + + +#endif diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/tests/compizconfig_ccs_mocked_allocator.h compiz-0.9.8.4/compizconfig/tests/compizconfig_ccs_mocked_allocator.h --- compiz-0.9.8.2+bzr3377/compizconfig/tests/compizconfig_ccs_mocked_allocator.h 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/tests/compizconfig_ccs_mocked_allocator.h 2012-09-27 11:04:02.000000000 +0000 @@ -1,3 +1,25 @@ +/* + * Compiz configuration system library + * + * Copyright (C) 2012 Canonical Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authored By: + * Sam Spilsbury + */ #ifndef _COMPIZCONFIG_CCS_MOCKED_ALLOCATION_H #define _COMPIZCONFIG_CCS_MOCKED_ALLOCATION_H diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/tests/compizconfig_ccs_setting_value_matcher.cpp compiz-0.9.8.4/compizconfig/tests/compizconfig_ccs_setting_value_matcher.cpp --- compiz-0.9.8.2+bzr3377/compizconfig/tests/compizconfig_ccs_setting_value_matcher.cpp 1970-01-01 00:00:00.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/tests/compizconfig_ccs_setting_value_matcher.cpp 2012-09-27 11:04:02.000000000 +0000 @@ -0,0 +1,69 @@ +/* + * Compiz configuration system library + * + * Copyright (C) 2012 Canonical Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authored By: + * Sam Spilsbury + */ +#include +#include + +#include +#include "compizconfig_ccs_setting_value_matcher.h" + +CCSSettingValueMatcher::CCSSettingValueMatcher (const CCSSettingValue &match, + CCSSettingType type, + CCSSettingInfo *info) : + mMatch (match), + mType (type), + mInfo (info) +{ +} + +bool +CCSSettingValueMatcher::MatchAndExplain (CCSSettingValue x, MatchResultListener *listener) const +{ + if (ccsCheckValueEq (&x, + mType, + mInfo, + &mMatch, + mType, + mInfo)) + return true; + return false; +} + +void +CCSSettingValueMatcher::DescribeTo (std::ostream *os) const +{ + *os << "Value Matches"; +} + +void +CCSSettingValueMatcher::DescribeNegationTo (std::ostream *os) const +{ + *os << "Value does not Match"; +} + +Matcher +SettingValueMatch (const CCSSettingValue &match, + CCSSettingType type, + CCSSettingInfo *info) +{ + return MakeMatcher (new CCSSettingValueMatcher (match, type, info)); +} diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/tests/compizconfig_ccs_setting_value_matcher.h compiz-0.9.8.4/compizconfig/tests/compizconfig_ccs_setting_value_matcher.h --- compiz-0.9.8.2+bzr3377/compizconfig/tests/compizconfig_ccs_setting_value_matcher.h 1970-01-01 00:00:00.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/tests/compizconfig_ccs_setting_value_matcher.h 2012-09-27 11:04:02.000000000 +0000 @@ -0,0 +1,64 @@ +/* + * Compiz configuration system library + * + * Copyright (C) 2012 Canonical Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authored By: + * Sam Spilsbury + */ +#ifndef _COMPIZCONFIG_CCS_SETTING_VALUE_MATCHER_H +#define _COMPIZCONFIG_CCS_SETTING_VALUE_MATCHER_H + +#include +#include + +#include +#include + +using ::testing::MatcherInterface; +using ::testing::Matcher; +using ::testing::MatchResultListener; + +typedef struct _CCSSettingValue CCSSettingValue; +typedef union _CCSSettingInfo CCSSettingInfo; + +class CCSSettingValueMatcher : + public ::testing::MatcherInterface +{ + public: + + CCSSettingValueMatcher (const CCSSettingValue &match, + CCSSettingType type, + CCSSettingInfo *info); + + virtual bool MatchAndExplain (CCSSettingValue x, MatchResultListener *listener) const; + virtual void DescribeTo (std::ostream *os) const; + virtual void DescribeNegationTo (std::ostream *os) const; + + private: + + const CCSSettingValue &mMatch; + CCSSettingType mType; + CCSSettingInfo *mInfo; +}; + +Matcher +SettingValueMatch (const CCSSettingValue &match, + CCSSettingType type, + CCSSettingInfo *info); + +#endif diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/tests/compizconfig_ccs_setting_value_operators.cpp compiz-0.9.8.4/compizconfig/tests/compizconfig_ccs_setting_value_operators.cpp --- compiz-0.9.8.2+bzr3377/compizconfig/tests/compizconfig_ccs_setting_value_operators.cpp 1970-01-01 00:00:00.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/tests/compizconfig_ccs_setting_value_operators.cpp 2012-09-27 11:04:02.000000000 +0000 @@ -0,0 +1,103 @@ +/* + * Compiz configuration system library + * + * Copyright (C) 2012 Canonical Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authored By: + * Sam Spilsbury + */ + +#include +#include +#include + +bool +operator== (const CCSSettingColorValue &lhs, + const CCSSettingColorValue &rhs) +{ + if (ccsIsEqualColor (lhs, rhs)) + return true; + return false; +} + +std::ostream & +operator<< (std::ostream &os, const CCSSettingColorValue &v) +{ + return os << "Red: " << std::hex << v.color.red << "Blue: " << std::hex << v.color.blue << "Green: " << v.color.green << "Alpha: " << v.color.alpha + << std::dec << std::endl; +} + +bool +operator== (const CCSSettingKeyValue &lhs, + const CCSSettingKeyValue &rhs) +{ + if (ccsIsEqualKey (lhs, rhs)) + return true; + return false; +} + +std::ostream & +operator<< (std::ostream &os, const CCSSettingKeyValue &v) +{ + return os << "Keysym: " << v.keysym << " KeyModMask " << std::hex << v.keyModMask << std::dec << std::endl; +} + +bool +operator== (const CCSSettingButtonValue &lhs, + const CCSSettingButtonValue &rhs) +{ + if (ccsIsEqualButton (lhs, rhs)) + return true; + return false; +} + +std::ostream & +operator<< (std::ostream &os, const CCSSettingButtonValue &v) +{ + return os << "Button " << v.button << "Button Key Mask: " << std::hex << v.buttonModMask << "Edge Mask: " << v.edgeMask << std::dec << std::endl; +} + +bool +operator== (const CCSString &lhs, + const std::string &rhs) +{ + if (rhs == lhs.value) + return true; + + return false; +} + +bool +operator== (const std::string &lhs, + const CCSString &rhs) +{ + return rhs == lhs; +} + +bool +operator== (const std::string &rhs, + CCSString *lhs) +{ + return *lhs == rhs; +} + +std::ostream & +operator<< (std::ostream &os, CCSString &string) +{ + os << string.value << std::endl; + return os; +} diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/tests/compizconfig_ccs_setting_value_operators.h compiz-0.9.8.4/compizconfig/tests/compizconfig_ccs_setting_value_operators.h --- compiz-0.9.8.2+bzr3377/compizconfig/tests/compizconfig_ccs_setting_value_operators.h 1970-01-01 00:00:00.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/tests/compizconfig_ccs_setting_value_operators.h 2012-09-27 11:04:02.000000000 +0000 @@ -0,0 +1,70 @@ +/* + * Compiz configuration system library + * + * Copyright (C) 2012 Canonical Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authored By: + * Sam Spilsbury + */ +#ifndef _COMPIZCONFIG_CCS_SETTING_VALUE_OPERATORS_H +#define _COMPIZCONFIG_CCS_SETTING_VALUE_OPERATORS_H + +#include +#include + +typedef union _CCSSettingColorValue CCSSettingColorValue; +typedef struct _CCSSettingKeyValue CCSSettingKeyValue; +typedef struct _CCSSettingButtonValue CCSSettingButtonValue; +typedef struct _CCSString CCSString; + +bool +operator== (const CCSSettingColorValue &lhs, + const CCSSettingColorValue &rhs); + +std::ostream & +operator<< (std::ostream &os, const CCSSettingColorValue &v); + +bool +operator== (const CCSSettingKeyValue &lhs, + const CCSSettingKeyValue &rhs); + +std::ostream & +operator<< (std::ostream &os, const CCSSettingKeyValue &v); + +bool +operator== (const CCSSettingButtonValue &lhs, + const CCSSettingButtonValue &rhs); + +std::ostream & +operator<< (std::ostream &os, const CCSSettingButtonValue &v); + +bool +operator== (const CCSString &lhs, + const std::string &rhs); + +bool +operator== (const std::string &lhs, + const CCSString &rhs); + +bool +operator== (const std::string &rhs, + CCSString *lhs); + +std::ostream & +operator<< (std::ostream &os, CCSString &string); + +#endif diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/tests/compizconfig_ccs_settings_test_fixture.h compiz-0.9.8.4/compizconfig/tests/compizconfig_ccs_settings_test_fixture.h --- compiz-0.9.8.2+bzr3377/compizconfig/tests/compizconfig_ccs_settings_test_fixture.h 1970-01-01 00:00:00.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/tests/compizconfig_ccs_settings_test_fixture.h 2012-09-27 11:04:02.000000000 +0000 @@ -0,0 +1,106 @@ +/* + * Compiz configuration system library + * + * Copyright (C) 2012 Canonical Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authored By: + * Sam Spilsbury + */ +#ifndef _COMPIZCONFIG_CCS_SETTINGS_TEST_FIXTURE_H +#define _COMPIZCONFIG_CCS_SETTINGS_TEST_FIXTURE_H +#include +#include +#include "compizconfig_ccs_variant_types.h" + +typedef enum _CCSSettingType CCSSettingType; +typedef struct _CCSSetting CCSSetting; + +namespace compizconfig +{ + namespace test + { + Bool boolToBool (bool v); + } +} + +class CCSSettingsConceptTestEnvironmentInterface +{ + public: + + virtual void SetUp () = 0; + virtual void TearDown () = 0; + + virtual void WriteBoolAtKey (const std::string &plugin, + const std::string &key, + const VariantTypes &value) = 0; + virtual void WriteIntegerAtKey (const std::string &plugin, + const std::string &key, + const VariantTypes &value) = 0; + virtual void WriteFloatAtKey (const std::string &plugin, + const std::string &key, + const VariantTypes &value) = 0; + virtual void WriteStringAtKey (const std::string &plugin, + const std::string &key, + const VariantTypes &value) = 0; + virtual void WriteColorAtKey (const std::string &plugin, + const std::string &key, + const VariantTypes &value) = 0; + virtual void WriteKeyAtKey (const std::string &plugin, + const std::string &key, + const VariantTypes &value) = 0; + virtual void WriteButtonAtKey (const std::string &plugin, + const std::string &key, + const VariantTypes &value) = 0; + virtual void WriteEdgeAtKey (const std::string &plugin, + const std::string &key, + const VariantTypes &value) = 0; + virtual void WriteMatchAtKey (const std::string &plugin, + const std::string &key, + const VariantTypes &value) = 0; + virtual void WriteBellAtKey (const std::string &plugin, + const std::string &key, + const VariantTypes &value) = 0; + virtual void WriteListAtKey (const std::string &plugin, + const std::string &key, + const VariantTypes &value) = 0; + + virtual Bool ReadBoolAtKey (const std::string &plugin, + const std::string &key) = 0; + virtual int ReadIntegerAtKey (const std::string &plugin, + const std::string &key) = 0; + virtual float ReadFloatAtKey (const std::string &plugin, + const std::string &key) = 0; + virtual const char * ReadStringAtKey (const std::string &plugin, + const std::string &key) = 0; + virtual CCSSettingColorValue ReadColorAtKey (const std::string &plugin, + const std::string &key) = 0; + virtual CCSSettingKeyValue ReadKeyAtKey (const std::string &plugin, + const std::string &key) = 0; + virtual CCSSettingButtonValue ReadButtonAtKey (const std::string &plugin, + const std::string &key) = 0; + virtual unsigned int ReadEdgeAtKey (const std::string &plugin, + const std::string &key) = 0; + virtual const char * ReadMatchAtKey (const std::string &plugin, + const std::string &key) = 0; + virtual Bool ReadBellAtKey (const std::string &plugin, + const std::string &key) = 0; + virtual CCSSettingValueList ReadListAtKey (const std::string &plugin, + const std::string &key, + CCSSetting *setting) = 0; +}; + +#endif diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/tests/compizconfig_ccs_variant_types.h compiz-0.9.8.4/compizconfig/tests/compizconfig_ccs_variant_types.h --- compiz-0.9.8.2+bzr3377/compizconfig/tests/compizconfig_ccs_variant_types.h 1970-01-01 00:00:00.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/tests/compizconfig_ccs_variant_types.h 2012-09-27 11:04:02.000000000 +0000 @@ -0,0 +1,40 @@ +/* + * Compiz configuration system library + * + * Copyright (C) 2012 Canonical Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authored By: + * Sam Spilsbury + */ +#ifndef _COMPIZCONFIG_CCS_VARIANT_TYPES_H +#define _COMPIZCONFIG_CCS_VARIANT_TYPES_H + +#include +#include +#include "compizconfig_ccs_list_wrapper.h" + +typedef boost::variant VariantTypes; + +#endif diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/tests/compizconfig_test_value_combiners.cpp compiz-0.9.8.4/compizconfig/tests/compizconfig_test_value_combiners.cpp --- compiz-0.9.8.2+bzr3377/compizconfig/tests/compizconfig_test_value_combiners.cpp 1970-01-01 00:00:00.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/tests/compizconfig_test_value_combiners.cpp 2012-09-27 11:04:02.000000000 +0000 @@ -0,0 +1,147 @@ +/* + * Compiz configuration system library + * + * Copyright (C) 2012 Canonical Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authored By: + * Sam Spilsbury + */ +#include +#include +#include +#include +#include + +namespace compizconfig +{ + namespace test + { + namespace impl + { + Bool boolValues[] = { TRUE, FALSE, TRUE }; + int intValues[] = { 1, 2, 3 }; + float floatValues[] = { 1.0, 2.0, 3.0 }; + const char * stringValues[] = { "foo", "grill", "bar" }; + const char * matchValues[] = { "type=foo", "class=bar", "xid=42" }; + + const unsigned int NUM_COLOR_VALUES = 3; + + CCSSettingKeyValue keyValue = { XK_A, + (1 << 0)}; + + CCSSettingButtonValue buttonValue = { 1, + (1 << 0), + (1 << 1) }; + + CCSSettingColorValue * + getColorValueList (); + } + } +} + +namespace cctesti = compizconfig::test::impl; +namespace cclistpopulatorsi = compizconfig::test::impl::populators::list; + +CCSSettingColorValue * +cctesti::getColorValueList () +{ + static const unsigned short max = std::numeric_limits ::max (); + static const unsigned short maxD2 = max / 2; + static const unsigned short maxD4 = max / 4; + static const unsigned short maxD8 = max / 8; + + static bool colorValueListInitialized = false; + + static CCSSettingColorValue colorValues[NUM_COLOR_VALUES]; + + if (!colorValueListInitialized) + { + colorValues[0].color.red = maxD2; + colorValues[0].color.blue = maxD4; + colorValues[0].color.green = maxD8; + colorValues[0].color.alpha = max; + + colorValues[1].color.red = maxD8; + colorValues[1].color.blue = maxD4; + colorValues[1].color.green = maxD2; + colorValues[1].color.alpha = max; + + colorValues[1].color.red = max; + colorValues[1].color.blue = maxD4; + colorValues[1].color.green = maxD2; + colorValues[1].color.alpha = maxD8; + + for (unsigned int i = 0; i < NUM_COLOR_VALUES; i++) + { + CharacterWrapper s (ccsColorToString (&colorValues[i])); + + ccsStringToColor (s, &colorValues[i]); + } + + colorValueListInitialized = true; + } + + return colorValues; +} + +CCSSettingValueList +cclistpopulatorsi::boolean (CCSSetting *setting) +{ + return ccsGetValueListFromBoolArray (cctesti::boolValues, + sizeof (cctesti::boolValues) / sizeof (cctesti::boolValues[0]), + setting); +} + +CCSSettingValueList +cclistpopulatorsi::integer (CCSSetting *setting) +{ + return ccsGetValueListFromIntArray (cctesti::intValues, + sizeof (cctesti::intValues) / sizeof (cctesti::intValues[0]), + setting); +} + +CCSSettingValueList +cclistpopulatorsi::doubleprecision (CCSSetting *setting) +{ + return ccsGetValueListFromFloatArray (cctesti::floatValues, + sizeof (cctesti::floatValues) / sizeof (cctesti::floatValues[0]), + setting); +} + +CCSSettingValueList +cclistpopulatorsi::string (CCSSetting *setting) +{ + return ccsGetValueListFromStringArray (cctesti::stringValues, + sizeof (cctesti::stringValues) / sizeof (cctesti::stringValues[0]), + setting); +} + +CCSSettingValueList +cclistpopulatorsi::match (CCSSetting *setting) +{ + return ccsGetValueListFromMatchArray (cctesti::matchValues, + sizeof (cctesti::matchValues) / sizeof (cctesti::matchValues[0]), + setting); +} + +CCSSettingValueList +cclistpopulatorsi::color (CCSSetting *setting) +{ + return ccsGetValueListFromColorArray (cctesti::getColorValueList (), + cctesti::NUM_COLOR_VALUES, + setting); +} diff -Nru compiz-0.9.8.2+bzr3377/compizconfig/tests/compizconfig_test_value_combiners.h compiz-0.9.8.4/compizconfig/tests/compizconfig_test_value_combiners.h --- compiz-0.9.8.2+bzr3377/compizconfig/tests/compizconfig_test_value_combiners.h 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/compizconfig/tests/compizconfig_test_value_combiners.h 2012-09-27 11:04:02.000000000 +0000 @@ -1,3 +1,25 @@ +/* + * Compiz configuration system library + * + * Copyright (C) 2012 Canonical Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authored By: + * Sam Spilsbury + */ #ifndef _COMPIZCONFIG_TEST_VALUE_COMBINERS_H #define _COMPIZCONFIG_TEST_VALUE_COMBINERS_H @@ -11,95 +33,30 @@ { namespace impl { - Bool boolValues[] = { TRUE, FALSE, TRUE }; - int intValues[] = { 1, 2, 3 }; - float floatValues[] = { 1.0, 2.0, 3.0 }; - const char * stringValues[] = { "foo", "grill", "bar" }; - const char * matchValues[] = { "type=foo", "class=bar", "xid=42" }; + extern Bool boolValues[]; + extern int intValues[]; + extern float floatValues[]; + extern const char * stringValues[]; + extern const char * matchValues[]; - const unsigned int NUM_COLOR_VALUES = 3; + extern CCSSettingKeyValue keyValue; + extern CCSSettingButtonValue buttonValue; - CCSSettingColorValue * - getColorValueList () - { - static const unsigned short max = std::numeric_limits ::max (); - static const unsigned short maxD2 = max / 2; - static const unsigned short maxD4 = max / 4; - static const unsigned short maxD8 = max / 8; - - static bool colorValueListInitialized = false; - - static CCSSettingColorValue colorValues[NUM_COLOR_VALUES]; - - if (!colorValueListInitialized) - { - colorValues[0].color.red = maxD2; - colorValues[0].color.blue = maxD4; - colorValues[0].color.green = maxD8; - colorValues[0].color.alpha = max; - - colorValues[1].color.red = maxD8; - colorValues[1].color.blue = maxD4; - colorValues[1].color.green = maxD2; - colorValues[1].color.alpha = max; - - colorValues[1].color.red = max; - colorValues[1].color.blue = maxD4; - colorValues[1].color.green = maxD2; - colorValues[1].color.alpha = maxD8; - - for (unsigned int i = 0; i < NUM_COLOR_VALUES; i++) - { - CharacterWrapper s (ccsColorToString (&colorValues[i])); + extern const unsigned int NUM_COLOR_VALUES; - ccsStringToColor (s, &colorValues[i]); - } - - colorValueListInitialized = true; - } - - return colorValues; - } - CCSSettingKeyValue keyValue = { XK_A, - (1 << 0)}; - - CCSSettingButtonValue buttonValue = { 1, - (1 << 0), - (1 << 1) }; + CCSSettingColorValue * + getColorValueList (); namespace populators { namespace list { - CCSSettingValueList boolean (CCSSetting *setting) - { - return ccsGetValueListFromBoolArray (boolValues, sizeof (boolValues) / sizeof (boolValues[0]), setting); - } - - CCSSettingValueList integer (CCSSetting *setting) - { - return ccsGetValueListFromIntArray (intValues, sizeof (intValues) / sizeof (intValues[0]), setting); - } - - CCSSettingValueList doubleprecision (CCSSetting *setting) - { - return ccsGetValueListFromFloatArray (floatValues, sizeof (floatValues) / sizeof (floatValues[0]), setting); - } - - CCSSettingValueList string (CCSSetting *setting) - { - return ccsGetValueListFromStringArray (stringValues, sizeof (stringValues) / sizeof (stringValues[0]), setting); - } - - CCSSettingValueList match (CCSSetting *setting) - { - return ccsGetValueListFromMatchArray (matchValues, sizeof (matchValues) / sizeof (matchValues[0]), setting); - } - - CCSSettingValueList color (CCSSetting *setting) - { - return ccsGetValueListFromColorArray (getColorValueList (), 3, setting); - } + CCSSettingValueList boolean (CCSSetting *setting); + CCSSettingValueList integer (CCSSetting *setting); + CCSSettingValueList doubleprecision (CCSSetting *setting); + CCSSettingValueList string (CCSSetting *setting); + CCSSettingValueList match (CCSSetting *setting); + CCSSettingValueList color (CCSSetting *setting); } } } diff -Nru compiz-0.9.8.2+bzr3377/debian/changelog compiz-0.9.8.4/debian/changelog --- compiz-0.9.8.2+bzr3377/debian/changelog 2012-10-01 12:36:18.000000000 +0000 +++ compiz-0.9.8.4/debian/changelog 2012-10-01 12:36:18.000000000 +0000 @@ -1,3 +1,50 @@ +compiz (1:0.9.8.4-0ubuntu1) quantal-proposed; urgency=low + + * debian/control: + - Add dependency on gnome-settings-daemon for compiz-gnome, since some + tests need the g-s-d gsetting schemas + * New upstream release. + - FTBFS with -DCOMPIZ_BUILD_TESTING=OFF if libgtest-dev is not installed + (LP: #1057421) + - [performance] glXSwapIntervalEXT called every frame, which is very slow + on Nvidia. (LP: #1051286) + - opacify plugin: opacity isn't reset after switching window (LP: #1050757) + - cmake fails on python 2.6 as sys.version_info does not contain + major_version or minor_version (LP: #1048964) + - scale mode is not visible if a fullscreen window is unredirected + (LP: #1047168) + - Unredirected fullscreen windows flicker briefly when another window + (like a menu) opens above them (LP: #1046664) + - Week33 - Grid highlight window appears while switching between workspaces + (LP: #1037142) + - gtk-window-decorator leaks large numbers of pixmaps and pixmap memory + (LP: #1057263) + - [fglrx] compiz crashed with SIGSEGV in glXDestroyContext() + [/usr/lib/fglrx/libGL.so.1] from GLScreen::~GLScreen() (LP: #1054724) + - Maximized window gets unredirected when it's not fullscreen + (LP: #1053902) + - Double shortcuts conflict with gnome-control-center ones (LP: #1050796) + - gtk-window-decorator leaking window handles. Window operations become + sluggish after a few days of usage (LP: #1050610) + - [valgrind] Up to 520,000 bytes lost when running + CCSGSettingsBackendConceptTest (LP: #1049169) + - 1:0.9.8+bzr3319-0ubuntu1 regression: keeps setting gsettings keys to + wrong values (LP: #1042041) + - Compiz r3275 breaks VirtualBox Guest Additions: black screen or just + wallpaper (LP: #1030891) + - Incorrect (low/stuttering) refresh rate with NVIDIA driver (LP: #92599) + - ARM build broken with 'swapInterval' is not a member of 'GL' + (LP: #1056645) + - compiz.fix_927168 broke ARM building (LP: #1052838) + - compiz crashed with SIGSEGV in __strcasestr_ia32() from + ccsStringToModifiers(binding=NULL) (LP: #1041535) + * Cherry-picked from upstream: + - ABI bump due to an ABI change in the composite plugin + - Removed schema keys still used in keybindings and automated tests + (LP: #1057955) + + -- Łukasz 'sil2100' Zemczak Thu, 27 Sep 2012 15:43:59 +0200 + compiz (1:0.9.8.2+bzr3377-0ubuntu1) quantal-proposed; urgency=low [ Sam Spilsbury ] diff -Nru compiz-0.9.8.2+bzr3377/debian/control compiz-0.9.8.4/debian/control --- compiz-0.9.8.2+bzr3377/debian/control 2012-10-01 12:36:18.000000000 +0000 +++ compiz-0.9.8.4/debian/control 2012-10-01 12:36:18.000000000 +0000 @@ -138,6 +138,7 @@ ${misc:Depends}, compiz-plugins-default (= ${binary:Version}), gsettings-desktop-schemas, + gnome-settings-daemon (>= 3.4.2-0ubuntu9), Recommends: python-gconf Replaces: compiz-plugins-main (<= 1:0.9.8), compiz-plugins-main-default (<= 1:0.9.8), diff -Nru compiz-0.9.8.2+bzr3377/gtk/gnome/CMakeLists.txt compiz-0.9.8.4/gtk/gnome/CMakeLists.txt --- compiz-0.9.8.2+bzr3377/gtk/gnome/CMakeLists.txt 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/gtk/gnome/CMakeLists.txt 2012-10-01 12:36:18.000000000 +0000 @@ -10,10 +10,7 @@ ) set (_keybindings_files - 50-compiz-launchers.xml.in 50-compiz-navigation.xml.in - 50-compiz-screenshot.xml.in - 50-compiz-system.xml.in 50-compiz-windows.xml.in) set (_keybindings_files_translated "") diff -Nru compiz-0.9.8.2+bzr3377/gtk/window-decorator/decorator.c compiz-0.9.8.4/gtk/window-decorator/decorator.c --- compiz-0.9.8.2+bzr3377/gtk/window-decorator/decorator.c 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/gtk/window-decorator/decorator.c 2012-09-27 11:04:02.000000000 +0000 @@ -686,7 +686,16 @@ /* Destroy the old pixmaps and pictures */ if (d->pixmap) - g_hash_table_insert (destroyed_pixmaps_table, GINT_TO_POINTER (GDK_PIXMAP_XID (d->pixmap)), d->pixmap); + { + gpointer key = GINT_TO_POINTER (GDK_PIXMAP_XID (d->pixmap)); + + if (d->old_pixmaps == NULL) + d->old_pixmaps = g_hash_table_new_full (NULL, NULL, NULL, + g_object_unref); + + g_hash_table_insert (destroyed_pixmaps_table, key, d); + g_hash_table_insert (d->old_pixmaps, key, d->pixmap); + } if (d->buffer_pixmap) g_object_unref (G_OBJECT (d->buffer_pixmap)); diff -Nru compiz-0.9.8.2+bzr3377/gtk/window-decorator/events.c compiz-0.9.8.4/gtk/window-decorator/events.c --- compiz-0.9.8.2+bzr3377/gtk/window-decorator/events.c 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/gtk/window-decorator/events.c 2012-09-27 11:04:02.000000000 +0000 @@ -1094,7 +1094,14 @@ } else if (xevent->xclient.message_type == decor_delete_pixmap_atom) { - g_hash_table_remove (destroyed_pixmaps_table, GINT_TO_POINTER (xevent->xclient.data.l[0])); + gconstpointer key = GINT_TO_POINTER (xevent->xclient.data.l[0]); + decor_t *d = g_hash_table_lookup (destroyed_pixmaps_table, key); + + if (d != NULL) + { + g_hash_table_remove (d->old_pixmaps, key); + g_hash_table_remove (destroyed_pixmaps_table, key); + } } default: break; diff -Nru compiz-0.9.8.2+bzr3377/gtk/window-decorator/gtk-window-decorator.c compiz-0.9.8.4/gtk/window-decorator/gtk-window-decorator.c --- compiz-0.9.8.2+bzr3377/gtk/window-decorator/gtk-window-decorator.c 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/gtk/window-decorator/gtk-window-decorator.c 2012-09-27 11:04:02.000000000 +0000 @@ -342,7 +342,7 @@ xformat_rgb = XRenderFindStandardFormat (xdisplay, PictStandardRGB24); frame_table = g_hash_table_new (NULL, NULL); - destroyed_pixmaps_table = g_hash_table_new_full (NULL, NULL, NULL, g_object_unref); + destroyed_pixmaps_table = g_hash_table_new (NULL, NULL); if (!create_tooltip_window ()) { diff -Nru compiz-0.9.8.2+bzr3377/gtk/window-decorator/gtk-window-decorator.h compiz-0.9.8.4/gtk/window-decorator/gtk-window-decorator.h --- compiz-0.9.8.2+bzr3377/gtk/window-decorator/gtk-window-decorator.h 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/gtk/window-decorator/gtk-window-decorator.h 2012-09-27 11:04:02.000000000 +0000 @@ -401,6 +401,7 @@ GtkWidget *decor_window; GtkWidget *decor_event_box; GtkWidget *decor_image; + GHashTable *old_pixmaps; cairo_t *cr; decor_layout_t border_layout; decor_context_t *context; diff -Nru compiz-0.9.8.2+bzr3377/gtk/window-decorator/tests/CMakeLists.txt compiz-0.9.8.4/gtk/window-decorator/tests/CMakeLists.txt --- compiz-0.9.8.2+bzr3377/gtk/window-decorator/tests/CMakeLists.txt 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/gtk/window-decorator/tests/CMakeLists.txt 2012-09-27 11:04:02.000000000 +0000 @@ -2,7 +2,9 @@ include_directories (${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../ - ${CMAKE_CURRENT_BINARY_DIR}) + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_SOURCE_DIR}/tests/shared + ${CMAKE_SOURCE_DIR}/tests/shared/glib) configure_file (${CMAKE_CURRENT_SOURCE_DIR}/compiz_gwd_tests.h.in ${CMAKE_CURRENT_BINARY_DIR}/compiz_gwd_tests.h) diff -Nru compiz-0.9.8.2+bzr3377/gtk/window-decorator/tests/test_gwd_metacity_decorations.cpp compiz-0.9.8.4/gtk/window-decorator/tests/test_gwd_metacity_decorations.cpp --- compiz-0.9.8.2+bzr3377/gtk/window-decorator/tests/test_gwd_metacity_decorations.cpp 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/gtk/window-decorator/tests/test_gwd_metacity_decorations.cpp 2012-09-27 11:04:02.000000000 +0000 @@ -21,6 +21,8 @@ #include #include #include + +#include "gtest_unspecified_bool_type_matcher.h" #include "gwd-metacity-window-decoration-util.h" class GWDMetacityDecorationUtilTest : @@ -28,9 +30,6 @@ { }; -MATCHER(IsTrue, "Is TRUE") { if (arg) return true; else return false; } -MATCHER(IsFalse, "Is FALSE") { if (!arg) return true; else return false; } - namespace { MetaTheme * get_current_returns_null () diff -Nru compiz-0.9.8.2+bzr3377/gtk/window-decorator/tests/test_gwd_settings.cpp compiz-0.9.8.4/gtk/window-decorator/tests/test_gwd_settings.cpp --- compiz-0.9.8.2+bzr3377/gtk/window-decorator/tests/test_gwd_settings.cpp 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/gtk/window-decorator/tests/test_gwd_settings.cpp 2012-09-27 11:04:02.000000000 +0000 @@ -34,6 +34,11 @@ #include +#include +#include + +#include + #include "compiz_gwd_tests.h" #include "gwd-settings-interface.h" @@ -172,22 +177,6 @@ typename GValueCmp::GetFunc mGetFunc; }; -MATCHER (GBooleanTrue, "gboolean TRUE") -{ - if (arg) - return true; - else - return false; -} - -MATCHER (GBooleanFalse, "gboolean FALSE") -{ - if (!arg) - return true; - else - return false; -} - namespace testing_values { const gdouble ACTIVE_SHADOW_OPACITY_VALUE = 1.0; @@ -252,13 +241,16 @@ public: virtual void SetUp () { - g_setenv ("G_SLICE", "always-malloc", TRUE); + env.SetUpEnv (); g_type_init (); } virtual void TearDown () { - g_unsetenv ("G_SLICE"); + env.TearDownEnv (); } + private: + + CompizGLibGSliceOffEnv env; }; class GWDMockSettingsWritableTest : @@ -372,29 +364,29 @@ testing_values::INACTIVE_SHADOW_OPACITY_VALUE, testing_values::INACTIVE_SHADOW_OFFSET_X_VALUE, testing_values::INACTIVE_SHADOW_OFFSET_Y_VALUE, - testing_values::INACTIVE_SHADOW_COLOR_STR_VALUE.c_str ()), GBooleanTrue ()); - EXPECT_THAT (gwd_settings_writable_use_tooltips_changed (writableMock.get (), testing_values::USE_TOOLTIPS_VALUE), GBooleanTrue ()); - EXPECT_THAT (gwd_settings_writable_draggable_border_width_changed (writableMock.get (), testing_values::DRAGGABLE_BORDER_WIDTH_VALUE), GBooleanTrue ()); - EXPECT_THAT (gwd_settings_writable_attach_modal_dialogs_changed (writableMock.get (), testing_values::ATTACH_MODAL_DIALOGS_VALUE), GBooleanTrue ()); - EXPECT_THAT (gwd_settings_writable_blur_changed (writableMock.get (), testing_values::BLUR_TYPE_TITLEBAR_VALUE.c_str ()), GBooleanTrue ()); + testing_values::INACTIVE_SHADOW_COLOR_STR_VALUE.c_str ()), IsTrue ()); + EXPECT_THAT (gwd_settings_writable_use_tooltips_changed (writableMock.get (), testing_values::USE_TOOLTIPS_VALUE), IsTrue ()); + EXPECT_THAT (gwd_settings_writable_draggable_border_width_changed (writableMock.get (), testing_values::DRAGGABLE_BORDER_WIDTH_VALUE), IsTrue ()); + EXPECT_THAT (gwd_settings_writable_attach_modal_dialogs_changed (writableMock.get (), testing_values::ATTACH_MODAL_DIALOGS_VALUE), IsTrue ()); + EXPECT_THAT (gwd_settings_writable_blur_changed (writableMock.get (), testing_values::BLUR_TYPE_TITLEBAR_VALUE.c_str ()), IsTrue ()); EXPECT_THAT (gwd_settings_writable_metacity_theme_changed (writableMock.get (), testing_values::USE_METACITY_THEME_VALUE, - testing_values::METACITY_THEME_VALUE.c_str ()), GBooleanTrue ()); + testing_values::METACITY_THEME_VALUE.c_str ()), IsTrue ()); EXPECT_THAT (gwd_settings_writable_opacity_changed (writableMock.get (), testing_values::ACTIVE_OPACITY_VALUE, testing_values::INACTIVE_OPACITY_VALUE, testing_values::ACTIVE_SHADE_OPACITY_VALUE, - testing_values::INACTIVE_SHADE_OPACITY_VALUE), GBooleanTrue ()); + testing_values::INACTIVE_SHADE_OPACITY_VALUE), IsTrue ()); EXPECT_THAT (gwd_settings_writable_button_layout_changed (writableMock.get (), - testing_values::BUTTON_LAYOUT_VALUE.c_str ()), GBooleanTrue ()); + testing_values::BUTTON_LAYOUT_VALUE.c_str ()), IsTrue ()); EXPECT_THAT (gwd_settings_writable_font_changed (writableMock.get (), testing_values::USE_SYSTEM_FONT_VALUE, - testing_values::TITLEBAR_FONT_VALUE.c_str ()), GBooleanTrue ()); + testing_values::TITLEBAR_FONT_VALUE.c_str ()), IsTrue ()); EXPECT_THAT (gwd_settings_writable_titlebar_actions_changed (writableMock.get (), testing_values::TITLEBAR_ACTION_MAX.c_str (), testing_values::TITLEBAR_ACTION_MENU.c_str (), testing_values::TITLEBAR_ACTION_LOWER.c_str (), - testing_values::TITLEBAR_ACTION_SHADE.c_str ()), GBooleanTrue ()); + testing_values::TITLEBAR_ACTION_SHADE.c_str ()), IsTrue ()); } class GWDMockSettingsTest : @@ -604,7 +596,7 @@ { gwd_settings_writable_freeze_updates (GWD_SETTINGS_WRITABLE_INTERFACE (mSettings.get ())); EXPECT_THAT (gwd_settings_writable_use_tooltips_changed (GWD_SETTINGS_WRITABLE_INTERFACE (mSettings.get ()), - testing_values::USE_TOOLTIPS_VALUE), GBooleanTrue ()); + testing_values::USE_TOOLTIPS_VALUE), IsTrue ()); } /* We're just using use_tooltips here as an example */ @@ -612,7 +604,7 @@ { gwd_settings_writable_freeze_updates (GWD_SETTINGS_WRITABLE_INTERFACE (mSettings.get ())); EXPECT_THAT (gwd_settings_writable_use_tooltips_changed (GWD_SETTINGS_WRITABLE_INTERFACE (mSettings.get ()), - testing_values::USE_TOOLTIPS_VALUE), GBooleanTrue ()); + testing_values::USE_TOOLTIPS_VALUE), IsTrue ()); EXPECT_CALL (*mGMockNotified, updateDecorations ()); gwd_settings_writable_thaw_updates (GWD_SETTINGS_WRITABLE_INTERFACE (mSettings.get ())); @@ -623,11 +615,11 @@ { gwd_settings_writable_freeze_updates (GWD_SETTINGS_WRITABLE_INTERFACE (mSettings.get ())); EXPECT_THAT (gwd_settings_writable_use_tooltips_changed (GWD_SETTINGS_WRITABLE_INTERFACE (mSettings.get ()), - testing_values::USE_TOOLTIPS_VALUE), GBooleanTrue ()); + testing_values::USE_TOOLTIPS_VALUE), IsTrue ()); EXPECT_THAT (gwd_settings_writable_use_tooltips_changed (GWD_SETTINGS_WRITABLE_INTERFACE (mSettings.get ()), - !testing_values::USE_TOOLTIPS_VALUE), GBooleanTrue ()); + !testing_values::USE_TOOLTIPS_VALUE), IsTrue ()); EXPECT_THAT (gwd_settings_writable_use_tooltips_changed (GWD_SETTINGS_WRITABLE_INTERFACE (mSettings.get ()), - testing_values::USE_TOOLTIPS_VALUE), GBooleanTrue ()); + testing_values::USE_TOOLTIPS_VALUE), IsTrue ()); EXPECT_CALL (*mGMockNotified, updateDecorations ()).Times (1); gwd_settings_writable_thaw_updates (GWD_SETTINGS_WRITABLE_INTERFACE (mSettings.get ())); @@ -646,7 +638,7 @@ testing_values::INACTIVE_SHADOW_RADIUS_VALUE, testing_values::INACTIVE_SHADOW_OFFSET_X_VALUE, testing_values::INACTIVE_SHADOW_OFFSET_Y_VALUE, - testing_values::INACTIVE_SHADOW_COLOR_STR_VALUE.c_str ()), GBooleanTrue ()); + testing_values::INACTIVE_SHADOW_COLOR_STR_VALUE.c_str ()), IsTrue ()); AutoUnsetGValue activeShadowValue (G_TYPE_POINTER); AutoUnsetGValue inactiveShadowValue (G_TYPE_POINTER); @@ -700,14 +692,14 @@ INACTIVE_SHADOW_OPACITY_DEFAULT, INACTIVE_SHADOW_OFFSET_X_DEFAULT, INACTIVE_SHADOW_OFFSET_Y_DEFAULT, - INACTIVE_SHADOW_COLOR_DEFAULT), GBooleanFalse ()); + INACTIVE_SHADOW_COLOR_DEFAULT), IsFalse ()); } TEST_F(GWDSettingsTest, TestUseTooltipsChanged) { EXPECT_CALL (*mGMockNotified, updateDecorations ()); EXPECT_THAT (gwd_settings_writable_use_tooltips_changed (GWD_SETTINGS_WRITABLE_INTERFACE (mSettings.get ()), - testing_values::USE_TOOLTIPS_VALUE), GBooleanTrue ()); + testing_values::USE_TOOLTIPS_VALUE), IsTrue ()); AutoUnsetGValue useTooltipsValue (G_TYPE_BOOLEAN); GValue &useTooltipsGValue = useTooltipsValue; @@ -723,14 +715,14 @@ TEST_F(GWDSettingsTest, TestUseTooltipsChangedIsDefault) { EXPECT_THAT (gwd_settings_writable_use_tooltips_changed (GWD_SETTINGS_WRITABLE_INTERFACE (mSettings.get ()), - USE_TOOLTIPS_DEFAULT), GBooleanFalse ()); + USE_TOOLTIPS_DEFAULT), IsFalse ()); } TEST_F(GWDSettingsTest, TestDraggableBorderWidthChanged) { EXPECT_CALL (*mGMockNotified, updateDecorations ()); EXPECT_THAT (gwd_settings_writable_draggable_border_width_changed (GWD_SETTINGS_WRITABLE_INTERFACE (mSettings.get ()), - testing_values::DRAGGABLE_BORDER_WIDTH_VALUE), GBooleanTrue ()); + testing_values::DRAGGABLE_BORDER_WIDTH_VALUE), IsTrue ()); AutoUnsetGValue draggableBorderWidthValue (G_TYPE_INT); GValue &draggableBorderWidthGValue = draggableBorderWidthValue; @@ -746,14 +738,14 @@ TEST_F(GWDSettingsTest, TestDraggableBorderWidthChangedIsDefault) { EXPECT_THAT (gwd_settings_writable_draggable_border_width_changed (GWD_SETTINGS_WRITABLE_INTERFACE (mSettings.get ()), - DRAGGABLE_BORDER_WIDTH_DEFAULT), GBooleanFalse ()); + DRAGGABLE_BORDER_WIDTH_DEFAULT), IsFalse ()); } TEST_F(GWDSettingsTest, TestAttachModalDialogsChanged) { EXPECT_CALL (*mGMockNotified, updateDecorations ()); EXPECT_THAT (gwd_settings_writable_attach_modal_dialogs_changed (GWD_SETTINGS_WRITABLE_INTERFACE (mSettings.get ()), - testing_values::ATTACH_MODAL_DIALOGS_VALUE), GBooleanTrue ()); + testing_values::ATTACH_MODAL_DIALOGS_VALUE), IsTrue ()); AutoUnsetGValue attachModalDialogsValue (G_TYPE_BOOLEAN); GValue &attachModalDialogsGValue = attachModalDialogsValue; @@ -769,14 +761,14 @@ TEST_F(GWDSettingsTest, TestAttachModalDialogsChangedIsDefault) { EXPECT_THAT (gwd_settings_writable_attach_modal_dialogs_changed (GWD_SETTINGS_WRITABLE_INTERFACE (mSettings.get ()), - ATTACH_MODAL_DIALOGS_DEFAULT), GBooleanFalse ()); + ATTACH_MODAL_DIALOGS_DEFAULT), IsFalse ()); } TEST_F(GWDSettingsTest, TestBlurChangedTitlebar) { EXPECT_CALL (*mGMockNotified, updateDecorations ()); EXPECT_THAT (gwd_settings_writable_blur_changed (GWD_SETTINGS_WRITABLE_INTERFACE (mSettings.get ()), - testing_values::BLUR_TYPE_TITLEBAR_VALUE.c_str ()), GBooleanTrue ()); + testing_values::BLUR_TYPE_TITLEBAR_VALUE.c_str ()), IsTrue ()); AutoUnsetGValue blurValue (G_TYPE_INT); GValue &blurGValue = blurValue; @@ -793,7 +785,7 @@ { EXPECT_CALL (*mGMockNotified, updateDecorations ()); EXPECT_THAT (gwd_settings_writable_blur_changed (GWD_SETTINGS_WRITABLE_INTERFACE (mSettings.get ()), - testing_values::BLUR_TYPE_ALL_VALUE.c_str ()), GBooleanTrue ()); + testing_values::BLUR_TYPE_ALL_VALUE.c_str ()), IsTrue ()); AutoUnsetGValue blurValue (G_TYPE_INT); GValue &blurGValue = blurValue; @@ -809,7 +801,7 @@ TEST_F(GWDSettingsTest, TestBlurChangedNone) { EXPECT_THAT (gwd_settings_writable_blur_changed (GWD_SETTINGS_WRITABLE_INTERFACE (mSettings.get ()), - testing_values::BLUR_TYPE_NONE_VALUE.c_str ()), GBooleanFalse ()); + testing_values::BLUR_TYPE_NONE_VALUE.c_str ()), IsFalse ()); AutoUnsetGValue blurValue (G_TYPE_INT); GValue &blurGValue = blurValue; @@ -835,7 +827,7 @@ boost::bind (gwd_settings_unref, _1)); EXPECT_THAT (gwd_settings_writable_blur_changed (GWD_SETTINGS_WRITABLE_INTERFACE (mSettings.get ()), - testing_values::BLUR_TYPE_NONE_VALUE.c_str ()), GBooleanFalse ()); + testing_values::BLUR_TYPE_NONE_VALUE.c_str ()), IsFalse ()); AutoUnsetGValue blurValue (G_TYPE_INT); GValue &blurGValue = blurValue; @@ -854,7 +846,7 @@ EXPECT_CALL (*mGMockNotified, updateDecorations ()); EXPECT_THAT (gwd_settings_writable_metacity_theme_changed (GWD_SETTINGS_WRITABLE_INTERFACE (mSettings.get ()), testing_values::USE_METACITY_THEME_VALUE, - testing_values::METACITY_THEME_VALUE.c_str ()), GBooleanTrue ()); + testing_values::METACITY_THEME_VALUE.c_str ()), IsTrue ()); AutoUnsetGValue metacityThemeValue (G_TYPE_STRING); GValue &metacityThemeGValue = metacityThemeValue; @@ -873,7 +865,7 @@ EXPECT_CALL (*mGMockNotified, updateDecorations ()); EXPECT_THAT (gwd_settings_writable_metacity_theme_changed (GWD_SETTINGS_WRITABLE_INTERFACE (mSettings.get ()), testing_values::NO_USE_METACITY_THEME_VALUE, - testing_values::METACITY_THEME_VALUE.c_str ()), GBooleanTrue ()); + testing_values::METACITY_THEME_VALUE.c_str ()), IsTrue ()); AutoUnsetGValue metacityThemeValue (G_TYPE_STRING); GValue &metacityThemeGValue = metacityThemeValue; @@ -890,7 +882,7 @@ { EXPECT_THAT (gwd_settings_writable_metacity_theme_changed (GWD_SETTINGS_WRITABLE_INTERFACE (mSettings.get ()), testing_values::USE_METACITY_THEME_VALUE, - METACITY_THEME_DEFAULT), GBooleanFalse ()); + METACITY_THEME_DEFAULT), IsFalse ()); } TEST_F(GWDSettingsTest, TestMetacityThemeSetCommandLine) @@ -905,7 +897,7 @@ EXPECT_THAT (gwd_settings_writable_metacity_theme_changed (GWD_SETTINGS_WRITABLE_INTERFACE (mSettings.get ()), testing_values::USE_METACITY_THEME_VALUE, - testing_values::METACITY_THEME_VALUE.c_str ()), GBooleanFalse ()); + testing_values::METACITY_THEME_VALUE.c_str ()), IsFalse ()); AutoUnsetGValue metacityThemeValue (G_TYPE_STRING); GValue &metacityThemeGValue = metacityThemeValue; @@ -925,7 +917,7 @@ testing_values::ACTIVE_OPACITY_VALUE, testing_values::INACTIVE_OPACITY_VALUE, testing_values::ACTIVE_SHADE_OPACITY_VALUE, - testing_values::INACTIVE_SHADE_OPACITY_VALUE), GBooleanTrue ()); + testing_values::INACTIVE_SHADE_OPACITY_VALUE), IsTrue ()); AutoUnsetGValue metacityInactiveOpacityValue (G_TYPE_DOUBLE); AutoUnsetGValue metacityActiveOpacityValue (G_TYPE_DOUBLE); @@ -966,7 +958,7 @@ METACITY_ACTIVE_OPACITY_DEFAULT, METACITY_INACTIVE_OPACITY_DEFAULT, METACITY_ACTIVE_SHADE_OPACITY_DEFAULT, - METACITY_INACTIVE_SHADE_OPACITY_DEFAULT), GBooleanFalse ()); + METACITY_INACTIVE_SHADE_OPACITY_DEFAULT), IsFalse ()); } TEST_F(GWDSettingsTest, TestButtonLayoutChanged) @@ -974,7 +966,7 @@ EXPECT_CALL (*mGMockNotified, updateMetacityButtonLayout ()); EXPECT_CALL (*mGMockNotified, updateDecorations ()); EXPECT_THAT (gwd_settings_writable_button_layout_changed (GWD_SETTINGS_WRITABLE_INTERFACE (mSettings.get ()), - testing_values::BUTTON_LAYOUT_VALUE.c_str ()), GBooleanTrue ()); + testing_values::BUTTON_LAYOUT_VALUE.c_str ()), IsTrue ()); AutoUnsetGValue buttonLayoutValue (G_TYPE_STRING); GValue &buttonLayoutGValue = buttonLayoutValue; @@ -990,7 +982,7 @@ TEST_F(GWDSettingsTest, TestButtonLayoutChangedIsDefault) { EXPECT_THAT (gwd_settings_writable_button_layout_changed (GWD_SETTINGS_WRITABLE_INTERFACE (mSettings.get ()), - METACITY_BUTTON_LAYOUT_DEFAULT), GBooleanFalse ()); + METACITY_BUTTON_LAYOUT_DEFAULT), IsFalse ()); } TEST_F(GWDSettingsTest, TestTitlebarFontChanged) @@ -999,7 +991,7 @@ EXPECT_CALL (*mGMockNotified, updateDecorations ()); EXPECT_THAT (gwd_settings_writable_font_changed (GWD_SETTINGS_WRITABLE_INTERFACE (mSettings.get ()), testing_values::NO_USE_SYSTEM_FONT_VALUE, - testing_values::TITLEBAR_FONT_VALUE.c_str ()), GBooleanTrue ()); + testing_values::TITLEBAR_FONT_VALUE.c_str ()), IsTrue ()); AutoUnsetGValue fontValue (G_TYPE_STRING); GValue &fontGValue = fontValue; @@ -1018,7 +1010,7 @@ EXPECT_CALL (*mGMockNotified, updateDecorations ()); EXPECT_THAT (gwd_settings_writable_font_changed (GWD_SETTINGS_WRITABLE_INTERFACE (mSettings.get ()), testing_values::USE_SYSTEM_FONT_VALUE, - testing_values::TITLEBAR_FONT_VALUE.c_str ()), GBooleanTrue ()); + testing_values::TITLEBAR_FONT_VALUE.c_str ()), IsTrue ()); AutoUnsetGValue fontValue (G_TYPE_STRING); GValue &fontGValue = fontValue; @@ -1036,7 +1028,7 @@ { EXPECT_THAT (gwd_settings_writable_font_changed (GWD_SETTINGS_WRITABLE_INTERFACE (mSettings.get ()), testing_values::NO_USE_SYSTEM_FONT_VALUE, - TITLEBAR_FONT_DEFAULT), GBooleanFalse ()); + TITLEBAR_FONT_DEFAULT), IsFalse ()); } namespace @@ -1071,14 +1063,14 @@ } class GWDSettingsTestClickActions : - public ::testing::TestWithParam + public GWDSettingsTestCommon, + public ::testing::WithParamInterface { public: virtual void SetUp () { - g_setenv ("G_SLICE", "always-malloc", TRUE); - g_type_init (); + GWDSettingsTestCommon::SetUp (); mGMockNotified.reset (new GWDMockSettingsNotifiedGMock ()); mMockNotified.reset (gwd_mock_settings_notified_new (mGMockNotified.get ()), boost::bind (gwd_settings_notified_do_nothing, _1)); @@ -1093,7 +1085,7 @@ EXPECT_CALL (*mGMockNotified, dispose ()); EXPECT_CALL (*mGMockNotified, finalize ()); - g_unsetenv ("G_SLICE"); + GWDSettingsTestCommon::TearDown (); } protected: @@ -1202,14 +1194,14 @@ }; class GWDSettingsTestStorageUpdates : - public ::testing::TestWithParam + public GWDSettingsTestCommon, + public ::testing::WithParamInterface { public: virtual void SetUp () { - g_setenv ("G_SLICE", "always-malloc", TRUE); - g_type_init (); + GWDSettingsTestCommon::SetUp (); mSettingsMock.reset (new GWDMockSettingsWritableGMock ()); mSettings.reset (gwd_mock_settings_writable_new (mSettingsMock.get ()), boost::bind (gwd_settings_writable_unref, _1)); @@ -1223,7 +1215,7 @@ EXPECT_CALL (*mSettingsMock, finalize ()); GetParam ()->TearDown (); - g_unsetenv ("G_SLICE"); + GWDSettingsTestCommon::TearDown (); } protected: @@ -1490,20 +1482,8 @@ #ifdef USE_GSETTINGS class GWDSettingsStorageGSettingsTest : - public ::testing::Test + public GWDSettingsTestCommon { - public: - - void SetUp () - { - g_setenv ("G_SLICE", "always-malloc", TRUE); - g_type_init (); - } - - void TearDown () - { - g_unsetenv ("G_SLICE"); - } }; TEST_F (GWDSettingsStorageGSettingsTest, TestNoDeathOnConnectingSignalToNULLObject) @@ -1527,8 +1507,8 @@ virtual void SetUp (GWDSettingsWritable *writable) { - g_setenv ("GSETTINGS_SCHEMA_DIR", MOCK_PATH.c_str (), true); - g_setenv ("GSETTINGS_BACKEND", "memory", 1); + gsliceEnv.SetUpEnv (); + gsettingsEnv.SetUpEnv (MOCK_PATH); /* We do not need to keep a reference to these */ mGWDSettings = gwd_get_org_compiz_gwd_settings (); @@ -1635,8 +1615,8 @@ mGWDSettings = NULL; mMutterSettings = NULL; mDesktopSettings = NULL; - g_unsetenv ("GSETTINGS_BACKEND"); - g_unsetenv ("GSETTINGS_SCHEMA_DIR"); + gsettingsEnv.TearDownEnv (); + gsliceEnv.TearDownEnv (); } private: @@ -1645,6 +1625,8 @@ GSettings *mMutterSettings; GSettings *mDesktopSettings; boost::shared_ptr mStorage; + CompizGLibGSliceOffEnv gsliceEnv; + CompizGLibGSettingsMemoryBackendTestingEnv gsettingsEnv; }; INSTANTIATE_TEST_CASE_P (GSettingsStorageUpdates, GWDSettingsTestStorageUpdates, diff -Nru compiz-0.9.8.2+bzr3377/gtk/window-decorator/wnck.c compiz-0.9.8.4/gtk/window-decorator/wnck.c --- compiz-0.9.8.2+bzr3377/gtk/window-decorator/wnck.c 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/gtk/window-decorator/wnck.c 2012-09-27 11:04:02.000000000 +0000 @@ -463,6 +463,28 @@ xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()); + if (!d->frame_window) + { + int i, j; + + for (i = 0; i < 3; i++) + { + for (j = 0; j < 3; j++) + { + XDestroyWindow (xdisplay, d->event_windows[i][j].window); + d->event_windows[i][j].window = None; + } + } + + for (i = 0; i < BUTTON_NUM; i++) + { + XDestroyWindow (xdisplay, d->button_windows[i].window); + d->button_windows[i].window = None; + + d->button_states[i] = 0; + } + } + if (d->pixmap) { g_object_unref (G_OBJECT (d->pixmap)); @@ -475,6 +497,12 @@ d->buffer_pixmap = NULL; } + if (d->old_pixmaps) + { + g_hash_table_destroy (d->old_pixmaps); + d->old_pixmaps = NULL; + } + if (d->cr) { cairo_destroy (d->cr); diff -Nru compiz-0.9.8.2+bzr3377/include/core/abiversion.h compiz-0.9.8.4/include/core/abiversion.h --- compiz-0.9.8.2+bzr3377/include/core/abiversion.h 2012-10-01 12:36:18.000000000 +0000 +++ compiz-0.9.8.4/include/core/abiversion.h 2012-10-01 12:36:18.000000000 +0000 @@ -5,6 +5,6 @@ # error Conflicting definitions of CORE_ABIVERSION #endif -#define CORE_ABIVERSION 20120920 +#define CORE_ABIVERSION 20120927 #endif // COMPIZ_ABIVERSION_H diff -Nru compiz-0.9.8.2+bzr3377/plugins/composite/include/composite/composite.h compiz-0.9.8.4/plugins/composite/include/composite/composite.h --- compiz-0.9.8.2+bzr3377/plugins/composite/include/composite/composite.h 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/plugins/composite/include/composite/composite.h 2012-09-27 11:04:02.000000000 +0000 @@ -30,7 +30,7 @@ #include -#define COMPIZ_COMPOSITE_ABI 4 +#define COMPIZ_COMPOSITE_ABI 5 #include "core/pluginclasshandler.h" #include "core/timer.h" @@ -106,6 +106,7 @@ const CompRegion ®ion) = 0; virtual bool hasVSync () { return false; }; + virtual bool requiredForcedRefreshRate () { return false; }; virtual void prepareDrawing () {}; virtual bool compositingActive () { return false; }; @@ -205,6 +206,7 @@ void showOutputWindow (); void hideOutputWindow (); void updateOutputWindow (); + bool outputWindowChanged () const; Window overlay (); Window output (); diff -Nru compiz-0.9.8.2+bzr3377/plugins/composite/src/privates.h compiz-0.9.8.4/plugins/composite/src/privates.h --- compiz-0.9.8.2+bzr3377/plugins/composite/src/privates.h 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/plugins/composite/src/privates.h 2012-09-27 11:04:02.000000000 +0000 @@ -93,6 +93,7 @@ CompPoint windowPaintOffset; int overlayWindowCount; + bool outputShapeChanged; struct timeval lastRedraw; int redrawTime; diff -Nru compiz-0.9.8.2+bzr3377/plugins/composite/src/screen.cpp compiz-0.9.8.4/plugins/composite/src/screen.cpp --- compiz-0.9.8.2+bzr3377/plugins/composite/src/screen.cpp 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/plugins/composite/src/screen.cpp 2012-09-27 11:04:02.000000000 +0000 @@ -281,6 +281,7 @@ exposeRects (), windowPaintOffset (0, 0), overlayWindowCount (0), + outputShapeChanged (false), redrawTime (1000 / FALLBACK_REFRESH_RATE), optimalRedrawTime (1000 / FALLBACK_REFRESH_RATE), scheduled (false), @@ -426,6 +427,8 @@ priv->pHnd = pHnd; + priv->detectRefreshRate (); + showOutputWindow (); return true; @@ -456,6 +459,8 @@ priv->pHnd = NULL; priv->paintTimer.stop (); + priv->detectRefreshRate (); + hideOutputWindow (); } @@ -543,6 +548,8 @@ XFixesDestroyRegion (dpy, region); damageScreen (); + + priv->outputShapeChanged = true; } } @@ -591,10 +598,18 @@ 0, 0, region); XFixesDestroyRegion (dpy, region); + + priv->outputShapeChanged = true; } } +bool +CompositeScreen::outputWindowChanged () const +{ + return priv->outputShapeChanged; +} + void PrivateCompositeScreen::makeOutputWindow () { @@ -639,7 +654,10 @@ void PrivateCompositeScreen::detectRefreshRate () { - if (optionGetDetectRefreshRate ()) + const bool forceRefreshRate = (pHnd ? pHnd->requiredForcedRefreshRate () : false); + const bool detect = optionGetDetectRefreshRate () && !forceRefreshRate; + + if (detect) { CompString name; CompOption::Value value; @@ -833,6 +851,8 @@ donePaint (); + priv->outputShapeChanged = false; + foreach (CompWindow *w, screen->windows ()) { if (w->destroyed ()) diff -Nru compiz-0.9.8.2+bzr3377/plugins/grid/src/grabhandler/include/grabhandler.h compiz-0.9.8.4/plugins/grid/src/grabhandler/include/grabhandler.h --- compiz-0.9.8.2+bzr3377/plugins/grid/src/grabhandler/include/grabhandler.h 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/plugins/grid/src/grabhandler/include/grabhandler.h 2012-09-27 11:04:02.000000000 +0000 @@ -1,3 +1,33 @@ +/* + * Compiz Fusion Grid plugin, GrabHandler class + * + * Copyright (c) 2011 Canonical Ltd. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * Description: + * + * Plugin to act like winsplit revolution (http://www.winsplit-revolution.com/) + * use NUMPAD_KEY to move and tile your windows. + * + * Press the tiling keys several times to cycle through some tiling options. + * + * Authored By: + * Sam Spilsbury + */ +#ifndef _COMPIZ_GRID_GRABHANDLER_H +#define _COMPIZ_GRID_GRABHANDLER_H + +#include + #define CompWindowGrabKeyMask (1 << 0) #define CompWindowGrabButtonMask (1 << 1) #define CompWindowGrabMoveMask (1 << 2) @@ -11,11 +41,14 @@ namespace window { +typedef boost::function GrabActiveFunc; + class GrabWindowHandler { public: - GrabWindowHandler (unsigned int mask); + GrabWindowHandler (unsigned int mask, + const GrabActiveFunc &grabActive); ~GrabWindowHandler (); bool track (); @@ -23,9 +56,12 @@ private: - unsigned int mMask; + unsigned int mMask; + GrabActiveFunc mGrabActive; }; } } } + +#endif diff -Nru compiz-0.9.8.2+bzr3377/plugins/grid/src/grabhandler/src/grabhandler.cpp compiz-0.9.8.4/plugins/grid/src/grabhandler/src/grabhandler.cpp --- compiz-0.9.8.2+bzr3377/plugins/grid/src/grabhandler/src/grabhandler.cpp 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/plugins/grid/src/grabhandler/src/grabhandler.cpp 2012-09-27 11:04:02.000000000 +0000 @@ -24,8 +24,10 @@ #include "grabhandler.h" -compiz::grid::window::GrabWindowHandler::GrabWindowHandler (unsigned int mask) : - mMask (mask) +compiz::grid::window::GrabWindowHandler::GrabWindowHandler (unsigned int mask, + const GrabActiveFunc &grabActive) : + mMask (mask), + mGrabActive (grabActive) { } @@ -36,6 +38,9 @@ bool compiz::grid::window::GrabWindowHandler::track () { + if (mGrabActive ("expo")) + return false; + return ((mMask & (CompWindowGrabMoveMask | CompWindowGrabButtonMask)) && !(mMask & CompWindowGrabResizeMask)); } diff -Nru compiz-0.9.8.2+bzr3377/plugins/grid/src/grabhandler/tests/test-grid-grab-handler.cpp compiz-0.9.8.4/plugins/grid/src/grabhandler/tests/test-grid-grab-handler.cpp --- compiz-0.9.8.2+bzr3377/plugins/grid/src/grabhandler/tests/test-grid-grab-handler.cpp 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/plugins/grid/src/grabhandler/tests/test-grid-grab-handler.cpp 2012-09-27 11:04:02.000000000 +0000 @@ -1,4 +1,32 @@ +/* + * Compiz Fusion Grid plugin, GrabHandler class + * + * Copyright (c) 2011 Canonical Ltd. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * Description: + * + * Plugin to act like winsplit revolution (http://www.winsplit-revolution.com/) + * use NUMPAD_KEY to move and tile your windows. + * + * Press the tiling keys several times to cycle through some tiling options. + * + * Authored By: + * Sam Spilsbury + */ + #include +#include +#include #include @@ -12,15 +40,26 @@ #define CompWindowGrabResizeMask (1 << 3) #define CompWindowGrabExternalAppMask (1 << 4) -class GridGrabHandlerTest : - public ::testing::Test +using testing::Eq; +using testing::Return; + +namespace { -}; + bool returnFalse () { return false; } + + class MockGrabExist + { + public: + + MOCK_METHOD1 (grabExist, bool (const char *)); + }; +} TEST(GridGrabHandlerTest, TestMoveHandler) { compiz::grid::window::GrabWindowHandler moveHandler (CompWindowGrabMoveMask | - CompWindowGrabButtonMask); + CompWindowGrabButtonMask, + boost::bind (returnFalse)); EXPECT_TRUE (moveHandler.track ()); EXPECT_FALSE (moveHandler.resetResize ()); @@ -29,8 +68,22 @@ TEST(GridGrabHandlerTest, TestResizeHandler) { compiz::grid::window::GrabWindowHandler resizeHandler (CompWindowGrabButtonMask | - CompWindowGrabResizeMask); + CompWindowGrabResizeMask, + boost::bind (returnFalse)); EXPECT_FALSE (resizeHandler.track ()); EXPECT_TRUE (resizeHandler.resetResize ()); } + +TEST(GridGrabHandlerTest, TestNoTrackOnExpoGrab) +{ + MockGrabExist mge; + compiz::grid::window::GrabActiveFunc grabExist (boost::bind (&MockGrabExist::grabExist, + &mge, _1)); + compiz::grid::window::GrabWindowHandler moveHandler (CompWindowGrabMoveMask | + CompWindowGrabButtonMask, + grabExist); + + EXPECT_CALL (mge, grabExist (Eq ("expo"))).WillOnce (Return (true)); + EXPECT_FALSE (moveHandler.track ()); +} diff -Nru compiz-0.9.8.2+bzr3377/plugins/grid/src/grid.cpp compiz-0.9.8.4/plugins/grid/src/grid.cpp --- compiz-0.9.8.2+bzr3377/plugins/grid/src/grid.cpp 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/plugins/grid/src/grid.cpp 2012-09-27 11:04:02.000000000 +0000 @@ -22,10 +22,12 @@ * Press the tiling keys several times to cycle through some tiling options. */ +#include #include "grid.h" #include "grabhandler.h" using namespace GridWindowType; +namespace cgw = compiz::grid::window; static std::map gridProps; @@ -834,7 +836,9 @@ unsigned int state, unsigned int mask) { - compiz::grid::window::GrabWindowHandler gwHandler (mask); + static cgw::GrabActiveFunc grabActive (boost::bind (&CompScreen::grabExist, + screen, _1)); + cgw::GrabWindowHandler gwHandler (mask, grabActive); if (gwHandler.track ()) { diff -Nru compiz-0.9.8.2+bzr3377/plugins/opacify/src/opacify.cpp compiz-0.9.8.4/plugins/opacify/src/opacify.cpp --- compiz-0.9.8.2+bzr3377/plugins/opacify/src/opacify.cpp 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/plugins/opacify/src/opacify.cpp 2012-09-27 11:04:02.000000000 +0000 @@ -64,7 +64,7 @@ */ void -OpacifyScreen::resetOpacity (Window id) +OpacifyScreen::resetWindowOpacity (Window id) { CompWindow *w; @@ -78,11 +78,39 @@ ow->cWindow->addDamage (); } +/* Resets all the windows on the screen to the original opacity + * if necessary. Then reset active. +*/ + +void +OpacifyScreen::resetScreenOpacity () +{ + if (active) + { + clearPassive(); + resetWindowOpacity(active); + active = 0; + } +} + /* Resets the opacity of windows on the passive list. */ void OpacifyScreen::clearPassive () { + foreach (Window xid, passive) + { + CompWindow *win = screen->findWindow (xid); + + if (!win) + continue; + + OPACIFY_WINDOW (win); + + ow->setOpacity (MAX (OPAQUE * optionGetActiveOpacity () / 100, + ow->gWindow->paintAttrib ().opacity)); + resetWindowOpacity (xid); + } passive.clear (); } @@ -116,20 +144,7 @@ int i = 0; /* Clear the list first to prevent memleaks */ - foreach (Window xid, passive) - { - CompWindow *win = screen->findWindow (xid); - - if (!win) - continue; - - OPACIFY_WINDOW (win); - - resetOpacity (xid); - ow->setOpacity (MAX (OPAQUE * optionGetActiveOpacity () / 100, - ow->gWindow->paintAttrib ().opacity)); - } - passive.clear (); + clearPassive (); foreach (CompWindow *w, screen->windows ()) { @@ -177,16 +192,14 @@ return; } - os->clearPassive (); - os->resetOpacity (os->active); - os->active = 0; + os->resetScreenOpacity (); return; } if (!window || os->active != window->id () || os->justMoved) { os->justMoved = false; - os->resetOpacity (os->active); + os->resetWindowOpacity (os->active); os->active = 0; } @@ -214,7 +227,7 @@ OpacifyScreen::handleTimeout () { if (newActive) - OpacifyWindow::get (newActive)->handleEnter (); + OpacifyWindow::get (newActive)->handleEnter (); return false; } @@ -287,7 +300,7 @@ Window id; id = event->xcrossing.window; - newActive = screen->findTopLevelWindow (id); + newActive = screen->findTopLevelWindow (id); if (timeoutHandle.active ()) timeoutHandle.stop (); @@ -296,7 +309,10 @@ handleTimeout (); else timeoutHandle.start (); - break; + break; + case FocusIn: + resetScreenOpacity(); + break; case ConfigureNotify: if (active != event->xconfigure.window) @@ -311,7 +327,7 @@ if (w) passiveWindows (w->region ()); } - break; + break; default: break; } @@ -329,12 +345,7 @@ isToggle = !isToggle; if (!isToggle && optionGetToggleReset ()) { - if (active) - { - clearPassive (); - resetOpacity (active); - active = 0; - } + resetScreenOpacity(); } setFunctions (isToggle); @@ -357,12 +368,7 @@ case OpacifyOptions::InitToggle: isToggle = option->value ().b (); setFunctions (isToggle); - if (active) - { - clearPassive (); - resetOpacity (active); - active = 0; - } + resetScreenOpacity(); break; case OpacifyOptions::Timeout: timeoutHandle.setTimes (optionGetTimeout (), optionGetTimeout () * 1.2); diff -Nru compiz-0.9.8.2+bzr3377/plugins/opacify/src/opacify.h compiz-0.9.8.4/plugins/opacify/src/opacify.h --- compiz-0.9.8.2+bzr3377/plugins/opacify/src/opacify.h 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/plugins/opacify/src/opacify.h 2012-09-27 11:04:02.000000000 +0000 @@ -61,7 +61,10 @@ handleEvent (XEvent *); void - resetOpacity (Window id); + resetWindowOpacity (Window id); + + void + resetScreenOpacity (); void clearPassive (); diff -Nru compiz-0.9.8.2+bzr3377/plugins/opengl/DRIVERS compiz-0.9.8.4/plugins/opengl/DRIVERS --- compiz-0.9.8.2+bzr3377/plugins/opengl/DRIVERS 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/plugins/opengl/DRIVERS 2012-09-27 11:04:02.000000000 +0000 @@ -52,3 +52,13 @@ RESOLVED. WORKAROUND: detect when llvmpipe is active and force the usage of glXSwapBuffers on every frame + +virtualbox +========== + + 1. vboxdrv may open a new X Server connection on the first call to + glXBindTexImageEXT. If compiz has a server grab during this time + (see the GLX_EXT_texture_from_pixmap spec s. 5) then compiz + will deadlock + + RESOLVED. WORKAROUND: don't implement this part of the spec for now diff -Nru compiz-0.9.8.2+bzr3377/plugins/opengl/src/fsregion/fsregion.cpp compiz-0.9.8.4/plugins/opengl/src/fsregion/fsregion.cpp --- compiz-0.9.8.2+bzr3377/plugins/opengl/src/fsregion/fsregion.cpp 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/plugins/opengl/src/fsregion/fsregion.cpp 2012-09-27 11:04:02.000000000 +0000 @@ -29,7 +29,6 @@ namespace opengl { FullscreenRegion::FullscreenRegion (const CompRect &rect) : - covered (false), untouched (rect), orig (untouched) { @@ -40,9 +39,10 @@ { bool fullscreen = false; - if (!covered && !(flags & (Desktop | Alpha)) && region == untouched) + if (!(flags & (Desktop | Alpha)) && + region == untouched && + region == orig) { - covered = true; fullscreen = true; } diff -Nru compiz-0.9.8.2+bzr3377/plugins/opengl/src/fsregion/fsregion.h compiz-0.9.8.4/plugins/opengl/src/fsregion/fsregion.h --- compiz-0.9.8.2+bzr3377/plugins/opengl/src/fsregion/fsregion.h 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/plugins/opengl/src/fsregion/fsregion.h 2012-09-27 11:04:02.000000000 +0000 @@ -49,7 +49,6 @@ bool allowRedirection (const CompRegion ®ion); private: - bool covered; CompRegion untouched; CompRegion orig; }; diff -Nru compiz-0.9.8.2+bzr3377/plugins/opengl/src/fsregion/tests/test-fsregion.cpp compiz-0.9.8.4/plugins/opengl/src/fsregion/tests/test-fsregion.cpp --- compiz-0.9.8.2+bzr3377/plugins/opengl/src/fsregion/tests/test-fsregion.cpp 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/plugins/opengl/src/fsregion/tests/test-fsregion.cpp 2012-09-27 11:04:02.000000000 +0000 @@ -148,3 +148,13 @@ EXPECT_FALSE (monitor.allowRedirection (window)); } +TEST (OpenGLFullscreenRegion, MaximizedWithDocks) // LP: #1053902 +{ + FullscreenRegion monitor (CompRect (0, 0, 1024, 768)); + EXPECT_FALSE (monitor.isCoveredBy (CompRegion (0, 0, 1024, 24))); + EXPECT_FALSE (monitor.isCoveredBy (CompRegion (0, 24, 64, 744))); + EXPECT_FALSE (monitor.isCoveredBy (CompRegion (64, 24, 960, 744))); + EXPECT_FALSE (monitor.isCoveredBy (CompRegion (0, 0, 1024, 768), + FullscreenRegion::Desktop)); +} + diff -Nru compiz-0.9.8.2+bzr3377/plugins/opengl/src/glxtfpbind/include/glx-tfp-bind.h compiz-0.9.8.4/plugins/opengl/src/glxtfpbind/include/glx-tfp-bind.h --- compiz-0.9.8.2+bzr3377/plugins/opengl/src/glxtfpbind/include/glx-tfp-bind.h 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/plugins/opengl/src/glxtfpbind/include/glx-tfp-bind.h 2012-09-27 11:04:02.000000000 +0000 @@ -25,6 +25,10 @@ #ifndef _COMPIZ_OPENGL_GLX_TFP_BIND_H #define _COMPIZ_OPENGL_GLX_TFP_BIND_H +#ifndef LP_1030891_NOT_FIXED +#define LP_1030891_NOT_FIXED +#endif + #include #include diff -Nru compiz-0.9.8.2+bzr3377/plugins/opengl/src/glxtfpbind/src/glx-tfp-bind.cpp compiz-0.9.8.4/plugins/opengl/src/glxtfpbind/src/glx-tfp-bind.cpp --- compiz-0.9.8.2+bzr3377/plugins/opengl/src/glxtfpbind/src/glx-tfp-bind.cpp 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/plugins/opengl/src/glxtfpbind/src/glx-tfp-bind.cpp 2012-09-27 11:04:02.000000000 +0000 @@ -37,15 +37,22 @@ const cgl::WaitGLXFunc &waitGLX, cgl::PixmapSource source) { +#ifndef LP_1030891_NOT_FIXED ServerLock lock (serverGrabInterface); waitGLX (); +#endif /* External pixmaps can disappear on us, but not * while we have a server grab at least */ if (source == cgl::ExternallyManaged) + { +#ifdef LP_1030891_NOT_FIXED + ServerLock lock (serverGrabInterface); +#endif if (!checkPixmapValidity (x11Pixmap)) return false; + } bindTexImageEXT (glxPixmap); diff -Nru compiz-0.9.8.2+bzr3377/plugins/opengl/src/glxtfpbind/tests/test-opengl-glx-tfp-bind.cpp compiz-0.9.8.4/plugins/opengl/src/glxtfpbind/tests/test-opengl-glx-tfp-bind.cpp --- compiz-0.9.8.2+bzr3377/plugins/opengl/src/glxtfpbind/tests/test-opengl-glx-tfp-bind.cpp 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/plugins/opengl/src/glxtfpbind/tests/test-opengl-glx-tfp-bind.cpp 2012-09-27 11:04:02.000000000 +0000 @@ -62,11 +62,12 @@ { MockServerGrab mockServerGrab; InSequence s; - +#ifndef LP_1030891_NOT_FIXED EXPECT_CALL (mockServerGrab, grabServer ()); EXPECT_CALL (mockServerGrab, syncServer ()); EXPECT_CALL (mockServerGrab, ungrabServer ()); EXPECT_CALL (mockServerGrab, syncServer ()); +#endif cgl::bindTexImageGLX (&mockServerGrab, pixmap, @@ -77,6 +78,31 @@ cgl::InternallyManaged); } +#ifdef LP_1030891_NOT_FIXED +TEST (CompizOpenGLGLXTextureFromPixmapBindTest, TestTakesServerGrabLP1030891SpecialCase) +{ + MockServerGrab mockServerGrab; + StrictMock mockPixmapCheck; + StrictMock mockBindTexImage; + + cgl::PixmapCheckValidityFunc pixmapCheckFunc (boost::bind (&MockPixmapCheckValidity::checkValidity, &mockPixmapCheck, _1)); + cgl::BindTexImageEXTFunc bindTexImageEXTFunc (boost::bind (&MockBindTexImageEXT::bindTexImageEXT, &mockBindTexImage, _1)); + + EXPECT_CALL (mockServerGrab, grabServer ()); + EXPECT_CALL (mockServerGrab, syncServer ()).Times (2); + EXPECT_CALL (mockServerGrab, ungrabServer ()); + EXPECT_CALL (mockPixmapCheck, checkValidity (pixmap)).WillOnce (Return (true)); + EXPECT_CALL (mockBindTexImage, bindTexImageEXT (glxPixmap)); + cgl::bindTexImageGLX (&mockServerGrab, + pixmap, + glxPixmap, + pixmapCheckFunc, + bindTexImageEXTFunc, + waitGLX (), + cgl::ExternallyManaged); +} +#endif + TEST (CompizOpenGLGLXTextureFromPixmapBindTest, TestCallsWaitGLX) { NiceMock mockServerGrab; @@ -84,7 +110,9 @@ cgl::WaitGLXFunc waitGLXFuncMock (boost::bind (&MockWaitGLX::waitGLX, &mockWaitGLX)); +#ifndef LP_1030891_NOT_FIXED EXPECT_CALL (mockWaitGLX, waitGLX ()); +#endif cgl::bindTexImageGLX (&mockServerGrab, pixmap, diff -Nru compiz-0.9.8.2+bzr3377/plugins/opengl/src/paint.cpp compiz-0.9.8.4/plugins/opengl/src/paint.cpp --- compiz-0.9.8.2+bzr3377/plugins/opengl/src/paint.cpp 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/plugins/opengl/src/paint.cpp 2012-09-27 11:04:02.000000000 +0000 @@ -352,6 +352,7 @@ */ if (unredirectFS && !(mask & PAINT_SCREEN_TRANSFORMED_MASK) && + !(mask & PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS_MASK) && fs.isCoveredBy (w->region (), flags)) { unredirected.insert (w); @@ -618,7 +619,19 @@ sTransform.toScreenSpace (output, -DEFAULT_Z_CAMERA); - if (!region.isEmpty ()) + /* + * Sometimes region might be empty but we still need to force the + * repaint. This can happen when a fullscreen window is unredirected, + * and damageScreen is called. CompositeScreen::handlePaintTimeout + * then subtracts the whole screen of damage because it's an overlay + * and we're left with an empty damage region. + * Even when this happens we may want to force the repaint if + * windows are getting transformed (and so the unredirected window + * needs to be redirected again). + */ + if (!region.isEmpty () || + (mask & PAINT_SCREEN_FULL_MASK) || + (mask & PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS_MASK)) priv->paintOutputRegion (sTransform, region, output, mask); return true; diff -Nru compiz-0.9.8.2+bzr3377/plugins/opengl/src/privates.h compiz-0.9.8.4/plugins/opengl/src/privates.h --- compiz-0.9.8.2+bzr3377/plugins/opengl/src/privates.h 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/plugins/opengl/src/privates.h 2012-09-27 11:04:02.000000000 +0000 @@ -135,6 +135,7 @@ const CompRegion ®ion); bool hasVSync (); + bool requiredForcedRefreshRate (); void updateRenderMode (); @@ -199,6 +200,8 @@ std::vector bindPixmap; bool hasCompositing; bool commonFrontbuffer; + bool incorrectRefreshRate; // hack for NVIDIA specifying an incorrect + // refresh rate, causing us to miss vblanks GLIcon defaultIcon; diff -Nru compiz-0.9.8.2+bzr3377/plugins/opengl/src/screen.cpp compiz-0.9.8.4/plugins/opengl/src/screen.cpp --- compiz-0.9.8.2+bzr3377/plugins/opengl/src/screen.cpp 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/plugins/opengl/src/screen.cpp 2012-09-27 11:04:02.000000000 +0000 @@ -500,6 +500,8 @@ if (GL::textureFromPixmap) registerBindPixmap (EglTexture::bindPixmapToTexture); + priv->incorrectRefreshRate = false; + #else Display *dpy = screen->dpy (); @@ -509,6 +511,7 @@ GLfloat diffuseLight[] = { 0.9f, 0.9f, 0.9f, 0.9f }; GLfloat light0Position[] = { -0.5f, 0.5f, -9.0f, 1.0f }; const char *glRenderer; + const char *glVendor; CompOption::Vector o (0); priv->ctx = glXCreateContext (dpy, visinfo, NULL, True); @@ -548,6 +551,7 @@ } glRenderer = (const char *) glGetString (GL_RENDERER); + glVendor = (const char *) glGetString (GL_VENDOR); if (glRenderer != NULL && (strcmp (glRenderer, "Software Rasterizer") == 0 || strcmp (glRenderer, "Mesa X11") == 0)) @@ -560,6 +564,7 @@ } priv->commonFrontbuffer = true; + priv->incorrectRefreshRate = false; if (glRenderer != NULL && strstr (glRenderer, "on llvmpipe")) { /* @@ -572,6 +577,14 @@ priv->commonFrontbuffer = false; } + if (glVendor != NULL && strstr (glVendor, "NVIDIA")) + { + /* + * NVIDIA provides an incorrect refresh rate, we need to + * force 60Hz */ + priv->incorrectRefreshRate = true; + } + if (strstr (glExtensions, "GL_ARB_texture_non_power_of_two")) GL::textureNonPowerOfTwo = true; GL::textureNonPowerOfTwoMipmap = GL::textureNonPowerOfTwo; @@ -1093,13 +1106,15 @@ EGLDisplay dpy = eglGetDisplay (xdpy); eglMakeCurrent (dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); - eglDestroyContext (dpy, priv->ctx); + if (priv->ctx != EGL_NO_CONTEXT) + eglDestroyContext (dpy, priv->ctx); eglDestroySurface (dpy, priv->surface); eglTerminate (dpy); eglReleaseThread (); #else - glXDestroyContext (screen->dpy (), priv->ctx); + if (priv->ctx) + glXDestroyContext (screen->dpy (), priv->ctx); #endif if (priv->scratchFbo) @@ -1119,9 +1134,11 @@ clearBuffers (true), lighting (false), #ifndef USE_GLES + ctx (NULL), getProcAddress (0), doubleBuffer (screen->dpy (), *screen, cScreen->output ()), #else + ctx (EGL_NO_CONTEXT), doubleBuffer (screen->dpy (), *screen, surface), #endif scratchFbo (NULL), @@ -1674,6 +1691,27 @@ { void +fastSwapInterval (Display *dpy, int interval) +{ + static int prev = -1; +#ifndef USE_GLES + bool hasSwapInterval = GL::swapInterval ? true : false; +#else + bool hasSwapInterval = true; +#endif + + if (hasSwapInterval && interval != prev) + { +#ifndef USE_GLES + (*GL::swapInterval) (interval); +#else + eglSwapInterval (eglGetDisplay (dpy), interval); +#endif + prev = interval; + } +} + +void waitForVideoSync () { #ifndef USE_GLES @@ -1681,8 +1719,7 @@ if (GL::waitVideoSync) { // Don't wait twice. Just in case. - if (GL::swapInterval) - (*GL::swapInterval) (0); + fastSwapInterval (screen->dpy (), 0); /* * While glXSwapBuffers/glXCopySubBufferMESA are meant to do a @@ -1711,13 +1748,13 @@ // Docs: http://www.opengl.org/registry/specs/SGI/swap_control.txt if (GL::swapInterval) { - (*GL::swapInterval) (sync ? 1 : 0); + fastSwapInterval (screen->dpy (), sync ? 1 : 0); GL::unthrottledFrames++; } else if (sync) waitForVideoSync (); #else - eglSwapInterval (eglGetDisplay (screen->dpy ()), sync ? 1 : 0); + fastSwapInterval (screen->dpy (), sync ? 1 : 0); GL::unthrottledFrames++; #endif } @@ -2035,6 +2072,17 @@ gScreen->glPaintCompositedOutput (screen->region (), scratchFbo, mask); } + if (cScreen->outputWindowChanged ()) + { + /* + * Changes to the composite output window seem to take a whole frame + * to take effect. So to avoid a visible flicker, we skip this frame + * and do a full redraw next time. + */ + cScreen->damageScreen (); + return; + } + bool alwaysSwap = optionGetAlwaysSwapBuffers (); bool fullscreen = useFbo || alwaysSwap || @@ -2061,6 +2109,12 @@ } bool +PrivateGLScreen::requiredForcedRefreshRate () +{ + return incorrectRefreshRate; +} + +bool PrivateGLScreen::compositingActive () { return true; diff -Nru compiz-0.9.8.2+bzr3377/plugins/wall/CMakeLists.txt compiz-0.9.8.4/plugins/wall/CMakeLists.txt --- compiz-0.9.8.2+bzr3377/plugins/wall/CMakeLists.txt 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/plugins/wall/CMakeLists.txt 2012-09-27 11:04:02.000000000 +0000 @@ -3,7 +3,9 @@ include (CompizPlugin) include (CompizDefaults) -add_subdirectory (src/offset_movement) -include_directories (src/offset_movement/include) +if (NOT COMPIZ_DISABLE_PLUGIN_WALL) + add_subdirectory (src/offset_movement) + include_directories (src/offset_movement/include) +endif (NOT COMPIZ_DISABLE_PLUGIN_WALL) compiz_plugin (wall PLUGINDEPS composite opengl mousepoll PKGDEPS cairo cairo-xlib-xrender LIBRARIES compiz_wall_offset_movement dl) diff -Nru compiz-0.9.8.2+bzr3377/po/POTFILES.in compiz-0.9.8.4/po/POTFILES.in --- compiz-0.9.8.2+bzr3377/po/POTFILES.in 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/po/POTFILES.in 2012-10-01 12:36:18.000000000 +0000 @@ -3,11 +3,8 @@ gtk/window-decorator/forcequit.c gtk/window-decorator/gtk-window-decorator.c gtk/window-decorator/gwd.schemas.in -gtk/gnome/50-compiz-launchers.xml.in gtk/gnome/50-compiz-navigation.xml.in -gtk/gnome/50-compiz-screenshot.xml.in gtk/gnome/50-compiz-windows.xml.in -gtk/gnome/50-compiz-system.xml.in metadata/core.xml.in plugins/annotate/annotate.xml.in plugins/blur/blur.xml.in diff -Nru compiz-0.9.8.2+bzr3377/postinst/convert-files/compiz-profile-independent-keys.convert compiz-0.9.8.4/postinst/convert-files/compiz-profile-independent-keys.convert --- compiz-0.9.8.2+bzr3377/postinst/convert-files/compiz-profile-independent-keys.convert 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/postinst/convert-files/compiz-profile-independent-keys.convert 2012-10-01 12:36:18.000000000 +0000 @@ -1,11 +1,3 @@ -[org.compiz.integrated] -run-command-terminal = /apps/metacity/global_keybindings/run_command_terminal -run-command-screenshot = /apps/metacity/global_keybindings/run_command_screenshot -run-command-window-screenshot = /apps/metacity/global_keybindings/run_command_window_screenshot -panel-run-dialog = /apps/metacity/global_keybindings/panel_run_dialog -panel-main-menu = /apps/metacity/global_keybindings/panel_main_menu - - [org.gnome.desktop.wm.keybindings] move-to-workspace-1 = /apps/metacity/window_keybindings/move_to_workspace_1 move-to-workspace-2 = /apps/metacity/window_keybindings/move_to_workspace_2 diff -Nru compiz-0.9.8.2+bzr3377/tests/CMakeLists.txt compiz-0.9.8.4/tests/CMakeLists.txt --- compiz-0.9.8.2+bzr3377/tests/CMakeLists.txt 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/tests/CMakeLists.txt 2012-09-27 11:04:02.000000000 +0000 @@ -1,3 +1,4 @@ if (COMPIZ_BUILD_TESTING) -add_subdirectory (integration) + add_subdirectory (integration) + add_subdirectory (system) endif (COMPIZ_BUILD_TESTING) diff -Nru compiz-0.9.8.2+bzr3377/tests/manual/GTKWindowDecoratorResourceUsage.txt compiz-0.9.8.4/tests/manual/GTKWindowDecoratorResourceUsage.txt --- compiz-0.9.8.2+bzr3377/tests/manual/GTKWindowDecoratorResourceUsage.txt 1970-01-01 00:00:00.000000000 +0000 +++ compiz-0.9.8.4/tests/manual/GTKWindowDecoratorResourceUsage.txt 2012-09-27 11:04:02.000000000 +0000 @@ -0,0 +1,12 @@ +GTK-Window-Decorator Resource Usage +=================================== +Sam Spilsbury + +XRestop usage +------------- +#. Install xrestop (sudo apt-get install xrestop) +#. Run xrestop (eg, $ xrestop &) +#. Note the number in the "Wns" column for gtk-window-decorator +#. Open a window +#. Close that window +#. The number should be the same diff -Nru compiz-0.9.8.2+bzr3377/tests/manual/NVIDIAForceRefreshRate.txt compiz-0.9.8.4/tests/manual/NVIDIAForceRefreshRate.txt --- compiz-0.9.8.2+bzr3377/tests/manual/NVIDIAForceRefreshRate.txt 1970-01-01 00:00:00.000000000 +0000 +++ compiz-0.9.8.4/tests/manual/NVIDIAForceRefreshRate.txt 2012-09-27 11:04:02.000000000 +0000 @@ -0,0 +1,12 @@ +NVIDIA REFRESH RATE +=================== +Sam Spilsbury + +Force Refresh Rate +------------------ +Actions +#. Open ccsm and turn "Benchmark" on +#. Hit Alt-F12 +#. Run glxgears +#. Benchmark should display roughly under 60 frames per second + and not under 50 frames per second diff -Nru compiz-0.9.8.2+bzr3377/tests/manual/Unredirect.txt compiz-0.9.8.4/tests/manual/Unredirect.txt --- compiz-0.9.8.2+bzr3377/tests/manual/Unredirect.txt 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/tests/manual/Unredirect.txt 2012-09-27 11:04:02.000000000 +0000 @@ -75,3 +75,23 @@ Expected Result: The gnome-terminal window should be visible on top. + + +Unredirect cancelation by transformed windows (LP: #1047168) +------------------------------------------------------------- +Setup: +#. Install Chromium or Chrome browser. +#. Run ccsm and ensure the Scale plugin is loaded and "Initiate Window Picker" + is bound to Shift+Alt+Up. + +Actions: +#. Open a Chrome/Chromium window. +#. Open a gnome-terminal window (Ctrl+Alt+T) +#. Move the gnome-terminal to the centre of the screen, above the Chrome + window. +#. Click on the Chrome window and make it fullscreen (F11). +#. Hold Shift+Alt and tap Up to engage scale mode. Keep holding Shift+Alt + for a few seconds. + +Expected Result: + Windows get scaled and you can see both the Chrome and Terminal windows. diff -Nru compiz-0.9.8.2+bzr3377/tests/shared/glib/glib_gsettings_memory_backend_env.h compiz-0.9.8.4/tests/shared/glib/glib_gsettings_memory_backend_env.h --- compiz-0.9.8.2+bzr3377/tests/shared/glib/glib_gsettings_memory_backend_env.h 1970-01-01 00:00:00.000000000 +0000 +++ compiz-0.9.8.4/tests/shared/glib/glib_gsettings_memory_backend_env.h 2012-09-27 11:04:02.000000000 +0000 @@ -0,0 +1,45 @@ +/* + * Compiz configuration system library + * + * Copyright (C) 2012 Canonical Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authored By: + * Sam Spilsbury + */ +#ifndef _COMPIZ_GLIB_GSETTINGS_MEMORY_BACKEND_TEST_ENV_H +#define _COMPIZ_GLIB_GSETTINGS_MEMORY_BACKEND_TEST_ENV_H + +#include + +class CompizGLibGSettingsMemoryBackendTestingEnv +{ + public: + + virtual void SetUpEnv (const std::string &MOCK_PATH) + { + g_setenv ("GSETTINGS_SCHEMA_DIR", MOCK_PATH.c_str (), true); + g_setenv ("GSETTINGS_BACKEND", "memory", 1); + } + + virtual void TearDownEnv () + { + g_unsetenv ("GSETTINGS_BACKEND"); + g_unsetenv ("GSETTINGS_SCHEMA_DIR"); + } +}; + +#endif diff -Nru compiz-0.9.8.2+bzr3377/tests/shared/glib/glib_gslice_off_env.h compiz-0.9.8.4/tests/shared/glib/glib_gslice_off_env.h --- compiz-0.9.8.2+bzr3377/tests/shared/glib/glib_gslice_off_env.h 1970-01-01 00:00:00.000000000 +0000 +++ compiz-0.9.8.4/tests/shared/glib/glib_gslice_off_env.h 2012-09-27 11:04:02.000000000 +0000 @@ -0,0 +1,43 @@ +/* + * Compiz configuration system library + * + * Copyright (C) 2012 Canonical Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authored By: + * Sam Spilsbury + */ +#ifndef _COMPIZ_GLIB_GSLICE_OFF_ENV_H +#define _COMPIZ_GLIB_GSLICE_OFF_ENV_H + +#include + +class CompizGLibGSliceOffEnv +{ + public: + + virtual void SetUpEnv () + { + g_setenv ("G_SLICE", "always-malloc", 1); + } + + virtual void TearDownEnv () + { + g_unsetenv ("G_SLICE"); + } +}; + +#endif diff -Nru compiz-0.9.8.2+bzr3377/tests/shared/gtest_shared_autodestroy.h compiz-0.9.8.4/tests/shared/gtest_shared_autodestroy.h --- compiz-0.9.8.2+bzr3377/tests/shared/gtest_shared_autodestroy.h 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/tests/shared/gtest_shared_autodestroy.h 2012-09-27 11:04:02.000000000 +0000 @@ -1,3 +1,23 @@ +/* + * Copyright (C) 2012 Canonical Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authored By: + * Sam Spilsbury + */ #ifndef _COMPIZ_GTEST_SHARED_AUTODESTROY_H #define _COMPIZ_GTEST_SHARED_AUTODESTROY_H diff -Nru compiz-0.9.8.2+bzr3377/tests/shared/gtest_shared_characterwrapper.h compiz-0.9.8.4/tests/shared/gtest_shared_characterwrapper.h --- compiz-0.9.8.2+bzr3377/tests/shared/gtest_shared_characterwrapper.h 2012-09-18 11:22:26.000000000 +0000 +++ compiz-0.9.8.4/tests/shared/gtest_shared_characterwrapper.h 2012-09-27 11:04:02.000000000 +0000 @@ -1,6 +1,27 @@ +/* + * Copyright (C) 2012 Canonical Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authored By: + * Sam Spilsbury + */ #ifndef _COMPIZ_GTEST_SHARED_CHARACTERWRAPPER #define _COMPIZ_GTEST_SHARED_CHARACTERWRAPPER +#include #include class CharacterWrapper : diff -Nru compiz-0.9.8.2+bzr3377/tests/shared/gtest_unspecified_bool_type_matcher.h compiz-0.9.8.4/tests/shared/gtest_unspecified_bool_type_matcher.h --- compiz-0.9.8.2+bzr3377/tests/shared/gtest_unspecified_bool_type_matcher.h 1970-01-01 00:00:00.000000000 +0000 +++ compiz-0.9.8.4/tests/shared/gtest_unspecified_bool_type_matcher.h 2012-09-27 11:04:02.000000000 +0000 @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2012 Canonical Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authored By: + * Sam Spilsbury + */ +#ifndef _COMPIZ_GTEST_UNSPECIFIED_BOOL_TYPE_MATCHER_H +#define _COMPIZ_GTEST_UNSPECIFIED_BOOL_TYPE_MATCHER_H + +#include +#include + +MATCHER (IsTrue, "Is True") { if (arg) return true; else return false; } +MATCHER (IsFalse, "Is False") { if (!arg) return true; else return false; } + +#endif diff -Nru compiz-0.9.8.2+bzr3377/tests/system/CMakeLists.txt compiz-0.9.8.4/tests/system/CMakeLists.txt --- compiz-0.9.8.2+bzr3377/tests/system/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 +++ compiz-0.9.8.4/tests/system/CMakeLists.txt 2012-09-27 11:04:02.000000000 +0000 @@ -0,0 +1 @@ +add_subdirectory (xorg-gtest) diff -Nru compiz-0.9.8.2+bzr3377/tests/system/xorg-gtest/CMakeLists.txt compiz-0.9.8.4/tests/system/xorg-gtest/CMakeLists.txt --- compiz-0.9.8.2+bzr3377/tests/system/xorg-gtest/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 +++ compiz-0.9.8.4/tests/system/xorg-gtest/CMakeLists.txt 2012-09-27 11:04:02.000000000 +0000 @@ -0,0 +1,28 @@ +include (FindPkgConfig) + +pkg_check_modules (XORG_SERVER xorg-gtest xorg-server x11) + +option (BUILD_XORG_GTEST "Build Xorg GTest integration tests" OFF) + +if (XORG_SERVER_FOUND AND BUILD_XORG_GTEST) + + execute_process (COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=prefix xorg-gtest OUTPUT_VARIABLE _xorg_gtest_prefix) + execute_process (COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=includedir xorg-gtest OUTPUT_VARIABLE _xorg_gtest_include_dir) + execute_process (COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=sourcedir xorg-gtest OUTPUT_VARIABLE _xorg_gtest_source_dir) + execute_process (COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=CPPflags xorg-gtest OUTPUT_VARIABLE _xorg_gtest_cflags) + + set (XORG_SERVER_INCLUDE_XORG_GTEST ${_xorg_gtest_include_dir} CACHE PATH "Path to Xorg GTest Headers") + set (XORG_SERVER_GTEST_SRC ${_xorg_gtest_source_dir} CACHE PATH "Path to Xorg GTest Sources") + set (COMPIZ_XORG_SYSTEM_TEST_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include CACHE PATH "Path to Compiz Xorg GTest Headers") + + message (STATUS "Found xorg-gtest sources at " ${XORG_SERVER_GTEST_SRC}) + + add_subdirectory (src) + add_subdirectory (tests) + +else (XORG_SERVER_FOUND AND BUILD_XORG_GTEST) + + message (WARNING "Could not found xorg-gtest, not building system tests") + set (BUILD_XORG_GTEST OFF) + +endif (XORG_SERVER_FOUND AND BUILD_XORG_GTEST) diff -Nru compiz-0.9.8.2+bzr3377/tests/system/xorg-gtest/include/compiz-xorg-gtest.h compiz-0.9.8.4/tests/system/xorg-gtest/include/compiz-xorg-gtest.h --- compiz-0.9.8.2+bzr3377/tests/system/xorg-gtest/include/compiz-xorg-gtest.h 1970-01-01 00:00:00.000000000 +0000 +++ compiz-0.9.8.4/tests/system/xorg-gtest/include/compiz-xorg-gtest.h 2012-09-27 11:04:02.000000000 +0000 @@ -0,0 +1,67 @@ +/* + * Compiz XOrg GTest + * + * Copyright (C) 2012 Canonical Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authored By: + * Sam Spilsbury + */ +#ifndef _COMPIZ_XORG_GTEST_H +#define _COMPIZ_XORG_GTEST_H +#include +#include +#include + +using ::testing::MatcherInterface; + +namespace compiz +{ + namespace testing + { + typedef ::testing::MatcherInterface XEventMatcher; + + std::list NET_CLIENT_LIST_STACKING (Display *); + bool WaitForEventOfTypeOnWindow (Display *dpy, + Window w, + int type, + int ext, + int extType, + int timeout = 1000); + bool WaitForEventOfTypeOnWindowMatching (Display *dpy, + Window w, + int type, + int ext, + int extType, + const XEventMatcher &matcher, + int timeout = 1000); + + class XorgSystemTest : + public xorg::testing::Test + { + public: + + virtual void SetUp (); + virtual void TearDown (); + + private: + + xorg::testing::Process mCompizProcess; + }; + } +} + +#endif diff -Nru compiz-0.9.8.2+bzr3377/tests/system/xorg-gtest/src/CMakeLists.txt compiz-0.9.8.4/tests/system/xorg-gtest/src/CMakeLists.txt --- compiz-0.9.8.2+bzr3377/tests/system/xorg-gtest/src/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 +++ compiz-0.9.8.4/tests/system/xorg-gtest/src/CMakeLists.txt 2012-09-27 11:04:02.000000000 +0000 @@ -0,0 +1,51 @@ +set (COMPIZ_LD_LIBRARY_PATH ${CMAKE_BINARY_DIR}/src CACHE STRING "" FORCE) +set (COMPIZ_BINARY ${CMAKE_BINARY_DIR}/src/compiz CACHE STRING "" FORCE) + +configure_file (${CMAKE_CURRENT_SOURCE_DIR}/compiz-xorg-gtest-config.h.in + ${CMAKE_CURRENT_BINARY_DIR}/compiz-xorg-gtest-config.h + @ONLY) + +add_definitions (${_xorg_gtest_cflags}) + +include_directories (${COMPIZ_XORG_SYSTEM_TEST_INCLUDE_DIR} + ${XORG_SERVER_INCLUDE_DIRS} + ${GTEST_INCLUDE_DIRS} + ${XORG_SERVER_INCLUDE_XORG_GTEST} + ${XORG_SERVER_GTEST_SRC} + ${CMAKE_CURRENT_BINARY_DIR}) + +link_directories (${XORG_SERVER_LIBRARY_DIRS}) + +# This actually includes xorg-gtest-all and the defines +set (_xorg_gtest_all_srcs + ${XORG_SERVER_GTEST_SRC}/src/xorg-gtest-all.cpp) + +set (_xorg_gtest_main_srcs + ${XORG_SERVER_GTEST_SRC}/src/xorg-gtest_main.cpp) + +add_library (xorg_gtest_all STATIC + ${_xorg_gtest_all_srcs}) + +add_library (xorg_gtest_main STATIC + ${_xorg_gtest_main_srcs}) + +add_library (compiz_xorg_gtest_system_test STATIC + ${CMAKE_CURRENT_SOURCE_DIR}/compiz-xorg-gtest.cpp) + +target_link_libraries (xorg_gtest_all + ${GTEST_BOTH_LIBRARIES} + ${CMAKE_THREAD_LIBS_INIT} + ${XORG_SERVER_LIBRARIES}) + +target_link_libraries (xorg_gtest_main + ${GTEST_BOTH_LIBRARIES} + ${CMAKE_THREAD_LIBS_INIT} + ${XORG_SERVER_LIBRARIES}) + +target_link_libraries (compiz_xorg_gtest_system_test + xorg_gtest_all + xorg_gtest_main + ${GTEST_BOTH_LIBRARIES} + ${CMAKE_THREAD_LIBS_INIT} + ${XORG_SERVER_LIBRARIES} + ${X11_XI_LIBRARIES}) diff -Nru compiz-0.9.8.2+bzr3377/tests/system/xorg-gtest/src/compiz-xorg-gtest-config.h.in compiz-0.9.8.4/tests/system/xorg-gtest/src/compiz-xorg-gtest-config.h.in --- compiz-0.9.8.2+bzr3377/tests/system/xorg-gtest/src/compiz-xorg-gtest-config.h.in 1970-01-01 00:00:00.000000000 +0000 +++ compiz-0.9.8.4/tests/system/xorg-gtest/src/compiz-xorg-gtest-config.h.in 2012-09-27 11:04:02.000000000 +0000 @@ -0,0 +1,32 @@ +/* + * Compiz XOrg GTest + * + * Copyright (C) 2012 Canonical Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authored By: + * Sam Spilsbury + */ +#ifndef _COMPIZ_XORG_GTEST_CONFIG_H +#define _COMPIZ_XORG_GTEST_CONFIG_H + +namespace +{ + const std::string compizLDLibraryPath ("@COMPIZ_LD_LIBRARY_PATH@");//("/home/smspillaz/Source/Compiz/dev/dev/merges/compiz/proposed/compiz/build/src/"); + const std::string compizBinaryPath ("@COMPIZ_BINARY@");//("/home/smspillaz/Source/Compiz/dev/dev/merges/compiz/proposed/compiz/build/src/compiz"); +} + +#endif diff -Nru compiz-0.9.8.2+bzr3377/tests/system/xorg-gtest/src/compiz-xorg-gtest.cpp compiz-0.9.8.4/tests/system/xorg-gtest/src/compiz-xorg-gtest.cpp --- compiz-0.9.8.2+bzr3377/tests/system/xorg-gtest/src/compiz-xorg-gtest.cpp 1970-01-01 00:00:00.000000000 +0000 +++ compiz-0.9.8.4/tests/system/xorg-gtest/src/compiz-xorg-gtest.cpp 2012-09-27 11:04:02.000000000 +0000 @@ -0,0 +1,150 @@ +/* + * Compiz XOrg GTest + * + * Copyright (C) 2012 Canonical Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authored By: + * Sam Spilsbury + */ +#include +#include +#include +#include +#include +#include +#include +#include + +#include "compiz-xorg-gtest-config.h" + +namespace ct = compiz::testing; +namespace +{ + void RemoveEventFromQueue (Display *dpy) + { + XEvent event; + + if (XNextEvent (dpy, &event) != Success) + throw std::runtime_error("Failed to remove X event"); + } +} + +bool +ct::WaitForEventOfTypeOnWindow (Display *dpy, + Window w, + int type, + int ext, + int extType, + int timeout) +{ + while (xorg::testing::XServer::WaitForEventOfType (dpy, type, ext, extType, timeout)) + { + XEvent event; + if (!XPeekEvent (dpy, &event)) + throw std::runtime_error ("Failed to peek event"); + + RemoveEventFromQueue (dpy); + + if (event.xany.window != w) + continue; + + return true; + } + + return false; +} + +bool +ct::WaitForEventOfTypeOnWindowMatching (Display *dpy, + Window w, + int type, + int ext, + int extType, + const XEventMatcher &matcher, + int timeout) +{ + while (ct::WaitForEventOfTypeOnWindow (dpy, w, type, ext, extType, timeout)) + { + XEvent event; + if (!XPeekEvent (dpy, &event)) + throw std::runtime_error ("Failed to peek event"); + + if (!matcher.MatchAndExplain (event, NULL)) + continue; + + RemoveEventFromQueue (dpy); + + return true; + } + + return false; +} + +std::list +ct::NET_CLIENT_LIST_STACKING (Display *dpy) +{ + Atom property = XInternAtom (dpy, "_NET_CLIENT_LIST_STACKING", false); + Atom actual_type; + int actual_fmt; + unsigned long nitems, nleft; + unsigned char *prop; + std::list stackingOrder; + + /* _NET_CLIENT_LIST_STACKING */ + if (XGetWindowProperty (dpy, DefaultRootWindow (dpy), property, 0L, 512L, false, XA_WINDOW, + &actual_type, &actual_fmt, &nitems, &nleft, &prop) == Success) + { + if (nitems && !nleft && actual_fmt == 32 && actual_type == XA_WINDOW) + { + Window *window = reinterpret_cast (prop); + + while (nitems--) + stackingOrder.push_back (*window++); + + } + + if (prop) + XFree (prop); + } + + return stackingOrder; +} + +void +ct::XorgSystemTest::SetUp () +{ + xorg::testing::Test::SetUp (); + + ::Display *dpy = Display (); + XSelectInput (dpy, DefaultRootWindow (dpy), SubstructureNotifyMask | PropertyChangeMask); + + xorg::testing::Process::SetEnv ("LD_LIBRARY_PATH", compizLDLibraryPath, true); + mCompizProcess.Start (compizBinaryPath, "--replace", NULL); + + /* Output buffer is flushed by this point, compiz has a server grab, + * so we will only get this once the relevant initialization is complete */ + ASSERT_TRUE (xorg::testing::XServer::WaitForEventOfType (Display (), PropertyNotify, -1, -1, 3000)); + + ASSERT_EQ (mCompizProcess.GetState (), xorg::testing::Process::RUNNING); +} + +void +ct::XorgSystemTest::TearDown () +{ + mCompizProcess.Kill (); + xorg::testing::Test::TearDown (); +} diff -Nru compiz-0.9.8.2+bzr3377/tests/system/xorg-gtest/tests/CMakeLists.txt compiz-0.9.8.4/tests/system/xorg-gtest/tests/CMakeLists.txt --- compiz-0.9.8.2+bzr3377/tests/system/xorg-gtest/tests/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 +++ compiz-0.9.8.4/tests/system/xorg-gtest/tests/CMakeLists.txt 2012-09-27 11:04:02.000000000 +0000 @@ -0,0 +1,27 @@ +pkg_check_modules (X11_XI x11 xi) + +if (BUILD_XORG_GTEST AND X11_XI_FOUND) + + include_directories (${COMPIZ_XORG_SYSTEM_TEST_INCLUDE_DIR} + ${X11_INCLUDE_DIRS} + ${XORG_SERVER_INCLUDE_XORG_GTEST} + ${XORG_SERVER_GTEST_SRC} + ${GTEST_INCLUDE_DIRS}) + + link_directories (${X11_XI_LIBRARY_DIRS}) + + add_executable (compiz_xorg_gtest_test_window_stacking + ${CMAKE_CURRENT_SOURCE_DIR}/compiz_xorg_gtest_test_window_stacking.cpp) + + target_link_libraries (compiz_xorg_gtest_test_window_stacking + compiz_xorg_gtest_system_test + xorg_gtest_all + xorg_gtest_main + ${GTEST_BOTH_LIBRARIES} + ${CMAKE_THREAD_LIBS_INIT} + ${XORG_SERVER_LIBRARIES} + ${X11_XI_LIBRARIES}) + + compiz_discover_tests (compiz_xorg_gtest_test_window_stacking) + +endif (BUILD_XORG_GTEST AND X11_XI_FOUND) diff -Nru compiz-0.9.8.2+bzr3377/tests/system/xorg-gtest/tests/compiz_xorg_gtest_test_window_stacking.cpp compiz-0.9.8.4/tests/system/xorg-gtest/tests/compiz_xorg_gtest_test_window_stacking.cpp --- compiz-0.9.8.2+bzr3377/tests/system/xorg-gtest/tests/compiz_xorg_gtest_test_window_stacking.cpp 1970-01-01 00:00:00.000000000 +0000 +++ compiz-0.9.8.4/tests/system/xorg-gtest/tests/compiz_xorg_gtest_test_window_stacking.cpp 2012-09-27 11:04:02.000000000 +0000 @@ -0,0 +1,217 @@ +/* + * Compiz XOrg GTest, window stacking + * + * Copyright (C) 2012 Canonical Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authored By: + * Sam Spilsbury + */ +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +using ::testing::MatchResultListener; +using ::testing::MakeMatcher; +using ::testing::Matcher; + +namespace ct = compiz::testing; + +class CompizXorgSystemStackingTest : + public compiz::testing::XorgSystemTest +{ +}; + +namespace +{ + const int WINDOW_X = 0; + const int WINDOW_Y = 0; + const unsigned int WINDOW_WIDTH = 640; + const unsigned int WINDOW_HEIGHT = 480; + const unsigned int WINDOW_BORDER = 0; + const unsigned int WINDOW_DEPTH = CopyFromParent; + const unsigned int WINDOW_CLASS = InputOutput; + Visual *WINDOW_VISUAL = CopyFromParent; + + + const long WINDOW_ATTRIB_VALUE_MASK = 0; + + void MakeDock (Display *dpy, Window w) + { + Atom _NET_WM_WINDOW_TYPE = XInternAtom (dpy, "_NET_WM_WINDOW_TYPE", false); + Atom _NET_WM_WINDOW_TYPE_DOCK = XInternAtom (dpy, "_NET_WM_WINDOW_TYPE_DOCK", false); + + XChangeProperty (dpy, + w, + _NET_WM_WINDOW_TYPE, + XA_ATOM, + 32, + PropModeReplace, + reinterpret_cast (&_NET_WM_WINDOW_TYPE_DOCK), + 1); + } + + Window CreateNormalWindow (Display *dpy) + { + XSetWindowAttributes WINDOW_ATTRIB; + Window w = XCreateWindow (dpy, + DefaultRootWindow (dpy), + WINDOW_X, + WINDOW_Y, + WINDOW_WIDTH, + WINDOW_HEIGHT, + WINDOW_BORDER, + WINDOW_DEPTH, + WINDOW_CLASS, + WINDOW_VISUAL, + WINDOW_ATTRIB_VALUE_MASK, + &WINDOW_ATTRIB); + + XSelectInput (dpy, w, StructureNotifyMask); + return w; + } + + class PropertyNotifyXEventMatcher : + public ct::XEventMatcher + { + public: + + PropertyNotifyXEventMatcher (Display *dpy, + const std::string &propertyName) : + mPropertyName (propertyName), + mProperty (XInternAtom (dpy, propertyName.c_str (), false)) + { + } + + virtual bool MatchAndExplain (const XEvent &event, MatchResultListener *listener) const + { + const XPropertyEvent *propertyEvent = reinterpret_cast (&event); + + if (mProperty == propertyEvent->atom) + return true; + else + return false; + } + + virtual void DescribeTo (std::ostream *os) const + { + *os << "Is property identified by " << mPropertyName; + } + + virtual void DescribeNegationTo (std::ostream *os) const + { + *os << "Is not a property identified by" << mPropertyName; + } + + private: + + std::string mPropertyName; + Atom mProperty; + }; +} + +TEST_F (CompizXorgSystemStackingTest, TestSetup) +{ +} + +TEST_F (CompizXorgSystemStackingTest, TestCreateWindowsAndRestackRelativeToEachOther) +{ + ::Display *dpy = Display (); + + Window w1 = CreateNormalWindow (dpy); + Window w2 = CreateNormalWindow (dpy); + + XMapRaised (dpy, w1); + XMapRaised (dpy, w2); + + /* Both reparented and both mapped */ + ASSERT_TRUE (ct::WaitForEventOfTypeOnWindow (dpy, w1, ReparentNotify, -1, -1)); + ASSERT_TRUE (ct::WaitForEventOfTypeOnWindow (dpy, w1, MapNotify, -1, -1)); + ASSERT_TRUE (ct::WaitForEventOfTypeOnWindow (dpy, w2, ReparentNotify, -1, -1)); + ASSERT_TRUE (ct::WaitForEventOfTypeOnWindow (dpy, w2, MapNotify, -1, -1)); + + PropertyNotifyXEventMatcher matcher (dpy, "_NET_CLIENT_LIST_STACKING"); + + /* Wait for property change notify on the root window to happen twice */ + ASSERT_TRUE (ct::WaitForEventOfTypeOnWindowMatching (dpy, DefaultRootWindow (dpy), PropertyNotify, -1, -1, matcher)); + ASSERT_TRUE (ct::WaitForEventOfTypeOnWindowMatching (dpy, DefaultRootWindow (dpy), PropertyNotify, -1, -1, matcher)); + + /* Check the client list to see that w2 > w1 */ + std::list clientList = ct::NET_CLIENT_LIST_STACKING (dpy); + + ASSERT_EQ (clientList.size (), 2); + EXPECT_EQ (clientList.front (), w1); + EXPECT_EQ (clientList.back (), w2); +} + +TEST_F (CompizXorgSystemStackingTest, TestCreateWindowsAndRestackRelativeToEachOtherDockAlwaysOnTop) +{ + ::Display *dpy = Display (); + PropertyNotifyXEventMatcher matcher (dpy, "_NET_CLIENT_LIST_STACKING"); + + Window dock = CreateNormalWindow (dpy); + + /* Make it a dock */ + MakeDock (dpy, dock); + + /* Immediately map the dock window and clear the event queue for it */ + XMapRaised (dpy, dock); + + ASSERT_TRUE (ct::WaitForEventOfTypeOnWindow (dpy, dock, ReparentNotify, -1, -1)); + ASSERT_TRUE (ct::WaitForEventOfTypeOnWindow (dpy, dock, MapNotify, -1, -1)); + + /* Dock window needs to be in the client list */ + ASSERT_TRUE (ct::WaitForEventOfTypeOnWindowMatching (dpy, DefaultRootWindow (dpy), PropertyNotify, -1, -1, matcher)); + + std::list clientList = ct::NET_CLIENT_LIST_STACKING (dpy); + ASSERT_EQ (clientList.size (), 1); + + Window w1 = CreateNormalWindow (dpy); + Window w2 = CreateNormalWindow (dpy); + + XSelectInput (dpy, w2, StructureNotifyMask); + + XMapRaised (dpy, w1); + XMapRaised (dpy, w2); + + /* Both reparented and both mapped */ + ASSERT_TRUE (ct::WaitForEventOfTypeOnWindow (dpy, w1, ReparentNotify, -1, -1)); + ASSERT_TRUE (ct::WaitForEventOfTypeOnWindow (dpy, w1, MapNotify, -1, -1)); + ASSERT_TRUE (ct::WaitForEventOfTypeOnWindow (dpy, w2, ReparentNotify, -1, -1)); + ASSERT_TRUE (ct::WaitForEventOfTypeOnWindow (dpy, w2, MapNotify, -1, -1)); + + /* Wait for property change notify on the root window to happen twice */ + ASSERT_TRUE (ct::WaitForEventOfTypeOnWindowMatching (dpy, DefaultRootWindow (dpy), PropertyNotify, -1, -1, matcher)); + ASSERT_TRUE (ct::WaitForEventOfTypeOnWindowMatching (dpy, DefaultRootWindow (dpy), PropertyNotify, -1, -1, matcher)); + + clientList = ct::NET_CLIENT_LIST_STACKING (dpy); + + /* Check the client list to see that dock > w2 > w1 */ + ASSERT_EQ (clientList.size (), 3); + + std::list ::iterator it = clientList.begin (); + + EXPECT_EQ (*it++, w1); /* first should be the bottom normal window */ + EXPECT_EQ (*it++, w2); /* second should be the top normal window */ + EXPECT_EQ (*it++, dock); /* dock must always be on top */ +}