blob: cb2f90fd7f1cb8dd690aa4cb8cf1a822f536af4f [file] [log] [blame]
tfarinacdc7e5d2015-02-23 09:52:241# 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.
4
5import("//build/config/features.gni")
6import("//testing/test.gni")
7
scheib56010cc2015-06-25 01:29:478if (is_android) {
9 import("//build/config/android/rules.gni") # For generate_jni().
10}
11
erikchenceb2fff2015-04-27 17:50:5412if (is_mac) {
13 import("//build/config/mac/mac_sdk.gni")
14}
15
scheib7a4cf042015-03-31 04:33:4416is_linux_without_udev = is_linux && !use_udev
scheib7a4cf042015-03-31 04:33:4417
tfarinacdc7e5d2015-02-23 09:52:2418test("device_unittests") {
19 sources = [
alexis.menardb39a30822016-09-30 15:14:3920 "base/synchronization/one_writer_seqlock_unittest.cc",
tfarinacdc7e5d2015-02-23 09:52:2421 "battery/battery_status_manager_win_unittest.cc",
22 "battery/battery_status_service_unittest.cc",
23 "bluetooth/bluetooth_adapter_mac_unittest.mm",
tfarinacdc7e5d2015-02-23 09:52:2424 "bluetooth/bluetooth_adapter_unittest.cc",
25 "bluetooth/bluetooth_adapter_win_unittest.cc",
ortuno945c90d2015-09-01 01:47:0826 "bluetooth/bluetooth_advertisement_unittest.cc",
tfarinacdc7e5d2015-02-23 09:52:2427 "bluetooth/bluetooth_device_unittest.cc",
28 "bluetooth/bluetooth_device_win_unittest.cc",
jpawlowskif54d01542015-04-13 22:24:4329 "bluetooth/bluetooth_discovery_filter_unittest.cc",
rkc3fb9aa6d2016-05-03 20:39:4430 "bluetooth/bluetooth_local_gatt_characteristic_unittest.cc",
31 "bluetooth/bluetooth_local_gatt_descriptor_unittest.cc",
rkc907af5d2016-05-10 00:20:0232 "bluetooth/bluetooth_local_gatt_service_unittest.cc",
tfarinacdc7e5d2015-02-23 09:52:2433 "bluetooth/bluetooth_low_energy_win_unittest.cc",
rkc122239752016-04-20 23:59:0834 "bluetooth/bluetooth_remote_gatt_characteristic_unittest.cc",
35 "bluetooth/bluetooth_remote_gatt_descriptor_unittest.cc",
36 "bluetooth/bluetooth_remote_gatt_service_unittest.cc",
tfarinacdc7e5d2015-02-23 09:52:2437 "bluetooth/bluetooth_service_record_win_unittest.cc",
tfarinacdc7e5d2015-02-23 09:52:2438 "bluetooth/bluetooth_task_manager_win_unittest.cc",
39 "bluetooth/bluetooth_uuid_unittest.cc",
ortunob755ff32016-08-25 21:29:3040 "bluetooth/string_util_icu_unittest.cc",
rkc3fb9aa6d2016-05-03 20:39:4441 "bluetooth/test/bluetooth_gatt_server_test.cc",
42 "bluetooth/test/bluetooth_gatt_server_test.h",
scheib545d7fd2015-06-30 22:26:5843 "bluetooth/test/bluetooth_test.cc",
44 "bluetooth/test/bluetooth_test.h",
45 "bluetooth/test/bluetooth_test_android.cc",
46 "bluetooth/test/bluetooth_test_android.h",
krstnmnlsn56d371032015-07-21 20:18:0747 "bluetooth/test/bluetooth_test_mac.h",
48 "bluetooth/test/bluetooth_test_mac.mm",
gogerald512935cc2016-01-27 01:11:1849 "bluetooth/test/bluetooth_test_win.cc",
50 "bluetooth/test/bluetooth_test_win.h",
jlebel620327d2016-06-20 13:01:0051 "bluetooth/test/mock_bluetooth_cbcharacteristic_mac.h",
52 "bluetooth/test/mock_bluetooth_cbcharacteristic_mac.mm",
jlebela58fd752016-03-14 10:33:2853 "bluetooth/test/mock_bluetooth_cbperipheral_mac.h",
54 "bluetooth/test/mock_bluetooth_cbperipheral_mac.mm",
jlebelc4b09782016-05-10 00:31:5855 "bluetooth/test/mock_bluetooth_cbservice_mac.h",
56 "bluetooth/test/mock_bluetooth_cbservice_mac.mm",
jlebela58fd752016-03-14 10:33:2857 "bluetooth/test/mock_bluetooth_central_manager_mac.h",
58 "bluetooth/test/mock_bluetooth_central_manager_mac.mm",
scheib42e6b49d2015-04-29 21:46:5759 "bluetooth/test/test_bluetooth_adapter_observer.cc",
60 "bluetooth/test/test_bluetooth_adapter_observer.h",
rkc3fb9aa6d2016-05-03 20:39:4461 "bluetooth/test/test_bluetooth_local_gatt_service_delegate.cc",
62 "bluetooth/test/test_bluetooth_local_gatt_service_delegate.h",
bajonesb9bb4c42016-07-07 00:10:5163 "gamepad/gamepad_provider_unittest.cc",
alexander.shalamovd08cd092016-11-03 07:46:3064 "generic_sensor/platform_sensor_and_provider_unittest_win.cc",
maksim.sisovd14d9caa2016-09-28 11:10:2465 "generic_sensor/platform_sensor_provider_unittest.cc",
ke.hebef990972016-11-11 07:47:0266 "power_monitor/power_monitor_message_broadcaster_unittest.cc",
67 "power_monitor/public/cpp/power_monitor_broadcast_source_unittest.cc",
tfarinacdc7e5d2015-02-23 09:52:2468 "test/run_all_unittests.cc",
blundelld46e8832016-10-07 10:34:2769 "wake_lock/wake_lock_service_context_unittest.cc",
tfarinacdc7e5d2015-02-23 09:52:2470 ]
71
72 deps = [
73 "//base/test:test_support",
alexis.menardb39a30822016-09-30 15:14:3974 "//base/third_party/dynamic_annotations:dynamic_annotations",
75 "//device/base/synchronization",
tfarinacdc7e5d2015-02-23 09:52:2476 "//device/battery",
77 "//device/battery:mojo_bindings",
78 "//device/bluetooth",
brettw011138d2015-10-21 03:05:3879 "//device/bluetooth:mocks",
bajonesb9bb4c42016-07-07 00:10:5180 "//device/gamepad",
81 "//device/gamepad:test_helpers",
maksim.sisovd14d9caa2016-09-28 11:10:2482 "//device/generic_sensor",
83 "//device/generic_sensor:testing",
mcasas4e216e72016-07-28 21:28:3884 "//device/geolocation:unittests",
ke.hebef990972016-11-11 07:47:0285 "//device/power_monitor",
86 "//device/power_monitor/public/cpp",
87 "//device/power_monitor/public/interfaces",
scottmgc40e8822016-06-17 17:57:4888 "//device/power_save_blocker",
blundelld46e8832016-10-07 10:34:2789 "//device/wake_lock",
brettwbda835b2015-12-04 22:12:3090 "//mojo/common",
rockotc637caf9b2016-02-10 09:57:0891 "//mojo/edk/system",
rockot85dce0862015-11-13 01:33:5992 "//mojo/public/cpp/bindings",
tfarinacdc7e5d2015-02-23 09:52:2493 "//net",
94 "//testing/gmock",
95 "//testing/gtest",
reillyg872fd9fc2016-02-04 21:50:0496 "//tools/usb_gadget",
tfarinacdc7e5d2015-02-23 09:52:2497 "//url",
98 ]
99
markuso472a0202016-08-23 15:49:11100 if (is_linux && !is_chromeos && use_dbus) {
scheib7a4cf042015-03-31 04:33:44101 sources += [ "battery/battery_status_manager_linux_unittest.cc" ]
markuso472a0202016-08-23 15:49:11102 deps += [ "//dbus:test_support" ]
scheib7a4cf042015-03-31 04:33:44103 }
tfarinacdc7e5d2015-02-23 09:52:24104
maksim.sisovc0876ac2016-11-04 22:54:12105 if (is_linux) {
106 sources += [ "generic_sensor/linux/sensor_reader_unittest.cc" ]
107 }
108
scheib7a4cf042015-03-31 04:33:44109 # HID and Serial:
scheibcfdca0e2015-04-01 05:27:58110 # Android doesn't compile.
scheib7a4cf042015-03-31 04:33:44111 # Linux, requires udev.
scheibcfdca0e2015-04-01 05:27:58112 if (!is_linux_without_udev && !is_android) {
scheib7a4cf042015-03-31 04:33:44113 sources += [
114 "hid/hid_connection_unittest.cc",
115 "hid/hid_device_filter_unittest.cc",
116 "hid/hid_report_descriptor_unittest.cc",
117 "hid/input_service_linux_unittest.cc",
118 "hid/test_report_descriptors.cc",
119 "hid/test_report_descriptors.h",
juncai923ede72015-07-30 22:58:30120 "serial/serial_io_handler_posix_unittest.cc",
scheib7a4cf042015-03-31 04:33:44121 ]
122 deps += [
123 "//device/hid",
124 "//device/serial",
125 "//device/serial:test_support",
126 ]
127 }
128
129 if (use_udev) {
130 sources += [ "udev_linux/udev_unittest.cc" ]
131 deps += [ "//device/udev_linux" ]
132 }
133
reillygcf1af632015-11-18 16:42:58134 # USB does not compile on iOS.
135 if (!is_ios) {
scheibcfdca0e2015-04-01 05:27:58136 sources += [
reillygbadbc5412015-08-28 23:08:10137 "test/test_device_client.cc",
138 "test/test_device_client.h",
scheibcfdca0e2015-04-01 05:27:58139 "test/usb_test_gadget_impl.cc",
reillyg64c8f4f2016-02-10 23:29:20140 "usb/mojo/device_impl_unittest.cc",
141 "usb/mojo/device_manager_impl_unittest.cc",
reillyg1f45f772016-04-02 02:46:55142 "usb/mojo/mock_permission_provider.cc",
143 "usb/mojo/mock_permission_provider.h",
reillyg86549e52015-08-15 03:00:43144 "usb/usb_descriptors_unittest.cc",
scheibcfdca0e2015-04-01 05:27:58145 "usb/usb_device_filter_unittest.cc",
146 "usb/usb_device_handle_unittest.cc",
147 "usb/usb_ids_unittest.cc",
148 "usb/usb_service_unittest.cc",
reillyg86549e52015-08-15 03:00:43149 "usb/webusb_descriptors_unittest.cc",
scheibcfdca0e2015-04-01 05:27:58150 ]
151 deps += [
alexis.menard2fe63eaa2016-10-13 21:42:43152 "//device/base",
153 "//device/base:mocks",
scheibcfdca0e2015-04-01 05:27:58154 "//device/usb",
reillygcff166d2016-05-20 20:15:42155 "//device/usb:test_support",
reillyg64c8f4f2016-02-10 23:29:20156 "//device/usb/mojo",
157 "//device/usb/public/interfaces",
scheibcfdca0e2015-04-01 05:27:58158 ]
159 }
160
reillygcf1af632015-11-18 16:42:58161 # UsbContext is a libusb-specific object.
reillygdee7c4ac2016-05-27 21:15:02162 if (is_mac || is_win) {
reillygcf1af632015-11-18 16:42:58163 sources += [ "usb/usb_context_unittest.cc" ]
brettwbda835b2015-12-04 22:12:30164 deps += [ "//third_party/libusb" ]
reillygcf1af632015-11-18 16:42:58165 }
166
scheib56010cc2015-06-25 01:29:47167 if (is_android) {
leon.han4e5d8102015-09-02 07:12:00168 sources -= [ "battery/battery_status_service_unittest.cc" ]
agrieve97176362015-12-01 16:36:19169 deps += [
170 ":bluetooth_test_java",
171 ":bluetooth_test_jni_headers",
mcasas4e216e72016-07-28 21:28:38172 "//device/geolocation:geolocation_java",
173 "//device/geolocation:geolocation_java_test_support",
reillyg16001d92016-06-01 00:44:30174 "//device/usb:java",
agrieve97176362015-12-01 16:36:19175 ]
leon.han4e5d8102015-09-02 07:12:00176 deps -= [ "//device/battery" ]
scheib56010cc2015-06-25 01:29:47177 }
178
scheib7a4cf042015-03-31 04:33:44179 if (is_chromeos) {
tfarinacdc7e5d2015-02-23 09:52:24180 deps += [
181 "//chromeos",
182 "//chromeos:test_support",
183 "//chromeos:test_support_without_gmock",
tfarinacdc7e5d2015-02-23 09:52:24184 ]
185 }
186
dnicoara59acb3022015-12-17 18:13:16187 if ((is_chromeos || is_linux) && use_dbus) {
agrieve95ba4442016-04-25 15:47:13188 configs += [ "//build/config/linux/dbus" ]
rkc41077042015-11-06 07:20:58189
190 sources += [
rkc122239752016-04-20 23:59:08191 "bluetooth/bluez/bluetooth_adapter_profile_bluez_unittest.cc",
192 "bluetooth/bluez/bluetooth_advertisement_bluez_unittest.cc",
rkc122239752016-04-20 23:59:08193 "bluetooth/bluez/bluetooth_bluez_unittest.cc",
194 "bluetooth/bluez/bluetooth_gatt_bluez_unittest.cc",
rkc2ffd5612016-06-24 02:00:22195 "bluetooth/bluez/bluetooth_service_attribute_value_bluez_unittest.cc",
196 "bluetooth/bluez/bluetooth_service_record_bluez_unittest.cc",
rkc122239752016-04-20 23:59:08197 "bluetooth/bluez/bluetooth_socket_bluez_unittest.cc",
rkca7a149d2016-04-29 08:15:37198 "bluetooth/dbus/bluetooth_gatt_application_service_provider_unittest.cc",
rkc519a20c62016-04-16 23:18:07199 "bluetooth/test/bluetooth_test_bluez.cc",
200 "bluetooth/test/bluetooth_test_bluez.h",
rkc41077042015-11-06 07:20:58201 ]
202
203 deps += [ "//dbus" ]
204 }
205
tfarinacdc7e5d2015-02-23 09:52:24206 if (is_mac) {
krstnmnlsn332a71cf2015-07-17 18:59:58207 deps += [ "//third_party/ocmock" ]
208 ldflags = [ "-ObjC" ]
rsesekdbb69c72016-05-11 17:26:35209 libs = [
210 "IOBluetooth.framework",
211 "IOKit.framework",
212 ]
erikchenceb2fff2015-04-27 17:50:54213
214 # In the OSX 10.10 SDK, CoreBluetooth became a top level framework.
215 # Previously, it was nested in IOBluetooth. In order for Chrome to run on
216 # OSes older than OSX 10.10, the top level CoreBluetooth framework must be
217 # weakly linked.
218 if (mac_sdk_version == "10.10") {
scheibdd941ba42015-10-27 05:40:12219 ldflags += [
220 "-weak_framework",
221 "CoreBluetooth",
222 ]
erikchenceb2fff2015-04-27 17:50:54223 }
tfarinacdc7e5d2015-02-23 09:52:24224 }
gogeraldcab31232016-02-03 21:20:33225
226 if (is_win) {
227 sources += [
gogeraldb8c706a2016-02-05 01:07:37228 "bluetooth/bluetooth_classic_win_fake.cc",
229 "bluetooth/bluetooth_classic_win_fake.h",
gogeraldcab31232016-02-03 21:20:33230 "bluetooth/bluetooth_low_energy_win_fake.cc",
231 "bluetooth/bluetooth_low_energy_win_fake.h",
232 ]
alexander.shalamovd08cd092016-11-03 07:46:30233
234 # Needed for "generic_sensor/platform_sensor_and_provider_unittest_win.cc"
235 libs = [ "sensorsapi.lib" ]
gogeraldcab31232016-02-03 21:20:33236 }
bajones7ab52ec32016-08-19 19:54:25237
238 if (enable_webvr) {
239 sources += [
240 "vr/vr_device_manager_unittest.cc",
241 "vr/vr_service_impl_unittest.cc",
242 ]
243
244 deps += [
245 "//device/vr",
246 "//device/vr:fakes",
247 "//device/vr:mojo_bindings",
248 ]
249 }
tfarinacdc7e5d2015-02-23 09:52:24250}
scheib56010cc2015-06-25 01:29:47251
252if (is_android) {
scheib545d7fd2015-06-30 22:26:58253 bluetooth_java_sources_needing_jni = [ "bluetooth/test/android/java/src/org/chromium/device/bluetooth/Fakes.java" ]
scheib56010cc2015-06-25 01:29:47254
255 generate_jni("bluetooth_test_jni_headers") {
256 sources = bluetooth_java_sources_needing_jni
257 jni_package = "bluetooth"
258 }
259
260 android_library("bluetooth_test_java") {
261 java_files = bluetooth_java_sources_needing_jni
262 deps = [
263 "//base:base_java",
ortuno5966ddb2016-07-01 02:07:25264 "//components/location/android:location_java",
scheib56010cc2015-06-25 01:29:47265 "//device/bluetooth:java",
ortunocc9b46d12016-08-25 16:47:23266 "//third_party/android_tools:android_support_annotations_java",
scheib56010cc2015-06-25 01:29:47267 ]
ortunocc9b46d12016-08-25 16:47:23268
269 srcjar_deps = [ ":bluetooth_test_javagen" ]
scheib56010cc2015-06-25 01:29:47270 }
bajonesb9bb4c42016-07-07 00:10:51271
272 junit_binary("device_junit_tests") {
alexander.shalamova0d87412016-09-16 06:59:14273 java_files = [
274 "gamepad/android/junit/src/org/chromium/device/gamepad/GamepadMappingsTest.java",
275 "generic_sensor/android/junit/src/org/chromium/device/sensors/PlatformSensorAndProviderTest.java",
276 ]
bajonesb9bb4c42016-07-07 00:10:51277 deps = [
278 "//base:base_java",
279 "//base:base_java_test_support",
280 "//device/gamepad:java",
alexander.shalamova0d87412016-09-16 06:59:14281 "//device/generic_sensor:java",
282 "//device/generic_sensor/public/interfaces:interfaces_java",
peconn2e675b52016-08-01 15:56:19283 "//third_party/android_tools:android_support_annotations_java",
bajonesb9bb4c42016-07-07 00:10:51284 ]
285 srcjar_deps = [ "//device/gamepad:java_enums_srcjar" ]
286 }
ortunocc9b46d12016-08-25 16:47:23287
288 java_cpp_enum("bluetooth_test_javagen") {
289 sources = [
290 "bluetooth/test/bluetooth_test.h",
291 ]
292 }
scheib56010cc2015-06-25 01:29:47293}