[Libreoffice-commits] core.git: include/test test/source
Tomaž Vajngerl
tomaz.vajngerl at collabora.co.uk
Wed May 9 00:04:06 UTC 2018
include/test/unoapi_property_testers.hxx | 34 +++++++++++++++++++++
test/source/unoapi_property_testers.cxx | 50 +++++++++++++++++++++++++++++--
2 files changed, 81 insertions(+), 3 deletions(-)
New commits:
commit 2af7daa18467cc7c3f4f435c58cd19ee682f754f
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date: Tue May 8 19:48:10 2018 +0900
extend property tester - add optional variants and color
Change-Id: Iad72470b5f1fc5405673d2d7781bc59002a3a44a
Reviewed-on: https://gerrit.libreoffice.org/53988
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
diff --git a/include/test/unoapi_property_testers.hxx b/include/test/unoapi_property_testers.hxx
index fce19763e21f..f45b772b86e3 100644
--- a/include/test/unoapi_property_testers.hxx
+++ b/include/test/unoapi_property_testers.hxx
@@ -12,6 +12,7 @@
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/util/Color.hpp>
#include <sal/config.h>
#include <test/testdllapi.hxx>
@@ -26,6 +27,16 @@ namespace apitest
void OOO_DLLPUBLIC_TEST testBooleanProperty(
css::uno::Reference<css::beans::XPropertySet> const& xPropertySet, const OUString& name);
+/** @brief Tester for optional property type 'boolean' of a @see com::sun::star::beans::XPropertySet.
+ *
+ * Pass the test also if the property doesn't exists (throws a com::sun::star::beans::UnknownPropertyException)
+ *
+ * @param xPropertySet The property set, which contains the property to test against.
+ * @param name Name of property to test.
+ */
+void OOO_DLLPUBLIC_TEST testBooleanOptionalProperty(
+ css::uno::Reference<css::beans::XPropertySet> const& xPropertySet, const OUString& name);
+
/** @brief Tester for 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.
@@ -104,6 +115,18 @@ void OOO_DLLPUBLIC_TEST
testStringProperty(css::uno::Reference<css::beans::XPropertySet> const& xPropertySet,
const OUString& name, const OUString& rValue);
+/** @brief Tester for optional property type 'string' of a @see com::sun::star::beans::XPropertySet.
+ *
+ * Pass the test also if the property doesn't exists (throws a com::sun::star::beans::UnknownPropertyException)
+ *
+ * @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
+testStringOptionalProperty(css::uno::Reference<css::beans::XPropertySet> const& xPropertySet,
+ const OUString& name, const OUString& rValue = OUString("StringValue"));
+
/** @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.
@@ -113,6 +136,17 @@ testStringProperty(css::uno::Reference<css::beans::XPropertySet> const& xPropert
void OOO_DLLPUBLIC_TEST
testStringReadonlyProperty(css::uno::Reference<css::beans::XPropertySet> const& xPropertySet,
const OUString& name, const OUString& rValue);
+
+/** @brief Tester for property type com::sun::star::util::Color 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 testColorProperty(
+ css::uno::Reference<css::beans::XPropertySet> const& xPropertySet, const OUString& name,
+ const css::util::Color& rValue = css::util::Color(0x12345678));
+
} // namespace apitest
#endif // INCLUDED_TEST_INC_UNOAPIPROPERTYTESTERS_HXX
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: */
More information about the Libreoffice-commits
mailing list