From ccf8bdcf929e842ef42ae968e4f0532282357277 Mon Sep 17 00:00:00 2001 From: Michael Meeks Date: Mon, 5 Oct 2015 18:08:02 +0100 Subject: Create a wrapper to make listening for configmgr changes easy. Change-Id: Ib58d04f9e046e604b24e0e338796a7a60aa1d6fd Reviewed-on: https://gerrit.libreoffice.org/19253 Tested-by: Jenkins Reviewed-by: Michael Meeks --- configmgr/CppunitTest_configmgr_unit.mk | 4 +++ configmgr/qa/unit/test.cxx | 47 +++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) (limited to 'configmgr') diff --git a/configmgr/CppunitTest_configmgr_unit.mk b/configmgr/CppunitTest_configmgr_unit.mk index e8bddc24bee8..ca9653fd126e 100644 --- a/configmgr/CppunitTest_configmgr_unit.mk +++ b/configmgr/CppunitTest_configmgr_unit.mk @@ -21,6 +21,10 @@ $(eval $(call gb_CppunitTest_use_library_objects,configmgr_unit,configmgr)) $(eval $(call gb_CppunitTest_use_sdk_api,configmgr_unit,)) +$(eval $(call gb_CppunitTest_use_custom_headers,configmgr_unit,\ + officecfg/registry \ +)) + $(eval $(call gb_CppunitTest_use_libraries,configmgr_unit, \ comphelper \ cppu \ diff --git a/configmgr/qa/unit/test.cxx b/configmgr/qa/unit/test.cxx index a9f609bc3677..6985cab57fde 100644 --- a/configmgr/qa/unit/test.cxx +++ b/configmgr/qa/unit/test.cxx @@ -55,7 +55,11 @@ #include #include #include +#include +#include +#include #include +#include namespace { @@ -70,6 +74,7 @@ public: void testSetSetMemberName(); void testInsertSetMember(); void testReadCommands(); + void testListener(); #if 0 void testThreads(); #endif @@ -98,6 +103,7 @@ public: CPPUNIT_TEST(testSetSetMemberName); CPPUNIT_TEST(testInsertSetMember); CPPUNIT_TEST(testReadCommands); + CPPUNIT_TEST(testListener); #if 0 CPPUNIT_TEST(testThreads); #endif @@ -356,6 +362,47 @@ void Test::testReadCommands() access, css::uno::UNO_QUERY_THROW)->dispose(); } +void Test::testListener() +{ + OUString aRandomPath = "/org.openoffice.Office.Math/View"; + + // test with no props. + { + rtl::Reference xListener( + new comphelper::ConfigurationListener(aRandomPath)); + xListener->dispose(); + } + + // test some changes + { + rtl::Reference xListener( + new comphelper::ConfigurationListener(aRandomPath)); + + comphelper::ConfigurationListenerProperty aSetting(xListener, "AutoRedraw"); + CPPUNIT_ASSERT_MESSAGE("check AutoRedraw defaults to true", aSetting.get()); + + // set to false + { + std::shared_ptr< comphelper::ConfigurationChanges > xChanges( + comphelper::ConfigurationChanges::create()); + officecfg::Office::Math::View::AutoRedraw::set(false, xChanges); + xChanges->commit(); + } + CPPUNIT_ASSERT_MESSAGE("listener failed to trigger", !aSetting.get()); + + // set to true + { + std::shared_ptr< comphelper::ConfigurationChanges > xChanges( + comphelper::ConfigurationChanges::create()); + officecfg::Office::Math::View::AutoRedraw::set(true, xChanges); + xChanges->commit(); + } + CPPUNIT_ASSERT_MESSAGE("listener failed to trigger", aSetting.get()); + + xListener->dispose(); + } +} + void Test::testRecursive() { bool destroyed = false; -- cgit v1.2.3