summaryrefslogtreecommitdiff
path: root/editeng/qa
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2012-05-11 23:11:10 -0400
committerKohei Yoshida <kohei.yoshida@gmail.com>2012-05-11 23:12:28 -0400
commit8ed129b22d1d9f832011df1a7e37402fb8abdbb2 (patch)
tree83130cab15e29ad5f789425ee6fe84f74fce1838 /editeng/qa
parent78fcdec5b062161493511c0e898051478962f490 (diff)
Unit test for UNO field item implementation.
Make sure the type IDs are associated with correct service names. Change-Id: I5ff8ec7fb56f2790f9a3eca8e019c784cb27de43
Diffstat (limited to 'editeng/qa')
-rw-r--r--editeng/qa/unit/core-test.cxx139
1 files changed, 139 insertions, 0 deletions
diff --git a/editeng/qa/unit/core-test.cxx b/editeng/qa/unit/core-test.cxx
index fc5828f4a307..5c459328367d 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);
}