Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
fpdf_catalog_unittest.cpp
Go to the documentation of this file.
1
// Copyright 2017 The PDFium Authors
2
// Use of this source code is governed by a BSD-style license that can be
3
// found in the LICENSE file.
4
5
#
include
"public/fpdf_catalog.h"
6
7
#
include
<
memory
>
8
9
#
include
"core/fpdfapi/page/test_with_page_module.h"
10
#
include
"core/fpdfapi/parser/cpdf_dictionary.h"
11
#
include
"core/fpdfapi/parser/cpdf_document.h"
12
#
include
"core/fpdfapi/parser/cpdf_number.h"
13
#
include
"core/fpdfapi/parser/cpdf_parser.h"
14
#
include
"core/fpdfapi/parser/cpdf_string.h"
15
#
include
"core/fpdfapi/parser/cpdf_test_document.h"
16
#
include
"fpdfsdk/cpdfsdk_helpers.h"
17
#
include
"public/cpp/fpdf_scopers.h"
18
#
include
"testing/gtest/include/gtest/gtest.h"
19
20
class
PDFCatalogTest
:
public
TestWithPageModule
{
21
public
:
22
void
SetUp
()
override
{
23
TestWithPageModule
::
SetUp
();
24
auto
pTestDoc =
std
::make_unique<
CPDF_TestDocument
>();
25
m_pDoc.reset(FPDFDocumentFromCPDFDocument(pTestDoc.release()));
26
m_pRootObj = pdfium::MakeRetain<CPDF_Dictionary>();
27
}
28
29
void
TearDown
()
override
{
30
m_pDoc.reset();
31
TestWithPageModule
::
TearDown
();
32
}
33
34
protected
:
35
ScopedFPDFDocument
m_pDoc
;
36
RetainPtr
<
CPDF_Dictionary
>
m_pRootObj
;
37
};
38
39
TEST_F
(
PDFCatalogTest
,
IsTagged
) {
40
// Null doc
41
EXPECT_FALSE(
FPDFCatalog_IsTagged
(
nullptr
)
);
42
43
CPDF_TestDocument
* pTestDoc =
static_cast
<
CPDF_TestDocument
*>(
44
CPDFDocumentFromFPDFDocument(m_pDoc.get()));
45
46
// No root
47
pTestDoc
->
SetRoot
(
nullptr
);
48
EXPECT_FALSE(FPDFCatalog_IsTagged(m_pDoc.get()));
49
50
// Empty root
51
pTestDoc
->
SetRoot
(m_pRootObj);
52
EXPECT_FALSE(FPDFCatalog_IsTagged(m_pDoc.get()));
53
54
// Root with other key
55
m_pRootObj->SetNewFor<CPDF_String>(
"OTHER_KEY"
,
"other value"
);
56
EXPECT_FALSE(FPDFCatalog_IsTagged(m_pDoc.get()));
57
58
// Root with empty MarkInfo
59
auto
markInfoDict = m_pRootObj->SetNewFor<CPDF_Dictionary>(
"MarkInfo"
);
60
EXPECT_FALSE(FPDFCatalog_IsTagged(m_pDoc.get()));
61
62
// MarkInfo present but Marked is 0
63
markInfoDict->SetNewFor<CPDF_Number>(
"Marked"
, 0);
64
EXPECT_FALSE(FPDFCatalog_IsTagged(m_pDoc.get()));
65
66
// MarkInfo present and Marked is 1, PDF is considered tagged.
67
markInfoDict->SetNewFor<CPDF_Number>(
"Marked"
, 1);
68
EXPECT_TRUE(FPDFCatalog_IsTagged(m_pDoc.get()));
69
}
CPDF_Dictionary::DictMap
std::map< ByteString, RetainPtr< CPDF_Object >, std::less<> > DictMap
Definition
cpdf_dictionary.h:31
CPDF_TestDocument
Definition
cpdf_test_document.h:13
CPDF_TestDocument::SetRoot
void SetRoot(RetainPtr< CPDF_Dictionary > root)
Definition
cpdf_test_document.cpp:17
PDFCatalogTest
Definition
fpdf_catalog_unittest.cpp:20
PDFCatalogTest::TearDown
void TearDown() override
Definition
fpdf_catalog_unittest.cpp:29
PDFCatalogTest::m_pRootObj
RetainPtr< CPDF_Dictionary > m_pRootObj
Definition
fpdf_catalog_unittest.cpp:36
PDFCatalogTest::SetUp
void SetUp() override
Definition
fpdf_catalog_unittest.cpp:22
PDFCatalogTest::m_pDoc
ScopedFPDFDocument m_pDoc
Definition
fpdf_catalog_unittest.cpp:35
TestWithPageModule
Definition
test_with_page_module.h:10
TestWithPageModule::TearDown
void TearDown() override
Definition
test_with_page_module.cpp:13
TestWithPageModule::SetUp
void SetUp() override
Definition
test_with_page_module.cpp:9
fxcrt::RetainPtr
Definition
retain_ptr.h:28
FPDFCatalog_IsTagged
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFCatalog_IsTagged(FPDF_DOCUMENT document)
Definition
fpdf_catalog.cpp:14
TEST_F
TEST_F(PDFCatalogTest, IsTagged)
Definition
fpdf_catalog_unittest.cpp:39
std
[33]
Definition
src_corelib_tools_qhash.cpp:421
qtwebengine
src
3rdparty
chromium
third_party
pdfium
fpdfsdk
fpdf_catalog_unittest.cpp
Generated on
for Qt by
1.18.0