[Libreoffice-commits] core.git: include/test sw/CppunitTest_sw_apitests.mk sw/qa test/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu Jan 10 19:11:45 UTC 2019


 include/test/unoapi_property_testers.hxx |   20 ++++
 sw/CppunitTest_sw_apitests.mk            |    1 
 sw/qa/api/ApiTestBase.hxx                |   29 ++++++
 sw/qa/api/DocumentSettings.cxx           |   99 +++++++++++++++++++++
 sw/qa/api/DocumentSettingsTest.hxx       |   49 ++++++++++
 sw/qa/api/PrinterSettingsTest.hxx        |   81 +++++++++++++++++
 sw/qa/api/SettingsTest.hxx               |  140 +++++++++++++++++++++++++++++++
 test/source/unoapi_property_testers.cxx  |   26 +++++
 8 files changed, 445 insertions(+)

New commits:
commit 4631c5d4c129b826df1cc29af1a558149b823667
Author:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Sun Jan 6 21:59:21 2019 +0100
Commit:     Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Thu Jan 10 20:11:21 2019 +0100

    DocumentSettings Writer UNO API test (converted from Java test)
    
    Change-Id: Id9a691b1aae62f37ef7f865c5ed015b7c6a13976
    Reviewed-on: https://gerrit.libreoffice.org/65909
    Tested-by: Jenkins
    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 f45b772b86e3..4d83e8179ce4 100644
--- a/include/test/unoapi_property_testers.hxx
+++ b/include/test/unoapi_property_testers.hxx
@@ -75,6 +75,16 @@ void OOO_DLLPUBLIC_TEST
 testLongProperty(css::uno::Reference<css::beans::XPropertySet> const& xPropertySet,
                  const OUString& name, const sal_Int32& nValue = 42);
 
+/** @brief Tester for optional 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
+testLongOptionalProperty(css::uno::Reference<css::beans::XPropertySet> const& 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.
@@ -95,6 +105,16 @@ void OOO_DLLPUBLIC_TEST
 testShortProperty(css::uno::Reference<css::beans::XPropertySet> const& xPropertySet,
                   const OUString& name, const sal_Int16& nValue = 42);
 
+/** @brief Tester for optional 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
+testShortOptionalProperty(css::uno::Reference<css::beans::XPropertySet> const& 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.
diff --git a/sw/CppunitTest_sw_apitests.mk b/sw/CppunitTest_sw_apitests.mk
index fa0fc26e7d20..595a1940e27f 100644
--- a/sw/CppunitTest_sw_apitests.mk
+++ b/sw/CppunitTest_sw_apitests.mk
@@ -15,6 +15,7 @@ $(eval $(call gb_CppunitTest_use_external,sw_apitests,boost_headers))
 
 $(eval $(call gb_CppunitTest_add_exception_objects,sw_apitests, \
     sw/qa/api/SwXDocumentIndex \
+    sw/qa/api/DocumentSettings \
 ))
 
 $(eval $(call gb_CppunitTest_use_libraries,sw_apitests, \
diff --git a/sw/qa/api/ApiTestBase.hxx b/sw/qa/api/ApiTestBase.hxx
index 76871111ff3f..fc25bc3122be 100644
--- a/sw/qa/api/ApiTestBase.hxx
+++ b/sw/qa/api/ApiTestBase.hxx
@@ -11,6 +11,9 @@
 #define INCLUDED_SW_QA_CORE_APITESTBASE_HXX
 
 #include <com/sun/star/uno/XInterface.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/XPropertySetInfo.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
 
 #include <unordered_map>
 
@@ -19,6 +22,32 @@ namespace apitest
 class ApiTestBase
 {
 protected:
+    static bool extstsProperty(css::uno::Reference<css::beans::XPropertySet> const& rxPropertySet,
+                               OUString const& rPropertyName)
+    {
+        css::uno::Reference<css::beans::XPropertySetInfo> xPropertySetInfo(
+            rxPropertySet->getPropertySetInfo());
+        return xPropertySetInfo->hasPropertyByName(rPropertyName);
+    }
+
+    static bool
+    isPropertyReadOnly(css::uno::Reference<css::beans::XPropertySet> const& rxPropertySet,
+                       OUString const& rPropertyName)
+    {
+        css::uno::Reference<css::beans::XPropertySetInfo> xPropertySetInfo(
+            rxPropertySet->getPropertySetInfo());
+        css::uno::Sequence<css::beans::Property> xProperties = xPropertySetInfo->getProperties();
+
+        for (auto const& rProperty : xProperties)
+        {
+            if (rProperty.Name == rPropertyName)
+                return (rProperty.Attributes & com::sun::star::beans::PropertyAttribute::READONLY)
+                       != 0;
+        }
+
+        return false;
+    }
+
     virtual ~ApiTestBase() {}
 
     virtual std::unordered_map<OUString, css::uno::Reference<css::uno::XInterface>> init() = 0;
diff --git a/sw/qa/api/DocumentSettings.cxx b/sw/qa/api/DocumentSettings.cxx
new file mode 100644
index 000000000000..901730d0d65d
--- /dev/null
+++ b/sw/qa/api/DocumentSettings.cxx
@@ -0,0 +1,99 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/bootstrapfixture.hxx>
+#include <unotest/macros_test.hxx>
+
+#include <com/sun/star/frame/Desktop.hpp>
+#include <com/sun/star/frame/DispatchHelper.hpp>
+
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+
+#include <com/sun/star/text/XTextDocument.hpp>
+#include <com/sun/star/uno/XInterface.hpp>
+
+#include <comphelper/processfactory.hxx>
+
+#include "DocumentSettingsTest.hxx"
+#include "SettingsTest.hxx"
+#include "PrinterSettingsTest.hxx"
+
+using namespace css;
+
+namespace
+{
+/**
+ * Test for Java API test of file com.sun.star.comp.Writer.DocumentSettings.csv
+ */
+class DocumentSettingsTest : public test::BootstrapFixture,
+                             public unotest::MacrosTest,
+                             public apitest::DocumentSettingsTest,
+                             public apitest::SettingsTest,
+                             public apitest::PrinterSettingsTest
+{
+private:
+    uno::Reference<uno::XComponentContext> mxComponentContext;
+    uno::Reference<lang::XComponent> mxComponent;
+
+public:
+    virtual void setUp() override;
+    virtual void tearDown() override;
+
+    std::unordered_map<OUString, uno::Reference<uno::XInterface>> init() override;
+
+    CPPUNIT_TEST_SUITE(DocumentSettingsTest);
+    CPPUNIT_TEST(testDocumentSettingsProperties);
+    CPPUNIT_TEST(testSettingsProperties);
+    CPPUNIT_TEST(testPrinterSettingsProperties);
+    CPPUNIT_TEST_SUITE_END();
+};
+
+void DocumentSettingsTest::setUp()
+{
+    test::BootstrapFixture::setUp();
+
+    mxComponentContext.set(comphelper::getComponentContext(getMultiServiceFactory()));
+    mxDesktop.set(frame::Desktop::create(mxComponentContext));
+}
+
+void DocumentSettingsTest::tearDown()
+{
+    if (mxComponent.is())
+        mxComponent->dispose();
+
+    test::BootstrapFixture::tearDown();
+}
+
+std::unordered_map<OUString, uno::Reference<uno::XInterface>> DocumentSettingsTest::init()
+{
+    std::unordered_map<OUString, uno::Reference<uno::XInterface>> map;
+
+    mxComponent = loadFromDesktop("private:factory/swriter", "com.sun.star.text.TextDocument");
+    CPPUNIT_ASSERT(mxComponent.is());
+
+    uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY_THROW);
+    uno::Reference<lang::XMultiServiceFactory> xFactory(xTextDocument, uno::UNO_QUERY_THROW);
+
+    uno::Reference<uno::XInterface> xDocumentSettings(
+        xFactory->createInstance("com.sun.star.text.DocumentSettings"), uno::UNO_QUERY_THROW);
+
+    // DocumentSettings
+    map["text::DocumentSettings"] = xDocumentSettings;
+    // Settings
+    map["document::Settings"] = xDocumentSettings;
+    // Printer Settings
+    map["text::PrinterSettings"] = xDocumentSettings;
+    return map;
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(DocumentSettingsTest);
+
+} // end anonymous namespace
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/api/DocumentSettingsTest.hxx b/sw/qa/api/DocumentSettingsTest.hxx
new file mode 100644
index 000000000000..35508e0d74a6
--- /dev/null
+++ b/sw/qa/api/DocumentSettingsTest.hxx
@@ -0,0 +1,49 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_SW_QA_API_DOCUMENTSETTINGSTEST_HXX
+#define INCLUDED_SW_QA_API_DOCUMENTSETTINGSTEST_HXX
+
+#include "ApiTestBase.hxx"
+
+#include <cppunit/TestAssert.h>
+#include <test/unoapi_property_testers.hxx>
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+
+namespace apitest
+{
+class DocumentSettingsTest : public ApiTestBase
+{
+public:
+    void testDocumentSettingsProperties()
+    {
+        auto map = init();
+
+        css::uno::Reference<css::beans::XPropertySet> xDocumentSettings(
+            map["text::DocumentSettings"], css::uno::UNO_QUERY_THROW);
+
+        testBooleanOptionalProperty(xDocumentSettings, "ChartAutoUpdate");
+        testBooleanOptionalProperty(xDocumentSettings, "AddParaTableSpacing");
+        testBooleanOptionalProperty(xDocumentSettings, "AddParaTableSpacingAtStart");
+        testBooleanOptionalProperty(xDocumentSettings, "AlignTabStopPosition");
+        testBooleanOptionalProperty(xDocumentSettings, "SaveGlobalDocumentLinks");
+        testBooleanOptionalProperty(xDocumentSettings, "IsLabelDocument");
+        testBooleanOptionalProperty(xDocumentSettings, "UseFormerLineSpacing");
+        testBooleanOptionalProperty(xDocumentSettings, "AddParaSpacingToTableCells");
+        testBooleanOptionalProperty(xDocumentSettings, "UseFormerObjectPositioning");
+        testBooleanOptionalProperty(xDocumentSettings, "ConsiderTextWrapOnObjPos");
+        testBooleanOptionalProperty(xDocumentSettings, "MathBaselineAlignment");
+    }
+};
+} // end namespace apitest
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/api/PrinterSettingsTest.hxx b/sw/qa/api/PrinterSettingsTest.hxx
new file mode 100644
index 000000000000..7e8e157af0b2
--- /dev/null
+++ b/sw/qa/api/PrinterSettingsTest.hxx
@@ -0,0 +1,81 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_SW_QA_API_PRINTERSETTINGSTEST_HXX
+#define INCLUDED_SW_QA_API_PRINTERSETTINGSTEST_HXX
+
+#include "ApiTestBase.hxx"
+
+#include <cppunit/TestAssert.h>
+#include <test/unoapi_property_testers.hxx>
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/text/NotePrintMode.hpp>
+
+namespace apitest
+{
+class PrinterSettingsTest : public ApiTestBase
+{
+    static void
+    testPrintAnnotationMode(css::uno::Reference<css::beans::XPropertySet> const& rxPrinterSettings)
+    {
+        const OUString rPropertyName = "PrintAnnotationMode";
+
+        // This property is not optional but it's not set in some cases
+        if (!extstsProperty(rxPrinterSettings, rPropertyName))
+            return;
+
+        /*css::text::NotePrintMode aNotePrintMode_Get;
+
+        CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue",
+                               rxPrinterSettings->getPropertyValue(rPropertyName)
+                               >>= aNotePrintMode_Get);
+
+        css::text::NotePrintMode aNotePrintMode_Set;
+        css::uno::Any aNewValue;
+        aNewValue <<= css::text::NotePrintMode_ONLY;
+        rxPrinterSettings->setPropertyValue(rPropertyName, aNewValue);
+
+        CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue",
+                               rxPrinterSettings->getPropertyValue(rPropertyName)
+                               >>= aNotePrintMode_Set);
+        CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue", css::text::NotePrintMode_ONLY,
+                                     aNotePrintMode_Set);*/
+    }
+
+public:
+    void testPrinterSettingsProperties()
+    {
+        auto map = init();
+
+        css::uno::Reference<css::beans::XPropertySet> xPrinterSettings(map["text::PrinterSettings"],
+                                                                       css::uno::UNO_QUERY_THROW);
+
+        testBooleanProperty(xPrinterSettings, "PrintGraphics");
+        testBooleanProperty(xPrinterSettings, "PrintTables");
+        testBooleanProperty(xPrinterSettings, "PrintDrawings");
+        testBooleanProperty(xPrinterSettings, "PrintLeftPages");
+        testBooleanProperty(xPrinterSettings, "PrintRightPages");
+        testBooleanProperty(xPrinterSettings, "PrintControls");
+        testBooleanProperty(xPrinterSettings, "PrintReversed");
+        testBooleanProperty(xPrinterSettings, "PrintControls");
+        testStringProperty(xPrinterSettings, "PrintFaxName", "FaxName");
+        testPrintAnnotationMode(
+            xPrinterSettings); // it's not set in this case but it's not optional - bug?
+        testBooleanProperty(xPrinterSettings, "PrintProspect");
+        testBooleanProperty(xPrinterSettings, "PrintPageBackground");
+        testBooleanProperty(xPrinterSettings, "PrintBlackFonts");
+        testBooleanOptionalProperty(xPrinterSettings, "PrintEmptyPages");
+    }
+};
+} // end namespace apitest
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/api/SettingsTest.hxx b/sw/qa/api/SettingsTest.hxx
new file mode 100644
index 000000000000..73cfcfddecf2
--- /dev/null
+++ b/sw/qa/api/SettingsTest.hxx
@@ -0,0 +1,140 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_SW_QA_API_SETTINGSTEST_HXX
+#define INCLUDED_SW_QA_API_SETTINGSTEST_HXX
+
+#include "ApiTestBase.hxx"
+
+#include <cppunit/TestAssert.h>
+#include <test/unoapi_property_testers.hxx>
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/i18n/XForbiddenCharacters.hpp>
+
+namespace apitest
+{
+class SettingsTest : public ApiTestBase
+{
+    // [property] string PrinterName;
+    static void testPrinterName(css::uno::Reference<css::beans::XPropertySet> const& rxSettings)
+    {
+        const OUString rPropertyName("PrinterName");
+
+        if (!extstsProperty(rxSettings, rPropertyName))
+            return; // Property is sometimes not set - bug? it is not defined as optional
+
+        OUString aPrinterName_Get;
+
+        CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue",
+                               rxSettings->getPropertyValue(rPropertyName) >>= aPrinterName_Get);
+
+        OUString aPrinterName_Set;
+        css::uno::Any aNewValue;
+        aNewValue <<= aPrinterName_Get;
+        rxSettings->setPropertyValue(rPropertyName, aNewValue);
+
+        CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue",
+                               rxSettings->getPropertyValue(rPropertyName) >>= aPrinterName_Set);
+        CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue", aPrinterName_Get,
+                                     aPrinterName_Set);
+    }
+
+    // [optional, property] short PrinterIndependentLayout;
+    static void
+    testPrinterIndependentLayout(css::uno::Reference<css::beans::XPropertySet> const& rxSettings)
+    {
+        const OUString rPropertyName("PrinterIndependentLayout");
+
+        if (!extstsProperty(rxSettings, rPropertyName))
+            return; // Property is optional
+
+        sal_Int16 aValue_Get;
+
+        CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue",
+                               rxSettings->getPropertyValue(rPropertyName) >>= aValue_Get);
+
+        sal_Int16 aValue_New;
+        aValue_New = (aValue_Get == 1 ? 3 : 1);
+        rxSettings->setPropertyValue(rPropertyName, css::uno::Any(aValue_New));
+
+        sal_Int16 aValue_Set;
+
+        CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue",
+                               rxSettings->getPropertyValue(rPropertyName) >>= aValue_Set);
+        CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue", aValue_New, aValue_Set);
+    }
+
+    // [optional, property] com::sun::star::i18n::XForbiddenCharacters ForbiddenCharacters;
+    static void
+    testForbiddenCharacters(css::uno::Reference<css::beans::XPropertySet> const& rxSettings)
+    {
+        const OUString rPropertyName("ForbiddenCharacters");
+
+        if (!extstsProperty(rxSettings, rPropertyName))
+            return; // Property is optional
+
+        CPPUNIT_ASSERT_MESSAGE("Property is read-only but shouldn't be",
+                               !isPropertyReadOnly(rxSettings, rPropertyName));
+
+        css::uno::Reference<css::i18n::XForbiddenCharacters> aValue_Get;
+
+        CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue",
+                               rxSettings->getPropertyValue(rPropertyName) >>= aValue_Get);
+        CPPUNIT_ASSERT_MESSAGE("Empty reference to XForbiddenCharacters", aValue_Get.is());
+    }
+
+public:
+    void testSettingsProperties()
+    {
+        auto map = init();
+
+        css::uno::Reference<css::beans::XPropertySet> xSettings(map["document::Settings"],
+                                                                css::uno::UNO_QUERY_THROW);
+
+        testForbiddenCharacters(xSettings);
+        //testShortOptionalProperty(xSettings, "LinkUpdateMode");
+        testPrinterName(xSettings);
+        // [property] sequence< byte > PrinterSetup;
+        testBooleanOptionalProperty(xSettings, "IsKernAsianPunctuation");
+        //testShortOptionalProperty(xSettings, "CharacterCompressionType");
+        testBooleanOptionalProperty(xSettings, "ApplyUserData");
+        testBooleanOptionalProperty(xSettings, "SaveVersionOnClose");
+        testBooleanOptionalProperty(xSettings, "UpdateFromTemplate");
+        testBooleanOptionalProperty(xSettings, "FieldAutoUpdate");
+        testStringOptionalProperty(xSettings, "CurrentDatabaseDataSource");
+        testStringOptionalProperty(xSettings, "CurrentDatabaseCommand");
+        testLongOptionalProperty(xSettings, "CurrentDatabaseCommandType");
+        testLongOptionalProperty(xSettings, "DefaultTabStop");
+        testBooleanOptionalProperty(xSettings, "IsPrintBooklet");
+        testBooleanOptionalProperty(xSettings, "IsPrintBookletFront");
+        testBooleanOptionalProperty(xSettings, "IsPrintBookletBack");
+        testLongOptionalProperty(xSettings, "PrintQuality");
+        testStringOptionalProperty(xSettings, "ColorTableURL");
+        testStringOptionalProperty(xSettings, "DashTableURL");
+        testStringOptionalProperty(xSettings, "LineEndTableURL");
+        testStringOptionalProperty(xSettings, "HatchTableURL");
+        testStringOptionalProperty(xSettings, "GradientTableURL");
+        testStringOptionalProperty(xSettings, "BitmapTableURL");
+        testBooleanOptionalProperty(xSettings, "AutoCalculate");
+        testPrinterIndependentLayout(xSettings);
+        testBooleanOptionalProperty(xSettings, "AddExternalLeading");
+        testBooleanOptionalProperty(xSettings, "EmbedFonts");
+        testBooleanOptionalProperty(xSettings, "EmbedSystemFonts");
+        testBooleanOptionalProperty(xSettings, "EmbedOnlyUsedFonts");
+        testBooleanOptionalProperty(xSettings, "EmbedLatinScriptFonts");
+        testBooleanOptionalProperty(xSettings, "EmbedAsianScriptFonts");
+        testBooleanOptionalProperty(xSettings, "EmbedComplexScriptFonts");
+    }
+};
+} // end namespace apitest
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/test/source/unoapi_property_testers.cxx b/test/source/unoapi_property_testers.cxx
index 75eed2c9a70b..823972d25afd 100644
--- a/test/source/unoapi_property_testers.cxx
+++ b/test/source/unoapi_property_testers.cxx
@@ -127,6 +127,19 @@ void testLongProperty(uno::Reference<beans::XPropertySet> const& xPropertySet, c
     CPPUNIT_ASSERT_EQUAL_MESSAGE(msgSet.getStr(), nValue, nPropertySet);
 }
 
+void testLongOptionalProperty(uno::Reference<beans::XPropertySet> const& xPropertySet,
+                              const OUString& rName, const sal_Int32& rValue)
+{
+    try
+    {
+        testLongProperty(xPropertySet, rName, rValue);
+    }
+    catch (const css::beans::UnknownPropertyException& /*ex*/)
+    {
+        // ignore if the property is unknown as it is optional
+    }
+}
+
 void testLongReadonlyProperty(uno::Reference<beans::XPropertySet> const& xPropertySet,
                               const OUString& name, const sal_Int32& nValue)
 {
@@ -166,6 +179,19 @@ void testShortProperty(uno::Reference<beans::XPropertySet> const& xPropertySet,
     CPPUNIT_ASSERT_EQUAL_MESSAGE(msgSet.getStr(), nValue, nPropertySet);
 }
 
+void testShortOptionalProperty(uno::Reference<beans::XPropertySet> const& xPropertySet,
+                               const OUString& rName, const sal_Int16& rValue)
+{
+    try
+    {
+        testShortProperty(xPropertySet, rName, rValue);
+    }
+    catch (const css::beans::UnknownPropertyException& /*ex*/)
+    {
+        // ignore if the property is unknown as it is optional
+    }
+}
+
 void testShortReadonlyProperty(uno::Reference<beans::XPropertySet> const& xPropertySet,
                                const OUString& name, const sal_Int16& nValue)
 {


More information about the Libreoffice-commits mailing list