1 # Copyright 2015 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/buildflag_header.gni")
6 import("//build/config/features.gni")
7 import("//build/config/sanitizers/sanitizers.gni")
8 import("//build/config/ui.gni")
9 import("//chromecast/build/tests/cast_test.gni")
10 import("//chromecast/chromecast.gni")
11 import("//media/media_options.gni")
12 import("//tools/grit/repack.gni")
13 import("//ui/ozone/ozone.gni")
14 import("//v8/gni/v8.gni")
17 import("//build/config/android/rules.gni")
21 cast_test_extra_flags = ""
22 vendor_cast_media_gtest_excludes = []
25 # Depends on all non-test targets that should be built by the Chromecast
26 # internal build infrastructure.
29 if (is_android && chromecast_branding == "public") {
30 deps += [ ":cast_shell_apk" ]
33 deps += [ ":cast_shell" ]
36 deps += [ "//chromecast/tracing" ]
38 if (chromecast_branding != "public") {
39 deps += [ "//chromecast/internal:all" ]
41 if (enable_external_mojo_services) {
42 deps += [ "//chromecast/external_mojo/external_service_support:standalone_mojo_broker" ]
45 # No other targets should depend on this target, since it's just a convenience
46 # target for the Chromecast internal build infrastructure.
51 # This is a config which is applied on all cast_* targets (which should be all
52 # code under chromecast/).
53 config("cast_config") {
56 # A list of all public test() binaries. This is an organizational target that
57 # cannot be depended upon or built directly. Build cast_test_lists instead.
58 cast_test_group("cast_tests") {
61 "//base:base_unittests",
63 "//chromecast/base:cast_base_unittests",
64 "//chromecast/base/component:cast_component_unittests",
65 "//chromecast/crypto:cast_crypto_unittests",
66 "//chromecast/device/bluetooth:cast_bluetooth_unittests",
67 "//chromecast/media:cast_media_unittests",
68 "//chromecast/net:cast_net_unittests",
69 "//chromecast/system/reboot:cast_reboot_unittests",
70 "//content/test:content_unittests",
71 "//crypto:crypto_unittests",
72 "//media:media_unittests",
73 "//media/midi:midi_unittests",
74 "//net:net_unittests",
75 "//sql:sql_unittests",
76 "//storage:storage_unittests",
77 "//third_party/cacheinvalidation:cacheinvalidation_unittests",
78 "//ui/base:ui_base_unittests",
81 if (!is_cast_audio_only) {
82 tests += [ "//gpu:gpu_unittests" ]
85 tests += [ "//chromecast/graphics:cast_graphics_unittests" ]
91 "//chromecast/crash:cast_crash_unittests",
92 "//components/exo:exo_unittests",
93 "//sandbox/linux:sandbox_linux_unittests",
97 if (is_linux || is_fuchsia) {
98 tests += [ "//chromecast/media/cma/backend:cast_audio_backend_unittests" ]
101 if (is_android && is_cast_using_cma_backend) {
102 tests += [ "//chromecast/media/cma/backend/android:cast_android_cma_backend_unittests" ]
105 cast_media_unittests_filter = {
106 test_name = "cast_media_unittests"
108 gtest_excludes = vendor_cast_media_gtest_excludes
110 # --test-launcher-jobs=1 => so internal code can bind to port
111 args = [ "--test-launcher-jobs=1" ]
113 filters += [ cast_media_unittests_filter ]
117 ":cast_shell_browsertests",
118 ":cast_shell_unittests",
120 "//url:url_unittests",
124 tests += [ "//jingle:jingle_unittests" ]
127 cast_shell_browsertests_filter = {
128 test_name = "cast_shell_browsertests"
130 # --enable-local-file-accesses => to load sample media files
131 # --test-launcher-jobs=1 => so internal code can bind to port
134 "--enable-local-file-accesses",
135 "--test-launcher-jobs=1",
140 # TODO(b/112440248): This test was failing:
141 # * On v1 and Cast Audio devices since 2017-03-15.
142 # * On desktop builds since 2018-08-22
143 # Also see: b/36238710, b/36239051, hotlist/461351
144 gtest_excludes += [ "RendererPrelauncherTest.ReusedRenderer" ]
146 if (!is_cast_desktop_build) {
147 args += [ "--use-gpu-in-tests" ]
149 # TODO(derekjchow): Make these tests pass on Chromecast devices.
150 # Once all of the CastMediaBlockerTest.* have been un-DISABLEd and
151 # are running successfully, revisit these tests and see if they pass
152 # on devices. (crbug/665118, internal b/32023194)
154 "CastMediaBlockerBrowserTest.Video_BlockUnblock",
155 "CastMediaBlockerBrowserTest.Audio_BlockUnblock",
159 if (!is_cast_desktop_build && !is_cast_audio_only && !enable_assistant) {
160 # TODO(mbjorge): The VideoPlaybackMp4 test is failing on v1 devices.
161 # Temporarily disable it as part of an effort to re-green the unittests.
162 # Re-enable once the tests have been fixed. Limitations in the filter
163 # system mean this is getting temporarily disabled on all video devices,
164 # though it is only failing on v1.
165 # b/36723698, hotlist/461351
166 gtest_excludes += [ "CastNavigationBrowserTest.VideoPlaybackMp4" ]
169 # TODO(mbjorge): Temporarily disable AudioPlaybackWavPcm because it is
170 # failing on device. As part of an effort to re-green the unittests,
171 # current (2017-03-15) failures are being disabled to get back to a
172 # green state. Re-enable once the tests have been fixed.
173 # b/36239152, hotlist/461351
174 if (enable_assistant && !is_cast_desktop_build) {
175 gtest_excludes += [ "CastNavigationBrowserTest.AudioPlaybackWavPcm" ]
178 filters += [ cast_shell_browsertests_filter ]
181 test_name = "ipc_tests"
183 # --test-launcher-jobs=1 => so internal code can bind to port
184 args = [ "--test-launcher-jobs=1" ]
186 filters += [ ipc_tests_filter ]
188 url_unittests_filter = {
189 test_name = "url_unittests"
191 if (target_os == "linux" && !is_cast_desktop_build) {
192 # DoAppendUTF8Invalid fails because of dcheck_always_on flag in Eng builds
193 gtest_excludes = [ "URLCanonTest.DoAppendUTF8Invalid" ]
196 filters += [ url_unittests_filter ]
199 base_unittests_filter = {
200 test_name = "base_unittests"
202 if (target_os == "linux") {
203 if (is_cast_desktop_build) {
204 # Disable PartitionAllocDeathTest.* (b/67975693)
205 gtest_excludes += [ "PartitionAllocDeathTest.*" ]
207 # Disable ProcessMetricsTest.GetNumberOfThreads (b/15610509)
208 # Disable ProcessUtilTest.* (need to define OS_ANDROID)
209 # Disable StackContainer.BufferAlignment (don't support 16-byte alignment)
210 # Disable SystemMetrics2Test.GetSystemMemoryInfo (buffers>0 can't be guaranteed)
211 # Disable PostTasksViaTaskRunner/* to green up devices (b/62246873)
212 # Disable WorkerDetaches to green up devices (b/62246873)
214 "ProcessMetricsTest.GetNumberOfThreads",
216 "StackContainer.BufferAlignment",
217 "SystemMetrics2Test.GetSystemMemoryInfo",
218 "OneTraitsExecutionModePair/ThreadPoolImplTest.PostTasksViaTaskRunner/*",
219 "TaskSchedulerWorkerTest.WorkerDetaches",
223 if (is_cast_audio_only) {
224 # Also disable TimeFormattingTest on audio-only builds, since we don't
225 # include the necessary info in icudtl.dat.
226 gtest_excludes += [ "TimeFormattingTest.*" ]
230 filters += [ base_unittests_filter ]
232 cast_avsettings_unittests_filter = {
233 test_name = "cast_avsettings_unittests"
235 if (is_android_things) {
236 # Disable tests to enable presubmit. Re-enable for b/120669054.
238 "JniVolumeControllerTest.SetMutedNotifiesAllVolumeObservers",
239 "JniVolumeControllerTest.SetVolumeNotifiesVolumeObserver",
243 filters += [ cast_avsettings_unittests_filter ]
245 cc_unittests_filter = {
246 test_name = "cc_unittests"
248 # Temporarily disable all test cases (b/113324890)
249 gtest_excludes = [ "*" ]
251 if (!is_cast_desktop_build) {
252 #Disable ToColorSpace/ColorTransformPixelTest* (b/64346790)
253 #Disable ImageBackgroundFilter* (b/64346875)
254 #Disable LayerTreeHostTilesTestPartialInvalidation* (b/65844132)
256 "ToColorSpace/ColorTransformPixelTest.*",
257 "ImageBackgroundFilter.*",
258 "LayerTreeHostTilesTestPartialInvalidation.*",
262 filters += [ cc_unittests_filter ]
264 content_unittests_filter = {
265 test_name = "content_unittests"
267 # IsSupportedVideoConfig_VP9TransferFunctions fails on all cast builds since
268 # the cast IsSupporedVideoConfigs ignore the transfer function parameter.
270 gtest_excludes = [ "*.IsSupportedVideoConfig_VP9TransferFunctions" ]
271 if (is_android_things) {
273 "FontUniqueNameLookupTest.TestMatchPostScriptNameTtc",
274 "SiteInstanceTest.HasWrongProcessForURL",
277 if (target_os == "linux" && !is_cast_desktop_build) {
278 # DesktopCaptureDeviceTest.*: No capture device on Eureka
279 # Disable PepperGamepadHostTest.WaitForReply (pepper not supported on Eureka)
280 # Disable RenderWidgetHostTest.Background because we disable the
281 # blacklist to enable WebGL (b/16142554)
283 "DOMStorageDatabaseTest.TestCanOpenAndReadWebCoreDatabase",
284 "DesktopCaptureDeviceTest.Capture",
285 "GamepadProviderTest.PollingAccess",
286 "PepperGamepadHostTest.WaitForReply",
287 "RenderWidgetHostTest.Background",
290 if (is_cast_audio_only) {
291 # No way to display URL's on audio only cast devices.
292 gtest_excludes += [ "NavigationEntryTest.NavigationEntryURLs" ]
294 if (enable_assistant && !is_cast_desktop_build) {
295 # Temporarily disable InvalidUUID and DefaultConstructor on assistant
296 # device builds. Cause of failure is unclear, but it's highly likely it's
297 # related to them being DEATH tests. These were passing until the
298 # is_official_build flag was enabled. These tests are considered
299 # non-critical in this context. (b/62469368)
301 "BluetoothBlocklistTest.InvalidUUID",
302 "WebBluetoothDeviceIdTest.DefaultConstructor",
306 filters += [ content_unittests_filter ]
308 media_unittests_filter = {
309 test_name = "media_unittests"
310 if (target_os == "linux" && !is_cast_desktop_build) {
311 # Disable VP9 related tests (b/18593324)
312 # PipelineIntegrationTest.BasicPlayback_MediaSource_VP9_WebM
313 # PipelineIntegrationTest.BasicPlayback_VideoOnly_VP9_WebM
314 # PipelineIntegrationTest.BasicPlayback_VP9*
315 # PipelineIntegrationTest.P444_VP9_WebM
316 # Disable VP8A tests (b/18593324)
317 # PipelineIntegrationTest.BasicPlayback_VP8A*
318 # Disable OpusAudioDecoderTest/AudioDecoderTest.ProduceAudioSamples/0 (unit
319 # test fails when Opus decoder uses fixed-point)
320 # Due to b/16456550, disable the following four test cases:
321 # AudioOutputControllerTest.PlayDivertSwitchDeviceRevertClose
322 # AudioOutputControllerTest.PlaySwitchDeviceClose
323 # AudioStreamHandlerTest.Play
324 # SoundsManagerTest.Play
325 # Disable AudioStreamHandlerTest.ConsecutivePlayRequests (b/16539293)
327 "AudioOutputControllerTest.PlayDivertSwitchDeviceRevertClose",
328 "AudioOutputControllerTest.PlaySwitchDeviceClose",
329 "AudioStreamHandlerTest.Play",
330 "AudioStreamHandlerTest.ConsecutivePlayRequests",
331 "PipelineIntegrationTest.BasicPlayback_MediaSource_VP9_WebM",
332 "PipelineIntegrationTest.BasicPlayback_VideoOnly_VP9_WebM",
333 "PipelineIntegrationTest.BasicPlayback_VP9*",
334 "PipelineIntegrationTest.P444_VP9_WebM",
335 "PipelineIntegrationTest.BasicPlayback_VP8A*",
336 "OpusAudioDecoderTest/AudioDecoderTest.ProduceAudioSamples/0",
337 "SoundsManagerTest.Play",
339 } else if (target_os == "android" || is_cast_desktop_build) {
340 # Disable PipelineIntegrationTest.BasicPlayback_MediaSource_VP9_WebM (not supported)
342 [ "PipelineIntegrationTest.BasicPlayback_MediaSource_VP9_WebM" ]
345 filters += [ media_unittests_filter ]
347 net_unittests_filter = {
348 test_name = "net_unittests"
349 if (using_sanitizer) {
350 # TODO(mbjorge): net_unittests do not complete when run with sanitizers,
351 # (in particular, TSAN and UBSAN), resulting in build machines getting stuck
352 # for many hours. Disable them for now, since these are getting run on
353 # Chromium bots anyway. (internal b/31279943)
354 gtest_excludes = [ "*" ]
355 } else if (target_os == "linux" && !is_cast_desktop_build) {
356 # Run net_unittests first to avoid random failures due to slow python startup
357 # URLRequestTestHTTP.GetTest_ManyCookies takes roughly 55s to run. Increase
358 # timeout to 90s from 45s to allow it to pass (b/19821476)
359 # PacFileFetcherImplTest.HttpMimeType is flaking (b/19848784)
360 # Running a batch of net_unittests has high overhead. Run tests in batches of 50 to reduce number of batches (b/23156294).
361 gtest_excludes = [ "PacFileFetcherImplTest.HttpMimeType" ]
363 "--test-launcher-timeout=90000",
364 "--test-launcher-batch-limit=50",
366 } else if (is_cast_desktop_build || target_os == "android") {
367 # URLRequestTestHTTP.GetTest_ManyCookies takes roughly 55s to run. Increase
368 # timeout to 90s from 45s to allow it to pass (b/19821476) (b/29415636).
369 # CTLogVerifierTest.VerifiesValidConsistencyProofsFromReferenceGenerator
370 # times out occasionally, paricularly on the CQ bots; disable to reduce
371 # CQ flakiness (crbug/598406) (b/29415636).
372 # Running a batch of net_unittests has high overhead, so
373 # run tests in batches of 25 to reduce number of batches (b/23156294).
374 gtest_excludes = [ "CTLogVerifierTest.VerifiesValidConsistencyProofsFromReferenceGenerator" ]
376 "--test-launcher-timeout=90000",
377 "--test-launcher-batch-limit=25",
381 filters += [ net_unittests_filter ]
383 cast_receiver_unittests_filter = {
384 test_name = "cast_receiver_unittests"
386 if (is_android_things) {
387 # Disable tests to enable presubmit. Re-enable for b/120669054.
388 gtest_excludes += [ "ApplicationManagerImplTest.SwapBackgroundApp_StereoVirtualDevice_BitstreamNotSupported" ]
391 filters += [ cast_receiver_unittests_filter ]
394 # Creates the build and run lists for all test targets.
395 cast_test_group_list("cast_test_lists") {
396 build_list_path = "$root_out_dir/tests/build_test_list.txt"
397 runtime_deps_path = "$root_out_dir/tests/runtime_deps.json"
398 run_list_path = "$root_out_dir/tests/run_test_list.txt"
400 additional_options = [
401 "--ozone-platform=headless --test-launcher-bot-mode $cast_test_extra_flags",
404 test_groups = [ ":cast_tests" ]
406 if (chromecast_branding != "public") {
407 test_groups += [ "//chromecast/internal:internal_cast_tests" ]
412 cast_test_group("cast_junit_tests") {
415 "//base:base_junit_tests",
416 "//chromecast/base:cast_base_junit_tests",
417 "//chromecast/browser/android:cast_shell_junit_tests",
418 "//content/public/android:content_junit_tests",
419 "//net/android:net_junit_tests",
420 "//testing/android/junit:junit_unit_tests",
421 "//ui/android:ui_junit_tests",
425 cast_test_group_list("cast_junit_test_lists") {
427 build_list_path = "$root_out_dir/junit/build_junit_test_list.txt"
428 runtime_deps_path = "$root_out_dir/junit/runtime_deps.json"
429 run_list_path = "$root_out_dir/junit/run_junit_test_list.txt"
430 test_groups = [ ":cast_junit_tests" ]
431 if (chromecast_branding != "public") {
432 test_groups += [ "//chromecast/internal:internal_cast_junit_tests" ]
437 test("cast_shell_unittests") {
440 "//chromecast/app:test_support",
441 "//chromecast/app:unittests",
442 "//chromecast/browser:unittests",
443 "//ui/gl:test_support",
447 test("cast_shell_browsertests") {
450 "//chromecast/app:test_support",
451 "//chromecast/browser:browsertests",
455 ":chromecast_locales_pak",
459 group("cast_shell_lib") {
466 "//chromecast/browser",
467 "//chromecast/common",
468 "//chromecast/renderer",
471 if (chromecast_branding != "public") {
472 deps += [ "//chromecast/internal/shell" ]
476 cast_executable("cast_shell") {
483 ":chromecast_locales_pak",
485 "//content/public/app:both",
490 fuchsia_package("cast_shell_pkg") {
491 binary = ":cast_shell"
492 package_name_override = "cast_shell"
493 sandbox_policy = "//chromecast/cast_shell_sandbox_policy"
495 if (chromecast_branding != "public") {
497 "//chromecast/internal:fuchsia_internal_data_deps",
502 fuchsia_package_runner("cast_shell_fuchsia") {
503 package = ":cast_shell_pkg"
504 package_name_override = "cast_shell"
508 repack("cast_shell_pak") {
510 "$root_gen_dir/chromecast/app/shell_resources.pak",
511 "$root_gen_dir/content/app/resources/content_resources_100_percent.pak",
512 "$root_gen_dir/content/app/strings/content_strings_en-US.pak",
513 "$root_gen_dir/content/content_resources.pak",
514 "$root_gen_dir/mojo/public/js/mojo_bindings_resources.pak",
515 "$root_gen_dir/net/net_resources.pak",
516 "$root_gen_dir/third_party/blink/public/resources/blink_resources.pak",
517 "$root_gen_dir/third_party/blink/public/resources/blink_scaled_resources_100_percent.pak",
518 "$root_gen_dir/ui/resources/ui_resources_100_percent.pak",
519 "$root_gen_dir/ui/resources/webui_resources.pak",
520 "$root_gen_dir/ui/strings/app_locale_settings_en-US.pak",
521 "$root_gen_dir/ui/strings/ui_strings_en-US.pak",
524 output = "$root_out_dir/assets/cast_shell.pak"
527 "//chromecast/app:resources",
528 "//content:resources",
529 "//content/app/resources",
530 "//content/app/strings",
531 "//mojo/public/js:resources",
532 "//net:net_resources",
533 "//third_party/blink/public:resources",
534 "//third_party/blink/public:scaled_resources_100_percent",
539 if (enable_chromecast_extensions) {
541 "$root_gen_dir/chromecast/renderer/extensions_renderer_resources.pak",
542 "$root_gen_dir/extensions/extensions_renderer_resources.pak",
543 "$root_gen_dir/extensions/extensions_resources.pak",
544 "$root_gen_dir/extensions/shell/app_shell_resources.pak",
547 "//chromecast/renderer:extensions_resources",
548 "//extensions:extensions_resources",
549 "//extensions/shell:resources",
553 if (chromecast_branding != "public") {
554 sources += [ "$root_gen_dir/chromecast/internal/cast_shell_internal.pak" ]
556 deps += [ "//chromecast/internal:cast_shell_internal_pak" ]
560 # Intermediate targets that repack grit resources by locale. For each locale
561 # in |cast_locales| (see //chromecast/chromecast.gni), all resources
562 # are packed into a single .pak file in an output directory. These targets
563 # should not be depended on directly; depend on ":chromecast_locales_pak"
565 foreach(locale, cast_locales) {
566 repack("_cast_repack_${locale}") {
567 visibility = [ ":chromecast_locales_pak" ]
568 output = "$root_out_dir/chromecast_locales/${locale}.pak"
570 "$root_gen_dir/chromecast/app/chromecast_settings_${locale}.pak",
573 "//chromecast/app:chromecast_settings",
576 if (chromecast_branding != "public") {
578 "$root_gen_dir/chromecast/internal/webui/app_strings_${locale}.pak",
580 deps += [ "//chromecast/internal/webui:chromecast_app_strings" ]
582 if (enable_chromecast_webui) {
583 sources += [ "$root_gen_dir/chromecast/internal/webui/webui_localized_${locale}.pak" ]
584 deps += [ "//chromecast/internal/webui:chromecast_webui_localized" ]
590 # A meta-target which repacks resources by locale.
591 group("chromecast_locales_pak") {
593 foreach(locale, cast_locales) {
594 data_deps += [ ":_cast_repack_${locale}" ]
598 buildflag_header("chromecast_buildflags") {
599 header = "chromecast_buildflags.h"
601 "DEFAULT_COMMAND_LINE_FLAGS=\"$default_command_line_flags\"",
602 "DISABLE_SECURE_FLAC_OPUS_DECODING=$disable_secure_flac_and_opus_decoding",
603 "ENABLE_ASSISTANT=$enable_assistant",
604 "ENABLE_CAST_FRAGMENT=$enable_cast_fragment",
605 "ENABLE_CAST_WAYLAND_SERVER=$enable_cast_wayland_server",
606 "ENABLE_CHROMECAST_EXTENSIONS=$enable_chromecast_extensions",
607 "ENABLE_EXTERNAL_MOJO_SERVICES=$enable_external_mojo_services",
608 "ENABLE_HEADLESS_MUSIC_MODE=$enable_headless_music_mode",
609 "ENABLE_PLAYREADY=$enable_playready",
610 "ENABLE_VIDEO_CAPTURE_SERVICE=$enable_video_capture_service",
611 "ENABLE_VOLUME_TABLES_ACCESS=$enable_volume_tables_access",
612 "IS_ANDROID_THINGS=$is_android_things",
613 "IS_ANDROID_THINGS_NON_PUBLIC=$is_android_things_non_public",
614 "IS_CAST_AUDIO_ONLY=$is_cast_audio_only",
615 "IS_CAST_DESKTOP_BUILD=$is_cast_desktop_build",
616 "IS_CAST_USING_CMA_BACKEND=$is_cast_using_cma_backend",
617 "IS_SINGLE_VOLUME=$is_single_volume",
618 "SUPPORTS_MULTIZONE=$supports_multizone",
619 "USE_ANDROID_USER_AGENT=$use_android_user_agent",
620 "USE_CHROMECAST_CDMS=$use_chromecast_cdms",
621 "USE_ANDROID_THINGS_N=$build_for_android_things_n",
626 generate_jni_registration("cast_shell_jni_registration") {
627 target = ":cast_shell_apk"
628 header_output = "$root_gen_dir/chromecast/android/${target_name}.h"
631 android_assets("cast_shell_apk_assets") {
632 assert(v8_use_external_startup_data)
635 "$root_out_dir/assets/cast_shell.pak",
639 ":cast_shell_apk_locale_assets",
641 "//third_party/icu:icu_assets",
642 "//v8:v8_external_startup_data_assets",
644 disable_compression = true
647 android_assets("cast_shell_apk_locale_assets") {
648 renaming_sources = []
649 renaming_destinations = []
651 foreach(locale, cast_locales) {
652 renaming_sources += [ "$root_out_dir/chromecast_locales/${locale}.pak" ]
653 renaming_destinations += [ "stored-locales/${locale}.pak" ]
657 ":chromecast_locales_pak",
660 treat_as_locale_paks = true
661 disable_compression = true
664 android_apk("cast_shell_apk") {
665 apk_name = "CastShell"
666 android_manifest = "$root_gen_dir/cast_shell_manifest/AndroidManifest.xml"
667 android_manifest_dep = "//chromecast/browser/android:cast_shell_manifest"
669 shared_libraries = [ "//chromecast/android:libcast_shell_android" ]
672 ":cast_shell_apk_assets",
674 "//chromecast/android:libcast_shell_android",
675 "//chromecast/browser/android:cast_shell_java",
676 "//third_party/crashpad/crashpad/handler:crashpad_handler_named_as_so",
679 loadable_modules = [ "$root_out_dir/libcrashpad_handler.so" ]
681 command_line_flags_file = "castshell-command-line"
682 enable_multidex = true