blob: 1f688037e8942311cb2996adcec03578d0ca6747 [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",
tfarinacdc7e5d2015-02-23 09:52:2430 "bluetooth/bluetooth_low_energy_win_unittest.cc",
rkc122239752016-04-20 23:59:0831 "bluetooth/bluetooth_remote_gatt_characteristic_unittest.cc",
32 "bluetooth/bluetooth_remote_gatt_descriptor_unittest.cc",
33 "bluetooth/bluetooth_remote_gatt_service_unittest.cc",
tfarinacdc7e5d2015-02-23 09:52:2434 "bluetooth/bluetooth_service_record_win_unittest.cc",
tfarinacdc7e5d2015-02-23 09:52:2435 "bluetooth/bluetooth_task_manager_win_unittest.cc",
36 "bluetooth/bluetooth_uuid_unittest.cc",
scheib545d7fd2015-06-30 22:26:5837 "bluetooth/test/bluetooth_test.cc",
38 "bluetooth/test/bluetooth_test.h",
39 "bluetooth/test/bluetooth_test_android.cc",
40 "bluetooth/test/bluetooth_test_android.h",
krstnmnlsn56d371032015-07-21 20:18:0741 "bluetooth/test/bluetooth_test_mac.h",
42 "bluetooth/test/bluetooth_test_mac.mm",
gogerald512935cc2016-01-27 01:11:1843 "bluetooth/test/bluetooth_test_win.cc",
44 "bluetooth/test/bluetooth_test_win.h",
jlebela58fd752016-03-14 10:33:2845 "bluetooth/test/mock_bluetooth_cbperipheral_mac.h",
46 "bluetooth/test/mock_bluetooth_cbperipheral_mac.mm",
47 "bluetooth/test/mock_bluetooth_central_manager_mac.h",
48 "bluetooth/test/mock_bluetooth_central_manager_mac.mm",
scheib42e6b49d2015-04-29 21:46:5749 "bluetooth/test/test_bluetooth_adapter_observer.cc",
50 "bluetooth/test/test_bluetooth_adapter_observer.h",
tfarinacdc7e5d2015-02-23 09:52:2451 "nfc/nfc_chromeos_unittest.cc",
52 "nfc/nfc_ndef_record_unittest.cc",
tfarinacdc7e5d2015-02-23 09:52:2453 "test/run_all_unittests.cc",
tfarinacdc7e5d2015-02-23 09:52:2454 ]
55
56 deps = [
57 "//base/test:test_support",
58 "//device/battery",
59 "//device/battery:mojo_bindings",
60 "//device/bluetooth",
brettw011138d2015-10-21 03:05:3861 "//device/bluetooth:mocks",
tfarinacdc7e5d2015-02-23 09:52:2462 "//device/nfc",
brettwbda835b2015-12-04 22:12:3063 "//mojo/common",
rockotc637caf9b2016-02-10 09:57:0864 "//mojo/edk/system",
rockot85dce0862015-11-13 01:33:5965 "//mojo/public/cpp/bindings",
tfarinacdc7e5d2015-02-23 09:52:2466 "//net",
67 "//testing/gmock",
68 "//testing/gtest",
reillyg872fd9fc2016-02-04 21:50:0469 "//tools/usb_gadget",
tfarinacdc7e5d2015-02-23 09:52:2470 "//url",
71 ]
72
scheib7a4cf042015-03-31 04:33:4473 if (!is_linux_without_dbus && !is_chromeos) {
74 sources += [ "battery/battery_status_manager_linux_unittest.cc" ]
75 }
tfarinacdc7e5d2015-02-23 09:52:2476
scheib7a4cf042015-03-31 04:33:4477 # HID and Serial:
scheibcfdca0e2015-04-01 05:27:5878 # Android doesn't compile.
scheib7a4cf042015-03-31 04:33:4479 # Linux, requires udev.
scheibcfdca0e2015-04-01 05:27:5880 if (!is_linux_without_udev && !is_android) {
scheib7a4cf042015-03-31 04:33:4481 sources += [
82 "hid/hid_connection_unittest.cc",
83 "hid/hid_device_filter_unittest.cc",
84 "hid/hid_report_descriptor_unittest.cc",
85 "hid/input_service_linux_unittest.cc",
86 "hid/test_report_descriptors.cc",
87 "hid/test_report_descriptors.h",
88 "serial/data_sink_unittest.cc",
89 "serial/data_source_unittest.cc",
90 "serial/serial_connection_unittest.cc",
juncai923ede72015-07-30 22:58:3091 "serial/serial_io_handler_posix_unittest.cc",
scheib7a4cf042015-03-31 04:33:4492 "serial/serial_service_unittest.cc",
93 ]
94 deps += [
95 "//device/hid",
96 "//device/serial",
97 "//device/serial:test_support",
98 ]
99 }
100
101 if (use_udev) {
102 sources += [ "udev_linux/udev_unittest.cc" ]
103 deps += [ "//device/udev_linux" ]
104 }
105
reillygcf1af632015-11-18 16:42:58106 # USB does not compile on iOS.
107 if (!is_ios) {
scheibcfdca0e2015-04-01 05:27:58108 sources += [
reillygbadbc5412015-08-28 23:08:10109 "test/test_device_client.cc",
110 "test/test_device_client.h",
scheibcfdca0e2015-04-01 05:27:58111 "test/usb_test_gadget_impl.cc",
reillyg64c8f4f2016-02-10 23:29:20112 "usb/mojo/device_impl_unittest.cc",
113 "usb/mojo/device_manager_impl_unittest.cc",
reillyg1f45f772016-04-02 02:46:55114 "usb/mojo/mock_permission_provider.cc",
115 "usb/mojo/mock_permission_provider.h",
reillyg86549e52015-08-15 03:00:43116 "usb/usb_descriptors_unittest.cc",
scheibcfdca0e2015-04-01 05:27:58117 "usb/usb_device_filter_unittest.cc",
118 "usb/usb_device_handle_unittest.cc",
119 "usb/usb_ids_unittest.cc",
120 "usb/usb_service_unittest.cc",
reillyg86549e52015-08-15 03:00:43121 "usb/webusb_descriptors_unittest.cc",
scheibcfdca0e2015-04-01 05:27:58122 ]
123 deps += [
rockot8fcc2752015-05-28 02:07:55124 "//device/core",
reillygbcc08e212015-11-24 19:57:01125 "//device/core:mocks",
scheibcfdca0e2015-04-01 05:27:58126 "//device/usb",
reillygcf9be262015-05-14 16:06:06127 "//device/usb:mocks",
reillyg64c8f4f2016-02-10 23:29:20128 "//device/usb/mojo",
129 "//device/usb/public/interfaces",
scheibcfdca0e2015-04-01 05:27:58130 ]
131 }
132
reillygcf1af632015-11-18 16:42:58133 # UsbContext is a libusb-specific object.
134 if (!is_android && !is_ios) {
135 sources += [ "usb/usb_context_unittest.cc" ]
brettwbda835b2015-12-04 22:12:30136 deps += [ "//third_party/libusb" ]
reillygcf1af632015-11-18 16:42:58137 }
138
scheib56010cc2015-06-25 01:29:47139 if (is_android) {
leon.han4e5d8102015-09-02 07:12:00140 sources -= [ "battery/battery_status_service_unittest.cc" ]
agrieve97176362015-12-01 16:36:19141 deps += [
142 ":bluetooth_test_java",
143 ":bluetooth_test_jni_headers",
144 ]
leon.han4e5d8102015-09-02 07:12:00145 deps -= [ "//device/battery" ]
scheib56010cc2015-06-25 01:29:47146 }
147
scheib7a4cf042015-03-31 04:33:44148 if (is_chromeos) {
tfarinacdc7e5d2015-02-23 09:52:24149 deps += [
150 "//chromeos",
151 "//chromeos:test_support",
152 "//chromeos:test_support_without_gmock",
tfarinacdc7e5d2015-02-23 09:52:24153 ]
154 }
155
dnicoara59acb3022015-12-17 18:13:16156 if ((is_chromeos || is_linux) && use_dbus) {
agrieve95ba4442016-04-25 15:47:13157 configs += [ "//build/config/linux/dbus" ]
rkc41077042015-11-06 07:20:58158
159 sources += [
rkc122239752016-04-20 23:59:08160 "bluetooth/bluez/bluetooth_adapter_profile_bluez_unittest.cc",
161 "bluetooth/bluez/bluetooth_advertisement_bluez_unittest.cc",
162 "bluetooth/bluez/bluetooth_audio_sink_bluez_unittest.cc",
163 "bluetooth/bluez/bluetooth_bluez_unittest.cc",
164 "bluetooth/bluez/bluetooth_gatt_bluez_unittest.cc",
165 "bluetooth/bluez/bluetooth_socket_bluez_unittest.cc",
rkca7a149d2016-04-29 08:15:37166 "bluetooth/dbus/bluetooth_gatt_application_service_provider_unittest.cc",
rkc519a20c62016-04-16 23:18:07167 "bluetooth/test/bluetooth_test_bluez.cc",
168 "bluetooth/test/bluetooth_test_bluez.h",
rkc41077042015-11-06 07:20:58169 ]
170
171 deps += [ "//dbus" ]
172 }
173
tfarinacdc7e5d2015-02-23 09:52:24174 if (is_mac) {
krstnmnlsn332a71cf2015-07-17 18:59:58175 deps += [ "//third_party/ocmock" ]
176 ldflags = [ "-ObjC" ]
tfarinacdc7e5d2015-02-23 09:52:24177 libs = [ "IOBluetooth.framework" ]
erikchenceb2fff2015-04-27 17:50:54178
179 # In the OSX 10.10 SDK, CoreBluetooth became a top level framework.
180 # Previously, it was nested in IOBluetooth. In order for Chrome to run on
181 # OSes older than OSX 10.10, the top level CoreBluetooth framework must be
182 # weakly linked.
183 if (mac_sdk_version == "10.10") {
scheibdd941ba42015-10-27 05:40:12184 ldflags += [
185 "-weak_framework",
186 "CoreBluetooth",
187 ]
erikchenceb2fff2015-04-27 17:50:54188 }
tfarinacdc7e5d2015-02-23 09:52:24189 }
gogeraldcab31232016-02-03 21:20:33190
191 if (is_win) {
192 sources += [
gogeraldb8c706a2016-02-05 01:07:37193 "bluetooth/bluetooth_classic_win_fake.cc",
194 "bluetooth/bluetooth_classic_win_fake.h",
gogeraldcab31232016-02-03 21:20:33195 "bluetooth/bluetooth_low_energy_win_fake.cc",
196 "bluetooth/bluetooth_low_energy_win_fake.h",
197 ]
198 }
tfarinacdc7e5d2015-02-23 09:52:24199}
scheib56010cc2015-06-25 01:29:47200
201if (is_android) {
scheib545d7fd2015-06-30 22:26:58202 bluetooth_java_sources_needing_jni = [ "bluetooth/test/android/java/src/org/chromium/device/bluetooth/Fakes.java" ]
scheib56010cc2015-06-25 01:29:47203
204 generate_jni("bluetooth_test_jni_headers") {
205 sources = bluetooth_java_sources_needing_jni
206 jni_package = "bluetooth"
207 }
208
209 android_library("bluetooth_test_java") {
210 java_files = bluetooth_java_sources_needing_jni
211 deps = [
212 "//base:base_java",
213 "//device/bluetooth:java",
214 ]
215 }
216}