From 375d314cb48e0b9bab6c520bf2ceaf6de85db815 Mon Sep 17 00:00:00 2001 From: Xisco Fauli Date: Wed, 4 Mar 2020 17:13:50 +0100 Subject: sw: add test for date formats MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Idf6920278c82a1bdddeb4e1b43c444010fba1aa0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89985 Tested-by: Jenkins Reviewed-by: Xisco FaulĂ­ --- sw/qa/extras/odfimport/data/dateFormFormats.odt | Bin 0 -> 10664 bytes sw/qa/extras/odfimport/odfimport.cxx | 44 ++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 sw/qa/extras/odfimport/data/dateFormFormats.odt (limited to 'sw') diff --git a/sw/qa/extras/odfimport/data/dateFormFormats.odt b/sw/qa/extras/odfimport/data/dateFormFormats.odt new file mode 100644 index 000000000000..ef99e70f41dc Binary files /dev/null and b/sw/qa/extras/odfimport/data/dateFormFormats.odt differ 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 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 const xModel(mxComponent, uno::UNO_QUERY); + CPPUNIT_ASSERT(xModel.is()); + uno::Reference const xDPS(xModel, uno::UNO_QUERY); + uno::Reference const xDP = xDPS->getDrawPage(); + CPPUNIT_ASSERT(xDP.is()); + uno::Reference const xFS(xDP, uno::UNO_QUERY); + CPPUNIT_ASSERT(xFS.is()); + uno::Reference const xForms(xFS->getForms(), uno::UNO_QUERY); + CPPUNIT_ASSERT(xForms.is()); + uno::Reference xForm(xForms->getByIndex(0), uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT(xForm.is()); + uno::Reference xFormNC(xForm, uno::UNO_QUERY); + + uno::Any aAny; + uno::Reference xControlModel; + uno::Reference xController; + uno::Reference xControl; + uno::Reference xWindowPeer; + uno::Reference 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 -- cgit