OLD | NEW |
---|---|
(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 } | |
OLD | NEW |