Kaydet (Commit) f1cd64ec authored tarafından Miklos Vajna's avatar Miklos Vajna

CppunitTest_vcl_pdfexport: now we can assert the path segments

Instead of the bounding box workaround before commit
5352dfbb (pdfium: update to 3235,
2017-10-12).

Also stop using the deprecated FPDFPage_CountObject().

Change-Id: Iff04b5d5af492b564d7e4e918fb69aa881791b88
Reviewed-on: https://gerrit.libreoffice.org/43523Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
Tested-by: 's avatarJenkins <ci@libreoffice.org>
üst b462fa97
...@@ -250,7 +250,7 @@ void PdfExportTest::testTdf105461() ...@@ -250,7 +250,7 @@ void PdfExportTest::testTdf105461()
CPPUNIT_ASSERT(mpPdfPage); CPPUNIT_ASSERT(mpPdfPage);
// Make sure there is a filled rectangle inside. // Make sure there is a filled rectangle inside.
int nPageObjectCount = FPDFPage_CountObject(mpPdfPage); int nPageObjectCount = FPDFPage_CountObjects(mpPdfPage);
int nYellowPathCount = 0; int nYellowPathCount = 0;
for (int i = 0; i < nPageObjectCount; ++i) for (int i = 0; i < nPageObjectCount; ++i)
{ {
...@@ -306,7 +306,7 @@ void PdfExportTest::testTdf107868() ...@@ -306,7 +306,7 @@ void PdfExportTest::testTdf107868()
CPPUNIT_ASSERT(mpPdfPage); CPPUNIT_ASSERT(mpPdfPage);
// Make sure there is no filled rectangle inside. // Make sure there is no filled rectangle inside.
int nPageObjectCount = FPDFPage_CountObject(mpPdfPage); int nPageObjectCount = FPDFPage_CountObjects(mpPdfPage);
int nWhitePathCount = 0; int nWhitePathCount = 0;
for (int i = 0; i < nPageObjectCount; ++i) for (int i = 0; i < nPageObjectCount; ++i)
{ {
...@@ -703,7 +703,7 @@ void PdfExportTest::testTdf108963() ...@@ -703,7 +703,7 @@ void PdfExportTest::testTdf108963()
CPPUNIT_ASSERT(mpPdfPage); CPPUNIT_ASSERT(mpPdfPage);
// Make sure there is a filled rectangle inside. // Make sure there is a filled rectangle inside.
int nPageObjectCount = FPDFPage_CountObject(mpPdfPage); int nPageObjectCount = FPDFPage_CountObjects(mpPdfPage);
int nYellowPathCount = 0; int nYellowPathCount = 0;
for (int i = 0; i < nPageObjectCount; ++i) for (int i = 0; i < nPageObjectCount; ++i)
{ {
...@@ -716,14 +716,45 @@ void PdfExportTest::testTdf108963() ...@@ -716,14 +716,45 @@ void PdfExportTest::testTdf108963()
if (RGB_COLORDATA(nRed, nGreen, nBlue) == COL_YELLOW) if (RGB_COLORDATA(nRed, nGreen, nBlue) == COL_YELLOW)
{ {
++nYellowPathCount; ++nYellowPathCount;
float fLeft = 0, fBottom = 0, fRight = 0, fTop = 0; // The path described a yellow rectangle, but it was not rotated.
FPDFPageObj_GetBounds(pPdfPageObject, &fLeft, &fBottom, &fRight, &fTop); int nSegments = FPDFPath_CountSegments(pPdfPageObject);
int nWidth = fRight - fLeft; CPPUNIT_ASSERT_EQUAL(5, nSegments);
int nHeight = fTop - fBottom; FPDF_PATHSEGMENT pSegment = FPDFPath_GetPathSegment(pPdfPageObject, 0);
// This was 37 and 20, i.e. the bounding rectangle was much smaller CPPUNIT_ASSERT_EQUAL(FPDF_SEGMENT_MOVETO, FPDFPathSegment_GetType(pSegment));
// as the highlight polygon wasn't rotated. float fX = 0;
CPPUNIT_ASSERT_EQUAL(42, nWidth); float fY = 0;
CPPUNIT_ASSERT_EQUAL(39, nHeight); 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));
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment