summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2022-09-15 13:18:13 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2022-09-15 18:39:51 +0200
commitf089f56aa0035ca0ee33bac752a7a92086680c24 (patch)
tree413e4feee1629473cee57815228e4f5c964c0a94 /vcl
parentc7bb9521ba67f52e9d665fdd24d40d8b42f0387d (diff)
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 <xiscofauli@libreoffice.org>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/qa/cppunit/pdfexport/data/tdf150931.odsbin0 -> 8605 bytes
-rw-r--r--vcl/qa/cppunit/pdfexport/pdfexport.cxx45
2 files changed, 45 insertions, 0 deletions
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
--- /dev/null
+++ b/vcl/qa/cppunit/pdfexport/data/tdf150931.ods
Binary files 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