diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2018-05-08 19:48:10 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2018-05-09 02:03:43 +0200 |
commit | 2af7daa18467cc7c3f4f435c58cd19ee682f754f (patch) | |
tree | 14bbb90b8c4707d03cdc6833afe32ca087a76072 /test | |
parent | 711c2e49dd3c51877263148267344e2eb4ca7c0d (diff) |
extend property tester - add optional variants and color
Change-Id: Iad72470b5f1fc5405673d2d7781bc59002a3a44a
Reviewed-on: https://gerrit.libreoffice.org/53988
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/source/unoapi_property_testers.cxx | 50 |
1 files changed, 47 insertions, 3 deletions
diff --git a/test/source/unoapi_property_testers.cxx b/test/source/unoapi_property_testers.cxx index 421079a01093..5a74443a2550 100644 --- a/test/source/unoapi_property_testers.cxx +++ b/test/source/unoapi_property_testers.cxx @@ -9,10 +9,7 @@ #include <test/unoapi_property_testers.hxx> -#include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/uno/Any.hxx> -#include <com/sun/star/uno/Reference.hxx> - #include <cppunit/extensions/HelperMacros.h> using namespace css; @@ -39,6 +36,19 @@ void testBooleanProperty(uno::Reference<beans::XPropertySet> const& xPropertySet CPPUNIT_ASSERT_EQUAL_MESSAGE(msgSet.getStr(), !bPropertyGet, bPropertySet); } +void testBooleanOptionalProperty(uno::Reference<beans::XPropertySet> const& xPropertySet, + const OUString& rName) +{ + try + { + testBooleanProperty(xPropertySet, rName); + } + catch (css::beans::UnknownPropertyException /*ex*/) + { + // ignore if the property is unknown as it is optional + } +} + void testBooleanReadonlyProperty(uno::Reference<beans::XPropertySet> const& xPropertySet, const OUString& name) { @@ -175,6 +185,19 @@ void testShortReadonlyProperty(uno::Reference<beans::XPropertySet> const& xPrope CPPUNIT_ASSERT_EQUAL_MESSAGE(msgSet.getStr(), nPropertyGet, nPropertySet); } +void testStringOptionalProperty(uno::Reference<beans::XPropertySet> const& xPropertySet, + const OUString& rName, const OUString& rValue) +{ + try + { + testStringProperty(xPropertySet, rName, rValue); + } + catch (css::beans::UnknownPropertyException /*ex*/) + { + // ignore if the property is unknown as it is optional + } +} + void testStringProperty(uno::Reference<beans::XPropertySet> const& xPropertySet, const OUString& name, const OUString& rValue) { @@ -213,6 +236,27 @@ void testStringReadonlyProperty(uno::Reference<beans::XPropertySet> const& xProp OString msgSet = "Able to set PropertyValue: " + OUStringToOString(name, RTL_TEXTENCODING_UTF8); CPPUNIT_ASSERT_EQUAL_MESSAGE(msgSet.getStr(), sPropertyGet, sPropertySet); } + +void testColorProperty(uno::Reference<beans::XPropertySet> const& xPropertySet, + const OUString& name, const util::Color& rValue) +{ + uno::Any aNewValue; + + util::Color sPropertyGet; + util::Color 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 + = "Unable to set PropertyValue: " + OUStringToOString(name, RTL_TEXTENCODING_UTF8); + CPPUNIT_ASSERT_EQUAL_MESSAGE(msgSet.getStr(), rValue, sPropertySet); +} + } // namespace apitest /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ |