vcl/qa/cppunit/pdfexport/pdfexport.cxx | 53 ++++++++++++++++++++++++++------- 1 file changed, 42 insertions(+), 11 deletions(-)
New commits: commit f1cd64ec65253c1f84500b0af89c5b2990374a5d Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Thu Oct 19 09:08:32 2017 +0200 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 <vmik...@collabora.co.uk> Tested-by: Jenkins <c...@libreoffice.org> 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)); } } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits