summaryrefslogtreecommitdiff
path: root/sdext
diff options
context:
space:
mode:
authorKevin Suo <suokunlong@126.com>2022-10-21 00:40:19 +0800
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-10-24 09:13:11 +0200
commit8ae0ce1bfa9fe6fa7fa54bafb5541c3f78d9e9b5 (patch)
tree406e65a8e74d126c92fa30fbf0af7b0b66b45b13 /sdext
parentcd5acf308552ee878215e71251eb57dc5108b92a (diff)
sdext.pdfimport: refactor this unit test and active it for Windows
This unit test was disabled for Windows build in commit fc45e54be6ba5d4685ae4ef3c3ea696fc99cccd4, due to the "crashes on the windows jenkins boxes". In this patch, I: 1. Rename the test name to show its purpose for easier reading; 2. Test the whole string all at once using xpath, rather than use indexOf(). This way we can not only test the existance of the characters, but also the order they appear. 3. Activate it for Windows build and hope it passes on Jenkins. 4. Remove the std::cout debug code, and use CPPUNIT_ASSERT_EQUAL_MESSAGE instead, so that the xml content (i.e. aOutput) is only shown when the assertion fails. 5. Move the test document to testdocs directory. Change-Id: I39084eb4ddc451ecac5183213b7e6166facf617b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141601 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sdext')
-rw-r--r--sdext/source/pdfimport/test/testdocs/testTdf141709_chinesechar.pdf (renamed from sdext/source/pdfimport/test/testTdf141709.pdf)bin11119 -> 11119 bytes
-rw-r--r--sdext/source/pdfimport/test/tests.cxx28
2 files changed, 11 insertions, 17 deletions
diff --git a/sdext/source/pdfimport/test/testTdf141709.pdf b/sdext/source/pdfimport/test/testdocs/testTdf141709_chinesechar.pdf
index 3198782faa73..3198782faa73 100644
--- a/sdext/source/pdfimport/test/testTdf141709.pdf
+++ b/sdext/source/pdfimport/test/testdocs/testTdf141709_chinesechar.pdf
Binary files differ
diff --git a/sdext/source/pdfimport/test/tests.cxx b/sdext/source/pdfimport/test/tests.cxx
index 7cff15a36d0f..71661ae9e6d5 100644
--- a/sdext/source/pdfimport/test/tests.cxx
+++ b/sdext/source/pdfimport/test/tests.cxx
@@ -556,32 +556,26 @@ namespace
#endif
}
- void testTdf141709()
+ void testTdf141709_chinesechar()
{
// this test crashes on the windows jenkins boxes, but no-one can catch it locally
-#if HAVE_FEATURE_POPPLER && !defined(_WIN32)
+#if HAVE_FEATURE_POPPLER
rtl::Reference<pdfi::PDFIRawAdaptor> xAdaptor(new pdfi::PDFIRawAdaptor(OUString(), getComponentContext()));
xAdaptor->setTreeVisitorFactory(createDrawTreeVisitorFactory());
OString aOutput;
CPPUNIT_ASSERT_MESSAGE("Exporting to ODF",
- xAdaptor->odfConvert(m_directories.getURLFromSrc(u"/sdext/source/pdfimport/test/testTdf141709.pdf"),
+ xAdaptor->odfConvert(m_directories.getURLFromSrc(u"/sdext/source/pdfimport/test/testdocs/testTdf141709_chinesechar.pdf"),
new OutputWrapString(aOutput),
nullptr));
- std::cout << aOutput << std::endl;
+ xmlDocUniquePtr pXmlDoc(xmlParseDoc(reinterpret_cast<xmlChar const *>(aOutput.getStr())));
// This ensures that the imported text contains all of the characters
- CPPUNIT_ASSERT(aOutput.indexOf("敏") != -1);
- CPPUNIT_ASSERT(aOutput.indexOf("捷") != -1);
- CPPUNIT_ASSERT(aOutput.indexOf("的") != -1);
- CPPUNIT_ASSERT(aOutput.indexOf("狐") != -1);
- CPPUNIT_ASSERT(aOutput.indexOf("狸") != -1);
- CPPUNIT_ASSERT(aOutput.indexOf("跨") != -1);
- CPPUNIT_ASSERT(aOutput.indexOf("过") != -1);
- CPPUNIT_ASSERT(aOutput.indexOf("慵") != -1);
- CPPUNIT_ASSERT(aOutput.indexOf("懒") != -1);
- CPPUNIT_ASSERT(aOutput.indexOf("的") != -1);
- CPPUNIT_ASSERT(aOutput.indexOf("狗") != -1);
- CPPUNIT_ASSERT(aOutput.indexOf("。") != -1);
+ OString xpath = "//draw:frame[@draw:z-index='3'][1]/draw:text-box/text:p/text:span[1]";
+ OUString sContent = getXPathContent(pXmlDoc, xpath).replaceAll("\n", "");
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(aOutput.getStr(), OUString(u"敏捷的狐狸跨过慵懒的"), sContent);
+ xpath = "//draw:frame[@draw:z-index='4'][1]/draw:text-box/text:p/text:span[1]";
+ sContent = getXPathContent(pXmlDoc, xpath).replaceAll("\n", "");
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(aOutput.getStr(), OUString(u"狗。"), sContent);
#endif
}
@@ -854,7 +848,7 @@ namespace
CPPUNIT_TEST(testTdf96993);
CPPUNIT_TEST(testTdf98421);
CPPUNIT_TEST(testTdf105536);
- CPPUNIT_TEST(testTdf141709);
+ CPPUNIT_TEST(testTdf141709_chinesechar);
CPPUNIT_TEST(testTdf78427_FontFeatures);
CPPUNIT_TEST(testTdf78427_FontWeight_MyraidProSemibold);
CPPUNIT_TEST(testTdf143959_nameFromFontFile);