vcl/qa/cppunit/pdfexport/data/tdf150931.ods |binary vcl/qa/cppunit/pdfexport/pdfexport.cxx | 45 ++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+)
New commits: commit f089f56aa0035ca0ee33bac752a7a92086680c24 Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Thu Sep 15 13:18:13 2022 +0200 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Thu Sep 15 18:39:51 2022 +0200 tdf#150931: vcl_pdfexport: Add unittest Probably this test could be improved by checking the position of the pathes. For now, this is better than nothing Change-Id: I5063a9005a55be9d556eb147ba6a11fb2a1115a0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140013 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/vcl/qa/cppunit/pdfexport/data/tdf150931.ods b/vcl/qa/cppunit/pdfexport/data/tdf150931.ods new file mode 100644 index 000000000000..633362c614ef Binary files /dev/null and b/vcl/qa/cppunit/pdfexport/data/tdf150931.ods differ diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx b/vcl/qa/cppunit/pdfexport/pdfexport.cxx index e2c6ae39784b..1b6036abfee8 100644 --- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx +++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx @@ -2231,6 +2231,51 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf114256) CPPUNIT_ASSERT_EQUAL(13, pPdfPage->getObjectCount()); } +CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf150931) +{ + aMediaDescriptor["FilterName"] <<= OUString("calc_pdf_Export"); + saveAsPDF(u"tdf150931.ods"); + std::unique_ptr<vcl::pdf::PDFiumDocument> pPdfDocument = parseExport(); + CPPUNIT_ASSERT(pPdfDocument); + CPPUNIT_ASSERT_EQUAL(1, pPdfDocument->getPageCount()); + std::unique_ptr<vcl::pdf::PDFiumPage> pPdfPage = pPdfDocument->openPage(/*nIndex=*/0); + CPPUNIT_ASSERT(pPdfPage); + + int nPageObjectCount = pPdfPage->getObjectCount(); + // Without the fix in place, this test would have failed with + // - Expected: 15 + // - Actual : 16 + CPPUNIT_ASSERT_EQUAL(16, nPageObjectCount); + + int nYellowPathCount = 0; + int nBlackPathCount = 0; + int nGrayPathCount = 0; + int nRedPathCount = 0; + for (int i = 0; i < nPageObjectCount; ++i) + { + std::unique_ptr<vcl::pdf::PDFiumPageObject> pPdfPageObject = pPdfPage->getObject(i); + if (pPdfPageObject->getType() != vcl::pdf::PDFPageObjectType::Path) + continue; + + int nSegments = pPdfPageObject->getPathSegmentCount(); + CPPUNIT_ASSERT_EQUAL(5, nSegments); + + if (pPdfPageObject->getFillColor() == COL_YELLOW) + ++nYellowPathCount; + else if (pPdfPageObject->getFillColor() == COL_BLACK) + ++nBlackPathCount; + else if (pPdfPageObject->getFillColor() == COL_GRAY) + ++nGrayPathCount; + else if (pPdfPageObject->getFillColor() == COL_LIGHTRED) + ++nRedPathCount; + } + + CPPUNIT_ASSERT_EQUAL(3, nYellowPathCount); + CPPUNIT_ASSERT_EQUAL(3, nRedPathCount); + CPPUNIT_ASSERT_EQUAL(3, nGrayPathCount); + CPPUNIT_ASSERT_EQUAL(3, nBlackPathCount); +} + CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf147027) { // FIXME: the DPI check should be removed when either (1) the test is fixed to work with