# Copyright 2014 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. import("//build/config/chrome_build.gni") import("//build/config/features.gni") import("//build/config/ui.gni") import("//components/nacl/features.gni") import("//media/media_options.gni") import("//ppapi/buildflags/buildflags.gni") import("//printing/buildflags/buildflags.gni") import("//rlz/buildflags/buildflags.gni") import("//testing/test.gni") import("//tools/grit/repack.gni") if (is_android) { import("//build/config/android/rules.gni") import("//build/config/compiler/compiler.gni") import("//tools/v8_context_snapshot/v8_context_snapshot.gni") } if (is_ios) { import("//ios/build/config.gni") } if (is_ios) { bundle_data("components_tests_pak_bundle_data") { public_deps = [ ":components_tests_pak", "//ui/resources:ui_test_pak", ] sources = [ "$root_out_dir/components_tests_resources.pak", "$root_out_dir/ui_test.pak", ] outputs = [ "{{bundle_resources_dir}}/{{source_file_part}}", ] } } # To add a unit test to this target, make a "unit_test" source_set in your # component (it's important to use a source_set instead of a static library or # no tests will run) and add a reference here. You can add more than one unit # test target if convenient. test("components_unittests") { if (is_android || is_linux || is_mac || is_win) { data = [ "test/data/", # TODO(dpranke): Remove the next two lines after GN has rolled to 339778. "$root_out_dir/components_tests_resources.pak", "$root_out_dir/ui_test.pak", ] } if (is_android) { enable_multidex = true # The tracing unittests require this for testing unwinding. See # stack_unwinder_android_unittest.cc. if (can_unwind_with_cfi_table && is_official_build) { add_unwind_tables_in_apk = true } } # Add only ":unit_tests" dependencies here. If your tests have dependencies # (this would at least include the component itself), they should be on the # test source set and not here. deps = [ "//base", "//components/apdu:unit_tests", "//components/assist_ranker:unit_tests", "//components/autofill/core/browser:unit_tests", "//components/autofill/core/common:unit_tests", "//components/base32:unit_tests", "//components/blacklist/opt_out_blacklist:unit_tests", "//components/blacklist/opt_out_blacklist/sql:unit_tests", "//components/bookmarks/browser:unit_tests", "//components/bookmarks/managed:unit_tests", "//components/browser_sync:unit_tests", "//components/browsing_data/core:unit_tests", "//components/bubble:unit_tests", "//components/captive_portal:unit_tests", "//components/cbor:unit_tests", "//components/client_update_protocol:unit_tests", "//components/cloud_devices/common:unit_tests", "//components/component_updater:unit_tests", "//components/consent_auditor:unit_tests", "//components/content_settings/core/browser:unit_tests", "//components/content_settings/core/common:unit_tests", "//components/crx_file:unit_tests", "//components/device_event_log:unit_tests", "//components/dom_distiller/core:unit_tests", "//components/download:unit_tests", "//components/encrypted_messages:unit_tests", "//components/favicon/core:unit_tests", "//components/favicon_base:unit_tests", "//components/feature_engagement:unit_tests", "//components/feed:unit_tests", "//components/filename_generation:unit_tests", "//components/flags_ui:unit_tests", "//components/gcm_driver:unit_tests", "//components/gcm_driver/crypto:unit_tests", "//components/google/core/browser:unit_tests", "//components/grpc_support/test:unit_tests", "//components/history/core/browser:unit_tests", "//components/history/core/common:unit_tests", "//components/image_fetcher/core:unit_tests", "//components/keyed_service/core:unit_tests", "//components/language/core/browser:unit_tests", "//components/language/core/common:unit_tests", "//components/language_usage_metrics:unit_tests", "//components/leveldb_proto:unit_tests", "//components/live_tab_count_metrics:unit_tests", "//components/login:unit_tests", "//components/metrics:unit_tests", "//components/navigation_metrics:unit_tests", "//components/net_log:unit_tests", "//components/network_session_configurator/browser:unit_tests", "//components/network_time:unit_tests", "//components/ntp_snippets:unit_tests", "//components/ntp_tiles:unit_tests", "//components/offline_items_collection/core:unit_tests", "//components/omnibox/browser:unit_tests", "//components/open_from_clipboard:unit_tests", "//components/os_crypt:unit_tests", "//components/password_manager/core/browser:unit_tests", "//components/password_manager/core/common:unit_tests", "//components/password_manager/sync/browser:unit_tests", "//components/payments/core:unit_tests", "//components/prefs:unit_tests", "//components/previews/core:unit_tests", "//components/proxy_config:unit_tests", "//components/query_parser:unit_tests", "//components/rappor:unit_tests", "//components/reading_list/core:unit_tests", "//components/safe_search_api:unit_tests", "//components/scheduling_metrics:unit_tests", "//components/search:unit_tests", "//components/search_engines:unit_tests", "//components/search_provider_logos:unit_tests", "//components/security_state/core:unit_tests", "//components/services/heap_profiling/public/cpp:unit_tests", "//components/services/unzip:unit_tests", "//components/sessions:unit_tests", "//components/signin/core/browser:unit_tests", "//components/ssl_errors:unit_tests", "//components/subresource_filter/core/browser:unit_tests", "//components/subresource_filter/core/common:unit_tests", "//components/subresource_filter/tools:unit_tests", "//components/suggestions:unit_tests", "//components/supervised_user_error_page:unit_tests", "//components/sync:unit_tests", "//components/sync_bookmarks:unit_tests", "//components/sync_preferences:unit_tests", "//components/sync_sessions:unit_tests", "//components/task_scheduler_util:unit_tests", "//components/test:run_all_unittests", "//components/toolbar:unit_tests", "//components/translate/core/browser:unit_tests", "//components/translate/core/common:unit_tests", "//components/translate/core/language_detection:unit_tests", "//components/ukm:unit_tests", "//components/undo:unit_tests", "//components/unified_consent:unit_tests", "//components/update_client:unit_tests", "//components/upload_list:unit_tests", "//components/url_formatter:unit_tests", "//components/url_matcher:unit_tests", "//components/url_pattern_index:unit_tests", "//components/variations:unit_tests", "//components/variations/field_trial_config:unit_tests", "//components/variations/service:unit_tests", "//components/web_resource:unit_tests", "//components/webdata/common:unit_tests", ] if (toolkit_views && use_aura) { deps += [ "//components/ui_devtools/views:unit_tests" ] } if (enable_nacl) { deps += [ "//components/nacl/browser:unit_tests" ] } if (is_ios) { deps += [ "//components/autofill/ios/browser:unit_tests", "//components/autofill/ios/form_util:unit_tests", "//components/image_fetcher/ios:unit_tests", "//components/password_manager/ios:unit_tests", "//components/signin/ios/browser:unit_tests", "//components/translate/ios/browser:unit_tests", ] } else { # !iOS deps += [ "//components/app_modal:unit_tests", "//components/autofill/content/browser:unit_tests", "//components/autofill/content/common:unit_tests", "//components/autofill/content/renderer:unit_tests", "//components/cast_certificate:unit_tests", "//components/cast_channel:unit_tests", "//components/certificate_transparency:unit_tests", "//components/contextual_search/core:unit_tests", "//components/crash/content/app:unit_tests", "//components/crash/content/browser:unit_tests", "//components/crash/core/common:unit_tests", "//components/data_reduction_proxy/content/browser:unit_tests", "//components/data_reduction_proxy/content/renderer:unit_tests", "//components/data_reduction_proxy/core/browser:unit_tests", "//components/data_reduction_proxy/core/common:unit_tests", "//components/data_use_measurement/core:unit_tests", "//components/discardable_memory/common:unit_tests", "//components/discardable_memory/service:unit_tests", "//components/dom_distiller/content/browser:unit_tests", "//components/domain_reliability:unit_tests", "//components/favicon/content:unit_tests", "//components/gcm_driver/instance_id:unit_tests", "//components/history/content/browser:unit_tests", "//components/invalidation/impl:unit_tests", "//components/invalidation/public:unit_tests", "//components/keyed_service/content:unit_tests", "//components/language/content/browser:unit_tests", "//components/link_header_util:unit_tests", "//components/navigation_interception:unit_tests", "//components/network_hints/renderer:unit_tests", "//components/offline_pages:unit_tests", "//components/optimization_guide:unit_tests", "//components/password_manager/content/browser:unit_tests", "//components/payments/content:unit_tests", "//components/payments/content/utility:unit_tests", "//components/policy/content:unit_tests", "//components/policy/core/browser:unit_tests", "//components/policy/core/common:unit_tests", "//components/previews/content:unit_tests", "//components/safe_browsing/common:unit_tests", "//components/safe_browsing/password_protection:password_protection_unittest", "//components/safe_browsing/triggers:unit_tests", "//components/safe_browsing/web_ui:unit_tests", "//components/security_interstitials/content:unit_tests", "//components/security_state/content:unit_tests", "//components/services/heap_profiling:unit_tests", "//components/spellcheck/browser:unit_tests", "//components/spellcheck/renderer:unit_tests", "//components/subresource_filter/content/browser:unit_tests", "//components/subresource_filter/content/common:unit_tests", "//components/subresource_filter/content/renderer:unit_tests", "//components/tracing:unit_tests", "//components/translate/content/renderer:unit_tests", "//components/ukm/content:unit_tests", "//components/visitedlink/test:unit_tests", "//components/web_cache/browser:unit_tests", "//components/webcrypto:unit_tests", ] data_deps = [ ":components_tests_pak", "//third_party/mesa_headers", "//ui/resources:ui_test_pak", ] } # iOS/!iOS if (is_ios) { deps += [ ":components_tests_pak_bundle_data" ] } if (is_mac || is_linux) { data_deps += [ "//content/shell:pak" ] } if (is_android) { deps += [ "//base:base_java_unittest_support", "//components/autofill_assistant/browser:unit_tests", "//components/cdm/browser:unit_tests", "//components/gcm_driver/instance_id:test_support", "//components/gcm_driver/instance_id/android:instance_id_driver_java", "//components/gcm_driver/instance_id/android:instance_id_driver_test_support_java", "//components/invalidation/impl", "//components/invalidation/impl:java", "//components/policy/android:policy_java", "//components/signin/core/browser", "//components/signin/core/browser/android:java", "//components/spellcheck/browser/android:java", "//components/variations/android:variations_java", "//components/web_restrictions:test_support", "//components/web_restrictions:test_support_java", "//components/web_restrictions:unit_tests", "//content/public/android:content_java", "//content/public/browser", "//net", "//ui/android:ui_java", "//ui/base", "//ui/gfx", ] if (use_v8_context_snapshot) { deps += [ "//tools/v8_context_snapshot:v8_context_snapshot_assets" ] } else { deps += [ "//v8:v8_external_startup_data_assets" ] } } else { # !is_android deps += [ "//components/keep_alive_registry:unit_tests" ] } # Desktop-only deps. if (!is_android && !is_ios) { deps += [ "//components/feedback:unit_tests", # See comment in components/guest_view/browser/BUILD.gn for why # guest_view is currently non-mobile. "//components/guest_view/browser:unit_tests", "//components/storage_monitor:unit_tests", "//components/web_modal:unit_tests", "//components/zoom:unit_tests", ] } if (enable_rlz_support) { deps += [ "//components/rlz:unit_tests" ] } if (is_chromeos) { deps += [ "//components/arc:unit_tests", "//components/cryptauth:unit_tests", "//components/ownership:unit_tests", "//components/pairing:unit_tests", "//components/sync_wifi:unit_tests", "//components/timers:unit_tests", "//components/user_manager:unit_tests", ] } if (toolkit_views) { deps += [ "//components/constrained_window:unit_tests" ] } if (is_win) { deps += [ "//components/browser_watcher:unit_tests" ] } if (enable_basic_printing) { deps += [ "//components/services/pdf_compositor:unit_tests" ] } if (enable_print_preview) { deps += [ "//components/pwg_encoder:unit_tests" ] } if (safe_browsing_mode == 1) { deps += [ "//components/safe_browsing/db:unit_tests_desktop" ] } else if (safe_browsing_mode == 2) { deps += [ "//components/safe_browsing/android:unit_tests_mobile" ] } if (!is_ios) { deps += [ "//components/webrtc_logging/browser:unit_tests", "//components/webrtc_logging/common:unit_tests", ] } # No components should depend on Chrome. assert_no_deps = [ "//chrome/*" ] if (is_ios) { assert_no_deps += ios_assert_no_deps } } repack("components_tests_pak") { sources = [ "$root_gen_dir/components/components_resources.pak", "$root_gen_dir/components/strings/components_strings_en-US.pak", ] output = "$root_out_dir/components_tests_resources.pak" deps = [ "//components/resources", "//components/strings", ] if (is_chrome_branded) { sources += [ "${root_gen_dir}/components/strings/components_google_chrome_strings_en-US.pak" ] } else { sources += [ "${root_gen_dir}/components/strings/components_chromium_strings_en-US.pak" ] } } if (is_android) { android_assets("components_browsertests_assets") { testonly = true sources = [ "$root_out_dir/components_tests_resources.pak", "$root_out_dir/content_shell.pak", ] deps = [ ":components_tests_pak", "//content/shell:pak", "//third_party/icu:icu_assets", ] if (use_v8_context_snapshot) { deps += [ "//tools/v8_context_snapshot:v8_context_snapshot_assets" ] } else { deps += [ "//v8:v8_external_startup_data_assets" ] } } android_library("components_browsertests_java") { testonly = true deps = [ ":components_browsertests_resources", "//base:base_java", "//base:base_java_test_support", "//content/public/test/android:content_java_test_support", "//content/shell/android:content_shell_browsertests_java", "//testing/android/native_test:native_test_java", ] java_files = [ "test/android/browsertests_apk/src/org/chromium/components_browsertests_apk/ComponentsBrowserTestsActivity.java", "test/android/browsertests_apk/src/org/chromium/components_browsertests_apk/ComponentsBrowserTestsApplication.java", ] } jinja_template("components_browsertests_manifest") { testonly = true input = "//components/test/android/browsertests_apk/AndroidManifest.xml.jinja2" output = "${target_gen_dir}/components_browsertests_manifest/AndroidManifest.xml" } android_resources("components_browsertests_resources") { testonly = true resource_dirs = [ "//components/test/android/browsertests_apk/res" ] custom_package = "org.chromium.components_browsertests_apk" } } if (!is_ios) { test("components_browsertests") { defines = [ "HAS_OUT_OF_PROC_TEST_RUNNER" ] sources = [ "autofill/content/browser/risk/fingerprint_browsertest.cc", "autofill/content/renderer/field_data_manager_browsertest.cc", "autofill/content/renderer/form_autofill_util_browsertest.cc", "autofill/content/renderer/password_form_conversion_utils_browsertest.cc", "dom_distiller/content/browser/distillable_page_utils_browsertest.cc", "dom_distiller/content/browser/distiller_page_web_contents_browsertest.cc", "dom_distiller/content/browser/test/dom_distiller_js_browsertest.cc", "offline_pages/content/renovations/test/page_renovator_browsertest.cc", "security_state/content/content_utils_browsertest.cc", "ukm/content/source_url_recorder_browsertest.cc", ] data = [ "$root_out_dir/components_tests_resources.pak", "$root_out_dir/content_shell.pak", "test/data/", "dom_distiller/core/javascript/", "security_state/content/testdata/", "//content/test/data/", "//third_party/dom_distiller_js/dist/test/data/", ] deps = [ "//base", "//base/test:test_support", "//components/autofill/content/browser", "//components/autofill/content/renderer", "//components/autofill/core/browser", "//components/content_settings/core/common", "//components/dom_distiller/content/browser", "//components/dom_distiller/core", "//components/dom_distiller/core:test_support", "//components/offline_pages/content/renovations", "//components/offline_pages/core/renovations", "//components/password_manager/content/browser", "//components/security_state/content", "//components/security_state/core", "//components/strings", "//components/tracing", "//components/ukm:test_support", "//components/ukm/content", "//content/public/browser", "//content/shell:content_shell_lib", "//content/test:browsertest_support", "//content/test:test_support", "//device/bluetooth", "//google_apis", "//ipc:test_support", "//net:test_support", "//printing/buildflags", "//services/device/public/cpp/test:test_support", "//services/device/public/mojom", "//services/service_manager/public/cpp", "//services/service_manager/public/mojom", "//testing/gmock", "//testing/gtest", "//ui/base", "//url", ] data_deps = [ ":components_tests_pak", "//third_party/mesa_headers", ] if (is_mac) { data_deps += [ "//content/shell:content_shell" ] data += [ "$root_out_dir/Content Shell.app/" ] } if (enable_plugins) { sources += [ "pdf/renderer/pdf_accessibility_tree_browsertest.cc" ] deps += [ "//components/pdf/renderer" ] } if (is_android) { enable_multidex = true sources += [ "autofill_assistant/browser/assistant_web_controller_browsertest.cc", "test/android/browsertests_apk/components_browser_tests_jni_onload.cc", ] sources -= [ "autofill/content/browser/risk/fingerprint_browsertest.cc" ] deps += [ "//components/autofill_assistant/browser", "//content/public/test/android:layouttest_java_support", "//content/test:layouttest_support", "//testing/android/native_test:native_test_support", ] use_default_launcher = false android_manifest = "${target_gen_dir}/components_browsertests_manifest/AndroidManifest.xml" android_manifest_dep = ":components_browsertests_manifest" deps += [ ":components_browsertests_assets", ":components_browsertests_java", ] } if (is_linux) { # content_extractor_browsertest is a standalone content extraction tool built as # a MANUAL component_browsertest. sources += [ "dom_distiller/standalone/content_extractor_browsertest.cc" ] deps += [ "//components/leveldb_proto", "//components/prefs:test_support", "//components/sync_preferences:test_support", ] } if (enable_basic_printing) { sources += [ "printing/test/print_render_frame_helper_browsertest.cc" ] deps += [ "//components/printing/test:test_support" ] } assert_no_deps = [ "//chrome/*" ] } test("components_perftests") { sources = [ "discardable_memory/common/discardable_shared_memory_heap_perftest.cc", "leveldb_proto/proto_database_perftest.cc", "omnibox/browser/history_quick_provider_performance_unittest.cc", "subresource_filter/core/common/perftests/indexed_ruleset_perftest.cc", "test/run_all_perftests.cc", "visitedlink/test/visitedlink_perftest.cc", ] deps = [ "//base", "//components/discardable_memory/common", "//components/history/core/test", "//components/leveldb_proto", "//components/leveldb_proto/testing/proto", "//components/omnibox/browser", "//components/omnibox/browser:test_support", "//components/subresource_filter/core/common", "//components/subresource_filter/tools:tools_lib", "//components/test:test_support", "//components/visitedlink/browser", "//testing/perf", "//url", ] data_deps = [ ":components_tests_pak", "//ui/resources:ui_test_pak", # Needed for isolate script to execute. "//testing:run_perf_test", ] data = [ "$root_out_dir/components_tests_resources.pak", "$root_out_dir/ui_test.pak", "//components/subresource_filter/core/common/perftests/data", ] if (is_android) { enable_multidex = true deps += [ "//ui/android:ui_java" ] if (use_v8_context_snapshot) { deps += [ "//tools/v8_context_snapshot:v8_context_snapshot_assets" ] } else { deps += [ "//v8:v8_external_startup_data_assets" ] } } if (!is_android) { sources += [ "safe_browsing/db/v4_store_perftest.cc" ] deps += [ "//components/safe_browsing/db:v4_protocol_manager_util", "//components/safe_browsing/db:v4_store", "//components/safe_browsing/db:v4_test_util", "//crypto", ] } } }