Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
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 "fpdfsdk/cpdfsdk_annotiterator.h"
8#include "fpdfsdk/cpdfsdk_baannot.h"
9#include "fpdfsdk/cpdfsdk_formfillenvironment.h"
10#include "fpdfsdk/cpdfsdk_helpers.h"
11#include "fpdfsdk/cpdfsdk_pageview.h"
12#include "testing/embedder_test.h"
13#include "third_party/base/check.h"
14#include "third_party/base/check_op.h"
15
17 public:
22
24 UnloadPage(m_page);
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 =
38 ASSERT_TRUE(m_pPageView);
39 }
40
41 CPDFSDK_FormFillEnvironment* GetFormFillEnv() const { return m_pFormFillEnv; }
42 CPDFSDK_PageView* GetPageView() const { return m_pPageView; }
43
45 DCHECK_NE(n, 0);
47 m_pFormFillEnv->GetFocusableAnnotSubtypes());
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
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);
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);
87
88 {
89 ObservedPtr<CPDFSDK_Annot> observer(pAnnot);
90 EXPECT_TRUE(CPDFSDK_Annot::OnSetFocus(observer, {}));
91 EXPECT_TRUE(CPDFSDK_Annot::OnKillFocus(observer, {}));
92 }
93}
CPDFSDK_Annot * GetNextAnnot(CPDFSDK_Annot *pAnnot)
static bool OnKillFocus(ObservedPtr< CPDFSDK_Annot > &pAnnot, Mask< FWL_EVENTFLAG > nFlags)
virtual CPDF_Annot::Subtype GetAnnotSubtype() const =0
static bool OnSetFocus(ObservedPtr< CPDFSDK_Annot > &pAnnot, Mask< FWL_EVENTFLAG > nFlags)
CPDFSDK_FormFillEnvironment * GetFormFillEnv() const
CPDFSDK_Annot * GetNthFocusableAnnot(size_t n)
CPDFSDK_PageView * GetPageView() const
CPDFSDK_PageView * GetOrCreatePageView(IPDF_Page *pUnderlyingPage) override
void SetUp() override
void TearDown() override
void UnloadPage(FPDF_PAGE page)
FPDF_PAGE LoadPage(int page_number)
FPDF_FORMHANDLE form_handle() const
bool OpenDocument(const std::string &filename)
TEST_F(CPDFSDK_BAAnnotTest, TabToLinkOrHighlightAnnot)
IPDF_Page * IPDFPageFromFPDFPage(FPDF_PAGE page)