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..f27e7403f645b8b2c71f720ae07cc4bc119ad031 100644 |
--- a/core/fpdfapi/parser/cpdf_document_unittest.cpp |
+++ b/core/fpdfapi/parser/cpdf_document_unittest.cpp |
@@ -76,6 +76,27 @@ class CPDF_TestDocumentForPages : public CPDF_Document { |
std::unique_ptr<CPDF_Dictionary> m_pOwnedRootDict; |
}; |
+class CPDF_TestDocumentWithPageWithoutPageNum : public CPDF_Document { |
+ public: |
+ CPDF_TestDocumentWithPageWithoutPageNum() : CPDF_Document(nullptr) { |
+ // Set up test |
+ CPDF_Array* allPages = new CPDF_Array(); |
+ allPages->AddReference(this, AddIndirectObject(CreateNumberedPage(0))); |
+ allPages->AddReference(this, AddIndirectObject(CreateNumberedPage(1))); |
+ // Page without pageNum. |
+ allPages->Add(CreateNumberedPage(2)); |
+ CPDF_Dictionary* pagesDict = CreatePageTreeNode(allPages, this, 3); |
+ |
+ m_pOwnedRootDict.reset(new CPDF_Dictionary()); |
+ m_pOwnedRootDict->SetReferenceFor("Pages", this, pagesDict->GetObjNum()); |
+ m_pRootDict = m_pOwnedRootDict.get(); |
+ m_PageList.SetSize(3); |
+ } |
+ |
+ private: |
+ std::unique_ptr<CPDF_Dictionary> m_pOwnedRootDict; |
+}; |
+ |
class TestLinearized : public CPDF_LinearizedHeader { |
public: |
explicit TestLinearized(CPDF_Dictionary* dict) |
@@ -105,6 +126,18 @@ TEST_F(cpdf_document_test, GetPages) { |
EXPECT_FALSE(page); |
} |
+TEST_F(cpdf_document_test, GetPageWithoutObjNumTwice) { |
+ std::unique_ptr<CPDF_TestDocumentWithPageWithoutPageNum> document = |
+ pdfium::MakeUnique<CPDF_TestDocumentWithPageWithoutPageNum>(); |
+ const CPDF_Dictionary* page = document->GetPage(2); |
+ ASSERT_TRUE(page); |
+ // This is page without obj num. |
+ ASSERT_EQ(0ul, page->GetObjNum()); |
+ const CPDF_Dictionary* 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>(); |