diff options
author | Jens Carl <j.carl43@gmx.de> | 2018-03-22 04:15:34 +0000 |
---|---|---|
committer | Jens Carl <j.carl43@gmx.de> | 2018-03-22 16:53:15 +0100 |
commit | 3228251663fa866c3cc84bc19d64f77f13e99eef (patch) | |
tree | 295d6e59da04424b287e5911df4841c45dc8fd11 /test | |
parent | d8b7119859897fa98b6588e2426a13fbd51cf3dd (diff) |
Add UNO API property tester for double and read-only boolean.
Change-Id: I85ec413aa34bdc563294dc71520742515849fbca
Reviewed-on: https://gerrit.libreoffice.org/51722
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Jens Carl <j.carl43@gmx.de>
Diffstat (limited to 'test')
-rw-r--r-- | test/inc/unoapi_property_testers.hxx | 18 | ||||
-rw-r--r-- | test/source/unoapi_property_testers.cxx | 39 |
2 files changed, 57 insertions, 0 deletions
diff --git a/test/inc/unoapi_property_testers.hxx b/test/inc/unoapi_property_testers.hxx index 1449df16b719..67f2fc6b5f18 100644 --- a/test/inc/unoapi_property_testers.hxx +++ b/test/inc/unoapi_property_testers.hxx @@ -26,6 +26,24 @@ namespace apitest void OOO_DLLPUBLIC_TEST testBooleanProperty( css::uno::Reference<css::beans::XPropertySet>& xPropertySet, const OUString& name); +/** @brief Tester for test read-only property type 'boolean' of a @see com::sun::star::beans::XPropertySet. + * + * @param xPropertySet The property set, which contains the property to test against. + * @param name Name of property to test. + */ +void OOO_DLLPUBLIC_TEST testBooleanReadonlyProperty( + css::uno::Reference<css::beans::XPropertySet>& xPropertySet, const OUString& name); + +/** @brief Tester for test property type 'double' of a @see com::sun::star::beans::XPropertySet. + * + * @param xPropertySet The property set, which contains the property to test against. + * @param name Name of property to test. + * @param nValue Value to use when setting a new value. + */ +void OOO_DLLPUBLIC_TEST +testDoubleProperty(css::uno::Reference<css::beans::XPropertySet>& xPropertySet, + const OUString& name, const double& dValue = 42.0); + /** @brief Tester for test property type 'long' of a @see com::sun::star::beans::XPropertySet. * * @param xPropertySet The property set, which contains the property to test against. diff --git a/test/source/unoapi_property_testers.cxx b/test/source/unoapi_property_testers.cxx index 756321a7e317..14f4b3103e47 100644 --- a/test/source/unoapi_property_testers.cxx +++ b/test/source/unoapi_property_testers.cxx @@ -39,6 +39,45 @@ void testBooleanProperty(uno::Reference<beans::XPropertySet>& xPropertySet, cons CPPUNIT_ASSERT_EQUAL_MESSAGE(msgSet.getStr(), !bPropertyGet, bPropertySet); } +void testBooleanReadonlyProperty(uno::Reference<beans::XPropertySet>& xPropertySet, + const OUString& name) +{ + uno::Any aNewValue; + + bool bPropertyGet = false; + bool bPropertySet = false; + + OString msgGet + = "Unable to get PropertyValue: " + OUStringToOString(name, RTL_TEXTENCODING_UTF8); + CPPUNIT_ASSERT_MESSAGE(msgGet.getStr(), xPropertySet->getPropertyValue(name) >>= bPropertyGet); + + aNewValue <<= !bPropertyGet; + xPropertySet->setPropertyValue(name, aNewValue); + CPPUNIT_ASSERT(xPropertySet->getPropertyValue(name) >>= bPropertySet); + OString msgSet = "Able to set PropertyValue: " + OUStringToOString(name, RTL_TEXTENCODING_UTF8); + CPPUNIT_ASSERT_EQUAL_MESSAGE(msgSet.getStr(), bPropertyGet, bPropertySet); +} + +void testDoubleProperty(uno::Reference<beans::XPropertySet>& xPropertySet, const OUString& name, + const double& dValue) +{ + uno::Any aNewValue; + + double nPropertyGet; + double nPropertySet; + + OString msgGet + = "Unable to get PropertyValue: " + OUStringToOString(name, RTL_TEXTENCODING_UTF8); + CPPUNIT_ASSERT_MESSAGE(msgGet.getStr(), xPropertySet->getPropertyValue(name) >>= nPropertyGet); + + aNewValue <<= dValue; + xPropertySet->setPropertyValue(name, aNewValue); + CPPUNIT_ASSERT(xPropertySet->getPropertyValue(name) >>= nPropertySet); + OString msgSet + = "Unable to set PropertyValue: " + OUStringToOString(name, RTL_TEXTENCODING_UTF8); + CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE(msgSet.getStr(), dValue, nPropertySet, 0.5); +} + void testLongProperty(uno::Reference<beans::XPropertySet>& xPropertySet, const OUString& name, const sal_Int32& nValue) { |