Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(954)

Unified Diff: fpdfsdk/fpdfeditimg_unittest.cpp

Issue 2229103003: Add another PDFEditTest test case. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: use bitmap size constant more Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
+}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698