diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2017-10-19 09:08:32 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2017-10-19 12:05:16 +0200 |
commit | f1cd64ec65253c1f84500b0af89c5b2990374a5d (patch) | |
tree | 9bc56c9a800199cd496149c5b3de9c4d91f47fca /vcl | |
parent | b462fa972e27d9c1510ee547e95f3e9062e4579d (diff) |
CppunitTest_vcl_pdfexport: now we can assert the path segments
Instead of the bounding box workaround before commit
5352dfbbe22b59983e1b91366908724138b9783a (pdfium: update to 3235,
2017-10-12).
Also stop using the deprecated FPDFPage_CountObject().
Change-Id: Iff04b5d5af492b564d7e4e918fb69aa881791b88
Reviewed-on: https://gerrit.libreoffice.org/43523
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/qa/cppunit/pdfexport/pdfexport.cxx | 53 |
1 files changed, 42 insertions, 11 deletions
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx b/vcl/qa/cppunit/pdfexport/pdfexport.cxx index fecdee085f31..a904a5dc638d 100644 --- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx +++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx @@ -250,7 +250,7 @@ void PdfExportTest::testTdf105461() CPPUNIT_ASSERT(mpPdfPage); // Make sure there is a filled rectangle inside. - int nPageObjectCount = FPDFPage_CountObject(mpPdfPage); + int nPageObjectCount = FPDFPage_CountObjects(mpPdfPage); int nYellowPathCount = 0; for (int i = 0; i < nPageObjectCount; ++i) { @@ -306,7 +306,7 @@ void PdfExportTest::testTdf107868() CPPUNIT_ASSERT(mpPdfPage); // Make sure there is no filled rectangle inside. - int nPageObjectCount = FPDFPage_CountObject(mpPdfPage); + int nPageObjectCount = FPDFPage_CountObjects(mpPdfPage); int nWhitePathCount = 0; for (int i = 0; i < nPageObjectCount; ++i) { @@ -703,7 +703,7 @@ void PdfExportTest::testTdf108963() CPPUNIT_ASSERT(mpPdfPage); // Make sure there is a filled rectangle inside. - int nPageObjectCount = FPDFPage_CountObject(mpPdfPage); + int nPageObjectCount = FPDFPage_CountObjects(mpPdfPage); int nYellowPathCount = 0; for (int i = 0; i < nPageObjectCount; ++i) { @@ -716,14 +716,45 @@ void PdfExportTest::testTdf108963() if (RGB_COLORDATA(nRed, nGreen, nBlue) == COL_YELLOW) { ++nYellowPathCount; - float fLeft = 0, fBottom = 0, fRight = 0, fTop = 0; - FPDFPageObj_GetBounds(pPdfPageObject, &fLeft, &fBottom, &fRight, &fTop); - int nWidth = fRight - fLeft; - int nHeight = fTop - fBottom; - // This was 37 and 20, i.e. the bounding rectangle was much smaller - // as the highlight polygon wasn't rotated. - CPPUNIT_ASSERT_EQUAL(42, nWidth); - CPPUNIT_ASSERT_EQUAL(39, nHeight); + // The path described a yellow rectangle, but it was not rotated. + int nSegments = FPDFPath_CountSegments(pPdfPageObject); + CPPUNIT_ASSERT_EQUAL(5, nSegments); + FPDF_PATHSEGMENT pSegment = FPDFPath_GetPathSegment(pPdfPageObject, 0); + CPPUNIT_ASSERT_EQUAL(FPDF_SEGMENT_MOVETO, FPDFPathSegment_GetType(pSegment)); + float fX = 0; + float fY = 0; + FPDFPathSegment_GetPoint(pSegment, &fX, &fY); + CPPUNIT_ASSERT_EQUAL(static_cast<float>(245.4), fX); + CPPUNIT_ASSERT_EQUAL(static_cast<float>(244.2), fY); + CPPUNIT_ASSERT(!FPDFPathSegment_GetClose(pSegment)); + + pSegment = FPDFPath_GetPathSegment(pPdfPageObject, 1); + CPPUNIT_ASSERT_EQUAL(FPDF_SEGMENT_LINETO, FPDFPathSegment_GetType(pSegment)); + FPDFPathSegment_GetPoint(pSegment, &fX, &fY); + CPPUNIT_ASSERT_EQUAL(static_cast<float>(275.1), fX); + CPPUNIT_ASSERT_EQUAL(static_cast<float>(267.6), fY); + CPPUNIT_ASSERT(!FPDFPathSegment_GetClose(pSegment)); + + pSegment = FPDFPath_GetPathSegment(pPdfPageObject, 2); + CPPUNIT_ASSERT_EQUAL(FPDF_SEGMENT_LINETO, FPDFPathSegment_GetType(pSegment)); + FPDFPathSegment_GetPoint(pSegment, &fX, &fY); + CPPUNIT_ASSERT_EQUAL(static_cast<float>(287.5), fX); + CPPUNIT_ASSERT_EQUAL(static_cast<float>(251.8), fY); + CPPUNIT_ASSERT(!FPDFPathSegment_GetClose(pSegment)); + + pSegment = FPDFPath_GetPathSegment(pPdfPageObject, 3); + CPPUNIT_ASSERT_EQUAL(FPDF_SEGMENT_LINETO, FPDFPathSegment_GetType(pSegment)); + FPDFPathSegment_GetPoint(pSegment, &fX, &fY); + CPPUNIT_ASSERT_EQUAL(static_cast<float>(257.8), fX); + CPPUNIT_ASSERT_EQUAL(static_cast<float>(228.4), fY); + CPPUNIT_ASSERT(!FPDFPathSegment_GetClose(pSegment)); + + pSegment = FPDFPath_GetPathSegment(pPdfPageObject, 4); + CPPUNIT_ASSERT_EQUAL(FPDF_SEGMENT_LINETO, FPDFPathSegment_GetType(pSegment)); + FPDFPathSegment_GetPoint(pSegment, &fX, &fY); + CPPUNIT_ASSERT_EQUAL(static_cast<float>(245.4), fX); + CPPUNIT_ASSERT_EQUAL(static_cast<float>(244.2), fY); + CPPUNIT_ASSERT(FPDFPathSegment_GetClose(pSegment)); } } |