[Libreoffice-commits] .: editeng/qa

Kohei Yoshida kohei at kemper.freedesktop.org
Fri May 11 20:12:14 PDT 2012


 editeng/qa/unit/core-test.cxx |  139 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 139 insertions(+)

New commits:
commit 8ed129b22d1d9f832011df1a7e37402fb8abdbb2
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Fri May 11 23:11:10 2012 -0400

    Unit test for UNO field item implementation.
    
    Make sure the type IDs are associated with correct service names.
    
    Change-Id: I5ff8ec7fb56f2790f9a3eca8e019c784cb27de43

diff --git a/editeng/qa/unit/core-test.cxx b/editeng/qa/unit/core-test.cxx
index fc5828f..5c45932 100644
--- a/editeng/qa/unit/core-test.cxx
+++ b/editeng/qa/unit/core-test.cxx
@@ -41,6 +41,11 @@
 #include "editeng/eeitem.hxx"
 #include "editeng/editids.hrc"
 #include "editeng/editdoc.hxx"
+#include "editeng/unofield.hxx"
+
+#include <com/sun/star/text/textfield/Type.hpp>
+
+using namespace com::sun::star;
 
 namespace {
 
@@ -54,8 +59,14 @@ public:
 
     void testConstruction();
 
+    /**
+     * Test UNO service class that implements text field items.
+     */
+    void testUnoTextFields();
+
     CPPUNIT_TEST_SUITE(Test);
     CPPUNIT_TEST(testConstruction);
+    CPPUNIT_TEST(testUnoTextFields);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -85,6 +96,134 @@ void Test::testConstruction()
     aEngine.SetText(aParaText);
 }
 
+namespace {
+
+bool includes(const uno::Sequence<rtl::OUString>& rSeq, const rtl::OUString& rVal)
+{
+    for (sal_Int32 i = 0, n = rSeq.getLength(); i < n; ++i)
+        if (rSeq[i] == rVal)
+            return true;
+
+    return false;
+}
+
+}
+
+void Test::testUnoTextFields()
+{
+    {
+        // DATE
+        SvxUnoTextField aField(text::textfield::Type::DATE);
+        uno::Sequence<rtl::OUString> aSvcs = aField.getSupportedServiceNames();
+        bool bGood = includes(aSvcs, "com.sun.star.text.textfield.DateTime");
+        CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
+    }
+
+    {
+        // URL
+        SvxUnoTextField aField(text::textfield::Type::URL);
+        uno::Sequence<rtl::OUString> aSvcs = aField.getSupportedServiceNames();
+        bool bGood = includes(aSvcs, "com.sun.star.text.textfield.URL");
+        CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
+    }
+
+    {
+        // PAGE
+        SvxUnoTextField aField(text::textfield::Type::PAGE);
+        uno::Sequence<rtl::OUString> aSvcs = aField.getSupportedServiceNames();
+        bool bGood = includes(aSvcs, "com.sun.star.text.textfield.PageNumber");
+        CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
+    }
+
+    {
+        // PAGES
+        SvxUnoTextField aField(text::textfield::Type::PAGES);
+        uno::Sequence<rtl::OUString> aSvcs = aField.getSupportedServiceNames();
+        bool bGood = includes(aSvcs, "com.sun.star.text.textfield.PageCount");
+        CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
+    }
+
+    {
+        // TIME
+        SvxUnoTextField aField(text::textfield::Type::TIME);
+        uno::Sequence<rtl::OUString> aSvcs = aField.getSupportedServiceNames();
+        bool bGood = includes(aSvcs, "com.sun.star.text.textfield.DateTime");
+        CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
+    }
+
+    {
+        // FILE
+        SvxUnoTextField aField(text::textfield::Type::FILE);
+        uno::Sequence<rtl::OUString> aSvcs = aField.getSupportedServiceNames();
+        bool bGood = includes(aSvcs, "com.sun.star.text.textfield.docinfo.Title");
+        CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
+    }
+
+    {
+        // TABLE
+        SvxUnoTextField aField(text::textfield::Type::TABLE);
+        uno::Sequence<rtl::OUString> aSvcs = aField.getSupportedServiceNames();
+        bool bGood = includes(aSvcs, "com.sun.star.text.textfield.SheetName");
+        CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
+    }
+
+    {
+        // EXTENDED TIME
+        SvxUnoTextField aField(text::textfield::Type::EXTENDED_TIME);
+        uno::Sequence<rtl::OUString> aSvcs = aField.getSupportedServiceNames();
+        bool bGood = includes(aSvcs, "com.sun.star.text.textfield.DateTime");
+        CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
+    }
+
+    {
+        // EXTENDED FILE
+        SvxUnoTextField aField(text::textfield::Type::EXTENDED_FILE);
+        uno::Sequence<rtl::OUString> aSvcs = aField.getSupportedServiceNames();
+        bool bGood = includes(aSvcs, "com.sun.star.text.textfield.FileName");
+        CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
+    }
+
+    {
+        // AUTHOR
+        SvxUnoTextField aField(text::textfield::Type::AUTHOR);
+        uno::Sequence<rtl::OUString> aSvcs = aField.getSupportedServiceNames();
+        bool bGood = includes(aSvcs, "com.sun.star.text.textfield.Author");
+        CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
+    }
+
+    {
+        // MEASURE
+        SvxUnoTextField aField(text::textfield::Type::MEASURE);
+        uno::Sequence<rtl::OUString> aSvcs = aField.getSupportedServiceNames();
+        bool bGood = includes(aSvcs, "com.sun.star.text.textfield.Measure");
+        CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
+    }
+
+    {
+        // PRESENTATION HEADER
+        SvxUnoTextField aField(text::textfield::Type::PRESENTATION_HEADER);
+        uno::Sequence<rtl::OUString> aSvcs = aField.getSupportedServiceNames();
+        bool bGood = includes(aSvcs, "com.sun.star.presentation.textfield.Header");
+        CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
+    }
+
+    {
+        // PRESENTATION FOOTER
+        SvxUnoTextField aField(text::textfield::Type::PRESENTATION_FOOTER);
+        uno::Sequence<rtl::OUString> aSvcs = aField.getSupportedServiceNames();
+        bool bGood = includes(aSvcs, "com.sun.star.presentation.textfield.Footer");
+        CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
+    }
+
+    {
+        // PRESENTATION DATE TIME
+        SvxUnoTextField aField(text::textfield::Type::PRESENTATION_DATE_TIME);
+        uno::Sequence<rtl::OUString> aSvcs = aField.getSupportedServiceNames();
+        bool bGood = includes(aSvcs, "com.sun.star.presentation.textfield.DateTime");
+        CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
+    }
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
 
 }


More information about the Libreoffice-commits mailing list