OLD | NEW |
(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 } |
OLD | NEW |