From 12abfd04a42a1166f7d1496beb63515bc47ec360 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 15 Sep 2017 07:49:03 +0200 Subject: Add public method FPDFPath_CountPoint to get # of points of a path object. It was already possible to get the fill color, this exposes the number of points. Naming attempts to be consistent with existing FPDFPage_CountObject(). Change-Id: I79e8dd9f0c077de84ce9017a01d239e48e58174a Reviewed-on: https://pdfium-review.googlesource.com/13592 Reviewed-by: Lei Zhang Commit-Queue: Lei Zhang --- fpdfsdk/fpdfedit_embeddertest.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'fpdfsdk/fpdfedit_embeddertest.cpp') diff --git a/fpdfsdk/fpdfedit_embeddertest.cpp b/fpdfsdk/fpdfedit_embeddertest.cpp index 71933fea43..faf6d97adf 100644 --- a/fpdfsdk/fpdfedit_embeddertest.cpp +++ b/fpdfsdk/fpdfedit_embeddertest.cpp @@ -256,6 +256,10 @@ TEST_F(FPDFEditEmbeddertest, AddPaths) { EXPECT_EQ(0U, B); EXPECT_EQ(128U, A); + // Make sure the path has 5 points (1 FXPT_TYPE::MoveTo and 4 + // FXPT_TYPE::LineTo). + ASSERT_EQ(5, FPDFPath_CountPoint(green_rect)); + EXPECT_TRUE(FPDFPath_SetDrawMode(green_rect, FPDF_FILLMODE_WINDING, 0)); FPDFPage_InsertObject(page, green_rect); page_bitmap = RenderPage(page); @@ -269,6 +273,11 @@ TEST_F(FPDFEditEmbeddertest, AddPaths) { EXPECT_TRUE(FPDFPath_LineTo(black_path, 400, 200)); EXPECT_TRUE(FPDFPath_LineTo(black_path, 300, 100)); EXPECT_TRUE(FPDFPath_Close(black_path)); + + // Make sure the path has 3 points (1 FXPT_TYPE::MoveTo and 2 + // FXPT_TYPE::LineTo). + ASSERT_EQ(3, FPDFPath_CountPoint(black_path)); + FPDFPage_InsertObject(page, black_path); page_bitmap = RenderPage(page); CompareBitmap(page_bitmap, 612, 792, "eadc8020a14dfcf091da2688733d8806"); @@ -299,6 +308,18 @@ TEST_F(FPDFEditEmbeddertest, AddPaths) { TestAndCloseSaved(612, 792, last_md5); } +TEST_F(FPDFEditEmbeddertest, PathsPoints) { + CreateNewDocument(); + FPDF_PAGEOBJECT img = FPDFPageObj_NewImageObj(document_); + // This should fail gracefully, even if img is not a path. + ASSERT_EQ(-1, FPDFPath_CountPoint(img)); + + // This should fail gracefully, even if path is NULL. + ASSERT_EQ(-1, FPDFPath_CountPoint(nullptr)); + + FPDFPageObj_Destroy(img); +} + TEST_F(FPDFEditEmbeddertest, PathOnTopOfText) { // Load document with some text EXPECT_TRUE(OpenDocument("hello_world.pdf")); -- cgit v1.2.3