| OLD | NEW |
| 1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "public/fpdf_doc.h" | 5 #include "public/fpdf_doc.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "core/fpdfapi/cpdf_modulemgr.h" | 10 #include "core/fpdfapi/cpdf_modulemgr.h" |
| 11 #include "core/fpdfapi/parser/cpdf_document.h" | 11 #include "core/fpdfapi/parser/cpdf_document.h" |
| 12 #include "core/fpdfapi/parser/cpdf_name.h" | 12 #include "core/fpdfapi/parser/cpdf_name.h" |
| 13 #include "core/fpdfapi/parser/cpdf_number.h" | 13 #include "core/fpdfapi/parser/cpdf_number.h" |
| 14 #include "core/fpdfapi/parser/cpdf_parser.h" | 14 #include "core/fpdfapi/parser/cpdf_parser.h" |
| 15 #include "core/fpdfapi/parser/cpdf_reference.h" | 15 #include "core/fpdfapi/parser/cpdf_reference.h" |
| 16 #include "core/fpdfapi/parser/cpdf_string.h" | 16 #include "core/fpdfapi/parser/cpdf_string.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 18 #include "testing/test_support.h" | 18 #include "testing/test_support.h" |
| 19 #include "third_party/base/ptr_util.h" | 19 #include "third_party/base/ptr_util.h" |
| 20 | 20 |
| 21 #ifdef PDF_ENABLE_XFA | 21 #ifdef PDF_ENABLE_XFA |
| 22 #include "fpdfsdk/fpdfxfa/cpdfxfa_document.h" | 22 #include "fpdfsdk/fpdfxfa/cpdfxfa_context.h" |
| 23 #endif // PDF_ENABLE_XFA | 23 #endif // PDF_ENABLE_XFA |
| 24 | 24 |
| 25 class CPDF_TestDocument : public CPDF_Document { | 25 class CPDF_TestDocument : public CPDF_Document { |
| 26 public: | 26 public: |
| 27 CPDF_TestDocument() : CPDF_Document(nullptr) {} | 27 CPDF_TestDocument() : CPDF_Document(nullptr) {} |
| 28 | 28 |
| 29 void SetRoot(CPDF_Dictionary* root) { m_pRootDict = root; } | 29 void SetRoot(CPDF_Dictionary* root) { m_pRootDict = root; } |
| 30 CPDF_IndirectObjectHolder* GetHolder() { return this; } | 30 CPDF_IndirectObjectHolder* GetHolder() { return this; } |
| 31 }; | 31 }; |
| 32 | 32 |
| 33 #ifdef PDF_ENABLE_XFA | 33 #ifdef PDF_ENABLE_XFA |
| 34 class CPDF_TestXFADocument : public CPDFXFA_Document { | 34 class CPDF_TestXFAContext : public CPDFXFA_Context { |
| 35 public: | 35 public: |
| 36 CPDF_TestXFADocument() | 36 CPDF_TestXFAContext() |
| 37 : CPDFXFA_Document(pdfium::MakeUnique<CPDF_TestDocument>()) {} | 37 : CPDFXFA_Context(pdfium::MakeUnique<CPDF_TestDocument>()) {} |
| 38 | 38 |
| 39 void SetRoot(CPDF_Dictionary* root) { | 39 void SetRoot(CPDF_Dictionary* root) { |
| 40 reinterpret_cast<CPDF_TestDocument*>(GetPDFDoc())->SetRoot(root); | 40 reinterpret_cast<CPDF_TestDocument*>(GetPDFDoc())->SetRoot(root); |
| 41 } | 41 } |
| 42 | 42 |
| 43 CPDF_IndirectObjectHolder* GetHolder() { return GetPDFDoc(); } | 43 CPDF_IndirectObjectHolder* GetHolder() { return GetPDFDoc(); } |
| 44 }; | 44 }; |
| 45 using CPDF_TestPdfDocument = CPDF_TestXFADocument; | 45 using CPDF_TestPdfDocument = CPDF_TestXFAContext; |
| 46 #else // PDF_ENABLE_XFA | 46 #else // PDF_ENABLE_XFA |
| 47 using CPDF_TestPdfDocument = CPDF_TestDocument; | 47 using CPDF_TestPdfDocument = CPDF_TestDocument; |
| 48 #endif // PDF_ENABLE_XFA | 48 #endif // PDF_ENABLE_XFA |
| 49 | 49 |
| 50 class PDFDocTest : public testing::Test { | 50 class PDFDocTest : public testing::Test { |
| 51 public: | 51 public: |
| 52 struct DictObjInfo { | 52 struct DictObjInfo { |
| 53 uint32_t num; | 53 uint32_t num; |
| 54 CPDF_Dictionary* obj; | 54 CPDF_Dictionary* obj; |
| 55 }; | 55 }; |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 // Title with no match. | 223 // Title with no match. |
| 224 std::unique_ptr<unsigned short, pdfium::FreeDeleter> title = | 224 std::unique_ptr<unsigned short, pdfium::FreeDeleter> title = |
| 225 GetFPDFWideString(L"Chapter 8"); | 225 GetFPDFWideString(L"Chapter 8"); |
| 226 EXPECT_EQ(nullptr, FPDFBookmark_Find(m_pDoc.get(), title.get())); | 226 EXPECT_EQ(nullptr, FPDFBookmark_Find(m_pDoc.get(), title.get())); |
| 227 | 227 |
| 228 // Title with a match. | 228 // Title with a match. |
| 229 title = GetFPDFWideString(L"Chapter 3"); | 229 title = GetFPDFWideString(L"Chapter 3"); |
| 230 EXPECT_EQ(bookmarks[3].obj, FPDFBookmark_Find(m_pDoc.get(), title.get())); | 230 EXPECT_EQ(bookmarks[3].obj, FPDFBookmark_Find(m_pDoc.get(), title.get())); |
| 231 } | 231 } |
| 232 } | 232 } |
| OLD | NEW |