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

Side by Side Diff: fpdfsdk/fpdfeditimg_unittest.cpp

Issue 2494683007: Fix sevg above CPDF_PageContentGenerator::ProcessImage() (Closed)
Patch Set: Use IsInline() Created 4 years, 1 month 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 | « core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp ('k') | 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/cpdf_modulemgr.h" 7 #include "core/fpdfapi/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 25 matching lines...) Expand all
36 } 36 }
37 37
38 TEST_F(PDFEditTest, NewImgeObj) { 38 TEST_F(PDFEditTest, NewImgeObj) {
39 FPDF_DOCUMENT doc = FPDF_CreateNewDocument(); 39 FPDF_DOCUMENT doc = FPDF_CreateNewDocument();
40 FPDF_PAGE page = FPDFPage_New(doc, 0, 100, 100); 40 FPDF_PAGE page = FPDFPage_New(doc, 0, 100, 100);
41 EXPECT_EQ(0, FPDFPage_CountObject(page)); 41 EXPECT_EQ(0, FPDFPage_CountObject(page));
42 42
43 FPDF_PAGEOBJECT page_image = FPDFPageObj_NewImgeObj(doc); 43 FPDF_PAGEOBJECT page_image = FPDFPageObj_NewImgeObj(doc);
44 FPDFPage_InsertObject(page, page_image); 44 FPDFPage_InsertObject(page, page_image);
45 EXPECT_EQ(1, FPDFPage_CountObject(page)); 45 EXPECT_EQ(1, FPDFPage_CountObject(page));
46 EXPECT_TRUE(FPDFPage_GenerateContent(page));
46 47
47 FPDF_ClosePage(page); 48 FPDF_ClosePage(page);
48 FPDF_CloseDocument(doc); 49 FPDF_CloseDocument(doc);
49 } 50 }
50 51
51 TEST_F(PDFEditTest, NewImgeObjGenerateContent) { 52 TEST_F(PDFEditTest, NewImgeObjGenerateContent) {
52 FPDF_DOCUMENT doc = FPDF_CreateNewDocument(); 53 FPDF_DOCUMENT doc = FPDF_CreateNewDocument();
53 FPDF_PAGE page = FPDFPage_New(doc, 0, 100, 100); 54 FPDF_PAGE page = FPDFPage_New(doc, 0, 100, 100);
54 EXPECT_EQ(0, FPDFPage_CountObject(page)); 55 EXPECT_EQ(0, FPDFPage_CountObject(page));
55 56
56 constexpr int kBitmapSize = 50; 57 constexpr int kBitmapSize = 50;
57 FPDF_BITMAP bitmap = FPDFBitmap_Create(kBitmapSize, kBitmapSize, 0); 58 FPDF_BITMAP bitmap = FPDFBitmap_Create(kBitmapSize, kBitmapSize, 0);
58 FPDFBitmap_FillRect(bitmap, 0, 0, kBitmapSize, kBitmapSize, 0x00000000); 59 FPDFBitmap_FillRect(bitmap, 0, 0, kBitmapSize, kBitmapSize, 0x00000000);
59 EXPECT_EQ(kBitmapSize, FPDFBitmap_GetWidth(bitmap)); 60 EXPECT_EQ(kBitmapSize, FPDFBitmap_GetWidth(bitmap));
60 EXPECT_EQ(kBitmapSize, FPDFBitmap_GetHeight(bitmap)); 61 EXPECT_EQ(kBitmapSize, FPDFBitmap_GetHeight(bitmap));
61 62
62 FPDF_PAGEOBJECT page_image = FPDFPageObj_NewImgeObj(doc); 63 FPDF_PAGEOBJECT page_image = FPDFPageObj_NewImgeObj(doc);
63 ASSERT_TRUE(FPDFImageObj_SetBitmap(&page, 0, page_image, bitmap)); 64 ASSERT_TRUE(FPDFImageObj_SetBitmap(&page, 0, page_image, bitmap));
64 ASSERT_TRUE( 65 ASSERT_TRUE(
65 FPDFImageObj_SetMatrix(page_image, kBitmapSize, 0, 0, kBitmapSize, 0, 0)); 66 FPDFImageObj_SetMatrix(page_image, kBitmapSize, 0, 0, kBitmapSize, 0, 0));
66 FPDFPage_InsertObject(page, page_image); 67 FPDFPage_InsertObject(page, page_image);
67 EXPECT_EQ(1, FPDFPage_CountObject(page)); 68 EXPECT_EQ(1, FPDFPage_CountObject(page));
68 EXPECT_TRUE(FPDFPage_GenerateContent(page)); 69 EXPECT_TRUE(FPDFPage_GenerateContent(page));
69 70
70 FPDFBitmap_Destroy(bitmap); 71 FPDFBitmap_Destroy(bitmap);
71 FPDF_ClosePage(page); 72 FPDF_ClosePage(page);
72 FPDF_CloseDocument(doc); 73 FPDF_CloseDocument(doc);
73 } 74 }
OLDNEW
« no previous file with comments | « core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698