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

Side by Side Diff: fpdfsdk/fpdfeditimg_unittest.cpp

Issue 2194393002: Fix a leak with FPDFPageObj_NewImgeObj(). (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: nit 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 | « fpdfsdk/fpdfeditimg.cpp ('k') | pdfium.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "public/fpdf_edit.h"
6
7 #include "core/fpdfapi/include/cpdf_modulemgr.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9
10 class PDFEditTest : public testing::Test {
11 void SetUp() override {
12 CPDF_ModuleMgr* module_mgr = CPDF_ModuleMgr::Get();
13 module_mgr->InitPageModule();
14 }
15
16 void TearDown() override { CPDF_ModuleMgr::Destroy(); }
17 };
18
19 TEST_F(PDFEditTest, InsertObjectWithInvalidPage) {
20 FPDF_DOCUMENT doc = FPDF_CreateNewDocument();
21 FPDF_PAGE page = FPDFPage_New(doc, 0, 100, 100);
22 EXPECT_EQ(0, FPDFPage_CountObject(page));
23
24 FPDFPage_InsertObject(nullptr, nullptr);
25 EXPECT_EQ(0, FPDFPage_CountObject(page));
26
27 FPDFPage_InsertObject(page, nullptr);
28 EXPECT_EQ(0, FPDFPage_CountObject(page));
29
30 FPDF_PAGEOBJECT page_image = FPDFPageObj_NewImgeObj(doc);
31 FPDFPage_InsertObject(nullptr, page_image);
32 EXPECT_EQ(0, FPDFPage_CountObject(page));
33
34 FPDF_ClosePage(page);
35 FPDF_CloseDocument(doc);
36 }
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) {
42 FPDF_DOCUMENT doc = FPDF_CreateNewDocument();
43 FPDF_PAGE page = FPDFPage_New(doc, 0, 100, 100);
44 EXPECT_EQ(0, FPDFPage_CountObject(page));
45
46 FPDF_PAGEOBJECT page_image = FPDFPageObj_NewImgeObj(doc);
47 FPDFPage_InsertObject(page, page_image);
48 EXPECT_EQ(1, FPDFPage_CountObject(page));
49
50 FPDF_ClosePage(page);
51 FPDF_CloseDocument(doc);
52 }
OLDNEW
« no previous file with comments | « fpdfsdk/fpdfeditimg.cpp ('k') | pdfium.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698