blob: 96a719bed24e2277eec8626ae2f12b0c13f8211e [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
17is_linux_without_dbus = is_linux && !use_dbus
18
tfarinacdc7e5d2015-02-23 09:52:2419test("device_unittests") {
20 sources = [
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",
rkc3fb9aa6d2016-05-03 20:39:4440 "bluetooth/test/bluetooth_gatt_server_test.cc",
41 "bluetooth/test/bluetooth_gatt_server_test.h",
scheib545d7fd2015-06-30 22:26:5842 "bluetooth/test/bluetooth_test.cc",
43 "bluetooth/test/bluetooth_test.h",
44 "bluetooth/test/bluetooth_test_android.cc",
45 "bluetooth/test/bluetooth_test_android.h",
krstnmnlsn56d371032015-07-21 20:18:0746 "bluetooth/test/bluetooth_test_mac.h",
47 "bluetooth/test/bluetooth_test_mac.mm",
gogerald512935cc2016-01-27 01:11:1848 "bluetooth/test/bluetooth_test_win.cc",
49 "bluetooth/test/bluetooth_test_win.h",
jlebel620327d2016-06-20 13:01:0050 "bluetooth/test/mock_bluetooth_cbcharacteristic_mac.h",
51 "bluetooth/test/mock_bluetooth_cbcharacteristic_mac.mm",
jlebela58fd752016-03-14 10:33:2852 "bluetooth/test/mock_bluetooth_cbperipheral_mac.h",
53 "bluetooth/test/mock_bluetooth_cbperipheral_mac.mm",
jlebelc4b09782016-05-10 00:31:5854 "bluetooth/test/mock_bluetooth_cbservice_mac.h",
55 "bluetooth/test/mock_bluetooth_cbservice_mac.mm",
jlebela58fd752016-03-14 10:33:2856 "bluetooth/test/mock_bluetooth_central_manager_mac.h",
57 "bluetooth/test/mock_bluetooth_central_manager_mac.mm",
scheib42e6b49d2015-04-29 21:46:5758 "bluetooth/test/test_bluetooth_adapter_observer.cc",
59 "bluetooth/test/test_bluetooth_adapter_observer.h",
rkc3fb9aa6d2016-05-03 20:39:4460 "bluetooth/test/test_bluetooth_local_gatt_service_delegate.cc",
61 "bluetooth/test/test_bluetooth_local_gatt_service_delegate.h",
tfarinacdc7e5d2015-02-23 09:52:2462 "nfc/nfc_chromeos_unittest.cc",
63 "nfc/nfc_ndef_record_unittest.cc",
tfarinacdc7e5d2015-02-23 09:52:2464 "test/run_all_unittests.cc",
bajones98f96522016-06-03 22:43:5765 "vr/vr_device_manager_unittest.cc",
tfarinacdc7e5d2015-02-23 09:52:2466 ]
67
68 deps = [
69 "//base/test:test_support",
70 "//device/battery",
71 "//device/battery:mojo_bindings",
72 "//device/bluetooth",
brettw011138d2015-10-21 03:05:3873 "//device/bluetooth:mocks",
tfarinacdc7e5d2015-02-23 09:52:2474 "//device/nfc",
scottmgc40e8822016-06-17 17:57:4875 "//device/power_save_blocker",
bajones98f96522016-06-03 22:43:5776 "//device/vr",
77 "//device/vr:fakes",
bajones4ce365c2016-06-08 00:42:3478 "//device/vr:mojo_bindings",
brettwbda835b2015-12-04 22:12:3079 "//mojo/common",
rockotc637caf9b2016-02-10 09:57:0880 "//mojo/edk/system",
rockot85dce0862015-11-13 01:33:5981 "//mojo/public/cpp/bindings",
tfarinacdc7e5d2015-02-23 09:52:2482 "//net",
83 "//testing/gmock",
84 "//testing/gtest",
reillyg872fd9fc2016-02-04 21:50:0485 "//tools/usb_gadget",
tfarinacdc7e5d2015-02-23 09:52:2486 "//url",
87 ]
88
scheib7a4cf042015-03-31 04:33:4489 if (!is_linux_without_dbus && !is_chromeos) {
90 sources += [ "battery/battery_status_manager_linux_unittest.cc" ]
91 }
tfarinacdc7e5d2015-02-23 09:52:2492
scheib7a4cf042015-03-31 04:33:4493 # HID and Serial:
scheibcfdca0e2015-04-01 05:27:5894 # Android doesn't compile.
scheib7a4cf042015-03-31 04:33:4495 # Linux, requires udev.
scheibcfdca0e2015-04-01 05:27:5896 if (!is_linux_without_udev && !is_android) {
scheib7a4cf042015-03-31 04:33:4497 sources += [
98 "hid/hid_connection_unittest.cc",
99 "hid/hid_device_filter_unittest.cc",
100 "hid/hid_report_descriptor_unittest.cc",
101 "hid/input_service_linux_unittest.cc",
102 "hid/test_report_descriptors.cc",
103 "hid/test_report_descriptors.h",
104 "serial/data_sink_unittest.cc",
105 "serial/data_source_unittest.cc",
106 "serial/serial_connection_unittest.cc",
juncai923ede72015-07-30 22:58:30107 "serial/serial_io_handler_posix_unittest.cc",
scheib7a4cf042015-03-31 04:33:44108 "serial/serial_service_unittest.cc",
109 ]
110 deps += [
111 "//device/hid",
112 "//device/serial",
113 "//device/serial:test_support",
114 ]
115 }
116
117 if (use_udev) {
118 sources += [ "udev_linux/udev_unittest.cc" ]
119 deps += [ "//device/udev_linux" ]
120 }
121
reillygcf1af632015-11-18 16:42:58122 # USB does not compile on iOS.
123 if (!is_ios) {
scheibcfdca0e2015-04-01 05:27:58124 sources += [
reillygbadbc5412015-08-28 23:08:10125 "test/test_device_client.cc",
126 "test/test_device_client.h",
scheibcfdca0e2015-04-01 05:27:58127 "test/usb_test_gadget_impl.cc",
reillyg64c8f4f2016-02-10 23:29:20128 "usb/mojo/device_impl_unittest.cc",
129 "usb/mojo/device_manager_impl_unittest.cc",
reillyg1f45f772016-04-02 02:46:55130 "usb/mojo/mock_permission_provider.cc",
131 "usb/mojo/mock_permission_provider.h",
reillyg86549e52015-08-15 03:00:43132 "usb/usb_descriptors_unittest.cc",
scheibcfdca0e2015-04-01 05:27:58133 "usb/usb_device_filter_unittest.cc",
134 "usb/usb_device_handle_unittest.cc",
135 "usb/usb_ids_unittest.cc",
136 "usb/usb_service_unittest.cc",
reillyg86549e52015-08-15 03:00:43137 "usb/webusb_descriptors_unittest.cc",
scheibcfdca0e2015-04-01 05:27:58138 ]
139 deps += [
rockot8fcc2752015-05-28 02:07:55140 "//device/core",
reillygbcc08e212015-11-24 19:57:01141 "//device/core:mocks",
scheibcfdca0e2015-04-01 05:27:58142 "//device/usb",
reillygcff166d2016-05-20 20:15:42143 "//device/usb:test_support",
reillyg64c8f4f2016-02-10 23:29:20144 "//device/usb/mojo",
145 "//device/usb/public/interfaces",
scheibcfdca0e2015-04-01 05:27:58146 ]
147 }
148
reillygcf1af632015-11-18 16:42:58149 # UsbContext is a libusb-specific object.
reillygdee7c4ac2016-05-27 21:15:02150 if (is_mac || is_win) {
reillygcf1af632015-11-18 16:42:58151 sources += [ "usb/usb_context_unittest.cc" ]
brettwbda835b2015-12-04 22:12:30152 deps += [ "//third_party/libusb" ]
reillygcf1af632015-11-18 16:42:58153 }
154
scheib56010cc2015-06-25 01:29:47155 if (is_android) {
leon.han4e5d8102015-09-02 07:12:00156 sources -= [ "battery/battery_status_service_unittest.cc" ]
agrieve97176362015-12-01 16:36:19157 deps += [
158 ":bluetooth_test_java",
159 ":bluetooth_test_jni_headers",
reillyg16001d92016-06-01 00:44:30160 "//device/usb:java",
agrieve97176362015-12-01 16:36:19161 ]
leon.han4e5d8102015-09-02 07:12:00162 deps -= [ "//device/battery" ]
scheib56010cc2015-06-25 01:29:47163 }
164
scheib7a4cf042015-03-31 04:33:44165 if (is_chromeos) {
tfarinacdc7e5d2015-02-23 09:52:24166 deps += [
167 "//chromeos",
168 "//chromeos:test_support",
169 "//chromeos:test_support_without_gmock",
tfarinacdc7e5d2015-02-23 09:52:24170 ]
171 }
172
dnicoara59acb3022015-12-17 18:13:16173 if ((is_chromeos || is_linux) && use_dbus) {
agrieve95ba4442016-04-25 15:47:13174 configs += [ "//build/config/linux/dbus" ]
rkc41077042015-11-06 07:20:58175
176 sources += [
rkc122239752016-04-20 23:59:08177 "bluetooth/bluez/bluetooth_adapter_profile_bluez_unittest.cc",
178 "bluetooth/bluez/bluetooth_advertisement_bluez_unittest.cc",
179 "bluetooth/bluez/bluetooth_audio_sink_bluez_unittest.cc",
180 "bluetooth/bluez/bluetooth_bluez_unittest.cc",
181 "bluetooth/bluez/bluetooth_gatt_bluez_unittest.cc",
182 "bluetooth/bluez/bluetooth_socket_bluez_unittest.cc",
rkca7a149d2016-04-29 08:15:37183 "bluetooth/dbus/bluetooth_gatt_application_service_provider_unittest.cc",
rkc519a20c62016-04-16 23:18:07184 "bluetooth/test/bluetooth_test_bluez.cc",
185 "bluetooth/test/bluetooth_test_bluez.h",
rkc41077042015-11-06 07:20:58186 ]
187
188 deps += [ "//dbus" ]
189 }
190
tfarinacdc7e5d2015-02-23 09:52:24191 if (is_mac) {
krstnmnlsn332a71cf2015-07-17 18:59:58192 deps += [ "//third_party/ocmock" ]
193 ldflags = [ "-ObjC" ]
rsesekdbb69c72016-05-11 17:26:35194 libs = [
195 "IOBluetooth.framework",
196 "IOKit.framework",
197 ]
erikchenceb2fff2015-04-27 17:50:54198
199 # In the OSX 10.10 SDK, CoreBluetooth became a top level framework.
200 # Previously, it was nested in IOBluetooth. In order for Chrome to run on
201 # OSes older than OSX 10.10, the top level CoreBluetooth framework must be
202 # weakly linked.
203 if (mac_sdk_version == "10.10") {
scheibdd941ba42015-10-27 05:40:12204 ldflags += [
205 "-weak_framework",
206 "CoreBluetooth",
207 ]
erikchenceb2fff2015-04-27 17:50:54208 }
tfarinacdc7e5d2015-02-23 09:52:24209 }
gogeraldcab31232016-02-03 21:20:33210
211 if (is_win) {
212 sources += [
gogeraldb8c706a2016-02-05 01:07:37213 "bluetooth/bluetooth_classic_win_fake.cc",
214 "bluetooth/bluetooth_classic_win_fake.h",
gogeraldcab31232016-02-03 21:20:33215 "bluetooth/bluetooth_low_energy_win_fake.cc",
216 "bluetooth/bluetooth_low_energy_win_fake.h",
217 ]
218 }
tfarinacdc7e5d2015-02-23 09:52:24219}
scheib56010cc2015-06-25 01:29:47220
221if (is_android) {
scheib545d7fd2015-06-30 22:26:58222 bluetooth_java_sources_needing_jni = [ "bluetooth/test/android/java/src/org/chromium/device/bluetooth/Fakes.java" ]
scheib56010cc2015-06-25 01:29:47223
224 generate_jni("bluetooth_test_jni_headers") {
225 sources = bluetooth_java_sources_needing_jni
226 jni_package = "bluetooth"
227 }
228
229 android_library("bluetooth_test_java") {
230 java_files = bluetooth_java_sources_needing_jni
231 deps = [
232 "//base:base_java",
233 "//device/bluetooth:java",
234 ]
235 }
236}