# Copyright 2015 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/features.gni") import("//device/vr/buildflags/buildflags.gni") import("//testing/test.gni") if (is_android) { import("//build/config/android/config.gni") import("//build/config/android/rules.gni") # For generate_jni(). } if (is_mac) { import("//build/config/mac/mac_sdk.gni") } is_linux_without_udev = is_linux && !use_udev test("device_unittests") { sources = [ "base/synchronization/one_writer_seqlock_unittest.cc", "bluetooth/bluetooth_adapter_mac_unittest.mm", "bluetooth/bluetooth_adapter_unittest.cc", "bluetooth/bluetooth_adapter_win_unittest.cc", "bluetooth/bluetooth_advertisement_unittest.cc", "bluetooth/bluetooth_device_unittest.cc", "bluetooth/bluetooth_device_win_unittest.cc", "bluetooth/bluetooth_discovery_filter_unittest.cc", "bluetooth/bluetooth_local_gatt_characteristic_unittest.cc", "bluetooth/bluetooth_local_gatt_descriptor_unittest.cc", "bluetooth/bluetooth_local_gatt_service_unittest.cc", "bluetooth/bluetooth_low_energy_win_unittest.cc", "bluetooth/bluetooth_remote_gatt_characteristic_unittest.cc", "bluetooth/bluetooth_remote_gatt_descriptor_unittest.cc", "bluetooth/bluetooth_remote_gatt_service_unittest.cc", "bluetooth/bluetooth_service_record_win_unittest.cc", "bluetooth/bluetooth_task_manager_win_unittest.cc", "bluetooth/bluetooth_uuid_unittest.cc", "bluetooth/device_unittest.cc", "bluetooth/string_util_icu_unittest.cc", "bluetooth/test/bluetooth_gatt_server_test.cc", "bluetooth/test/bluetooth_gatt_server_test.h", "bluetooth/test/bluetooth_test.cc", "bluetooth/test/bluetooth_test.h", "bluetooth/test/bluetooth_test_android.cc", "bluetooth/test/bluetooth_test_android.h", "bluetooth/test/bluetooth_test_mac.h", "bluetooth/test/bluetooth_test_mac.mm", "bluetooth/test/bluetooth_test_win.cc", "bluetooth/test/bluetooth_test_win.h", "bluetooth/test/mock_bluetooth_cbcharacteristic_mac.h", "bluetooth/test/mock_bluetooth_cbcharacteristic_mac.mm", "bluetooth/test/mock_bluetooth_cbdescriptor_mac.h", "bluetooth/test/mock_bluetooth_cbdescriptor_mac.mm", "bluetooth/test/mock_bluetooth_cbperipheral_mac.h", "bluetooth/test/mock_bluetooth_cbperipheral_mac.mm", "bluetooth/test/mock_bluetooth_cbservice_mac.h", "bluetooth/test/mock_bluetooth_cbservice_mac.mm", "bluetooth/test/mock_bluetooth_central_manager_mac.h", "bluetooth/test/mock_bluetooth_central_manager_mac.mm", "bluetooth/test/test_bluetooth_adapter_observer.cc", "bluetooth/test/test_bluetooth_adapter_observer.h", "bluetooth/test/test_bluetooth_local_gatt_service_delegate.cc", "bluetooth/test/test_bluetooth_local_gatt_service_delegate.h", "bluetooth/uribeacon/uri_encoder_unittest.cc", "fido/ctap_request_unittest.cc", "fido/ctap_response_unittest.cc", "fido/fake_fido_discovery_unittest.cc", "fido/fido_ble_connection_unittest.cc", "fido/fido_ble_device_unittest.cc", "fido/fido_ble_frames_unittest.cc", "fido/fido_cable_device_unittest.cc", "fido/fido_cable_discovery_unittest.cc", "fido/fido_discovery_unittest.cc", "fido/fido_hid_message_unittest.cc", "fido/fido_parsing_utils_unittest.cc", "fido/fido_request_handler_unittest.cc", "fido/get_assertion_handler_unittest.cc", "fido/get_assertion_task_unittest.cc", "fido/mac/get_assertion_operation_unittest_mac.mm", "fido/mac/make_credential_operation_unittest_mac.mm", "fido/make_credential_handler_unittest.cc", "fido/make_credential_task_unittest.cc", "fido/test_callback_receiver_unittest.cc", "fido/u2f_command_constructor_unittest.cc", "fido/u2f_register_unittest.cc", "fido/u2f_request_unittest.cc", "fido/u2f_sign_unittest.cc", "gamepad/abstract_haptic_gamepad_unittest.cc", "gamepad/gamepad_provider_unittest.cc", "gamepad/gamepad_service_unittest.cc", "gamepad/public/mojom/gamepad_mojom_traits_unittest.cc", "test/run_all_unittests.cc", ] deps = [ "//base/test:test_support", "//base/third_party/dynamic_annotations:dynamic_annotations", "//components/apdu", "//components/cbor", "//device/base/synchronization", "//device/bluetooth", "//device/bluetooth:deprecated_experimental_mojo", "//device/bluetooth:mocks", "//device/bluetooth/uribeacon", "//device/fido", "//device/fido:mocks", "//device/fido:test_support", "//device/gamepad", "//device/gamepad:test_helpers", "//device/gamepad/public/cpp:shared_with_blink", "//device/gamepad/public/mojom", "//device/gamepad/public/mojom:gamepad_mojom_traits_test", "//device/geolocation:unittests", "//mojo/edk", "//mojo/public/cpp/bindings", "//net", "//testing/gmock", "//testing/gtest", "//third_party/blink/public:blink_headers", "//tools/usb_gadget", "//url", ] # U2F and Serial: # Android doesn't compile. # Linux, requires udev. if (!is_linux_without_udev && !is_android) { sources += [ "fido/fido_hid_device_unittest.cc", "fido/fido_hid_discovery_unittest.cc", ] deps += [ "//device/fido:test_support", "//services/device/public/cpp/hid", "//services/device/public/mojom", "//services/service_manager/public/cpp", "//services/service_manager/public/mojom", ] # Serial is supported in below platforms. See //device/servial/BUILD.gn if (is_win || is_linux || is_mac) { sources += [ "serial/serial_device_enumerator_unittest.cc" ] deps += [ "//device/serial" ] if (is_linux || is_mac) { sources += [ "serial/serial_io_handler_posix_unittest.cc" ] } } } if (use_udev) { sources += [ "udev_linux/udev_unittest.cc" ] deps += [ "//device/udev_linux" ] } # USB does not compile on iOS. if (!is_ios) { sources += [ "test/test_device_client.cc", "test/test_device_client.h", "usb/mojo/device_impl_unittest.cc", "usb/mojo/device_manager_impl_unittest.cc", "usb/mojo/mock_permission_provider.cc", "usb/mojo/mock_permission_provider.h", "usb/public/cpp/filter_utils_unittest.cc", "usb/usb_descriptors_unittest.cc", "usb/usb_device_handle_unittest.cc", "usb/usb_service_unittest.cc", "usb/webusb_descriptors_unittest.cc", ] deps += [ ":usb_test_gadget", "//device/base", "//device/base:mocks", "//device/usb", "//device/usb:test_support", "//device/usb/mojo", "//device/usb/public/cpp", "//device/usb/public/mojom", "//net:test_support", ] if (!is_android) { sources += [ "usb/usb_ids_unittest.cc" ] } } # UsbContext is a libusb-specific object. if (is_mac || is_win) { sources += [ "usb/usb_context_unittest.cc" ] deps += [ "//third_party/libusb" ] } if (is_android) { deps += [ ":bluetooth_test_java", ":bluetooth_test_jni_headers", "//device/geolocation:geolocation_java", "//device/geolocation:geolocation_java_test_support", "//device/usb:java", ] } if (is_chromeos) { deps += [ "//chromeos", "//chromeos:test_support", "//chromeos:test_support_without_gmock", ] } if ((is_chromeos || is_linux) && use_dbus) { configs += [ "//build/config/linux/dbus" ] sources += [ "bluetooth/bluez/bluetooth_adapter_profile_bluez_unittest.cc", "bluetooth/bluez/bluetooth_advertisement_bluez_unittest.cc", "bluetooth/bluez/bluetooth_bluez_unittest.cc", "bluetooth/bluez/bluetooth_gatt_bluez_unittest.cc", "bluetooth/bluez/bluetooth_service_attribute_value_bluez_unittest.cc", "bluetooth/bluez/bluetooth_service_record_bluez_unittest.cc", "bluetooth/bluez/bluetooth_socket_bluez_unittest.cc", "bluetooth/dbus/bluetooth_gatt_application_service_provider_unittest.cc", "bluetooth/test/bluetooth_test_bluez.cc", "bluetooth/test/bluetooth_test_bluez.h", ] deps += [ "//dbus" ] } if (is_linux) { if (is_chromecast) { # Cast does not support GATT server mode. sources -= [ "bluetooth/bluetooth_local_gatt_characteristic_unittest.cc", "bluetooth/bluetooth_local_gatt_descriptor_unittest.cc", "bluetooth/bluetooth_local_gatt_service_unittest.cc", ] sources += [ "bluetooth/cast/bluetooth_adapter_cast_unittest.cc", "bluetooth/cast/bluetooth_utils_unittest.cc", "bluetooth/test/bluetooth_test_cast.cc", "bluetooth/test/bluetooth_test_cast.h", ] deps += [ "//chromecast/device/bluetooth:util", "//chromecast/device/bluetooth/le", "//chromecast/device/bluetooth/le:test_support", "//chromecast/device/bluetooth/shlib:mock_shlib", ] } else { # BLE discovery: works on Linux. sources += [ "fido/fido_ble_discovery_unittest.cc" ] } } if (is_mac) { deps += [ "//third_party/ocmock" ] ldflags = [ "-ObjC" ] libs = [ "IOBluetooth.framework", "IOKit.framework", ] # In the OSX 10.10 SDK, CoreBluetooth became a top level framework. # Previously, it was nested in IOBluetooth. In order for Chrome to run on # OSes older than OSX 10.10, the top level CoreBluetooth framework must be # weakly linked. if (mac_sdk_version == "10.10") { ldflags += [ "-weak_framework", "CoreBluetooth", ] } } if (is_win) { sources += [ "bluetooth/bluetooth_classic_win_fake.cc", "bluetooth/bluetooth_classic_win_fake.h", "bluetooth/bluetooth_low_energy_win_fake.cc", "bluetooth/bluetooth_low_energy_win_fake.h", "bluetooth/test/fake_bluetooth_adapter_winrt.cc", "bluetooth/test/fake_bluetooth_adapter_winrt.h", "bluetooth/test/fake_device_information_winrt.cc", "bluetooth/test/fake_device_information_winrt.h", ] } if (enable_vr) { sources += [ "vr/orientation/orientation_device_provider_unittest.cc", "vr/orientation/orientation_device_unittest.cc", "vr/vr_device_base_unittest.cc", "vr/vr_display_impl_unittest.cc", ] if (is_android) { deps += [ "//device/vr:java" ] } defines = [ "DEVICE_VR_IMPLEMENTATION" ] deps += [ "//device/vr", "//device/vr:fakes", "//device/vr/public/mojom", "//services/device/public/cpp/generic_sensor", "//ui/display", "//ui/display:test_support", ] } } source_set("usb_test_gadget") { testonly = true sources = [ "test/usb_test_gadget.h", "test/usb_test_gadget_impl.cc", ] deps = [ "//device/base", "//device/usb", "//net:test_support", ] } if (is_android) { bluetooth_java_sources_needing_jni = [ "bluetooth/test/android/java/src/org/chromium/device/bluetooth/Fakes.java", ] generate_jni("bluetooth_test_jni_headers") { sources = bluetooth_java_sources_needing_jni jni_package = "bluetooth" } android_library("bluetooth_test_java") { testonly = true java_files = bluetooth_java_sources_needing_jni deps = [ "//base:base_java", "//components/location/android:location_java", "//device/bluetooth:java", "//third_party/android_tools:android_support_annotations_java", ] deps += android_extra_test_deps srcjar_deps = [ ":bluetooth_test_javagen" ] } junit_binary("device_junit_tests") { java_files = [ "gamepad/android/junit/src/org/chromium/device/gamepad/GamepadMappingsTest.java", "geolocation/android/junit/src/org/chromium/device/geolocation/LocationProviderTest.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", "//base:base_java", "//base:base_java_test_support", "//base:base_junit_test_support", "//device/gamepad:java", "//device/geolocation:geolocation_java", "//device/geolocation:geolocation_java_test_support", "//mojo/public/java:bindings_java", "//third_party/android_tools:android_support_annotations_java", ] srcjar_deps = [ "//device/gamepad:java_enums_srcjar" ] } java_cpp_enum("bluetooth_test_javagen") { sources = [ "bluetooth/test/bluetooth_test.h", ] } }