[Libreoffice-commits] core.git: test/inc test/source

Jens Carl j.carl43 at gmx.de
Thu Mar 22 15:53:38 UTC 2018


 test/inc/unoapi_property_testers.hxx    |   18 ++++++++++++++
 test/source/unoapi_property_testers.cxx |   39 ++++++++++++++++++++++++++++++++
 2 files changed, 57 insertions(+)

New commits:
commit 3228251663fa866c3cc84bc19d64f77f13e99eef
Author: Jens Carl <j.carl43 at gmx.de>
Date:   Thu Mar 22 04:15:34 2018 +0000

    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 at libreoffice.org>
    Reviewed-by: Jens Carl <j.carl43 at gmx.de>

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)
 {


More information about the Libreoffice-commits mailing list