diff options
author | Venetia <venetiarosita@gmail.com> | 2023-09-18 19:07:34 -0600 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2023-10-20 10:59:08 +0200 |
commit | d1ba7d0ae6d10c72a1503f88e9b9b32f54cade3b (patch) | |
tree | c7202811e6be4d9c1ead4c2ae3e82d7393614074 /sw | |
parent | 734db70ec85944aefb55a41b198fe1a60b91b2ea (diff) |
tdf#148952 sw: Add unit test
Change-Id: I151f3d59f924280311653de025560e6fd2a826c5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157037
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/tdf148952.odt | bin | 0 -> 11038 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport19.cxx | 56 |
2 files changed, 56 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf148952.odt b/sw/qa/extras/ooxmlexport/data/tdf148952.odt Binary files differnew file mode 100644 index 000000000000..b4f40f617da6 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/tdf148952.odt diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport19.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport19.cxx index fbd3bdb4aaaf..f851210048e0 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport19.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport19.cxx @@ -1156,6 +1156,62 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf157136) } } +//Tests for support of fallback for ECMA-376 1st ed to merge the title value with descr attribute +CPPUNIT_TEST_FIXTURE(Test, testTdf148952_2007) +{ + //Given a document with 1 image (with name, alt title and description field populated) in odt format + createSwDoc("tdf148952.odt"); + + OUString rFilterName = "MS Word 2007 XML"; + + //Export it to MS word 2007(.docx) format + saveAndReload(rFilterName); + + // Checks the number of images in the docx file + const OString sFailedMessage = OString::Concat("Failed on filter: ") + rFilterName.toUtf8(); + CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), 1, getShapes()); + + uno::Reference<beans::XPropertySet> xImage(getShape(1), uno::UNO_QUERY); + + // Check if alt title value is appended to description + OUString descr; + xImage->getPropertyValue("Description") >>= descr; + CPPUNIT_ASSERT_EQUAL(OUString("Black\nShapes"), descr); + + // Check if alt title field is empty + OUString title; + xImage->getPropertyValue("Title") >>= title; + CPPUNIT_ASSERT_EQUAL(OUString(""), title); +} + +//Tests for support of title attribute for ECMA-376 2nd ed and above +CPPUNIT_TEST_FIXTURE(Test, testTdf148952_2010) +{ + //Given a document with 1 image (with name, alt title and description field populated) in odt format + createSwDoc("tdf148952.odt"); + + OUString rFilterName = "Office Open XML Text"; + + //Export it to MS word 2010-365 (.docx) format + saveAndReload(rFilterName); + + // Checks the number of images in the docx file + const OString sFailedMessage = OString::Concat("Failed on filter: ") + rFilterName.toUtf8(); + CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), 1, getShapes()); + + uno::Reference<beans::XPropertySet> xImage(getShape(1), uno::UNO_QUERY); + + // Check if description field contains same value after export + OUString descr; + xImage->getPropertyValue("Description") >>= descr; + CPPUNIT_ASSERT_EQUAL(OUString("Shapes"), descr); + + // Check if alt title field contains same value after export + OUString title; + xImage->getPropertyValue("Title") >>= title; + CPPUNIT_ASSERT_EQUAL(OUString("Black"), title); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |