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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 PDFium Authors. All rights reserved. 1 // Copyright 2016 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "public/fpdf_edit.h" 5 #include "public/fpdf_edit.h"
6 6
7 #include "core/fpdfapi/include/cpdf_modulemgr.h" 7 #include "core/fpdfapi/include/cpdf_modulemgr.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 class PDFEditTest : public testing::Test { 10 class PDFEditTest : public testing::Test {
(...skipping 17 matching lines...) Expand all
28 EXPECT_EQ(0, FPDFPage_CountObject(page)); 28 EXPECT_EQ(0, FPDFPage_CountObject(page));
29 29
30 FPDF_PAGEOBJECT page_image = FPDFPageObj_NewImgeObj(doc); 30 FPDF_PAGEOBJECT page_image = FPDFPageObj_NewImgeObj(doc);
31 FPDFPage_InsertObject(nullptr, page_image); 31 FPDFPage_InsertObject(nullptr, page_image);
32 EXPECT_EQ(0, FPDFPage_CountObject(page)); 32 EXPECT_EQ(0, FPDFPage_CountObject(page));
33 33
34 FPDF_ClosePage(page); 34 FPDF_ClosePage(page);
35 FPDF_CloseDocument(doc); 35 FPDF_CloseDocument(doc);
36 } 36 }
37 37
38 // https://bugs.chromium.org/p/pdfium/issues/detail?id=545
39 // TODO(thestig): Add another test case that also calls
40 // FPDFPage_GenerateContent().
41 TEST_F(PDFEditTest, NewImgeObj) { 38 TEST_F(PDFEditTest, NewImgeObj) {
42 FPDF_DOCUMENT doc = FPDF_CreateNewDocument(); 39 FPDF_DOCUMENT doc = FPDF_CreateNewDocument();
43 FPDF_PAGE page = FPDFPage_New(doc, 0, 100, 100); 40 FPDF_PAGE page = FPDFPage_New(doc, 0, 100, 100);
44 EXPECT_EQ(0, FPDFPage_CountObject(page)); 41 EXPECT_EQ(0, FPDFPage_CountObject(page));
45 42
46 FPDF_PAGEOBJECT page_image = FPDFPageObj_NewImgeObj(doc); 43 FPDF_PAGEOBJECT page_image = FPDFPageObj_NewImgeObj(doc);
47 FPDFPage_InsertObject(page, page_image); 44 FPDFPage_InsertObject(page, page_image);
48 EXPECT_EQ(1, FPDFPage_CountObject(page)); 45 EXPECT_EQ(1, FPDFPage_CountObject(page));
49 46
50 FPDF_ClosePage(page); 47 FPDF_ClosePage(page);
51 FPDF_CloseDocument(doc); 48 FPDF_CloseDocument(doc);
52 } 49 }
50
51 TEST_F(PDFEditTest, NewImgeObjGenerateContent) {
52 FPDF_DOCUMENT doc = FPDF_CreateNewDocument();
53 FPDF_PAGE page = FPDFPage_New(doc, 0, 100, 100);
54 EXPECT_EQ(0, FPDFPage_CountObject(page));
55
56 constexpr int kBitmapSize = 50;
57 FPDF_BITMAP bitmap = FPDFBitmap_Create(kBitmapSize, kBitmapSize, 0);
58 FPDFBitmap_FillRect(bitmap, 0, 0, kBitmapSize, kBitmapSize, 0x00000000);
59 EXPECT_EQ(kBitmapSize, FPDFBitmap_GetWidth(bitmap));
60 EXPECT_EQ(kBitmapSize, FPDFBitmap_GetHeight(bitmap));
61
62 FPDF_PAGEOBJECT page_image = FPDFPageObj_NewImgeObj(doc);
63 ASSERT_TRUE(FPDFImageObj_SetBitmap(&page, 0, page_image, bitmap));
64 ASSERT_TRUE(
65 FPDFImageObj_SetMatrix(page_image, kBitmapSize, 0, 0, kBitmapSize, 0, 0));
66 FPDFPage_InsertObject(page, page_image);
67 EXPECT_EQ(1, FPDFPage_CountObject(page));
68 EXPECT_TRUE(FPDFPage_GenerateContent(page));
69
70 FPDFBitmap_Destroy(bitmap);
71 FPDF_ClosePage(page);
72 FPDF_CloseDocument(doc);
73 }
OLDNEW
« 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