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
embedder_test_environment.cpp
Go to the documentation of this file.
1
// Copyright 2020 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
"testing/embedder_test_environment.h"
6
7
#
include
<
ostream
>
8
9
#
include
"core/fxcrt/check.h"
10
#
include
"core/fxcrt/fx_system.h"
11
#
include
"public/fpdfview.h"
12
#
include
"testing/command_line_helpers.h"
13
14
#
ifdef
PDF_ENABLE_V8
15
#
include
"testing/v8_test_environment.h"
16
#
endif
// PDF_ENABLE_V8
17
18
namespace
{
19
20
EmbedderTestEnvironment
* g_environment =
nullptr
;
21
22
}
// namespace
23
24
EmbedderTestEnvironment
::
EmbedderTestEnvironment
()
25
: renderer_type_(
GetDefaultRendererType
(
)
) {
26
DCHECK
(!g_environment);
27
g_environment =
this
;
28
}
29
30
EmbedderTestEnvironment
::~
EmbedderTestEnvironment
() {
31
DCHECK
(g_environment);
32
g_environment =
nullptr
;
33
}
34
35
// static
36
EmbedderTestEnvironment
*
EmbedderTestEnvironment
::
GetInstance
() {
37
return
g_environment;
38
}
39
40
void
EmbedderTestEnvironment
::
SetUp
() {
41
FPDF_LIBRARY_CONFIG config = {
42
.version = 4,
43
.m_pUserFontPaths = test_fonts_.font_paths(),
44
45
#
ifdef
PDF_ENABLE_V8
46
.m_pIsolate = V8TestEnvironment::GetInstance()->isolate(),
47
.m_v8EmbedderSlot = 0,
48
.m_pPlatform = V8TestEnvironment::GetInstance()->platform(),
49
#
else
// PDF_ENABLE_V8
50
.m_pIsolate =
nullptr
,
51
.m_v8EmbedderSlot = 0,
52
.m_pPlatform =
nullptr
,
53
#
endif
// PDF_ENABLE_V8
54
55
.m_RendererType = renderer_type_,
56
};
57
58
FPDF_InitLibraryWithConfig
(
&config
)
;
59
60
test_fonts_.InstallFontMapper();
61
}
62
63
void
EmbedderTestEnvironment
::
TearDown
() {
64
FPDF_DestroyLibrary
(
)
;
65
}
66
67
void
EmbedderTestEnvironment
::
AddFlags
(
int
argc,
char
** argv) {
68
for
(
int
i = 1; i < argc; ++i)
69
AddFlag(argv[i]);
70
}
71
72
void
EmbedderTestEnvironment
::AddFlag(
const
std
::string& flag) {
73
if
(flag ==
"--write-pngs"
) {
74
write_pngs_ =
true
;
75
return
;
76
}
77
#
if
defined
(
PDF_USE_SKIA
)
78
std::string value;
79
if
(ParseSwitchKeyValue(flag,
"--use-renderer="
, &value)) {
80
if
(value ==
"agg"
) {
81
renderer_type_ = FPDF_RENDERERTYPE_AGG;
82
}
else
if
(value ==
"skia"
) {
83
renderer_type_ = FPDF_RENDERERTYPE_SKIA;
84
}
else
{
85
std::cerr <<
"Invalid --use-renderer argument, value must be one of agg "
86
"or skia\n"
;
87
}
88
return
;
89
}
90
#
endif
// defined(PDF_USE_SKIA)
91
92
std::cerr <<
"Unknown flag: "
<< flag <<
"\n"
;
93
}
DCHECK
#define DCHECK
Definition
check.h:33
EmbedderTestEnvironment
Definition
embedder_test_environment.h:14
EmbedderTestEnvironment::SetUp
void SetUp() override
Definition
embedder_test_environment.cpp:40
EmbedderTestEnvironment::EmbedderTestEnvironment
EmbedderTestEnvironment()
Definition
embedder_test_environment.cpp:24
EmbedderTestEnvironment::AddFlags
void AddFlags(int argc, char **argv)
Definition
embedder_test_environment.cpp:67
EmbedderTestEnvironment::TearDown
void TearDown() override
Definition
embedder_test_environment.cpp:63
EmbedderTestEnvironment::GetInstance
static EmbedderTestEnvironment * GetInstance()
Definition
embedder_test_environment.cpp:36
EmbedderTestEnvironment::~EmbedderTestEnvironment
~EmbedderTestEnvironment() override
Definition
embedder_test_environment.cpp:30
GetDefaultRendererType
FPDF_RENDERER_TYPE GetDefaultRendererType()
Definition
command_line_helpers.cpp:17
FPDF_DestroyLibrary
FPDF_EXPORT void FPDF_CALLCONV FPDF_DestroyLibrary()
Definition
fpdf_view.cpp:257
FPDF_InitLibraryWithConfig
FPDF_EXPORT void FPDF_CALLCONV FPDF_InitLibraryWithConfig(const FPDF_LIBRARY_CONFIG *config)
Definition
fpdf_view.cpp:229
std
[33]
Definition
src_corelib_tools_qhash.cpp:421
qtwebengine
src
3rdparty
chromium
third_party
pdfium
testing
embedder_test_environment.cpp
Generated on
for Qt by
1.18.0