summaryrefslogtreecommitdiff
path: root/core/fpdfapi/parser/cpdf_document_unittest.cpp
diff options
context:
space:
mode:
authorart-snake <art-snake@yandex-team.ru>2016-11-04 18:17:27 -0700
committerCommit bot <commit-bot@chromium.org>2016-11-04 18:17:27 -0700
commit71333dc57ac7e4cf7963c83333730b3882ab371f (patch)
treef675d5bfbe53b7803879acbe42a4663d9e390879 /core/fpdfapi/parser/cpdf_document_unittest.cpp
parent04bebfe590d6d27a825b881fd234e31501843edc (diff)
downloadpdfium-71333dc57ac7e4cf7963c83333730b3882ab371f.tar.xz
Unify some code
Move parsing of linearized header into separate CPDF_Linearized class. Review-Url: https://codereview.chromium.org/2466023002
Diffstat (limited to 'core/fpdfapi/parser/cpdf_document_unittest.cpp')
-rw-r--r--core/fpdfapi/parser/cpdf_document_unittest.cpp15
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);