Index: fpdfsdk/fpdfeditimg_unittest.cpp |
diff --git a/fpdfsdk/fpdfeditimg_unittest.cpp b/fpdfsdk/fpdfeditimg_unittest.cpp |
index abe0ffe25c0a9c054d9fb489b8b190042b2c6cef..2548ffe22ee51fdca4298599927f941fa1637a7b 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); |
+} |