diff options
author | Jens Carl <j.carl43@gmx.de> | 2018-03-29 06:24:58 +0000 |
---|---|---|
committer | Jens Carl <j.carl43@gmx.de> | 2018-03-30 22:37:21 +0200 |
commit | 940f90f3da170b62379e9d1d33d4e6d690997026 (patch) | |
tree | 4d2c8162b511bc0e08c1e23f41d48cfe6c765f96 /test | |
parent | b16eb0d91f204823339a78b353dc8097aa8f7e56 (diff) |
Add UNO API property tester for common read-only properties.
Add UNO API property tester for read-only properties 'double', 'long',
'short' and 'string'.
Change-Id: I7177e133972058b0272a3cf8493521fbfbcade32
Reviewed-on: https://gerrit.libreoffice.org/52142
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 | 42 | ||||
-rw-r--r-- | test/source/unoapi_property_testers.cxx | 87 |
2 files changed, 123 insertions, 6 deletions
diff --git a/test/inc/unoapi_property_testers.hxx b/test/inc/unoapi_property_testers.hxx index 43e0f506c18f..616ab3bc0cb5 100644 --- a/test/inc/unoapi_property_testers.hxx +++ b/test/inc/unoapi_property_testers.hxx @@ -44,6 +44,16 @@ void OOO_DLLPUBLIC_TEST testDoubleProperty(css::uno::Reference<css::beans::XPropertySet>& xPropertySet, const OUString& name, const double& dValue = 42.0); +/** @brief Tester for read-only 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 +testDoubleReadonlyProperty(css::uno::Reference<css::beans::XPropertySet>& xPropertySet, + const OUString& name, const double& dValue = 42.0); + /** @brief Tester for property type 'long' of a @see com::sun::star::beans::XPropertySet. * * @param xPropertySet The property set, which contains the property to test against. @@ -54,6 +64,16 @@ void OOO_DLLPUBLIC_TEST testLongProperty(css::uno::Reference<css::beans::XPropertySet>& xPropertySet, const OUString& name, const sal_Int32& nValue = 42); +/** @brief Tester for read-only property type 'long' 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 +testLongReadonlyProperty(css::uno::Reference<css::beans::XPropertySet>& xPropertySet, + const OUString& name, const sal_Int32& nValue = 42); + /** @brief Tester for property type 'short' of a @see com::sun::star::beans::XPropertySet. * * @param xPropertySet The property set, which contains the property to test against. @@ -64,6 +84,16 @@ void OOO_DLLPUBLIC_TEST testShortProperty(css::uno::Reference<css::beans::XPropertySet>& xPropertySet, const OUString& name, const sal_Int16& nValue = 42); +/** @brief Tester for read-only property type 'short' 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 +testShortReadonlyProperty(css::uno::Reference<css::beans::XPropertySet>& xPropertySet, + const OUString& name, const sal_Int16& nValue = 42); + /** @brief Tester for property type 'string' of a @see com::sun::star::beans::XPropertySet. * * @param xPropertySet The property set, which contains the property to test against. @@ -73,7 +103,17 @@ testShortProperty(css::uno::Reference<css::beans::XPropertySet>& xPropertySet, c void OOO_DLLPUBLIC_TEST testStringProperty(css::uno::Reference<css::beans::XPropertySet>& xPropertySet, const OUString& name, const OUString& rValue); -} + +/** @brief Tester for read-only property type 'string' 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 rValue Value to use when setting a new value. + */ +void OOO_DLLPUBLIC_TEST +testStringReadonlyProperty(css::uno::Reference<css::beans::XPropertySet>& xPropertySet, + const OUString& name, const OUString& rValue); +} // namespace apitest #endif // INCLUDED_TEST_INC_UNOAPIPROPERTYTESTERS_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/test/source/unoapi_property_testers.cxx b/test/source/unoapi_property_testers.cxx index 14f4b3103e47..67589367ad99 100644 --- a/test/source/unoapi_property_testers.cxx +++ b/test/source/unoapi_property_testers.cxx @@ -63,19 +63,38 @@ void testDoubleProperty(uno::Reference<beans::XPropertySet>& xPropertySet, const { uno::Any aNewValue; - double nPropertyGet; - double nPropertySet; + double dPropertyGet; + double dPropertySet; OString msgGet = "Unable to get PropertyValue: " + OUStringToOString(name, RTL_TEXTENCODING_UTF8); - CPPUNIT_ASSERT_MESSAGE(msgGet.getStr(), xPropertySet->getPropertyValue(name) >>= nPropertyGet); + CPPUNIT_ASSERT_MESSAGE(msgGet.getStr(), xPropertySet->getPropertyValue(name) >>= dPropertyGet); aNewValue <<= dValue; xPropertySet->setPropertyValue(name, aNewValue); - CPPUNIT_ASSERT(xPropertySet->getPropertyValue(name) >>= nPropertySet); + CPPUNIT_ASSERT(xPropertySet->getPropertyValue(name) >>= dPropertySet); OString msgSet = "Unable to set PropertyValue: " + OUStringToOString(name, RTL_TEXTENCODING_UTF8); - CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE(msgSet.getStr(), dValue, nPropertySet, 0.5); + CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE(msgSet.getStr(), dValue, dPropertySet, 0.5); +} + +void testDoubleReadonlyProperty(uno::Reference<beans::XPropertySet>& xPropertySet, + const OUString& name, const double& dValue) +{ + uno::Any aNewValue; + + double dPropertyGet; + double dPropertySet; + + OString msgGet + = "Unable to get PropertyValue: " + OUStringToOString(name, RTL_TEXTENCODING_UTF8); + CPPUNIT_ASSERT_MESSAGE(msgGet.getStr(), xPropertySet->getPropertyValue(name) >>= dPropertyGet); + + aNewValue <<= dValue; + xPropertySet->setPropertyValue(name, aNewValue); + CPPUNIT_ASSERT(xPropertySet->getPropertyValue(name) >>= dPropertySet); + OString msgSet = "Able to set PropertyValue: " + OUStringToOString(name, RTL_TEXTENCODING_UTF8); + CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE(msgSet.getStr(), dPropertyGet, dPropertySet, 0.5); } void testLongProperty(uno::Reference<beans::XPropertySet>& xPropertySet, const OUString& name, @@ -98,6 +117,25 @@ void testLongProperty(uno::Reference<beans::XPropertySet>& xPropertySet, const O CPPUNIT_ASSERT_EQUAL_MESSAGE(msgSet.getStr(), nValue, nPropertySet); } +void testLongReadonlyProperty(uno::Reference<beans::XPropertySet>& xPropertySet, + const OUString& name, const sal_Int32& nValue) +{ + uno::Any aNewValue; + + sal_Int32 nPropertyGet; + sal_Int32 nPropertySet; + + OString msgGet + = "Unable to get PropertyValue: " + OUStringToOString(name, RTL_TEXTENCODING_UTF8); + CPPUNIT_ASSERT_MESSAGE(msgGet.getStr(), xPropertySet->getPropertyValue(name) >>= nPropertyGet); + + aNewValue <<= nValue; + xPropertySet->setPropertyValue(name, aNewValue); + CPPUNIT_ASSERT(xPropertySet->getPropertyValue(name) >>= nPropertySet); + OString msgSet = "Able to set PropertyValue: " + OUStringToOString(name, RTL_TEXTENCODING_UTF8); + CPPUNIT_ASSERT_EQUAL_MESSAGE(msgSet.getStr(), nPropertyGet, nPropertySet); +} + void testShortProperty(uno::Reference<beans::XPropertySet>& xPropertySet, const OUString& name, const sal_Int16& nValue) { @@ -118,6 +156,25 @@ void testShortProperty(uno::Reference<beans::XPropertySet>& xPropertySet, const CPPUNIT_ASSERT_EQUAL_MESSAGE(msgSet.getStr(), nValue, nPropertySet); } +void testShortReadonlyProperty(uno::Reference<beans::XPropertySet>& xPropertySet, + const OUString& name, const sal_Int16& nValue) +{ + uno::Any aNewValue; + + sal_Int16 nPropertyGet; + sal_Int16 nPropertySet; + + OString msgGet + = "Unable to get PropertyValue: " + OUStringToOString(name, RTL_TEXTENCODING_UTF8); + CPPUNIT_ASSERT_MESSAGE(msgGet.getStr(), xPropertySet->getPropertyValue(name) >>= nPropertyGet); + + aNewValue <<= nValue; + xPropertySet->setPropertyValue(name, aNewValue); + CPPUNIT_ASSERT(xPropertySet->getPropertyValue(name) >>= nPropertySet); + OString msgSet = "Able to set PropertyValue: " + OUStringToOString(name, RTL_TEXTENCODING_UTF8); + CPPUNIT_ASSERT_EQUAL_MESSAGE(msgSet.getStr(), nPropertyGet, nPropertySet); +} + void testStringProperty(uno::Reference<beans::XPropertySet>& xPropertySet, const OUString& name, const OUString& rValue) { @@ -137,5 +194,25 @@ void testStringProperty(uno::Reference<beans::XPropertySet>& xPropertySet, const = "Unable to set PropertyValue: " + OUStringToOString(name, RTL_TEXTENCODING_UTF8); CPPUNIT_ASSERT_EQUAL_MESSAGE(msgSet.getStr(), rValue, sPropertySet); } + +void testStringReadonlyProperty(uno::Reference<beans::XPropertySet>& xPropertySet, + const OUString& name, const OUString& rValue) +{ + uno::Any aNewValue; + + OUString sPropertyGet; + OUString sPropertySet; + + OString msgGet + = "Unable to get PropertyValue: " + OUStringToOString(name, RTL_TEXTENCODING_UTF8); + CPPUNIT_ASSERT_MESSAGE(msgGet.getStr(), xPropertySet->getPropertyValue(name) >>= sPropertyGet); + + aNewValue <<= rValue; + xPropertySet->setPropertyValue(name, aNewValue); + CPPUNIT_ASSERT(xPropertySet->getPropertyValue(name) >>= sPropertySet); + OString msgSet = "Able to set PropertyValue: " + OUStringToOString(name, RTL_TEXTENCODING_UTF8); + CPPUNIT_ASSERT_EQUAL_MESSAGE(msgSet.getStr(), sPropertyGet, sPropertySet); } +} // namespace apitest + /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ |