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

Unified Diff: core/fpdfapi/parser/cpdf_document_unittest.cpp

Issue 2491583002: Fix receiving page, if it have not obj num. (Closed)
Patch Set: Fix signed/unsigned comparison 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 side-by-side diff with in-line comments
Download patch
Index: core/fpdfapi/parser/cpdf_document_unittest.cpp
diff --git a/core/fpdfapi/parser/cpdf_document_unittest.cpp b/core/fpdfapi/parser/cpdf_document_unittest.cpp
index 7b5ab43b5c339ef1a60b788982472a759bd2ffea..a94aba663c3266165b2926b37847d6fd167953c2 100644
--- a/core/fpdfapi/parser/cpdf_document_unittest.cpp
+++ b/core/fpdfapi/parser/cpdf_document_unittest.cpp
@@ -43,7 +43,8 @@ class CPDF_TestDocumentForPages : public CPDF_Document {
CPDF_Array* zeroToTwo = new CPDF_Array();
zeroToTwo->AddReference(this, AddIndirectObject(CreateNumberedPage(0)));
zeroToTwo->AddReference(this, AddIndirectObject(CreateNumberedPage(1)));
- zeroToTwo->AddReference(this, AddIndirectObject(CreateNumberedPage(2)));
+ // Page without pageNum.
+ zeroToTwo->Add(CreateNumberedPage(2));
CPDF_Dictionary* branch1 = CreatePageTreeNode(zeroToTwo, this, 3);
CPDF_Array* zeroToThree = new CPDF_Array();
@@ -105,6 +106,18 @@ TEST_F(cpdf_document_test, GetPages) {
EXPECT_FALSE(page);
}
+TEST_F(cpdf_document_test, GetPageWithoutObjNumTwice) {
+ std::unique_ptr<CPDF_TestDocumentForPages> document =
+ pdfium::MakeUnique<CPDF_TestDocumentForPages>();
+ const auto page = document->GetPage(2);
Lei Zhang 2016/11/09 20:19:41 There's room on this line, so let's write const CP
snake 2016/11/09 20:30:41 Done.
+ ASSERT_TRUE(page);
+ // This is page without obj num.
+ ASSERT_EQ(0ul, page->GetObjNum());
+ const auto second_call_page = document->GetPage(2);
+ EXPECT_TRUE(second_call_page);
+ EXPECT_EQ(page, second_call_page);
+}
+
TEST_F(cpdf_document_test, GetPagesReverseOrder) {
std::unique_ptr<CPDF_TestDocumentForPages> document =
pdfium::MakeUnique<CPDF_TestDocumentForPages>();
« core/fpdfapi/parser/cpdf_document.cpp ('K') | « core/fpdfapi/parser/cpdf_document.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698