diff options
author | art-snake <art-snake@yandex-team.ru> | 2016-11-07 08:42:04 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-11-07 08:42:04 -0800 |
commit | 240dec52b2e6502e7deb27a3535af3b1a3e23428 (patch) | |
tree | ead5a550c7988ac3291452e524296634423f3012 /core/fpdfapi/parser/cpdf_document_unittest.cpp | |
parent | a94fc11866adb1b9ca4a4e1afb4fb574ed472e07 (diff) | |
download | pdfium-240dec52b2e6502e7deb27a3535af3b1a3e23428.tar.xz |
Reland of Unify some code
Unify some code
Move parsing of linearized header into separate CPDF_Linearized class.
Original review:
https://codereview.chromium.org/2466023002/
Revert review:
https://codereview.chromium.org/2474283005/
Revert reason was:
Breaking the chrome roll.
See https://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_rel_ng/builds/331856
___
Added Fix for fuzzers.
Review-Url: https://codereview.chromium.org/2477213003
Diffstat (limited to 'core/fpdfapi/parser/cpdf_document_unittest.cpp')
-rw-r--r-- | core/fpdfapi/parser/cpdf_document_unittest.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/core/fpdfapi/parser/cpdf_document_unittest.cpp b/core/fpdfapi/parser/cpdf_document_unittest.cpp index 16d0ade069..e20a5a1d1d 100644 --- a/core/fpdfapi/parser/cpdf_document_unittest.cpp +++ b/core/fpdfapi/parser/cpdf_document_unittest.cpp @@ -9,15 +9,13 @@ #include "core/fpdfapi/cpdf_modulemgr.h" #include "core/fpdfapi/parser/cpdf_array.h" #include "core/fpdfapi/parser/cpdf_dictionary.h" +#include "core/fpdfapi/parser/cpdf_linearized.h" #include "core/fpdfapi/parser/cpdf_parser.h" #include "core/fxcrt/fx_memory.h" #include "testing/gtest/include/gtest/gtest.h" namespace { -using ScopedDictionary = - std::unique_ptr<CPDF_Dictionary, ReleaseDeleter<CPDF_Dictionary>>; - CPDF_Dictionary* CreatePageTreeNode(CPDF_Array* kids, CPDF_Document* pDoc, int count) { @@ -77,6 +75,11 @@ class CPDF_TestDocumentForPages : public CPDF_Document { private: std::unique_ptr<CPDF_Dictionary> m_pOwnedRootDict; }; + +class TestLinearized : public CPDF_Linearized { + public: + explicit TestLinearized(CPDF_Dictionary* dict) : CPDF_Linearized(dict) {} +}; } // namespace class cpdf_document_test : public testing::Test { @@ -142,10 +145,12 @@ TEST_F(cpdf_document_test, UseCachedPageObjNumIfHaveNotPagesDict) { // can be not exists in this case. // (case, when hint table is used to page check in CPDF_DataAvail). CPDF_Document document(pdfium::MakeUnique<CPDF_Parser>()); - std::unique_ptr<CPDF_Dictionary> dict(new CPDF_Dictionary()); + auto dict = pdfium::MakeUnique<CPDF_Dictionary>(); + dict->SetBooleanFor("Linearized", true); const int page_count = 100; dict->SetIntegerFor("N", page_count); - document.LoadLinearizedDoc(dict.get()); + TestLinearized linearized(dict.get()); + document.LoadLinearizedDoc(&linearized); ASSERT_EQ(page_count, document.GetPageCount()); CPDF_Object* page_stub = new CPDF_Dictionary(); const uint32_t obj_num = document.AddIndirectObject(page_stub); |