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

Side by Side Diff: core/fpdfapi/parser/cpdf_document_unittest.cpp

Issue 2437773003: Fix loading page using hint tables. (Closed)
Patch Set: fix compilation on linux. Created 4 years, 2 months 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 unified diff | Download patch
OLDNEW
(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 "core/fpdfapi/parser/cpdf_document.h"
6
7 #include <memory>
8
9 #include "core/fpdfapi/parser/cpdf_parser.h"
10 #include "core/fpdfapi/parser/cpdf_dictionary.h"
11 #include "core/fxcrt/fx_memory.h"
12 #include "testing/gtest/include/gtest/gtest.h"
13
14 namespace {
15
16 using ScopedDictionary =
17 std::unique_ptr<CPDF_Dictionary, ReleaseDeleter<CPDF_Dictionary>>;
18
19 } // namespace
20
21 TEST(cpdf_document, UseCachedPageObjNumIfHaveNotPagesDict) {
22 // ObjNum can be added in CPDF_DataAvail::IsPageAvail, and PagesDict
23 // can be not exists in this case.
24 // (case, when hint table is used to page check in CPDF_DataAvail).
25 std::unique_ptr<CPDF_Parser> parser(new CPDF_Parser());
Lei Zhang 2016/10/20 21:43:36 BTW, we have pdfium::MakeUnique, so please take ad
26 CPDF_Document document(std::move(parser));
27 ScopedDictionary dict(new CPDF_Dictionary());
28 const int page_count = 100;
29 dict->SetIntegerFor("N", page_count);
30 document.LoadLinearizedDoc(dict.get());
31 ASSERT_EQ(page_count, document.GetPageCount());
32 CPDF_Object* page_stub = new CPDF_Dictionary();
33 const uint32_t obj_num = document.AddIndirectObject(page_stub);
34 const int test_page_num = 33;
35
36 EXPECT_FALSE(document.IsPageLoaded(test_page_num));
37 EXPECT_EQ(nullptr, document.GetPage(test_page_num));
38
39 document.SetPageObjNum(test_page_num, obj_num);
40 EXPECT_TRUE(document.IsPageLoaded(test_page_num));
41 EXPECT_EQ(page_stub, document.GetPage(test_page_num));
42 }
OLDNEW
« core/fpdfapi/parser/cpdf_data_avail.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