blob: 4b52e523118452c9f2469cb040d9a01d8e950e5d [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",
scheibdd941ba42015-10-27 05:40:1230 "bluetooth/bluetooth_gatt_characteristic_unittest.cc",
scheib81a0ff262016-01-13 00:58:3031 "bluetooth/bluetooth_gatt_descriptor_unittest.cc",
scheib33aa3f42015-10-16 01:23:1532 "bluetooth/bluetooth_gatt_service_unittest.cc",
tfarinacdc7e5d2015-02-23 09:52:2433 "bluetooth/bluetooth_low_energy_win_unittest.cc",
34 "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",
scheib42e6b49d2015-04-29 21:46:5745 "bluetooth/test/test_bluetooth_adapter_observer.cc",
46 "bluetooth/test/test_bluetooth_adapter_observer.h",
tfarinacdc7e5d2015-02-23 09:52:2447 "nfc/nfc_chromeos_unittest.cc",
48 "nfc/nfc_ndef_record_unittest.cc",
tfarinacdc7e5d2015-02-23 09:52:2449 "test/run_all_unittests.cc",
tfarinacdc7e5d2015-02-23 09:52:2450 ]
51
52 deps = [
53 "//base/test:test_support",
54 "//device/battery",
55 "//device/battery:mojo_bindings",
56 "//device/bluetooth",
brettw011138d2015-10-21 03:05:3857 "//device/bluetooth:mocks",
tfarinacdc7e5d2015-02-23 09:52:2458 "//device/nfc",
brettwbda835b2015-12-04 22:12:3059 "//mojo/common",
rockotc637caf9b2016-02-10 09:57:0860 "//mojo/edk/system",
tfarinacdc7e5d2015-02-23 09:52:2461 "//mojo/environment:chromium",
rockot85dce0862015-11-13 01:33:5962 "//mojo/public/cpp/bindings",
tfarinacdc7e5d2015-02-23 09:52:2463 "//net",
64 "//testing/gmock",
65 "//testing/gtest",
reillyg872fd9fc2016-02-04 21:50:0466 "//tools/usb_gadget",
tfarinacdc7e5d2015-02-23 09:52:2467 "//url",
68 ]
69
scheib7a4cf042015-03-31 04:33:4470 if (!is_linux_without_dbus && !is_chromeos) {
71 sources += [ "battery/battery_status_manager_linux_unittest.cc" ]
72 }
tfarinacdc7e5d2015-02-23 09:52:2473
scheib7a4cf042015-03-31 04:33:4474 # HID and Serial:
scheibcfdca0e2015-04-01 05:27:5875 # Android doesn't compile.
scheib7a4cf042015-03-31 04:33:4476 # Linux, requires udev.
scheibcfdca0e2015-04-01 05:27:5877 if (!is_linux_without_udev && !is_android) {
scheib7a4cf042015-03-31 04:33:4478 sources += [
79 "hid/hid_connection_unittest.cc",
80 "hid/hid_device_filter_unittest.cc",
81 "hid/hid_report_descriptor_unittest.cc",
82 "hid/input_service_linux_unittest.cc",
83 "hid/test_report_descriptors.cc",
84 "hid/test_report_descriptors.h",
85 "serial/data_sink_unittest.cc",
86 "serial/data_source_unittest.cc",
87 "serial/serial_connection_unittest.cc",
juncai923ede72015-07-30 22:58:3088 "serial/serial_io_handler_posix_unittest.cc",
scheib7a4cf042015-03-31 04:33:4489 "serial/serial_service_unittest.cc",
90 ]
91 deps += [
92 "//device/hid",
93 "//device/serial",
94 "//device/serial:test_support",
95 ]
96 }
97
98 if (use_udev) {
99 sources += [ "udev_linux/udev_unittest.cc" ]
100 deps += [ "//device/udev_linux" ]
101 }
102
reillygcf1af632015-11-18 16:42:58103 # USB does not compile on iOS.
104 if (!is_ios) {
scheibcfdca0e2015-04-01 05:27:58105 sources += [
reillygbadbc5412015-08-28 23:08:10106 "test/test_device_client.cc",
107 "test/test_device_client.h",
scheibcfdca0e2015-04-01 05:27:58108 "test/usb_test_gadget_impl.cc",
reillyg64c8f4f2016-02-10 23:29:20109 "usb/mojo/device_impl_unittest.cc",
110 "usb/mojo/device_manager_impl_unittest.cc",
111 "usb/mojo/fake_permission_provider.cc",
112 "usb/mojo/fake_permission_provider.h",
reillyg86549e52015-08-15 03:00:43113 "usb/usb_descriptors_unittest.cc",
scheibcfdca0e2015-04-01 05:27:58114 "usb/usb_device_filter_unittest.cc",
115 "usb/usb_device_handle_unittest.cc",
116 "usb/usb_ids_unittest.cc",
117 "usb/usb_service_unittest.cc",
reillyg86549e52015-08-15 03:00:43118 "usb/webusb_descriptors_unittest.cc",
scheibcfdca0e2015-04-01 05:27:58119 ]
120 deps += [
rockot8fcc2752015-05-28 02:07:55121 "//device/core",
reillygbcc08e212015-11-24 19:57:01122 "//device/core:mocks",
scheibcfdca0e2015-04-01 05:27:58123 "//device/usb",
reillygcf9be262015-05-14 16:06:06124 "//device/usb:mocks",
reillyg64c8f4f2016-02-10 23:29:20125 "//device/usb/mojo",
126 "//device/usb/public/interfaces",
scheibcfdca0e2015-04-01 05:27:58127 ]
128 }
129
reillygcf1af632015-11-18 16:42:58130 # UsbContext is a libusb-specific object.
131 if (!is_android && !is_ios) {
132 sources += [ "usb/usb_context_unittest.cc" ]
brettwbda835b2015-12-04 22:12:30133 deps += [ "//third_party/libusb" ]
reillygcf1af632015-11-18 16:42:58134 }
135
scheib56010cc2015-06-25 01:29:47136 if (is_android) {
leon.han4e5d8102015-09-02 07:12:00137 sources -= [ "battery/battery_status_service_unittest.cc" ]
agrieve97176362015-12-01 16:36:19138 deps += [
139 ":bluetooth_test_java",
140 ":bluetooth_test_jni_headers",
141 ]
leon.han4e5d8102015-09-02 07:12:00142 deps -= [ "//device/battery" ]
scheib56010cc2015-06-25 01:29:47143 }
144
scheib7a4cf042015-03-31 04:33:44145 if (is_chromeos) {
tfarinacdc7e5d2015-02-23 09:52:24146 deps += [
147 "//chromeos",
148 "//chromeos:test_support",
149 "//chromeos:test_support_without_gmock",
tfarinacdc7e5d2015-02-23 09:52:24150 ]
151 }
152
dnicoara59acb3022015-12-17 18:13:16153 if ((is_chromeos || is_linux) && use_dbus) {
rkc41077042015-11-06 07:20:58154 configs += [ "//build/config/linux:dbus" ]
155
156 sources += [
157 "bluetooth/bluetooth_adapter_profile_bluez_unittest.cc",
158 "bluetooth/bluetooth_advertisement_bluez_unittest.cc",
159 "bluetooth/bluetooth_audio_sink_bluez_unittest.cc",
160 "bluetooth/bluetooth_bluez_unittest.cc",
161 "bluetooth/bluetooth_gatt_bluez_unittest.cc",
162 "bluetooth/bluetooth_socket_bluez_unittest.cc",
163 ]
164
165 deps += [ "//dbus" ]
166 }
167
tfarinacdc7e5d2015-02-23 09:52:24168 if (is_mac) {
krstnmnlsn332a71cf2015-07-17 18:59:58169 deps += [ "//third_party/ocmock" ]
170 ldflags = [ "-ObjC" ]
tfarinacdc7e5d2015-02-23 09:52:24171 libs = [ "IOBluetooth.framework" ]
erikchenceb2fff2015-04-27 17:50:54172
173 # In the OSX 10.10 SDK, CoreBluetooth became a top level framework.
174 # Previously, it was nested in IOBluetooth. In order for Chrome to run on
175 # OSes older than OSX 10.10, the top level CoreBluetooth framework must be
176 # weakly linked.
177 if (mac_sdk_version == "10.10") {
scheibdd941ba42015-10-27 05:40:12178 ldflags += [
179 "-weak_framework",
180 "CoreBluetooth",
181 ]
erikchenceb2fff2015-04-27 17:50:54182 }
tfarinacdc7e5d2015-02-23 09:52:24183 }
gogeraldcab31232016-02-03 21:20:33184
185 if (is_win) {
186 sources += [
gogeraldb8c706a2016-02-05 01:07:37187 "bluetooth/bluetooth_classic_win_fake.cc",
188 "bluetooth/bluetooth_classic_win_fake.h",
gogeraldcab31232016-02-03 21:20:33189 "bluetooth/bluetooth_low_energy_win_fake.cc",
190 "bluetooth/bluetooth_low_energy_win_fake.h",
191 ]
192 }
tfarinacdc7e5d2015-02-23 09:52:24193}
scheib56010cc2015-06-25 01:29:47194
195if (is_android) {
scheib545d7fd2015-06-30 22:26:58196 bluetooth_java_sources_needing_jni = [ "bluetooth/test/android/java/src/org/chromium/device/bluetooth/Fakes.java" ]
scheib56010cc2015-06-25 01:29:47197
198 generate_jni("bluetooth_test_jni_headers") {
199 sources = bluetooth_java_sources_needing_jni
200 jni_package = "bluetooth"
201 }
202
203 android_library("bluetooth_test_java") {
204 java_files = bluetooth_java_sources_needing_jni
205 deps = [
206 "//base:base_java",
207 "//device/bluetooth:java",
208 ]
209 }
210}