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

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

Issue 2470803003: Traverse PDF page tree only once in CPDF_Document Try 3 (Closed)
Patch Set: Comments 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 c09665b716a98d2693329661fbf00d5e0ea90b21..71716a649ea1e198c71ada56173a3254e267a425 100644
--- a/core/fpdfapi/parser/cpdf_document_unittest.cpp
+++ b/core/fpdfapi/parser/cpdf_document_unittest.cpp
@@ -95,7 +95,7 @@ TEST_F(cpdf_document_test, GetPages) {
for (int i = 0; i < 7; i++) {
CPDF_Dictionary* page = document->GetPage(i);
ASSERT_TRUE(page);
- ASSERT_TRUE(page->GetObjectFor("PageNumbering"));
+ ASSERT_TRUE(page->KeyExist("PageNumbering"));
EXPECT_EQ(i, page->GetIntegerFor("PageNumbering"));
}
CPDF_Dictionary* page = document->GetPage(7);
@@ -108,13 +108,36 @@ TEST_F(cpdf_document_test, GetPagesReverseOrder) {
for (int i = 6; i >= 0; i--) {
CPDF_Dictionary* page = document->GetPage(i);
ASSERT_TRUE(page);
- ASSERT_TRUE(page->GetObjectFor("PageNumbering"));
+ ASSERT_TRUE(page->KeyExist("PageNumbering"));
EXPECT_EQ(i, page->GetIntegerFor("PageNumbering"));
}
CPDF_Dictionary* page = document->GetPage(7);
EXPECT_FALSE(page);
}
+TEST(cpdf_document, GetPagesInDisorder) {
+ std::unique_ptr<CPDF_TestDocumentForPages> document =
+ pdfium::MakeUnique<CPDF_TestDocumentForPages>();
+
+ CPDF_Dictionary* page = document->GetPage(1);
+ ASSERT_TRUE(page);
+ ASSERT_TRUE(page->KeyExist("PageNumbering"));
+ EXPECT_EQ(1, page->GetIntegerFor("PageNumbering"));
+
+ page = document->GetPage(3);
+ ASSERT_TRUE(page);
+ ASSERT_TRUE(page->KeyExist("PageNumbering"));
+ EXPECT_EQ(3, page->GetIntegerFor("PageNumbering"));
+
+ page = document->GetPage(7);
+ EXPECT_FALSE(page);
+
+ page = document->GetPage(6);
+ ASSERT_TRUE(page);
+ ASSERT_TRUE(page->KeyExist("PageNumbering"));
+ EXPECT_EQ(6, page->GetIntegerFor("PageNumbering"));
+}
+
TEST_F(cpdf_document_test, UseCachedPageObjNumIfHaveNotPagesDict) {
// ObjNum can be added in CPDF_DataAvail::IsPageAvail, and PagesDict
// can be not exists in this case.
« 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