summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdfedit_embeddertest.cpp
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2017-09-15 07:49:03 +0200
committerChromium commit bot <commit-bot@chromium.org>2017-09-15 06:03:35 +0000
commit12abfd04a42a1166f7d1496beb63515bc47ec360 (patch)
tree573057f4cf24780bdf17d2ac113e48eec0897780 /fpdfsdk/fpdfedit_embeddertest.cpp
parent69fe7110e6af83ca82d71275a70ae4983daddd6f (diff)
downloadpdfium-12abfd04a42a1166f7d1496beb63515bc47ec360.tar.xz
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 <thestig@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'fpdfsdk/fpdfedit_embeddertest.cpp')
-rw-r--r--fpdfsdk/fpdfedit_embeddertest.cpp21
1 files changed, 21 insertions, 0 deletions
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"));