summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdf_catalog_unittest.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-05-01 17:25:25 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-05-01 17:25:25 +0000
commitfe06d5109cd575c1e53b9b1cc3cc4ec3c5d7364f (patch)
treefb6744bab0823722b566978e6a8195bf1509b8b2 /fpdfsdk/fpdf_catalog_unittest.cpp
parent302c8ce0ee78ecb10398c9b1fa2796d116bbb4a5 (diff)
downloadpdfium-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_catalog_unittest.cpp')
-rw-r--r--fpdfsdk/fpdf_catalog_unittest.cpp33
1 files changed, 9 insertions, 24 deletions
diff --git a/fpdfsdk/fpdf_catalog_unittest.cpp b/fpdfsdk/fpdf_catalog_unittest.cpp
index 648cb24e7a..54eb4f77a0 100644
--- a/fpdfsdk/fpdf_catalog_unittest.cpp
+++ b/fpdfsdk/fpdf_catalog_unittest.cpp
@@ -12,6 +12,7 @@
#include "core/fpdfapi/parser/cpdf_parser.h"
#include "core/fpdfapi/parser/cpdf_string.h"
#include "fpdfsdk/cpdfsdk_helpers.h"
+#include "public/cpp/fpdf_scopers.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/test_support.h"
@@ -29,31 +30,12 @@ class CPDF_TestDocument : public CPDF_Document {
}
};
-#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 PDFCatalogTest : public testing::Test {
public:
void SetUp() override {
CPDF_ModuleMgr::Get()->Init();
-
- m_pDoc = pdfium::MakeUnique<CPDF_TestPdfDocument>();
-
- // Setup the root directory.
+ auto pTestDoc = pdfium::MakeUnique<CPDF_TestDocument>();
+ m_pDoc.reset(FPDFDocumentFromCPDFDocument(pTestDoc.release()));
m_pRootObj = pdfium::MakeUnique<CPDF_Dictionary>();
}
@@ -63,7 +45,7 @@ class PDFCatalogTest : public testing::Test {
}
protected:
- std::unique_ptr<CPDF_TestPdfDocument> m_pDoc;
+ ScopedFPDFDocument m_pDoc;
std::unique_ptr<CPDF_Dictionary> m_pRootObj;
};
@@ -71,12 +53,15 @@ TEST_F(PDFCatalogTest, IsTagged) {
// Null doc
EXPECT_FALSE(FPDFCatalog_IsTagged(nullptr));
+ CPDF_TestDocument* pTestDoc = static_cast<CPDF_TestDocument*>(
+ CPDFDocumentFromFPDFDocument(m_pDoc.get()));
+
// No root
- m_pDoc->SetRoot(nullptr);
+ pTestDoc->SetRoot(nullptr);
EXPECT_FALSE(FPDFCatalog_IsTagged(m_pDoc.get()));
// Empty root
- m_pDoc->SetRoot(m_pRootObj.get());
+ pTestDoc->SetRoot(m_pRootObj.get());
EXPECT_FALSE(FPDFCatalog_IsTagged(m_pDoc.get()));
// Root with other key