diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2020-03-04 17:13:50 +0100 |
---|---|---|
committer | Xisco Faulí <xiscofauli@libreoffice.org> | 2020-03-06 11:46:09 +0100 |
commit | 375d314cb48e0b9bab6c520bf2ceaf6de85db815 (patch) | |
tree | 484a541ebbcadb0395f97c26a2e4fa767a432d76 /sw | |
parent | 9a1dd2e242794b4f26d207efc80a2f5bc088ab7c (diff) |
sw: add test for date formats
Change-Id: Idf6920278c82a1bdddeb4e1b43c444010fba1aa0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89985
Tested-by: Jenkins
Reviewed-by: Xisco Faulí <xiscofauli@libreoffice.org>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/odfimport/data/dateFormFormats.odt | bin | 0 -> 10664 bytes | |||
-rw-r--r-- | sw/qa/extras/odfimport/odfimport.cxx | 44 |
2 files changed, 44 insertions, 0 deletions
diff --git a/sw/qa/extras/odfimport/data/dateFormFormats.odt b/sw/qa/extras/odfimport/data/dateFormFormats.odt Binary files differnew file mode 100644 index 000000000000..ef99e70f41dc --- /dev/null +++ b/sw/qa/extras/odfimport/data/dateFormFormats.odt diff --git a/sw/qa/extras/odfimport/odfimport.cxx b/sw/qa/extras/odfimport/odfimport.cxx index 8eff1cf92e1f..55a477ba0aa5 100644 --- a/sw/qa/extras/odfimport/odfimport.cxx +++ b/sw/qa/extras/odfimport/odfimport.cxx @@ -269,6 +269,7 @@ DECLARE_ODFIMPORT_TEST(testTimeFormFormats, "timeFormFormats.odt") { //FIXME: make it an ODFEXPORT_TEST. Validator fails with //attribute "form:current-value" has a bad value: "PT12H12M" does not satisfy the "time" type + //See tdf#131127 uno::Reference<frame::XModel> const xModel(mxComponent, uno::UNO_QUERY); CPPUNIT_ASSERT(xModel.is()); @@ -305,6 +306,49 @@ DECLARE_ODFIMPORT_TEST(testTimeFormFormats, "timeFormFormats.odt") } } +DECLARE_ODFIMPORT_TEST(testDateFormFormats, "dateFormFormats.odt") +{ + //FIXME: make it an ODFEXPORT_TEST. Validator fails with + //unexpected attribute "form:input-required" + //See tdf#131148 + + uno::Reference<frame::XModel> const xModel(mxComponent, uno::UNO_QUERY); + CPPUNIT_ASSERT(xModel.is()); + uno::Reference<drawing::XDrawPageSupplier> const xDPS(xModel, uno::UNO_QUERY); + uno::Reference<drawing::XDrawPage> const xDP = xDPS->getDrawPage(); + CPPUNIT_ASSERT(xDP.is()); + uno::Reference<form::XFormsSupplier> const xFS(xDP, uno::UNO_QUERY); + CPPUNIT_ASSERT(xFS.is()); + uno::Reference<container::XIndexContainer> const xForms(xFS->getForms(), uno::UNO_QUERY); + CPPUNIT_ASSERT(xForms.is()); + uno::Reference<form::XForm> xForm(xForms->getByIndex(0), uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT(xForm.is()); + uno::Reference<container::XNameContainer> xFormNC(xForm, uno::UNO_QUERY); + + uno::Any aAny; + uno::Reference<awt::XControlModel> xControlModel; + uno::Reference<view::XControlAccess> xController; + uno::Reference<awt::XControl> xControl; + uno::Reference<awt::XWindowPeer> xWindowPeer; + uno::Reference<awt::XTextComponent> xTextComponent; + OUString aName = "Date Field "; + + static const char* const aExpectedResults[] = { "03/04/20", "03/04/20", "03/04/2020", + "Wednesday, March 4, 2020", "04/03/20", "03/04/20", "20/03/04", "04/03/2020", "03/04/2020", + "2020/03/04", "20-03-04", "2020-03-04"}; + + for (size_t i = 1; i <= 12; ++i) + { + aAny = xFormNC->getByName(aName + OUString::number(i)); + xControlModel.set(aAny, uno::UNO_QUERY); + xController.set(xModel->getCurrentController(), uno::UNO_QUERY_THROW); + xControl = xController->getControl(xControlModel); + xWindowPeer = xControl->getPeer(); + xTextComponent.set(xWindowPeer, uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString::fromUtf8(aExpectedResults[i - 1]), xTextComponent->getText()); + } +} + DECLARE_ODFIMPORT_TEST(testTdf64038, "space.odt") { // no space |