# Copyright 2016 The Chromium Authors # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. import("//build/config/features.gni") import("//build/config/ui.gni") import("//services/on_device_model/on_device_model.gni") import("//services/screen_ai/buildflags/features.gni") import("//testing/test.gni") if (is_android) { import("//build/config/android/config.gni") } # One Big Target for services to register their unit test sources. This exists # to avoid having to maintain a separate test binary for every service. # # To add tests for a new service, please define a "tests" source_set in the # service subdirectory and add it as a dependency here. test("services_unittests") { use_xvfb = use_xvfb_in_this_config # The tracing unittests require this for testing unwinding. See # stack_unwinder_android_unittest.cc. if (is_android && can_unwind_with_cfi_table && is_official_build) { add_unwind_tables_in_apk = true } # If your service does not run on iOS, its tests should go in the !iOS # section below. If you are unsure, contact blundell@chromium.org. deps = [ "//services/cert_verifier:tests", "//services/cert_verifier/cert_net_url_loader:tests", "//services/metrics/public/cpp:tests", "//services/network:tests", "//services/network/public/cpp:tests", "//services/test:run_all_unittests", "//services/tracing:tests", ] fuzztests = [ "UsbIdsTest.NameLookupsReturnValidStrings", "TrustTokenKeyCommitmentFuzzer.ParsesOneIssuerCorrectly", "TrustTokenKeyCommitmentFuzzer.ParsesMultipleIssuersCorrectly", "HitTestStructTraitsFuzzTest.AggregatedHitTestRegionFuzz", "HitTestStructTraitsFuzzTest.HitTestRegionListFuzz", "RendererSettingsStructTraitsFuzzTest.DebugRendererSettingsFuzz", "RendererSettingsStructTraitsFuzzTest.RendererSettingsFuzz", "CompositingStructTraitsFuzzTest.BeginFrameArgsFuzz", "CompositingStructTraitsFuzzTest.BeginFrameAckFuzz", "CompositingStructTraitsFuzzTest.BeginFrameAckAsValueFuzz", "CompositingStructTraitsFuzzTest.SurfaceIdFuzz", "CompositingStructTraitsFuzzTest.FilterOperationFuzz", "CompositingStructTraitsFuzzTest.FilterOperationsFuzz", "CompositingStructTraitsFuzzTest.SharedQuadStateFuzz", "CompositingStructTraitsFuzzTest.CompositorFrameTransitionDirectiveFuzz", "CompositingStructTraitsFuzzTest.CompositorFrameFuzz", "CompositingStructTraitsFuzzTest.FrameSinkIdFuzz", "CompositingStructTraitsFuzzTest.LocalSurfaceIdFuzz", "CompositingStructTraitsFuzzTest.SurfaceRangeFuzz", "CompositingStructTraitsFuzzTest.SelectionFuzz", "CompositingStructTraitsFuzzTest.ViewTransitionElementResourceIdFuzz", "CompositingStructTraitsFuzzTest.SurfaceInfoFuzz", "CompositingStructTraitsFuzzTest.ReturnedResourceFuzz", "CompositingStructTraitsFuzzTest.CompositorFrameMetadataFuzz", "CompositingStructTraitsFuzzTest.CompositorRenderPassFuzz", "CompositingStructTraitsFuzzTest.OffsetTagFuzz", "CompositingStructTraitsFuzzTest.OffsetTagValueFuzz", "CompositingStructTraitsFuzzTest.OffsetTagDefinitionFuzz", "CompositingStructTraitsFuzzTest.TransferableResourceFuzz", "CompositingStructTraitsFuzzTest.SharedImageFormatFuzz", "CompositingStructTraitsFuzzTest.CopyOutputResultFuzz", "CompositingStructTraitsFuzzTest.TreesInVizTimingFuzz", "CompositingStructTraitsFuzzTest.RegionCaptureBoundsFuzz", "CompositingStructTraitsFuzzTest.VerticalScrollDirectionFuzz", "CompositingStructTraitsFuzzTest.FrameTimingDetailsFuzz", "CompositingStructTraitsFuzzTest.TrackedElementRectsFuzz", "CompositingStructTraitsFuzzTest.BlitRequestFuzz", "CompositingStructTraitsFuzzTest.FrameIntervalInputsFuzz", "CompositingStructTraitsFuzzTest.ThreadFuzz", "CompositingStructTraitsFuzzTest.FrameSinkBundleIdFuzz", "ConnectionAllowlistFuzz.FuzzConnectionAllowlistParser", ] data_deps = [ "//testing/buildbot/filters:services_unittests_filters" ] if (use_blink) { deps += [ "//services/audio:tests", "//services/data_decoder:tests", "//services/device:tests", "//services/image_annotation:tests", "//services/image_annotation/public/cpp:tests", "//services/media_session:tests", "//services/media_session/public/cpp:tests", "//services/on_device_model:tests", "//services/preferences/tracked:unit_tests", "//services/proxy_resolver:tests", "//services/resource_coordinator:tests", "//services/shape_detection:tests", "//services/viz/privileged/mojom:unit_tests", "//services/viz/public/cpp/compositing:tests", "//services/viz/public/cpp/gpu:tests", "//services/viz/public/cpp/hit_test:tests", "//services/webnn:tests", "//services/webnn/public/cpp:tests", "//services/webnn/public/mojom:tests", ] if (is_android) { deps += [ # The java target is added explicitly because the unit tests below # require connection to the Java classes. Without a direct dependency, # the unit tests will encounter a ClassNotFoundException error at # runtime. "//services/device/serial:native_unittests_java", "//services/on_device_model/android:java", "//services/on_device_model/android:native_java_unittests_java", "//services/on_device_model/android:unit_tests", ] } } if (is_android && (current_cpu == "arm" || current_cpu == "arm64")) { deps += [ "//base:base_profiler_test_support_library" ] } if (is_ios) { bundle_deps = [ "//services/tracing:services_tracing_perfetto_bundle_data" ] } if (is_linux) { deps += [ "//services/accessibility:tests" ] } if (is_win) { deps += [ "//services/proxy_resolver_win:tests" ] } if (is_android) { deps += [ "//components/signin/public/android:java", "//services/device:java", "//services/media_session/public/cpp/android:media_session_java", "//services/tracing:tracing_test_helper_java", # Some tests make network requests. "//net/android:net_java", # Some tests need to initialize V8. "//gin:v8_snapshot_assets", ] if (enable_chrome_android_internal) { data_deps += [ "//clank/build/bot/filters:services_unittests_filters" ] } } if (!is_android && !is_ios) { # NOTE: We do not currently support standalone service binaries on Android # or iOS, so any tests which use the ServiceTest framework to connect to # standalone services must be added here. deps += [ "//services/passage_embeddings:tests", "//services/video_capture:tests", ] } if (is_fuchsia) { additional_manifest_fragments = [ "//build/config/fuchsia/test/mark_vmo_executable.shard.test-cml", "//build/config/fuchsia/test/network.shard.test-cml", ] } if (enable_screen_ai_service) { deps += [ "//services/screen_ai:unit_tests" ] } } if (!is_ios) { test("services_perftests") { deps = [ "//services/device:perftests", "//services/network/public/cpp:perftests", "//services/test:run_all_unittests", "//services/viz/public/cpp/compositing:perftests", ] if (is_android) { deps += [ "//components/signin/public/android:java" ] } } } if (is_android) { robolectric_binary("services_junit_tests") { enable_android_resources = false sources = [ "device/generic_sensor/android/junit/src/org/chromium/device/sensors/PlatformSensorAndProviderTest.java", "device/geolocation/android/junit/src/org/chromium/device/geolocation/LocationProviderTest.java", "device/nfc/android/junit/src/org/chromium/device/nfc/NFCTest.java", "device/nfc/android/junit/src/org/chromium/device/nfc/NfcBlocklistTest.java", "device/serial/android/javatests/src/org/chromium/device/serial/ChromeSerialManagerTest.java", "shape_detection/android/junit/src/org/chromium/shape_detection/BitmapUtilsTest.java", ] deps = [ "$google_play_services_package:google_play_services_base_java", "$google_play_services_package:google_play_services_basement_java", "$google_play_services_package:google_play_services_location_java", "$google_play_services_package:google_play_services_tasks_java", "$google_play_services_package:google_play_services_vision_common_java", "$google_play_services_package:google_play_services_vision_java", "//base:base_java", "//base:base_java_test_support", "//base:base_junit_test_support", "//base:flagged_apis_java", "//mojo/public/java:base_java", "//mojo/public/java:bindings_java", "//mojo/public/java:system_java", "//mojo/public/mojom/base:base_java", "//services/device/generic_sensor:java", "//services/device/geolocation:geolocation_java", "//services/device/nfc/android:java", "//services/device/public/java:device_feature_list_java", "//services/device/public/java:geolocation_java", "//services/device/public/java:geolocation_java_test_support", "//services/device/public/java:nfc_java", "//services/device/public/mojom:generic_sensor_java", "//services/device/public/mojom:mojom_java", "//services/device/serial:java", "//services/shape_detection:shape_detection_java", "//skia/public/mojom:mojom_java", "//third_party/androidx:androidx_annotation_annotation_java", "//third_party/google-truth:google_truth_java", ] # Enable tests for MLKit-based implementations for AICore. if (use_mlkit_for_aicore) { deps += [ "//services/on_device_model/android:junit" ] } } android_library("services_javatests") { testonly = true sources = [ "shape_detection/android/javatests/src/org/chromium/shape_detection/BarcodeDetectionImplTest.java", "shape_detection/android/javatests/src/org/chromium/shape_detection/FaceDetectionImplTest.java", "shape_detection/android/javatests/src/org/chromium/shape_detection/TestUtils.java", "shape_detection/android/javatests/src/org/chromium/shape_detection/TextDetectionImplTest.java", ] deps = [ "$google_play_services_package:google_play_services_base_java", "$google_play_services_package:google_play_services_basement_java", "$google_play_services_package:google_play_services_vision_common_java", "$google_play_services_package:google_play_services_vision_java", "//base:base_java", "//base:base_java_test_support", "//mojo/public/java:base_java", "//mojo/public/java:bindings_java", "//mojo/public/mojom/base:base_java", "//services/shape_detection:shape_detection_java", "//services/shape_detection/public/mojom:mojom_java", "//skia/public/mojom:mojom_java", "//third_party/android_deps:chromium_play_services_availability_java", "//third_party/androidx:androidx_test_runner_java", "//third_party/google-truth:google_truth_java", "//third_party/hamcrest:hamcrest_java", "//third_party/hamcrest:hamcrest_library_java", "//third_party/junit", "//ui/gfx/geometry/mojom:mojom_java", ] data = [ "test/data/" ] } }