diff options
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; }; |