summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Horák <dan@danny.cz>2023-09-15 11:17:58 +0200
committerMichael Stahl <michael.stahl@allotropia.de>2023-09-18 11:19:10 +0200
commite03be024ae9c16fa8542757ad2c327259d5b9b0c (patch)
tree6e9b5cfa30389379a55ed1ee388ff85c887e994f
parentfec20d4bba32b06fa3641290deaa4e4fec98ae42 (diff)
sw/qa/extras/globalfilter: check for pdfium availability
A section of testListLabelPDFExport requires pdfium. The pPdfDocument pointer is set to NULL when pdfium is not available, so check it first. This avoids a segfault when LO would be built without pdfium. Change-Id: Ic66a4552c8512702bbfd6d24f5bb581ab824bbe0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156940 Reviewed-by: Michael Stahl <michael.stahl@allotropia.de> Tested-by: Jenkins
-rw-r--r--sw/qa/extras/globalfilter/globalfilter.cxx38
1 files changed, 21 insertions, 17 deletions
diff --git a/sw/qa/extras/globalfilter/globalfilter.cxx b/sw/qa/extras/globalfilter/globalfilter.cxx
index 64bc2063beb1..3eb328f0b5cc 100644
--- a/sw/qa/extras/globalfilter/globalfilter.cxx
+++ b/sw/qa/extras/globalfilter/globalfilter.cxx
@@ -1286,23 +1286,27 @@ CPPUNIT_TEST_FIXTURE(Test, testListLabelPDFExport)
// Parse the export result with pdfium.
std::unique_ptr<vcl::pdf::PDFiumDocument> pPdfDocument = parsePDFExport();
- // The document has one page.
- CPPUNIT_ASSERT_EQUAL(1, pPdfDocument->getPageCount());
- std::unique_ptr<vcl::pdf::PDFiumPage> pPdfPage = pPdfDocument->openPage(/*nIndex=*/0);
- CPPUNIT_ASSERT(pPdfPage);
-
- std::unique_ptr<vcl::pdf::PDFiumTextPage> pPdfTextPage = pPdfPage->getTextPage();
- CPPUNIT_ASSERT(pPdfTextPage);
-
- int nChars = pPdfTextPage->countChars();
- CPPUNIT_ASSERT_EQUAL(22, nChars);
-
- // Check that the label strings were exported correctly
- std::vector<sal_uInt32> aChars(nChars);
- for (int i = 0; i < nChars; i++)
- aChars[i] = pPdfTextPage->getUnicode(i);
- OUString aText(aChars.data(), aChars.size());
- CPPUNIT_ASSERT_EQUAL(OUString(u"\u0623\r\n.\r\n\u0623.\u0623\r\n.\r\n\u0623.\u0623.\u0623\r\n."), aText);
+ // Non-NULL pPdfDocument means pdfium is available.
+ if (pPdfDocument != nullptr)
+ {
+ // The document has one page.
+ CPPUNIT_ASSERT_EQUAL(1, pPdfDocument->getPageCount());
+ std::unique_ptr<vcl::pdf::PDFiumPage> pPdfPage = pPdfDocument->openPage(/*nIndex=*/0);
+ CPPUNIT_ASSERT(pPdfPage);
+
+ std::unique_ptr<vcl::pdf::PDFiumTextPage> pPdfTextPage = pPdfPage->getTextPage();
+ CPPUNIT_ASSERT(pPdfTextPage);
+
+ int nChars = pPdfTextPage->countChars();
+ CPPUNIT_ASSERT_EQUAL(22, nChars);
+
+ // Check that the label strings were exported correctly
+ std::vector<sal_uInt32> aChars(nChars);
+ for (int i = 0; i < nChars; i++)
+ aChars[i] = pPdfTextPage->getUnicode(i);
+ OUString aText(aChars.data(), aChars.size());
+ CPPUNIT_ASSERT_EQUAL(OUString(u"\u0623\r\n.\r\n\u0623.\u0623\r\n.\r\n\u0623.\u0623.\u0623\r\n."), aText);
+ }
// Parse the document again to get its raw content
// TODO: get the content from PDFiumPage somehow