summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdfedit_embeddertest.cpp
diff options
context:
space:
mode:
authorNicolas Pena <npm@chromium.org>2017-02-09 18:17:33 -0500
committerChromium commit bot <commit-bot@chromium.org>2017-02-10 04:08:27 +0000
commit2eb1a705c243b2d5ab912268dd453f5ade075b6f (patch)
tree7cbf6aabde7ecf3e1327535a9f6066856fc6626b /fpdfsdk/fpdfedit_embeddertest.cpp
parente818bcba7e036d7e1dc8f282a88022b814dbfb40 (diff)
downloadpdfium-2eb1a705c243b2d5ab912268dd453f5ade075b6f.tar.xz
Add line width option for stroking pathschromium/3011chromium/3010chromium/3009
BUG=pdfium:661 Change-Id: Ie1dc82a1323a35ebbd63a5b7b8f8c95f9a5325fe Reviewed-on: https://pdfium-review.googlesource.com/2613 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Nicolás Peña <npm@chromium.org>
Diffstat (limited to 'fpdfsdk/fpdfedit_embeddertest.cpp')
-rw-r--r--fpdfsdk/fpdfedit_embeddertest.cpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/fpdfsdk/fpdfedit_embeddertest.cpp b/fpdfsdk/fpdfedit_embeddertest.cpp
index 4a67c1720b..83d26312fc 100644
--- a/fpdfsdk/fpdfedit_embeddertest.cpp
+++ b/fpdfsdk/fpdfedit_embeddertest.cpp
@@ -267,3 +267,54 @@ TEST_F(FPDFEditEmbeddertest, PathOnTopOfText) {
FPDFBitmap_Destroy(bitmap);
UnloadPage(page);
}
+
+TEST_F(FPDFEditEmbeddertest, AddStrokedPaths) {
+ // Start with a blank page
+ FPDF_DOCUMENT doc = FPDF_CreateNewDocument();
+ FPDF_PAGE page = FPDFPage_New(doc, 0, 612, 792);
+
+ // Add a large stroked rectangle (fill color should not affect it).
+ FPDF_PAGEOBJECT rect = FPDFPageObj_CreateNewRect(20, 20, 200, 400);
+ EXPECT_TRUE(FPDFPath_SetFillColor(rect, 255, 0, 0, 255));
+ EXPECT_TRUE(FPDFPath_SetStrokeColor(rect, 0, 255, 0, 255));
+ EXPECT_TRUE(FPDFPath_SetStrokeWidth(rect, 15.0f));
+ EXPECT_TRUE(FPDFPath_SetDrawMode(rect, 0, 1));
+ FPDFPage_InsertObject(page, rect);
+ EXPECT_TRUE(FPDFPage_GenerateContent(page));
+ FPDF_BITMAP page_bitmap = RenderPage(page);
+ CompareBitmap(page_bitmap, 612, 792, "64bd31f862a89e0a9e505a5af6efd506");
+ FPDFBitmap_Destroy(page_bitmap);
+
+ // Add crossed-checkmark
+ FPDF_PAGEOBJECT check = FPDFPageObj_CreateNewPath(300, 500);
+ EXPECT_TRUE(FPDFPath_LineTo(check, 400, 400));
+ EXPECT_TRUE(FPDFPath_LineTo(check, 600, 600));
+ EXPECT_TRUE(FPDFPath_MoveTo(check, 400, 600));
+ EXPECT_TRUE(FPDFPath_LineTo(check, 600, 400));
+ EXPECT_TRUE(FPDFPath_SetStrokeColor(check, 128, 128, 128, 180));
+ EXPECT_TRUE(FPDFPath_SetStrokeWidth(check, 8.35f));
+ EXPECT_TRUE(FPDFPath_SetDrawMode(check, 0, 1));
+ FPDFPage_InsertObject(page, check);
+ EXPECT_TRUE(FPDFPage_GenerateContent(page));
+ page_bitmap = RenderPage(page);
+ CompareBitmap(page_bitmap, 612, 792, "4b6f3b9d25c4e194821217d5016c3724");
+ FPDFBitmap_Destroy(page_bitmap);
+
+ // Add stroked and filled oval-ish path.
+ FPDF_PAGEOBJECT path = FPDFPageObj_CreateNewPath(250, 100);
+ EXPECT_TRUE(FPDFPath_BezierTo(path, 180, 166, 180, 233, 250, 300));
+ EXPECT_TRUE(FPDFPath_LineTo(path, 255, 305));
+ EXPECT_TRUE(FPDFPath_BezierTo(path, 325, 233, 325, 166, 255, 105));
+ EXPECT_TRUE(FPDFPath_Close(path));
+ EXPECT_TRUE(FPDFPath_SetFillColor(path, 200, 128, 128, 100));
+ EXPECT_TRUE(FPDFPath_SetStrokeColor(path, 128, 200, 128, 150));
+ EXPECT_TRUE(FPDFPath_SetStrokeWidth(path, 10.5f));
+ EXPECT_TRUE(FPDFPath_SetDrawMode(path, FPDF_FILLMODE_ALTERNATE, 1));
+ FPDFPage_InsertObject(page, path);
+ EXPECT_TRUE(FPDFPage_GenerateContent(page));
+ page_bitmap = RenderPage(page);
+ CompareBitmap(page_bitmap, 612, 792, "ff3e6a22326754944cc6e56609acd73b");
+ FPDFBitmap_Destroy(page_bitmap);
+ FPDF_ClosePage(page);
+ FPDF_CloseDocument(doc);
+}