Upload upstream chromium 69.0.3497
[platform/framework/web/chromium-efl.git] / device / BUILD.gn
1 # 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
5 import("//build/config/features.gni")
6 import("//device/vr/buildflags/buildflags.gni")
7 import("//testing/test.gni")
8
9 if (is_android) {
10   import("//build/config/android/config.gni")
11   import("//build/config/android/rules.gni")  # For generate_jni().
12 }
13
14 if (is_mac) {
15   import("//build/config/mac/mac_sdk.gni")
16 }
17
18 is_linux_without_udev = is_linux && !use_udev
19
20 test("device_unittests") {
21   sources = [
22     "base/synchronization/one_writer_seqlock_unittest.cc",
23     "bluetooth/bluetooth_adapter_mac_unittest.mm",
24     "bluetooth/bluetooth_adapter_unittest.cc",
25     "bluetooth/bluetooth_adapter_win_unittest.cc",
26     "bluetooth/bluetooth_advertisement_unittest.cc",
27     "bluetooth/bluetooth_device_unittest.cc",
28     "bluetooth/bluetooth_device_win_unittest.cc",
29     "bluetooth/bluetooth_discovery_filter_unittest.cc",
30     "bluetooth/bluetooth_local_gatt_characteristic_unittest.cc",
31     "bluetooth/bluetooth_local_gatt_descriptor_unittest.cc",
32     "bluetooth/bluetooth_local_gatt_service_unittest.cc",
33     "bluetooth/bluetooth_low_energy_win_unittest.cc",
34     "bluetooth/bluetooth_remote_gatt_characteristic_unittest.cc",
35     "bluetooth/bluetooth_remote_gatt_descriptor_unittest.cc",
36     "bluetooth/bluetooth_remote_gatt_service_unittest.cc",
37     "bluetooth/bluetooth_service_record_win_unittest.cc",
38     "bluetooth/bluetooth_task_manager_win_unittest.cc",
39     "bluetooth/bluetooth_uuid_unittest.cc",
40     "bluetooth/device_unittest.cc",
41     "bluetooth/string_util_icu_unittest.cc",
42     "bluetooth/test/bluetooth_gatt_server_test.cc",
43     "bluetooth/test/bluetooth_gatt_server_test.h",
44     "bluetooth/test/bluetooth_test.cc",
45     "bluetooth/test/bluetooth_test.h",
46     "bluetooth/test/bluetooth_test_android.cc",
47     "bluetooth/test/bluetooth_test_android.h",
48     "bluetooth/test/bluetooth_test_mac.h",
49     "bluetooth/test/bluetooth_test_mac.mm",
50     "bluetooth/test/bluetooth_test_win.cc",
51     "bluetooth/test/bluetooth_test_win.h",
52     "bluetooth/test/mock_bluetooth_cbcharacteristic_mac.h",
53     "bluetooth/test/mock_bluetooth_cbcharacteristic_mac.mm",
54     "bluetooth/test/mock_bluetooth_cbdescriptor_mac.h",
55     "bluetooth/test/mock_bluetooth_cbdescriptor_mac.mm",
56     "bluetooth/test/mock_bluetooth_cbperipheral_mac.h",
57     "bluetooth/test/mock_bluetooth_cbperipheral_mac.mm",
58     "bluetooth/test/mock_bluetooth_cbservice_mac.h",
59     "bluetooth/test/mock_bluetooth_cbservice_mac.mm",
60     "bluetooth/test/mock_bluetooth_central_manager_mac.h",
61     "bluetooth/test/mock_bluetooth_central_manager_mac.mm",
62     "bluetooth/test/test_bluetooth_adapter_observer.cc",
63     "bluetooth/test/test_bluetooth_adapter_observer.h",
64     "bluetooth/test/test_bluetooth_local_gatt_service_delegate.cc",
65     "bluetooth/test/test_bluetooth_local_gatt_service_delegate.h",
66     "bluetooth/uribeacon/uri_encoder_unittest.cc",
67     "fido/ctap_request_unittest.cc",
68     "fido/ctap_response_unittest.cc",
69     "fido/fake_fido_discovery_unittest.cc",
70     "fido/fido_ble_connection_unittest.cc",
71     "fido/fido_ble_device_unittest.cc",
72     "fido/fido_ble_frames_unittest.cc",
73     "fido/fido_cable_device_unittest.cc",
74     "fido/fido_cable_discovery_unittest.cc",
75     "fido/fido_cable_handshake_handler_unittest.cc",
76     "fido/fido_discovery_unittest.cc",
77     "fido/fido_hid_message_unittest.cc",
78     "fido/fido_parsing_utils_unittest.cc",
79     "fido/fido_request_handler_unittest.cc",
80     "fido/get_assertion_handler_unittest.cc",
81     "fido/get_assertion_task_unittest.cc",
82     "fido/mac/browsing_data_deletion_unittest.mm",
83     "fido/mac/credential_metadata_unittest.cc",
84     "fido/mac/get_assertion_operation_unittest_mac.mm",
85     "fido/mac/make_credential_operation_unittest_mac.mm",
86     "fido/mac/util_unittest.cc",
87     "fido/make_credential_handler_unittest.cc",
88     "fido/make_credential_task_unittest.cc",
89     "fido/test_callback_receiver_unittest.cc",
90     "fido/u2f_command_constructor_unittest.cc",
91     "fido/u2f_register_operation_unittest.cc",
92     "fido/u2f_sign_operation_unittest.cc",
93     "gamepad/abstract_haptic_gamepad_unittest.cc",
94     "gamepad/gamepad_provider_unittest.cc",
95     "gamepad/gamepad_service_unittest.cc",
96     "gamepad/public/mojom/gamepad_mojom_traits_unittest.cc",
97     "test/run_all_unittests.cc",
98   ]
99
100   deps = [
101     "//base/test:test_support",
102     "//base/third_party/dynamic_annotations:dynamic_annotations",
103     "//components/apdu",
104     "//components/cbor",
105     "//device/base/synchronization",
106     "//device/bluetooth",
107     "//device/bluetooth:deprecated_experimental_mojo",
108     "//device/bluetooth:mocks",
109     "//device/bluetooth/uribeacon",
110     "//device/fido",
111     "//device/fido:mocks",
112     "//device/fido:test_support",
113     "//device/gamepad",
114     "//device/gamepad:test_helpers",
115     "//device/gamepad/public/cpp:shared_with_blink",
116     "//device/gamepad/public/mojom",
117     "//device/gamepad/public/mojom:gamepad_mojom_traits_test",
118     "//mojo/core/embedder",
119     "//mojo/public/cpp/bindings",
120     "//net",
121     "//testing/gmock",
122     "//testing/gtest",
123     "//third_party/blink/public:blink_headers",
124     "//tools/usb_gadget",
125     "//url",
126   ]
127
128   # U2F and Serial:
129   # Android doesn't compile.
130   # Linux, requires udev.
131   if (!is_linux_without_udev && !is_android) {
132     sources += [
133       "fido/fido_hid_device_unittest.cc",
134       "fido/fido_hid_discovery_unittest.cc",
135     ]
136     deps += [
137       "//device/fido:test_support",
138       "//services/device/public/cpp/hid",
139       "//services/device/public/mojom",
140       "//services/service_manager/public/cpp",
141       "//services/service_manager/public/mojom",
142     ]
143
144     # Serial is supported in below platforms. See //device/servial/BUILD.gn
145     if (is_win || is_linux || is_mac) {
146       sources += [ "serial/serial_device_enumerator_unittest.cc" ]
147       deps += [ "//device/serial" ]
148       if (is_linux || is_mac) {
149         sources += [ "serial/serial_io_handler_posix_unittest.cc" ]
150       }
151     }
152   }
153
154   if (use_udev) {
155     sources += [ "udev_linux/udev_unittest.cc" ]
156     deps += [ "//device/udev_linux" ]
157   }
158
159   # USB does not compile on iOS.
160   if (!is_ios) {
161     sources += [
162       "test/test_device_client.cc",
163       "test/test_device_client.h",
164       "usb/mojo/device_impl_unittest.cc",
165       "usb/mojo/device_manager_impl_unittest.cc",
166       "usb/mojo/mock_permission_provider.cc",
167       "usb/mojo/mock_permission_provider.h",
168       "usb/public/cpp/filter_utils_unittest.cc",
169       "usb/usb_descriptors_unittest.cc",
170       "usb/usb_device_handle_unittest.cc",
171       "usb/usb_service_unittest.cc",
172       "usb/webusb_descriptors_unittest.cc",
173     ]
174     deps += [
175       ":usb_test_gadget",
176       "//device/base",
177       "//device/base:mocks",
178       "//device/usb",
179       "//device/usb:test_support",
180       "//device/usb/mojo",
181       "//device/usb/public/cpp",
182       "//device/usb/public/mojom",
183       "//net:test_support",
184     ]
185
186     if (!is_android) {
187       sources += [ "usb/usb_ids_unittest.cc" ]
188     }
189   }
190
191   # UsbContext is a libusb-specific object.
192   if (is_mac || is_win) {
193     sources += [ "usb/usb_context_unittest.cc" ]
194     deps += [ "//third_party/libusb" ]
195   }
196
197   if (is_android) {
198     deps += [
199       ":bluetooth_test_java",
200       ":bluetooth_test_jni_headers",
201       "//device/usb:java",
202     ]
203   }
204
205   if (is_chromeos) {
206     deps += [
207       "//chromeos",
208       "//chromeos:test_support",
209       "//chromeos:test_support_without_gmock",
210     ]
211   }
212
213   if ((is_chromeos || is_linux) && use_dbus) {
214     configs += [ "//build/config/linux/dbus" ]
215
216     sources += [
217       "bluetooth/bluez/bluetooth_adapter_profile_bluez_unittest.cc",
218       "bluetooth/bluez/bluetooth_advertisement_bluez_unittest.cc",
219       "bluetooth/bluez/bluetooth_bluez_unittest.cc",
220       "bluetooth/bluez/bluetooth_gatt_bluez_unittest.cc",
221       "bluetooth/bluez/bluetooth_service_attribute_value_bluez_unittest.cc",
222       "bluetooth/bluez/bluetooth_service_record_bluez_unittest.cc",
223       "bluetooth/bluez/bluetooth_socket_bluez_unittest.cc",
224       "bluetooth/dbus/bluetooth_gatt_application_service_provider_unittest.cc",
225       "bluetooth/test/bluetooth_test_bluez.cc",
226       "bluetooth/test/bluetooth_test_bluez.h",
227     ]
228
229     deps += [ "//dbus" ]
230   }
231
232   if (is_linux) {
233     if (is_chromecast) {
234       # Cast does not support GATT server mode.
235       sources -= [
236         "bluetooth/bluetooth_local_gatt_characteristic_unittest.cc",
237         "bluetooth/bluetooth_local_gatt_descriptor_unittest.cc",
238         "bluetooth/bluetooth_local_gatt_service_unittest.cc",
239       ]
240
241       sources += [
242         "bluetooth/cast/bluetooth_adapter_cast_unittest.cc",
243         "bluetooth/cast/bluetooth_utils_unittest.cc",
244         "bluetooth/test/bluetooth_test_cast.cc",
245         "bluetooth/test/bluetooth_test_cast.h",
246       ]
247
248       deps += [
249         "//chromecast/device/bluetooth:util",
250         "//chromecast/device/bluetooth/le",
251         "//chromecast/device/bluetooth/le:test_support",
252         "//chromecast/device/bluetooth/shlib:mock_shlib",
253       ]
254     } else {
255       # BLE discovery: works on Linux.
256       sources += [ "fido/fido_ble_discovery_unittest.cc" ]
257     }
258   }
259
260   if (is_mac) {
261     deps += [ "//third_party/ocmock" ]
262     ldflags = [ "-ObjC" ]
263     libs = [
264       "IOBluetooth.framework",
265       "IOKit.framework",
266     ]
267
268     # In the OSX 10.10 SDK, CoreBluetooth became a top level framework.
269     # Previously, it was nested in IOBluetooth. In order for Chrome to run on
270     # OSes older than OSX 10.10, the top level CoreBluetooth framework must be
271     # weakly linked.
272     if (mac_sdk_version == "10.10") {
273       ldflags += [
274         "-weak_framework",
275         "CoreBluetooth",
276       ]
277     }
278   }
279
280   if (is_win) {
281     sources += [
282       "bluetooth/bluetooth_classic_win_fake.cc",
283       "bluetooth/bluetooth_classic_win_fake.h",
284       "bluetooth/bluetooth_low_energy_win_fake.cc",
285       "bluetooth/bluetooth_low_energy_win_fake.h",
286       "bluetooth/test/fake_bluetooth_adapter_winrt.cc",
287       "bluetooth/test/fake_bluetooth_adapter_winrt.h",
288       "bluetooth/test/fake_bluetooth_le_advertisement_received_event_args_winrt.cc",
289       "bluetooth/test/fake_bluetooth_le_advertisement_received_event_args_winrt.h",
290       "bluetooth/test/fake_bluetooth_le_advertisement_watcher_winrt.cc",
291       "bluetooth/test/fake_bluetooth_le_advertisement_watcher_winrt.h",
292       "bluetooth/test/fake_bluetooth_le_advertisement_winrt.cc",
293       "bluetooth/test/fake_bluetooth_le_advertisement_winrt.h",
294       "bluetooth/test/fake_bluetooth_le_device_winrt.cc",
295       "bluetooth/test/fake_bluetooth_le_device_winrt.h",
296       "bluetooth/test/fake_device_information_winrt.cc",
297       "bluetooth/test/fake_device_information_winrt.h",
298       "bluetooth/test/fake_gatt_characteristic_winrt.cc",
299       "bluetooth/test/fake_gatt_characteristic_winrt.h",
300       "bluetooth/test/fake_gatt_characteristics_result_winrt.cc",
301       "bluetooth/test/fake_gatt_characteristics_result_winrt.h",
302       "bluetooth/test/fake_gatt_device_service_winrt.cc",
303       "bluetooth/test/fake_gatt_device_service_winrt.h",
304       "bluetooth/test/fake_gatt_device_services_result_winrt.cc",
305       "bluetooth/test/fake_gatt_device_services_result_winrt.h",
306       "bluetooth/test/fake_radio_winrt.cc",
307       "bluetooth/test/fake_radio_winrt.h",
308     ]
309   }
310
311   if (enable_vr) {
312     sources += [
313       "vr/orientation/orientation_device_provider_unittest.cc",
314       "vr/orientation/orientation_device_unittest.cc",
315       "vr/vr_device_base_unittest.cc",
316       "vr/vr_display_impl_unittest.cc",
317     ]
318
319     if (is_android) {
320       deps += [ "//device/vr:java" ]
321     }
322
323     defines = [ "DEVICE_VR_IMPLEMENTATION" ]
324
325     deps += [
326       "//device/vr",
327       "//device/vr:fakes",
328       "//device/vr/public/mojom",
329       "//services/device/public/cpp/generic_sensor",
330       "//ui/display",
331       "//ui/display:test_support",
332     ]
333   }
334 }
335
336 source_set("usb_test_gadget") {
337   testonly = true
338
339   sources = [
340     "test/usb_test_gadget.h",
341     "test/usb_test_gadget_impl.cc",
342   ]
343
344   deps = [
345     "//device/base",
346     "//device/usb",
347     "//net:test_support",
348   ]
349 }
350
351 if (is_android) {
352   bluetooth_java_sources_needing_jni = [
353     "bluetooth/test/android/java/src/org/chromium/device/bluetooth/Fakes.java",
354   ]
355
356   generate_jni("bluetooth_test_jni_headers") {
357     sources = bluetooth_java_sources_needing_jni
358     jni_package = "bluetooth"
359   }
360
361   android_library("bluetooth_test_java") {
362     testonly = true
363     java_files = bluetooth_java_sources_needing_jni
364     deps = [
365       "//base:base_java",
366       "//components/location/android:location_java",
367       "//device/bluetooth:java",
368       "//third_party/android_tools:android_support_annotations_java",
369       "//third_party/android_tools:android_test_mock_java",
370     ]
371
372     srcjar_deps = [ ":bluetooth_test_javagen" ]
373   }
374
375   junit_binary("device_junit_tests") {
376     java_files = [ "gamepad/android/junit/src/org/chromium/device/gamepad/GamepadMappingsTest.java" ]
377     deps = [
378       "$google_play_services_package:google_play_services_base_java",
379       "$google_play_services_package:google_play_services_basement_java",
380       "$google_play_services_package:google_play_services_location_java",
381       "//base:base_java",
382       "//base:base_java_test_support",
383       "//base:base_junit_test_support",
384       "//device/gamepad:java",
385       "//mojo/public/java:bindings_java",
386       "//third_party/android_tools:android_support_annotations_java",
387     ]
388     srcjar_deps = [ "//device/gamepad:java_enums_srcjar" ]
389   }
390
391   java_cpp_enum("bluetooth_test_javagen") {
392     sources = [
393       "bluetooth/test/bluetooth_test.h",
394     ]
395   }
396 }