diff options
author | Tom Sepez <tsepez@chromium.org> | 2018-05-01 17:25:25 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-05-01 17:25:25 +0000 |
commit | fe06d5109cd575c1e53b9b1cc3cc4ec3c5d7364f (patch) | |
tree | fb6744bab0823722b566978e6a8195bf1509b8b2 /fpdfsdk/fpdf_doc_unittest.cpp | |
parent | 302c8ce0ee78ecb10398c9b1fa2796d116bbb4a5 (diff) | |
download | pdfium-fe06d5109cd575c1e53b9b1cc3cc4ec3c5d7364f.tar.xz |
Make FPDF_Document always be CPDF_Document.
Greatly minimize the impact between going back and forth from
XFA being on/off, so that XFA case is just an extension beyond
the non-XFA data structures we've shipped for years, instead of
being a complete replacement of them.
Change-Id: I6c98206e0ec99ea443547a4931eba912b1764d54
Reviewed-on: https://pdfium-review.googlesource.com/31690
Reviewed-by: dsinclair <dsinclair@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fpdfsdk/fpdf_doc_unittest.cpp')
-rw-r--r-- | fpdfsdk/fpdf_doc_unittest.cpp | 30 |
1 files changed, 6 insertions, 24 deletions
diff --git a/fpdfsdk/fpdf_doc_unittest.cpp b/fpdfsdk/fpdf_doc_unittest.cpp index bfd42628d1..01c790507f 100644 --- a/fpdfsdk/fpdf_doc_unittest.cpp +++ b/fpdfsdk/fpdf_doc_unittest.cpp @@ -18,6 +18,7 @@ #include "core/fpdfapi/parser/cpdf_string.h" #include "core/fpdfdoc/cpdf_dest.h" #include "fpdfsdk/cpdfsdk_helpers.h" +#include "public/cpp/fpdf_scopers.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/test_support.h" #include "third_party/base/ptr_util.h" @@ -34,23 +35,6 @@ class CPDF_TestDocument : public CPDF_Document { CPDF_IndirectObjectHolder* GetHolder() { return this; } }; -#ifdef PDF_ENABLE_XFA -class CPDF_TestXFAContext : public CPDFXFA_Context { - public: - CPDF_TestXFAContext() - : CPDFXFA_Context(pdfium::MakeUnique<CPDF_TestDocument>()) {} - - void SetRoot(CPDF_Dictionary* root) { - static_cast<CPDF_TestDocument*>(GetPDFDoc())->SetRoot(root); - } - - CPDF_IndirectObjectHolder* GetHolder() { return GetPDFDoc(); } -}; -using CPDF_TestPdfDocument = CPDF_TestXFAContext; -#else // PDF_ENABLE_XFA -using CPDF_TestPdfDocument = CPDF_TestDocument; -#endif // PDF_ENABLE_XFA - class PDFDocTest : public testing::Test { public: struct DictObjInfo { @@ -60,13 +44,11 @@ class PDFDocTest : public testing::Test { void SetUp() override { CPDF_ModuleMgr::Get()->Init(); - - m_pDoc = pdfium::MakeUnique<CPDF_TestPdfDocument>(); - m_pIndirectObjs = m_pDoc->GetHolder(); - - // Setup the root directory. + auto pTestDoc = pdfium::MakeUnique<CPDF_TestDocument>(); + m_pIndirectObjs = pTestDoc->GetHolder(); m_pRootObj = pdfium::MakeUnique<CPDF_Dictionary>(); - m_pDoc->SetRoot(m_pRootObj.get()); + pTestDoc->SetRoot(m_pRootObj.get()); + m_pDoc.reset(FPDFDocumentFromCPDFDocument(pTestDoc.release())); } void TearDown() override { @@ -87,7 +69,7 @@ class PDFDocTest : public testing::Test { } protected: - std::unique_ptr<CPDF_TestPdfDocument> m_pDoc; + ScopedFPDFDocument m_pDoc; UnownedPtr<CPDF_IndirectObjectHolder> m_pIndirectObjs; std::unique_ptr<CPDF_Dictionary> m_pRootObj; }; |