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
cpdfsdk_baannot_embeddertest.cpp
Go to the documentation of this file.
1
// Copyright 2019 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
<
vector
>
6
7
#
include
"core/fxcrt/check.h"
8
#
include
"core/fxcrt/check_op.h"
9
#
include
"fpdfsdk/cpdfsdk_annotiterator.h"
10
#
include
"fpdfsdk/cpdfsdk_baannot.h"
11
#
include
"fpdfsdk/cpdfsdk_formfillenvironment.h"
12
#
include
"fpdfsdk/cpdfsdk_helpers.h"
13
#
include
"fpdfsdk/cpdfsdk_pageview.h"
14
#
include
"testing/embedder_test.h"
15
16
class
CPDFSDKBAAnnotTest
:
public
EmbedderTest
{
17
public
:
18
void
SetUp
()
override
{
19
EmbedderTest
::
SetUp
();
20
SetUpBAAnnot
(
)
;
21
}
22
23
void
TearDown
()
override
{
24
UnloadPage
(m_page);
25
EmbedderTest
::
TearDown
();
26
}
27
28
void
SetUpBAAnnot
() {
29
ASSERT_TRUE(
OpenDocument
(
"links_highlights_annots.pdf"
));
30
m_page =
LoadPage
(0);
31
ASSERT_TRUE(m_page);
32
33
m_pFormFillEnv =
34
CPDFSDKFormFillEnvironmentFromFPDFFormHandle(
form_handle
());
35
ASSERT_TRUE(m_pFormFillEnv);
36
m_pPageView =
37
m_pFormFillEnv
->
GetOrCreatePageView
(
IPDFPageFromFPDFPage
(
m_page
)
)
;
38
ASSERT_TRUE(m_pPageView);
39
}
40
41
CPDFSDK_FormFillEnvironment*
GetFormFillEnv
()
const
{
return
m_pFormFillEnv; }
42
CPDFSDK_PageView*
GetPageView
()
const
{
return
m_pPageView; }
43
44
CPDFSDK_Annot
*
GetNthFocusableAnnot
(size_t n) {
45
DCHECK_NE
(n, 0);
46
CPDFSDK_AnnotIterator
ai(
GetPageView
(
)
,
47
m_pFormFillEnv->GetFocusableAnnotSubtypes());
48
CPDFSDK_Annot
* pAnnot = ai
.
GetFirstAnnot
(
)
;
49
DCHECK
(pAnnot);
50
51
for
(size_t i = 1; i < n; i++) {
52
pAnnot = ai
.
GetNextAnnot
(
pAnnot
)
;
53
DCHECK
(pAnnot);
54
}
55
56
return
pAnnot;
57
}
58
59
private
:
60
FPDF_PAGE m_page =
nullptr
;
61
CPDFSDK_PageView* m_pPageView =
nullptr
;
62
CPDFSDK_FormFillEnvironment* m_pFormFillEnv =
nullptr
;
63
};
64
65
TEST_F
(
CPDFSDKBAAnnotTest
,
TabToLinkOrHighlightAnnot
) {
66
std::vector<CPDF_Annot::Subtype> focusable_annot_types = {
67
CPDF_Annot
::
Subtype
::
WIDGET
,
CPDF_Annot
::
Subtype
::
LINK
,
68
CPDF_Annot
::
Subtype
::
HIGHLIGHT
};
69
70
GetFormFillEnv()->SetFocusableAnnotSubtypes(focusable_annot_types);
71
72
// Get link annot.
73
CPDFSDK_Annot
* pAnnot = GetNthFocusableAnnot(2);
74
ASSERT_TRUE(pAnnot);
75
EXPECT_EQ(pAnnot
->
GetAnnotSubtype
(
)
,
CPDF_Annot
::
Subtype
::
LINK
);
76
77
{
78
ObservedPtr<
CPDFSDK_Annot
> observer(pAnnot);
79
EXPECT_TRUE(
CPDFSDK_Annot
::
OnSetFocus
(
observer
,
{}
)
);
80
EXPECT_TRUE(
CPDFSDK_Annot
::
OnKillFocus
(
observer
,
{}
)
);
81
}
82
83
// Get highlight annot.
84
pAnnot = GetNthFocusableAnnot(4);
85
ASSERT_TRUE(pAnnot);
86
EXPECT_EQ(pAnnot
->
GetAnnotSubtype
(
)
,
CPDF_Annot
::
Subtype
::
HIGHLIGHT
);
87
88
{
89
ObservedPtr<
CPDFSDK_Annot
> observer(pAnnot);
90
EXPECT_TRUE(
CPDFSDK_Annot
::
OnSetFocus
(
observer
,
{}
)
);
91
EXPECT_TRUE(
CPDFSDK_Annot
::
OnKillFocus
(
observer
,
{}
)
);
92
}
93
}
DCHECK
#define DCHECK
Definition
check.h:33
DCHECK_NE
#define DCHECK_NE(x, y)
Definition
check_op.h:18
CPDFSDKBAAnnotTest
Definition
cpdfsdk_baannot_embeddertest.cpp:16
CPDFSDKBAAnnotTest::GetFormFillEnv
CPDFSDK_FormFillEnvironment * GetFormFillEnv() const
Definition
cpdfsdk_baannot_embeddertest.cpp:41
CPDFSDKBAAnnotTest::GetPageView
CPDFSDK_PageView * GetPageView() const
Definition
cpdfsdk_baannot_embeddertest.cpp:42
CPDFSDKBAAnnotTest::SetUpBAAnnot
void SetUpBAAnnot()
Definition
cpdfsdk_baannot_embeddertest.cpp:28
CPDFSDKBAAnnotTest::TearDown
void TearDown() override
Definition
cpdfsdk_baannot_embeddertest.cpp:23
CPDFSDKBAAnnotTest::GetNthFocusableAnnot
CPDFSDK_Annot * GetNthFocusableAnnot(size_t n)
Definition
cpdfsdk_baannot_embeddertest.cpp:44
CPDFSDKBAAnnotTest::SetUp
void SetUp() override
Definition
cpdfsdk_baannot_embeddertest.cpp:18
CPDFSDK_AnnotIterator
Definition
cpdfsdk_annotiterator.h:20
CPDFSDK_AnnotIterator::GetFirstAnnot
CPDFSDK_Annot * GetFirstAnnot()
Definition
cpdfsdk_annotiterator.cpp:48
CPDFSDK_AnnotIterator::GetNextAnnot
CPDFSDK_Annot * GetNextAnnot(CPDFSDK_Annot *pAnnot)
Definition
cpdfsdk_annotiterator.cpp:56
CPDFSDK_Annot
Definition
cpdfsdk_annot.h:24
CPDFSDK_Annot::OnKillFocus
static bool OnKillFocus(ObservedPtr< CPDFSDK_Annot > &pAnnot, Mask< FWL_EVENTFLAG > nFlags)
Definition
cpdfsdk_annot.cpp:110
CPDFSDK_Annot::GetAnnotSubtype
virtual CPDF_Annot::Subtype GetAnnotSubtype() const =0
CPDFSDK_Annot::OnSetFocus
static bool OnSetFocus(ObservedPtr< CPDFSDK_Annot > &pAnnot, Mask< FWL_EVENTFLAG > nFlags)
Definition
cpdfsdk_annot.cpp:104
CPDFSDK_FormFillEnvironment::GetOrCreatePageView
CPDFSDK_PageView * GetOrCreatePageView(IPDF_Page *pUnderlyingPage) override
Definition
cpdfsdk_formfillenvironment.cpp:618
CPDF_Annot
Definition
cpdf_annot.h:32
CPDF_Annot::Subtype
Subtype
Definition
cpdf_annot.h:35
CPDF_Annot::Subtype::WIDGET
@ WIDGET
Definition
cpdf_annot.h:56
CPDF_Annot::Subtype::HIGHLIGHT
@ HIGHLIGHT
Definition
cpdf_annot.h:45
CPDF_Annot::Subtype::LINK
@ LINK
Definition
cpdf_annot.h:38
EmbedderTest
Definition
embedder_test.h:40
EmbedderTest::SetUp
void SetUp() override
Definition
embedder_test.cpp:276
EmbedderTest::TearDown
void TearDown() override
Definition
embedder_test.cpp:284
EmbedderTest::LoadPage
FPDF_PAGE LoadPage(int page_index)
Definition
embedder_test.cpp:517
EmbedderTest::UnloadPage
void UnloadPage(FPDF_PAGE page)
Definition
embedder_test.cpp:542
EmbedderTest::form_handle
FPDF_FORMHANDLE form_handle() const
Definition
embedder_test.h:128
EmbedderTest::OpenDocument
bool OpenDocument(const std::string &filename)
Definition
embedder_test.cpp:304
TEST_F
TEST_F(CPDFSDKBAAnnotTest, TabToLinkOrHighlightAnnot)
Definition
cpdfsdk_baannot_embeddertest.cpp:65
IPDFPageFromFPDFPage
IPDF_Page * IPDFPageFromFPDFPage(FPDF_PAGE page)
Definition
cpdfsdk_helpers.cpp:197
qtwebengine
src
3rdparty
chromium
third_party
pdfium
fpdfsdk
cpdfsdk_baannot_embeddertest.cpp
Generated on
for Qt by
1.18.0