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

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

Issue 2491583002: Fix receiving page, if it have not obj num. (Closed)
Patch Set: Fix review issues 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
« no previous file with comments | « core/fpdfapi/parser/cpdf_document.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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>();
« no previous file with comments | « core/fpdfapi/parser/cpdf_document.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698