tree: 2fcc0a6c0dadb375a14a71c782cceaed33adf92e [path history] [tgz]
  1. README.md
  2. android/
  3. bluetooth_gatt_server_test.cc
  4. bluetooth_gatt_server_test.h
  5. bluetooth_test.cc
  6. bluetooth_test.h
  7. bluetooth_test_android.cc
  8. bluetooth_test_android.h
  9. bluetooth_test_bluez.cc
  10. bluetooth_test_bluez.h
  11. bluetooth_test_cast.cc
  12. bluetooth_test_cast.h
  13. bluetooth_test_fuchsia.cc
  14. bluetooth_test_fuchsia.h
  15. bluetooth_test_mac.h
  16. bluetooth_test_mac.mm
  17. bluetooth_test_win.cc
  18. bluetooth_test_win.h
  19. fake_bluetooth.cc
  20. fake_bluetooth.h
  21. fake_bluetooth_adapter_winrt.cc
  22. fake_bluetooth_adapter_winrt.h
  23. fake_bluetooth_le_advertisement_data_section_winrt.cc
  24. fake_bluetooth_le_advertisement_data_section_winrt.h
  25. fake_bluetooth_le_advertisement_publisher_status_changed_event_args_winrt.cc
  26. fake_bluetooth_le_advertisement_publisher_status_changed_event_args_winrt.h
  27. fake_bluetooth_le_advertisement_publisher_winrt.cc
  28. fake_bluetooth_le_advertisement_publisher_winrt.h
  29. fake_bluetooth_le_advertisement_received_event_args_winrt.cc
  30. fake_bluetooth_le_advertisement_received_event_args_winrt.h
  31. fake_bluetooth_le_advertisement_watcher_winrt.cc
  32. fake_bluetooth_le_advertisement_watcher_winrt.h
  33. fake_bluetooth_le_advertisement_winrt.cc
  34. fake_bluetooth_le_advertisement_winrt.h
  35. fake_bluetooth_le_device_winrt.cc
  36. fake_bluetooth_le_device_winrt.h
  37. fake_bluetooth_le_manufacturer_data_winrt.cc
  38. fake_bluetooth_le_manufacturer_data_winrt.h
  39. fake_central.cc
  40. fake_central.h
  41. fake_device_information_custom_pairing_winrt.cc
  42. fake_device_information_custom_pairing_winrt.h
  43. fake_device_information_pairing_winrt.cc
  44. fake_device_information_pairing_winrt.h
  45. fake_device_information_winrt.cc
  46. fake_device_information_winrt.h
  47. fake_device_pairing_requested_event_args_winrt.cc
  48. fake_device_pairing_requested_event_args_winrt.h
  49. fake_device_pairing_result_winrt.cc
  50. fake_device_pairing_result_winrt.h
  51. fake_device_watcher_winrt.cc
  52. fake_device_watcher_winrt.h
  53. fake_gatt_characteristic_winrt.cc
  54. fake_gatt_characteristic_winrt.h
  55. fake_gatt_characteristics_result_winrt.cc
  56. fake_gatt_characteristics_result_winrt.h
  57. fake_gatt_descriptor_winrt.cc
  58. fake_gatt_descriptor_winrt.h
  59. fake_gatt_descriptors_result_winrt.cc
  60. fake_gatt_descriptors_result_winrt.h
  61. fake_gatt_device_service_winrt.cc
  62. fake_gatt_device_service_winrt.h
  63. fake_gatt_device_services_result_winrt.cc
  64. fake_gatt_device_services_result_winrt.h
  65. fake_gatt_read_result_winrt.cc
  66. fake_gatt_read_result_winrt.h
  67. fake_gatt_value_changed_event_args_winrt.cc
  68. fake_gatt_value_changed_event_args_winrt.h
  69. fake_gatt_write_result_winrt.cc
  70. fake_gatt_write_result_winrt.h
  71. fake_peripheral.cc
  72. fake_peripheral.h
  73. fake_radio_winrt.cc
  74. fake_radio_winrt.h
  75. fake_read_response.cc
  76. fake_read_response.h
  77. fake_remote_gatt_characteristic.cc
  78. fake_remote_gatt_characteristic.h
  79. fake_remote_gatt_descriptor.cc
  80. fake_remote_gatt_descriptor.h
  81. fake_remote_gatt_service.cc
  82. fake_remote_gatt_service.h
  83. mock_bluetooth_adapter.cc
  84. mock_bluetooth_adapter.h
  85. mock_bluetooth_advertisement.cc
  86. mock_bluetooth_advertisement.h
  87. mock_bluetooth_cbcharacteristic_mac.h
  88. mock_bluetooth_cbcharacteristic_mac.mm
  89. mock_bluetooth_cbdescriptor_mac.h
  90. mock_bluetooth_cbdescriptor_mac.mm
  91. mock_bluetooth_cbperipheral_mac.h
  92. mock_bluetooth_cbperipheral_mac.mm
  93. mock_bluetooth_cbservice_mac.h
  94. mock_bluetooth_cbservice_mac.mm
  95. mock_bluetooth_central_manager_mac.h
  96. mock_bluetooth_central_manager_mac.mm
  97. mock_bluetooth_device.cc
  98. mock_bluetooth_device.h
  99. mock_bluetooth_discovery_session.cc
  100. mock_bluetooth_discovery_session.h
  101. mock_bluetooth_gatt_characteristic.cc
  102. mock_bluetooth_gatt_characteristic.h
  103. mock_bluetooth_gatt_connection.cc
  104. mock_bluetooth_gatt_connection.h
  105. mock_bluetooth_gatt_descriptor.cc
  106. mock_bluetooth_gatt_descriptor.h
  107. mock_bluetooth_gatt_notify_session.cc
  108. mock_bluetooth_gatt_notify_session.h
  109. mock_bluetooth_gatt_service.cc
  110. mock_bluetooth_gatt_service.h
  111. mock_bluetooth_socket.cc
  112. mock_bluetooth_socket.h
  113. test_bluetooth_adapter_observer.cc
  114. test_bluetooth_adapter_observer.h
  115. test_bluetooth_advertisement_observer.cc
  116. test_bluetooth_advertisement_observer.h
  117. test_bluetooth_local_gatt_service_delegate.cc
  118. test_bluetooth_local_gatt_service_delegate.h
  119. test_pairing_delegate.cc
  120. test_pairing_delegate.h
device/bluetooth/test/README.md

Bluetooth Testing

This page describes testing APIs for both clients and implementation of the Bluetooth component.

There are also notable higher level bluetooth tests:

Client Testing

Mock Bluetooth Objects

test/mock_bluetooth_* files provide GoogleMock based fake objects that subclass the cross platform C++ device/bluetooth API.

These are used by numerous clients and are stable.

Fake Bluetooth Mojo Testing Interface Implementation

WORK IN PROGRESS.

Web Platform Tests for Web Bluetooth are being refactored to use third_party/WebKit/LayoutTests/resources/bluetooth/web-bluetooth-test.js.

That library is implemented over a mojo interface fake_bluetooth.mojom in bluetooth/public/mojom/test and is implemented in the bluetooth/test/fake_* files.

The fake_bluetooth.mojom interface is not intended to be used directly. web-bluetooth-test.js makes the Fake Bluetooth interface easier to work with.

  • Calls are synchronous.
  • IDs are cached.

If another C++ client intends to use Fake Bluetooth a C++ wrapper similar to web-bluetooth-test.js should be created.

When a Bluetooth service is created the fake_bluetooth.mojom and bluetooth/test/fake_* files should be removed and the client facing test wrapper web-bluetooth-test.js converted to implement the Bluetooth service as needed for tests.

Design Doc: https://docs.google.com/document/d/1Nhv_oVDCodd1pEH_jj9k8gF4rPGb_84VYaZ9IG8M_WY

Implementation Testing

Cross Platform Unit Tests

New feature development uses cross platform unit tests. This reduces test code redundancy and produces consistency across all implementations.

Unit tests operate at the public device/bluetooth API layer and the BluetoothTest fixture controls fake operating system behavior as close to the platfom as possible. The resulting test coverage spans the cross platform API, common implementation, and platform specific implementation as close to operating system APIs as possible.

test/bluetooth_test.h defines the cross platform test fixture BluetoothTestBase. Platform implementations provide subclasses, such as test/bluetooth_test_android.h and typedef to the name BluetoothTest.

More testing information

Legacy Platform Specific Unit Tests

Early code (Classic on most platforms, and Low Energy on BlueZ) was tested with platform specific unit tests, e.g. bluetooth_bluez_unittest.cc & bluetooth_adapter_win_unittest.cc. The BlueZ style has platform specific methods to create fake devices and the public API is used to interact with them.

Maintenance of these earlier implementation featuress should update tests in place. Long term these tests should be refactored into cross platform tests.

Chrome OS Blueooth Controller Tests

Bluetooth controller system tests generating radio signals are run and managed by the Chrome OS team. See: https://chromium.googlesource.com/chromiumos/third_party/autotest/+/master/server/site_tests/ https://chromium.googlesource.com/chromiumos/third_party/autotest/+/master/server/cros/bluetooth/ https://chromium.googlesource.com/chromiumos/third_party/autotest/+/master/client/cros/bluetooth/