• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2018 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
5import("//build/config/sanitizers/sanitizers.gni")
6import("//build_overrides/build.gni")
7import("../pdfium.gni")
8
9source_set("test_support") {
10  testonly = true
11  sources = [
12    "command_line_helpers.cpp",
13    "command_line_helpers.h",
14    "font_renamer.cpp",
15    "font_renamer.h",
16    "fx_string_testhelpers.cpp",
17    "fx_string_testhelpers.h",
18    "invalid_seekable_read_stream.cpp",
19    "invalid_seekable_read_stream.h",
20    "pseudo_retainable.h",
21    "scoped_set_tz.cpp",
22    "scoped_set_tz.h",
23    "string_write_stream.cpp",
24    "string_write_stream.h",
25    "test_fonts.cpp",
26    "test_fonts.h",
27    "test_loader.cpp",
28    "test_loader.h",
29    "test_support.h",
30    "utils/bitmap_saver.cpp",
31    "utils/bitmap_saver.h",
32    "utils/file_util.cpp",
33    "utils/file_util.h",
34    "utils/hash.cpp",
35    "utils/hash.h",
36  ]
37  data = [ "resources/" ]
38  public_deps = [
39    ":path_service",
40    "//third_party/test_fonts",
41  ]
42  deps = [
43    "../:pdfium_public_headers",
44    "../core/fdrm",
45    "../core/fxcrt",
46    "../core/fxge",
47    "../fpdfsdk",
48    "image_diff",
49  ]
50  configs += [
51    "../:pdfium_strict_config",
52    "../:pdfium_noshorten_config",
53  ]
54  visibility = [ "../*" ]
55  if (is_posix) {
56    sources += [
57      "scoped_locale.cc",
58      "scoped_locale.h",
59    ]
60  }
61  if (pdf_use_partition_alloc) {
62    sources += [
63      "allocator_shim_config.cpp",
64      "allocator_shim_config.h",
65    ]
66    deps += [ "//base/allocator/partition_allocator/src/partition_alloc" ]
67  }
68  if (pdf_enable_v8) {
69    sources += [
70      "v8_initializer.cpp",
71      "v8_initializer.h",
72    ]
73    deps += [
74      "//v8",
75      "//v8:v8_libplatform",
76    ]
77    configs += [ "//v8:external_startup_data" ]
78  }
79}
80
81source_set("path_service") {
82  testonly = true
83  sources = [
84    "utils/path_service.cpp",
85    "utils/path_service.h",
86  ]
87  deps = [ "../core/fxcrt" ]
88  configs += [
89    "../:pdfium_strict_config",
90    "../:pdfium_noshorten_config",
91  ]
92  visibility = [ "../*" ]
93}
94
95source_set("test_environments") {
96  testonly = true
97  sources = [
98    "pdf_test_environment.cpp",
99    "pdf_test_environment.h",
100  ]
101  deps = [
102    ":test_support",
103    "../core/fxcrt",
104    "../core/fxge",
105    "//testing/gtest",
106  ]
107  configs += [
108    "../:pdfium_strict_config",
109    "../:pdfium_noshorten_config",
110  ]
111  if (pdf_enable_v8) {
112    sources += [
113      "v8_test_environment.cpp",
114      "v8_test_environment.h",
115    ]
116    deps += [
117      "../fxjs",
118      "//v8",
119      "//v8:v8_libplatform",
120    ]
121    configs += [ "//v8:external_startup_data" ]
122  }
123  if (pdf_enable_xfa) {
124    sources += [
125      "xfa_test_environment.cpp",
126      "xfa_test_environment.h",
127    ]
128    deps += [
129      "../fxjs:gc",
130      "../xfa/fgas/font",
131    ]
132  }
133}
134
135source_set("unit_test_support") {
136  testonly = true
137  sources = []
138  deps = []
139  configs += [
140    "../:pdfium_strict_config",
141    "../:pdfium_noshorten_config",
142  ]
143  public_deps = [
144    ":test_environments",
145    ":test_support",
146  ]
147  if (pdf_enable_v8) {
148    sources += [
149      "fxv8_unittest.cpp",
150      "fxv8_unittest.h",
151    ]
152    deps += [
153      "../fxjs",
154      "//testing/gtest",
155    ]
156    configs += [ "//v8:external_startup_data" ]
157    if (pdf_enable_xfa) {
158      sources += [
159        "fxgc_unittest.cpp",
160        "fxgc_unittest.h",
161      ]
162      deps += [
163        "../fxjs:gc",
164        "//testing/gtest",
165      ]
166    }
167  }
168}
169
170source_set("embedder_test_support") {
171  testonly = true
172  sources = [
173    "embedder_test.cpp",
174    "embedder_test.h",
175    "embedder_test_constants.cpp",
176    "embedder_test_constants.h",
177    "embedder_test_environment.cpp",
178    "embedder_test_environment.h",
179    "embedder_test_mock_delegate.h",
180    "embedder_test_timer_handling_delegate.h",
181    "fake_file_access.cpp",
182    "fake_file_access.h",
183    "range_set.cpp",
184    "range_set.h",
185    "utils/compare_coordinates.cc",
186    "utils/compare_coordinates.h",
187  ]
188  deps = [
189    "../:pdfium_public_headers",
190    "../core/fdrm",
191    "../core/fxge",
192    "../fpdfsdk",
193    "//testing/gmock",
194    "//testing/gtest",
195  ]
196  public_deps = [
197    ":test_environments",
198    ":test_support",
199    "../core/fxcrt",
200  ]
201  configs += [
202    "../:pdfium_strict_config",
203    "../:pdfium_noshorten_config",
204  ]
205  visibility = [ "../*" ]
206  if (pdf_enable_v8) {
207    sources += [
208      "external_engine_embedder_test.cpp",
209      "external_engine_embedder_test.h",
210      "js_embedder_test.cpp",
211      "js_embedder_test.h",
212    ]
213    deps += [
214      "../fxjs",
215      "//v8",
216      "//v8:v8_libplatform",
217    ]
218    configs += [ "//v8:external_startup_data" ]
219    if (pdf_enable_xfa) {
220      sources += [
221        "xfa_js_embedder_test.cpp",
222        "xfa_js_embedder_test.h",
223      ]
224      deps += [
225        "../fpdfsdk",
226        "../fpdfsdk/fpdfxfa",
227        "../xfa/fxfa",
228        "../xfa/fxfa/parser",
229      ]
230    }
231  }
232}
233
234config("pdfium_test_config") {
235  cflags = []
236  ldflags = []
237  defines = []
238  include_dirs = [ ".." ]
239  if (pdf_use_skia) {
240    defines += [ "PDF_ENABLE_SKIA" ]
241  }
242  if (is_asan) {
243    defines += [ "PDF_ENABLE_ASAN" ]
244  }
245  if (pdf_use_partition_alloc) {
246    defines += [ "PDF_USE_PARTITION_ALLOC" ]
247  }
248  if (enable_callgrind) {
249    defines += [ "ENABLE_CALLGRIND" ]
250  }
251  if (build_with_chromium) {
252    defines += [ "BUILD_WITH_CHROMIUM" ]
253  }
254}
255
256executable("pdfium_test") {
257  testonly = true
258  sources = [
259    "helpers/dump.cc",
260    "helpers/dump.h",
261    "helpers/event.cc",
262    "helpers/event.h",
263    "helpers/page_renderer.cc",
264    "helpers/page_renderer.h",
265    "helpers/write.cc",
266    "helpers/write.h",
267    "pdfium_test.cc",
268  ]
269
270  # Note: One should write programs that depend on ../:pdfium. Whereas this
271  # test program does not set a good example, and depends on PDFium internals,
272  # as well as test support code, for convenience.
273  deps = [
274    "../:pdfium_public_headers",
275    "../fpdfsdk",
276    "../testing:test_support",
277    "../testing/image_diff",
278    "//build/win:default_exe_manifest",
279  ]
280  configs += [
281    ":pdfium_test_config",
282    "../:pdfium_common_config",
283  ]
284
285  if (is_win) {
286    sources += [
287      "helpers/win32/com_factory.cc",
288      "helpers/win32/com_factory.h",
289    ]
290  }
291
292  if (pdf_enable_v8) {
293    deps += [
294      "//v8:v8_headers",
295      "//v8:v8_libplatform",
296    ]
297    include_dirs = [ "//v8" ]
298    configs += [ "//v8:external_startup_data" ]
299  }
300  if (pdf_use_skia) {
301    deps += [ "//skia" ]
302    if (build_with_chromium) {
303      sources += [
304        "chromium_support/discardable_memory_allocator.cc",
305        "chromium_support/discardable_memory_allocator.h",
306      ]
307      deps += [ "//base/test:test_support" ]
308    }
309  }
310
311  if (!build_with_chromium) {
312    assert_no_deps = [ "//testing/gtest/*" ]
313  }
314}
315
316# Dummy group to keep satisfy references from //build.
317group("test_scripts_shared") {
318}
319