diff options
author | thestig <thestig@chromium.org> | 2016-08-09 17:13:14 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-08-09 17:13:14 -0700 |
commit | 85af2a3cfcdfb2200510d337bfbf5b405858aa3b (patch) | |
tree | fcc92bf20cb6afdfd4a4f7b1f0f948d9496cefbc /fpdfsdk/fpdfeditimg_unittest.cpp | |
parent | f4dc38bbc52501b322e1c39115f5ce4231773eab (diff) | |
download | pdfium-85af2a3cfcdfb2200510d337bfbf5b405858aa3b.tar.xz |
Add another PDFEditTest test case.chromium/2827chromium/2826
BUG=pdfium:545
Review-Url: https://codereview.chromium.org/2229103003
Diffstat (limited to 'fpdfsdk/fpdfeditimg_unittest.cpp')
-rw-r--r-- | fpdfsdk/fpdfeditimg_unittest.cpp | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/fpdfsdk/fpdfeditimg_unittest.cpp b/fpdfsdk/fpdfeditimg_unittest.cpp index abe0ffe25c..2548ffe22e 100644 --- a/fpdfsdk/fpdfeditimg_unittest.cpp +++ b/fpdfsdk/fpdfeditimg_unittest.cpp @@ -35,9 +35,6 @@ TEST_F(PDFEditTest, InsertObjectWithInvalidPage) { FPDF_CloseDocument(doc); } -// https://bugs.chromium.org/p/pdfium/issues/detail?id=545 -// TODO(thestig): Add another test case that also calls -// FPDFPage_GenerateContent(). TEST_F(PDFEditTest, NewImgeObj) { FPDF_DOCUMENT doc = FPDF_CreateNewDocument(); FPDF_PAGE page = FPDFPage_New(doc, 0, 100, 100); @@ -50,3 +47,27 @@ TEST_F(PDFEditTest, NewImgeObj) { FPDF_ClosePage(page); FPDF_CloseDocument(doc); } + +TEST_F(PDFEditTest, NewImgeObjGenerateContent) { + FPDF_DOCUMENT doc = FPDF_CreateNewDocument(); + FPDF_PAGE page = FPDFPage_New(doc, 0, 100, 100); + EXPECT_EQ(0, FPDFPage_CountObject(page)); + + constexpr int kBitmapSize = 50; + FPDF_BITMAP bitmap = FPDFBitmap_Create(kBitmapSize, kBitmapSize, 0); + FPDFBitmap_FillRect(bitmap, 0, 0, kBitmapSize, kBitmapSize, 0x00000000); + EXPECT_EQ(kBitmapSize, FPDFBitmap_GetWidth(bitmap)); + EXPECT_EQ(kBitmapSize, FPDFBitmap_GetHeight(bitmap)); + + FPDF_PAGEOBJECT page_image = FPDFPageObj_NewImgeObj(doc); + ASSERT_TRUE(FPDFImageObj_SetBitmap(&page, 0, page_image, bitmap)); + ASSERT_TRUE( + FPDFImageObj_SetMatrix(page_image, kBitmapSize, 0, 0, kBitmapSize, 0, 0)); + FPDFPage_InsertObject(page, page_image); + EXPECT_EQ(1, FPDFPage_CountObject(page)); + EXPECT_TRUE(FPDFPage_GenerateContent(page)); + + FPDFBitmap_Destroy(bitmap); + FPDF_ClosePage(page); + FPDF_CloseDocument(doc); +} |