gl/test: Move some initialization code used in tests to a separate component.
[chromium-blink-merge.git] / content / test / BUILD.gn
blob0dbffbdb0022a76a505f145e135c6838fb53a41f
1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
5 import("//build/config/chrome_build.gni")
6 import("//build/config/crypto.gni")
7 import("//build/config/features.gni")
8 import("//build/config/ui.gni")
9 import("//build/module_args/v8.gni")
10 import("//testing/test.gni")
11 import("//third_party/mojo/src/mojo/public/tools/bindings/mojom.gni")
13 content_tests_gypi_values =
14     exec_script("//build/gypi_to_gn.py",
15                 [
16                   rebase_path("../content_tests.gypi"),
17                   "--replace=<(SHARED_INTERMEDIATE_DIR)=$root_gen_dir",
18                 ],
19                 "scope",
20                 [ "../content_tests.gypi" ])
22 # GYP version //content/content_tests.gypi:test_support_content
23 source_set("test_support") {
24   testonly = true
25   public_deps = [
26     "//content/public/app:both",
27     "//content/public/browser",
28     "//content/public/common",
29   ]
30   deps = [
31     "//cc/blink",
32     "//net:test_support",
33     "//skia",
34     "//storage/common",
35     "//testing/gmock",
36     "//testing/gtest",
37     "//ui/accessibility:ax_gen",
38     "//ui/base",
39     "//ui/base/ime",
40     "//ui/base:test_support",
41     "//ui/events:dom_keycode_converter",
42     "//ui/events:events_base",
43     "//ui/events:test_support",
44     "//ui/events:gesture_detection",
45     "//ui/gfx:test_support",
46     "//ui/gl",
47     "//ui/gl:test_support",
48     "//ui/resources",
49     "//url",
50   ]
52   if (!is_ios) {
53     sources =
54         rebase_path(content_tests_gypi_values.test_support_content_sources,
55                     ".",
56                     "//content")
58     public_deps += [ "//third_party/WebKit/public:blink" ]
59     deps += [
60       ":content_test_mojo_bindings",
61       "//components/scheduler:scheduler",
62       "//components/scheduler:test_support",
63       "//content/browser/speech/proto",
64       "//content/public/child",
65       "//content/gpu",
66       "//content/public/plugin",
67       "//content/public/renderer",
68       "//content/public/utility",
69       "//content/shell:pak",
70       "//cc",
71       "//cc:test_support",
72       "//ipc/mojo",
73       "//media",
74       "//mojo/application/public/cpp:cpp_for_chromium",
75       "//mojo/environment:chromium",
76       "//ppapi/host",
77       "//ppapi/proxy",
78       "//ppapi/proxy:test_support",
79       "//ppapi/shared_impl",
80       "//ppapi/shared_impl:test_support",
81       "//storage/browser",
82       "//storage/common",
83       "//ui/surface",
84       "//v8",
85     ]
87     if (enable_plugins) {
88       deps += [ "//content/ppapi_plugin" ]
89     }
91     if (enable_webrtc) {
92       sources += [
93         "../renderer/media/mock_data_channel_impl.cc",
94         "../renderer/media/mock_data_channel_impl.h",
95         "../renderer/media/mock_media_stream_dispatcher.cc",
96         "../renderer/media/mock_media_stream_dispatcher.h",
97         "../renderer/media/mock_peer_connection_impl.cc",
98         "../renderer/media/mock_peer_connection_impl.h",
99         "../renderer/media/mock_web_rtc_peer_connection_handler_client.cc",
100         "../renderer/media/mock_web_rtc_peer_connection_handler_client.h",
101         "../renderer/media/webrtc/mock_peer_connection_dependency_factory.cc",
102         "../renderer/media/webrtc/mock_peer_connection_dependency_factory.h",
103       ]
105       deps += [
106         "//third_party/libjingle:libjingle_webrtc",
107         "//third_party/libjingle:libpeerconnection",
108         "//third_party/webrtc/modules/video_capture",
109       ]
110     }
111     if (!enable_plugins) {
112       sources -= [ "ppapi_unittest.cc" ]
113     }
115     if (use_glib) {
116       configs += [ "//build/config/linux:glib" ]
117     }
119     if (use_aura) {
120       deps += [
121         "//ui/aura:test_support",
122         "//ui/resources:ui_test_pak",
123         "//ui/wm",
124       ]
125     }
127     if (use_aura || is_mac) {
128       deps += [ "//ui/compositor" ]
129     }
131     if (use_ozone) {
132       deps += [ "//ui/ozone" ]
133     }
135     if (is_win) {
136       deps += [
137         "//content:startup_helper_win",
138         "//third_party/iaccessible2",
139       ]
140     }
142     if (!is_android && !is_ios) {
143       sources += [
144         "../browser/compositor/test/no_transport_image_transport_factory.cc",
145         "../browser/compositor/test/no_transport_image_transport_factory.h",
146       ]
147       deps += [
148         "//ui/compositor",
149         "//third_party/libvpx",
150       ]
151     }
153     if (is_android) {
154       deps += [
155         "//content/shell/android:copy_content_shell_assets",
156         "//ui/android",
157         "//ui/shell_dialogs",
158       ]
159     }
161     if (is_win) {
162       deps += [ "//sandbox" ]
163     }
164   } else {  # is_ios
165     sources = [
166       "public/test/content_test_suite_base.cc",
167       "public/test/mock_notification_observer.cc",
168       "public/test/mock_resource_context.cc",
169       "public/test/test_browser_thread.cc",
170       "public/test/test_content_client_initializer.cc",
171       "public/test/test_notification_tracker.cc",
172       "public/test/test_utils.cc",
173       "public/test/unittest_test_suite.cc",
174       "test/content_test_suite.cc",
175       "test/test_content_browser_client.cc",
176       "test/test_content_client.cc",
177     ]
178   }
179   if (v8_use_external_startup_data) {
180     deps += [ "//gin:gin" ]
181   }
184 source_set("browsertest_support") {
185   testonly = true
187   sources = [
188     "../public/test/content_browser_test.cc",
189     "../public/test/content_browser_test.h",
190     "../public/test/content_browser_test_utils.cc",
191     "../public/test/content_browser_test_utils.h",
192     "../public/test/content_browser_test_utils_mac.mm",
193     "content_browser_test_utils_internal.cc",
194     "content_browser_test_utils_internal.h",
195     "content_test_launcher.cc",
196   ]
198   deps = [
199     "//content/shell:content_shell_lib",
200     "//skia",
201     "//testing/gtest",
202     "//ui/accessibility:ax_gen",
203   ]
205   if (is_android) {
206     deps += [ "//content/public/app:both" ]
207   } else {
208     deps += [ "//content/public/browser" ]
209   }
212 mojom("content_test_mojo_bindings") {
213   sources = [
214     "../public/test/test_mojo_service.mojom",
215   ]
218 mojom("web_ui_test_mojo_bindings") {
219   sources = [
220     "data/web_ui_test_mojo_bindings.mojom",
221   ]
224 if (!is_ios) {
225   # GYP version //content/content_tests.gypi:layouttest_support_content
226   static_library("layouttest_support") {
227     testonly = true
228     sources = rebase_path(
229             content_tests_gypi_values.layouttest_support_content_sources,
230             ".",
231             "//content")
233     deps = [
234       ":test_support",
235       "//cc",
236       "//cc/blink",
237       "//components/test_runner:test_runner",
238       "//content/public/common",
239       "//skia",
240       "//v8",
241       "//ui/accessibility:ax_gen",
242     ]
244     if (is_android) {
245       deps += [ ":jni" ]
246     }
247   }
249   if (is_android) {
250     import("//build/config/android/rules.gni")
252     generate_jni("jni") {
253       sources = [
254         "../public/test/android/javatests/src/org/chromium/content/browser/test/NestedSystemMessageHandler.java",
255       ]
256       jni_package = "content/public/test"
257     }
258   }
259 }  # !is_ios
261 # TODO(GYP) enable content_browsertests on Mac when it links.
262 if (!is_mac) {
263   test("content_browsertests") {
264     sources =
265         rebase_path(content_tests_gypi_values.content_browsertests_sources,
266                     ".",
267                     "//content")
269     defines = [ "HAS_OUT_OF_PROC_TEST_RUNNER" ]
271     configs += [ "//build/config/compiler:no_size_t_to_int_warning" ]
273     deps = [
274       ":browsertest_support",
275       ":web_ui_test_mojo_bindings",
276       "//base/allocator",
277       "//base/test:test_support",
278       "//content/common:mojo_bindings",
279       "//content/gpu",
280       "//content/public/common",
281       "//content/public/plugin",
282       "//content/public/renderer",
283       "//content:resources",
284       "//content/shell:content_shell_lib",
285       "//content/shell:pak",
286       "//content/test:test_support",
287       "//device/battery",
288       "//device/battery:mojo_bindings",
289       "//gin",
290       "//gpu",
291       "//ipc:test_support",
292       "//media:test_support",
293       "//media/audio:test_support",
294       "//media/base:test_support",
295       "//media:shared_memory_support",
296       "//mojo/application/public/cpp:cpp_for_chromium",
297       "//mojo/environment:chromium",
298       "//mojo/test:test_support",
299       "//net:test_support",
300       "//ppapi/host",
301       "//ppapi/proxy",
302       "//ppapi/proxy:ipc",
303       "//ppapi/shared_impl",
304       "//third_party/mojo/src/mojo/edk/system",
305       "//third_party/mojo/src/mojo/edk/test:test_support",
306       "//third_party/mojo/src/mojo/public/cpp/bindings",
307       "//third_party/mojo/src/mojo/public/js",
308       "//testing/gmock",
309       "//testing/gtest",
310       "//third_party/WebKit/public:blink",
311       "//third_party/leveldatabase",
312       "//third_party/mesa:osmesa",
313       "//third_party/zlib",
314       "//ui/accessibility",
315       "//ui/accessibility:ax_gen",
316       "//ui/base",
317       "//ui/base/ime",
318       "//ui/gfx",
319       "//ui/gfx/geometry",
320       "//ui/gl",
321       "//ui/gl:test_support",
322       "//ui/resources",
323       "//ui/shell_dialogs",
324       "//ui/snapshot",
325     ]
327     data_deps = [ "//ppapi:ppapi_tests" ]  # Loaded at runtime.
329     if (!is_chromeos) {
330       sources -=
331           [ "../browser/web_contents/touch_editable_impl_aura_browsertest.cc" ]
332     }
334     if (is_win) {
335       sources += rebase_path(
336               content_tests_gypi_values.content_browsertests_win_sources,
337               ".",
338               "//content")
340       deps += [
341         "//content/app/strings",
342         "//net:net_resources",
343         "//third_party/WebKit/public:resources",
344         "//third_party/iaccessible2",
345         "//third_party/isimpledom",
346       ]
348       libs = [ "oleacc.lib" ]
349     }
351     if (is_linux) {
352       sources -=
353           [ "../browser/accessibility/dump_accessibility_tree_browsertest.cc" ]
354     }
356     if (is_android) {
357       sources += rebase_path(
358               content_tests_gypi_values.content_browsertests_android_sources,
359               ".",
360               "//content")
361       sources -=
362           [ "../browser/battery_status/battery_monitor_impl_browsertest.cc" ]
363       deps += [
364         "//content/shell/android:content_shell_jni_headers",
365         "//content/shell:content_shell_lib",
366         "//testing/android/native_test:native_test_support",
367       ]
369       use_launcher = false
370     }
372     if (is_mac) {
373       sources += [ "../renderer/external_popup_menu_browsertest.cc" ]
374       deps += [
375         # Needed for Content Shell.app's Helper.
376         #"//content/shell:content_shell",  #TODO(GYP) enable for mac
377       ]
378     }
380     if (use_aura && !is_win) {
381       deps += [ "//ui/events:test_support" ]
382     }
384     if (!use_aura && !is_mac) {
385       sources -=
386           [ "../browser/compositor/image_transport_factory_browsertest.cc" ]
387     }
389     if (enable_webrtc) {
390       sources += rebase_path(
391               content_tests_gypi_values.content_browsertests_webrtc_sources,
392               ".",
393               "//content")
394       deps += [ "//testing/perf" ]
395     }
397     if (enable_plugins) {
398       sources += rebase_path(
399               content_tests_gypi_values.content_browsertests_plugins_sources,
400               ".",
401               "//content")
402       data_deps += [ "//ppapi:ppapi_tests" ]
403     }
405     if (enable_web_speech) {
406       sources += rebase_path(
407               content_tests_gypi_values.content_browsertests_speech_sources,
408               ".",
409               "//content")
410     }
412     if (!is_chrome_branded) {
413       sources += rebase_path(
414               content_tests_gypi_values.content_browsertests_unofficial_build_sources,
415               ".",
416               "//content")
417     }
419     if (!use_aura) {
420       sources -=
421           [ "../browser/web_contents/web_contents_view_aura_browsertest.cc" ]
422     }
423   }
426 test("content_unittests") {
427   sources = rebase_path(content_tests_gypi_values.content_unittests_sources,
428                         ".",
429                         "//content")
430   deps = [
431     ":test_support",
432     "//base/allocator",
433     "//base/test:test_support",
434     "//content/browser/background_sync:background_sync_proto",
435     "//content/browser/notifications:notification_proto",
436     "//content/browser/service_worker:service_worker_proto",
437     "//content/browser/speech/proto",
438     "//content/common:mojo_bindings",
439     "//content/public/browser",
440     "//content/public/common",
441     "//content/public/common:mojo_bindings",
442     "//crypto",
443     "//device/battery",
444     "//device/battery:mojo_bindings",
445     "//mojo/environment:chromium",
446     "//net:extras",
447     "//net:test_support",
448     "//skia",
449     "//sql",
450     "//sql:test_support",
451     "//testing/gmock",
452     "//testing/gtest",
453     "//third_party/mojo/src/mojo/edk/test:test_support",
454     "//third_party/mojo/src/mojo/public/cpp/bindings",
455     "//third_party/re2",
456     "//ui/accessibility",
457     "//ui/base",
458     "//ui/events/blink",
459     "//ui/gfx",
460     "//ui/gfx/geometry",
461     "//ui/gfx/ipc",
462   ]
464   if (!is_ios) {
465     deps += [
466       "//base/third_party/dynamic_annotations",
467       "//cc",
468       "//cc:test_support",
469       "//cc/surfaces",
470       "//content:resources",
471       "//content/gpu",
472       "//content/public/browser",
473       "//content/public/child",
474       "//content/public/plugin",
475       "//content/public/renderer",
476       "//gin",
477       "//gpu",
478       "//gpu:test_support",
479       "//ipc:test_support",
480       "//media:test_support",
481       "//media:shared_memory_support",
482       "//media/audio:test_support",
483       "//media/base:test_support",
484       "//media/midi:midi",
485       "//storage/browser",
486       "//storage/common",
487       "//third_party/WebKit/public:blink",
488       "//third_party/icu",
489       "//third_party/leveldatabase",
490       "//third_party/libjingle",
491       "//ui/gl",
492       "//ui/gl:test_support",
493     ]
494   }
496   if (!is_win) {
497     sources += [ "../browser/file_descriptor_info_impl_unittest.cc" ]
498   }
500   if (enable_plugins) {
501     sources +=
502         rebase_path(content_tests_gypi_values.content_unittests_plugins_sources,
503                     ".",
504                     "//content")
505   }
507   if (enable_webrtc) {
508     sources +=
509         rebase_path(content_tests_gypi_values.content_unittests_webrtc_sources,
510                     ".",
511                     "//content")
512     deps += [
513       "//third_party/libjingle:libjingle_webrtc",
514       "//third_party/libjingle:libpeerconnection",
515       "//third_party/webrtc/modules/video_capture",
516     ]
518     if (is_linux || is_mac || is_win) {
519       sources +=
520           [ "../browser/media/capture/desktop_capture_device_unittest.cc" ]
521       deps += [ "//third_party/webrtc/modules/desktop_capture" ]
522     }
524     if (is_chromeos) {
525       sources +=
526           [ "../browser/media/capture/desktop_capture_device_aura_unittest.cc" ]
527     }
528   } else {
529     if (enable_plugins) {
530       # This file is added only when plugins are enabled, but we don't want it
531       # unless webrtc is also enabled.
532       sources -=
533           [ "../renderer/media/webrtc/video_destination_handler_unittest.cc" ]
534     }
535   }
537   if (enable_web_speech) {
538     sources +=
539         rebase_path(content_tests_gypi_values.content_unittests_speech_sources,
540                     ".",
541                     "//content")
542   }
544   if (is_linux) {
545     if (use_dbus) {
546       deps += [ "//dbus:test_support" ]
547     } else {
548       sources -=
549           [ "../browser/geolocation/wifi_data_provider_linux_unittest.cc" ]
550     }
551   }
552   if (is_win) {
553     deps += [ "//third_party/iaccessible2" ]
554   }
555   if (is_mac) {
556     # These flags are needed to run the test on Mac.
557     # Search for comments about "xcode_settings" in chrome_tests.gypi.
558     ldflags = [ "-Wl,-ObjC" ]
560     deps += [ "//third_party/ocmock" ]
561   }
562   if (is_chromeos) {
563     sources -= [ "../browser/geolocation/wifi_data_provider_linux_unittest.cc" ]
564     deps += [ "//chromeos" ]
565   }
566   if (is_android) {
567     sources +=
568         rebase_path(content_tests_gypi_values.content_unittests_android_sources,
569                     ".",
570                     "//content")
571     sources -= [
572       "../browser/geolocation/network_location_provider_unittest.cc",
573       "../browser/geolocation/wifi_data_provider_common_unittest.cc",
574       "../browser/renderer_host/begin_frame_observer_proxy_unittest.cc",
575       "../browser/webui/url_data_manager_backend_unittest.cc",
576     ]
577     deps += [ "//testing/android/native_test:native_test_native_code" ]
578   }
579   if (!is_android && !is_ios) {
580     deps += [ "//third_party/libvpx" ]
581   }
583   if (use_aura) {
584     deps += [
585       "//ui/aura",
586       "//ui/aura_extra",
587       "//ui/wm",
588     ]
589   } else {
590     sources -= [
591       "../browser/renderer_host/render_widget_host_view_aura_unittest.cc",
592       "../browser/renderer_host/web_input_event_aura_unittest.cc",
593       "../browser/web_contents/aura/overscroll_navigation_overlay_unittest.cc",
594       "../browser/web_contents/aura/overscroll_window_animation_unittest.cc",
595       "../browser/web_contents/aura/overscroll_window_delegate_unittest.cc",
596       "../browser/web_contents/web_contents_view_aura_unittest.cc",
597     ]
598   }
599   if (use_aura || toolkit_views) {
600     deps += [ "//ui/events:test_support" ]
601   }
602   if (!use_aura && !is_mac) {
603     sources -= [
604       "../browser/compositor/buffer_queue_unittest.cc",
605       "../browser/compositor/reflector_impl_unittest.cc",
606       "../browser/compositor/software_browser_compositor_output_surface_unittest.cc",
607     ]
608   }
610   if (!is_win && !is_mac) {
611     sources -= [ "../common/plugin_list_unittest.cc" ]
612   }
614   if (use_ozone) {
615     deps += [
616       "//ui/ozone",
617       "//ui/ozone:ozone_base",
618     ]
619   } else {
620     sources -=
621         [ "../browser/compositor/software_output_device_ozone_unittest.cc" ]
622   }
624   if (is_mac && use_openssl) {
625     deps += [ "//third_party/boringssl" ]
626   }
629 if (!is_mac) {  # TODO(GYP) enable on Mac once it links.
630   test("content_perftests") {
631     sources = [
632       "../browser/renderer_host/input/input_router_impl_perftest.cc",
633       "../common/cc_messages_perftest.cc",
634       "../test/run_all_perftests.cc",
635     ]
636     deps = [
637       "//base/allocator",
638       "//base/test:test_support",
639       "//content/public/browser",
640       "//content/public/common",
641       "//content/test:test_support",
642       "//cc",
643       "//skia",
644       "//testing/gtest",
645       "//testing/perf",
646       "//ui/gfx",
647       "//ui/gfx/geometry",
648     ]
650     if (is_android) {
651       deps += [ "//testing/android/native_test:native_test_native_code" ]
652     }
653   }
655   test("content_gl_tests") {
656     sources = [
657       "../common/gpu/client/gl_helper_unittest.cc",
658       "../common/gpu/client/gpu_in_process_context_tests.cc",
659     ]
661     deps = [
662       ":test_support",
663       "//base/allocator",
664       "//base/test:test_support",
665       "//content/public/common",
666       "//gpu/blink",
667       "//gpu/command_buffer/common",
668       "//testing/gtest",
669       "//third_party/WebKit/public:blink",
670       "//ui/base",
671       "//ui/gfx",
672       "//ui/gfx:test_support",
673       "//ui/gfx/geometry",
674       "//ui/gl",
675       "//ui/gl:test_support",
676       "//v8",
677     ]
679     if (is_android) {
680       deps += [ "//testing/android/native_test:native_test_native_code" ]
681     } else {
682       data_deps = [
683         "//third_party/ffmpeg",
684         "//third_party/mesa:osmesa",
685       ]
686     }
687   }
689   test("content_gl_benchmark") {
690     sources = [
691       "../common/gpu/client/gl_helper_benchmark.cc",
692     ]
694     deps = [
695       ":test_support",
696       "//base/allocator",
697       "//base/test:test_support",
698       "//content/public/common",
699       "//gpu/blink",
700       "//testing/gtest",
701       "//third_party/WebKit/public:blink",
702       "//ui/base",
703       "//ui/gfx",
704       "//ui/gfx/geometry",
705       "//ui/gl",
706       "//ui/gl:test_support",
707     ]
708   }