| OLD | NEW |
| 1 # Bluetooth | 1 # Testing |
| 2 | 2 |
| 3 `device/bluetooth` abstracts | |
| 4 [Bluetooth Classic](https://en.wikipedia.org/wiki/Bluetooth) and | |
| 5 [Low Energy](https://en.wikipedia.org/wiki/Bluetooth_low_energy) features | |
| 6 across multiple platforms. | |
| 7 | |
| 8 Classic and Low Energy based profiles differ substantially. Platform | |
| 9 implementations may support only one or the other, even though several classes | |
| 10 have interfaces for both, e.g. `BluetoothAdapter` & `BluetoothDevice`. | |
| 11 | |
| 12 | | Classic | Low Energy | | |
| 13 |-----------|:-------:|:-----------:| | |
| 14 | Android | no | yes | | |
| 15 | Chrome OS | yes | yes | | |
| 16 | Linux | yes | yes | | |
| 17 | Mac | yes | yes | | |
| 18 | Windows | some | nearly | | |
| 19 | |
| 20 Chrome OS and Linux are supported via BlueZ, see `*_bluez` files. | |
| 21 | |
| 22 [Mojo](https://www.chromium.org/developers/design-documents/mojo) | |
| 23 interfaces in [public/interfaces](public/interfaces) have been started | |
| 24 but are *not* ready for production use. | |
| 25 | |
| 26 | |
| 27 ## Maintainer History | |
| 28 | |
| 29 Initial implementation OWNERS were youngki@chromium.org, keybuk@chromium.org, | |
| 30 armansito@chromium.org, and rpaquay@chromium.org. They no longer contribute to | |
| 31 chromium fulltime. They were responsible for support for Chrome OS Bluetooth | |
| 32 features and the Chrome Apps APIs: | |
| 33 | |
| 34 * [chrome.bluetooth](https://developer.chrome.com/apps/bluetooth) | |
| 35 * [chrome.bluetoothLowEnergy](https://developer.chrome.com/apps/bluetoothLowEner
gy) | |
| 36 * [chrome.bluetoothSocket](https://developer.chrome.com/apps/bluetoothSocket) | |
| 37 | |
| 38 Active development in 2015 & 2016 is focused on enabling GATT features for: | |
| 39 | |
| 40 * [Web Bluetooth](https://crbug.com/419413) | |
| 41 * Peripheral mode for Chrome OS. | |
| 42 | |
| 43 Known future work is tracked in the | |
| 44 [Refactoring meta issue](https://crbug.com/580406). | |
| 45 | |
| 46 | |
| 47 ## Testing | |
| 48 | |
| 49 Implementation of the Bluetooth component is tested via unittests. Client code | 3 Implementation of the Bluetooth component is tested via unittests. Client code |
| 50 uses Mock Bluetooth objects: | 4 uses Mock Bluetooth objects: |
| 51 | 5 |
| 6 ## Mojo Testing Interface Implementation |
| 7 See [//public/interfaces/test/README.md](//device/bluetooth/public/interfaces/te
st/README.md) |
| 8 for details about the interface. The current implementation of this interface |
| 9 creates a fake implementation of the current non-mojo C++ Bluetooth interface. |
| 10 This interface is implemented across files with a "fake_" prefix. |
| 11 *This interface may be removed when a Bluetooth Mojo Service is introduced, if |
| 12 Web Bluetooth remains its only client. Testing code would implement the service |
| 13 as needed for tests.* |
| 52 | 14 |
| 53 ### Cross Platform Unit Tests | 15 ## Cross Platform Unit Tests |
| 54 | 16 |
| 55 New feature development uses cross platform unit tests. This reduces test code | 17 New feature development uses cross platform unit tests. This reduces test code |
| 56 redundancy and produces consistency across all implementations. | 18 redundancy and produces consistency across all implementations. |
| 57 | 19 |
| 58 Unit tests operate at the public `device/bluetooth` API layer and the | 20 Unit tests operate at the public `device/bluetooth` API layer and the |
| 59 `BluetoothTest` fixture controls fake operating system behavior as close to the | 21 `BluetoothTest` fixture controls fake operating system behavior as close to the |
| 60 platfom as possible. The resulting test coverage spans the cross platform API, | 22 platfom as possible. The resulting test coverage spans the cross platform API, |
| 61 common implementation, and platform specific implementation as close to | 23 common implementation, and platform specific implementation as close to |
| 62 operating system APIs as possible. | 24 operating system APIs as possible. |
| 63 | 25 |
| 64 `test/bluetooth_test.h` defines the cross platform test fixture | 26 `test/bluetooth_test.h` defines the cross platform test fixture |
| 65 `BluetoothTestBase`. Platform implementations provide subclasses, such as | 27 `BluetoothTestBase`. Platform implementations provide subclasses, such as |
| 66 `test/bluetooth_test_android.h` and typedef to the name `BluetoothTest`. | 28 `test/bluetooth_test_android.h` and typedef to the name `BluetoothTest`. |
| 67 | 29 |
| 68 [More testing information](https://docs.google.com/document/d/1mBipxn1sJu6jMqP0R
QZpkYXC1o601bzLCpCxwTA2yGA/edit?usp=sharing) | 30 [More testing information](https://docs.google.com/document/d/1mBipxn1sJu6jMqP0R
QZpkYXC1o601bzLCpCxwTA2yGA/edit?usp=sharing) |
| 69 | 31 |
| 70 ### Legacy Platform Specific Unit Tests | 32 ## Legacy Platform Specific Unit Tests |
| 71 | 33 |
| 72 Early code (Classic on most platforms, and Low Energy on BlueZ) was tested with | 34 Early code (Classic on most platforms, and Low Energy on BlueZ) was tested with |
| 73 platform specific unit tests, e.g. `bluetooth_bluez_unittest.cc` & | 35 platform specific unit tests, e.g. `bluetooth_bluez_unittest.cc` & |
| 74 `bluetooth_adapter_win_unittest.cc`. The BlueZ style has platform specific | 36 `bluetooth_adapter_win_unittest.cc`. The BlueZ style has platform specific |
| 75 methods to create fake devices and the public API is used to interact with them. | 37 methods to create fake devices and the public API is used to interact with them. |
| 76 | 38 |
| 77 Maintenance of these earlier implementation featuress should update tests in | 39 Maintenance of these earlier implementation featuress should update tests in |
| 78 place. Long term these tests should be [refactored into cross platform | 40 place. Long term these tests should be [refactored into cross platform |
| 79 tests](https://crbug.com/580403). | 41 tests](https://crbug.com/580403). |
| 80 | 42 |
| 81 | 43 |
| 82 ### Mock Bluetooth Objects | 44 ## Mock Bluetooth Objects |
| 83 | 45 |
| 84 `test/mock_bluetooth_*` files provide GoogleMock based fake objects for use in | 46 `test/mock_bluetooth_*` files provide GoogleMock based fake objects for use in |
| 85 client code. | 47 client code. |
| 86 | 48 |
| 87 | 49 |
| 88 ### Chrome OS Blueooth Controller Tests | 50 ## Chrome OS Blueooth Controller Tests |
| 89 | 51 |
| 90 Bluetooth controller system tests generating radio signals are run and managed | 52 Bluetooth controller system tests generating radio signals are run and managed |
| 91 by the Chrome OS team. See: | 53 by the Chrome OS team. See: |
| 92 https://chromium.googlesource.com/chromiumos/third_party/autotest/+/master/serve
r/site_tests/ | 54 https://chromium.googlesource.com/chromiumos/third_party/autotest/+/master/serve
r/site_tests/ |
| 93 https://chromium.googlesource.com/chromiumos/third_party/autotest/+/master/serve
r/cros/bluetooth/ | 55 https://chromium.googlesource.com/chromiumos/third_party/autotest/+/master/serve
r/cros/bluetooth/ |
| 94 https://chromium.googlesource.com/chromiumos/third_party/autotest/+/master/clien
t/cros/bluetooth/ | 56 https://chromium.googlesource.com/chromiumos/third_party/autotest/+/master/clien
t/cros/bluetooth/ |
| 95 | 57 |
| 96 | 58 |
| 97 ## Android | 59 # Android |
| 98 | 60 |
| 99 The android implementation requires crossing from C++ to Java using | 61 The android implementation requires crossing from C++ to Java using |
| 100 [__JNI__](https://www.chromium.org/developers/design-documents/android-jni). | 62 [__JNI__](https://www.chromium.org/developers/design-documents/android-jni). |
| 101 | 63 |
| 102 Object ownership is rooted in the C++ classes, starting with the Adapter, which | 64 Object ownership is rooted in the C++ classes, starting with the Adapter, which |
| 103 owns Devices, Services, etc. Java counter parts interface with the Android | 65 owns Devices, Services, etc. Java counter parts interface with the Android |
| 104 Bluetooth objects. E.g. | 66 Bluetooth objects. E.g. |
| 105 | 67 |
| 106 For testing, the Android objects are __wrapped__ in: | 68 For testing, the Android objects are __wrapped__ in: |
| 107 `android/java/src/org/chromium/device/bluetooth/Wrappers.java`. <br> | 69 `android/java/src/org/chromium/device/bluetooth/Wrappers.java`. <br> |
| (...skipping 14 matching lines...) Expand all Loading... |
| 122 * `android/.../ChromeBluetoothService.java` uses: | 84 * `android/.../ChromeBluetoothService.java` uses: |
| 123 * `android/.../Wrappers.java`: `BluetoothServiceWrapper` | 85 * `android/.../Wrappers.java`: `BluetoothServiceWrapper` |
| 124 * Which under test is a `FakeBluetoothService` | 86 * Which under test is a `FakeBluetoothService` |
| 125 * ... and so on for characteristics and descriptors. | 87 * ... and so on for characteristics and descriptors. |
| 126 | 88 |
| 127 Fake objects are controlled by `bluetooth_test_android.cc`. | 89 Fake objects are controlled by `bluetooth_test_android.cc`. |
| 128 | 90 |
| 129 See also: [Class Diagram of Web Bluetooth through Bluetooth Android][Class] | 91 See also: [Class Diagram of Web Bluetooth through Bluetooth Android][Class] |
| 130 | 92 |
| 131 [Class]: https://sites.google.com/a/chromium.org/dev/developers/design-documents
/bluetooth-design-docs/web-bluetooth-through-bluetooth-android-class-diagram | 93 [Class]: https://sites.google.com/a/chromium.org/dev/developers/design-documents
/bluetooth-design-docs/web-bluetooth-through-bluetooth-android-class-diagram |
| 132 | |
| 133 | |
| 134 ## Design Documents | |
| 135 | |
| 136 * [Bluetooth Notifications](https://docs.google.com/document/d/1guBtAnQUP8ZoZre4
VQGrjR5uX0ZYxfK-lwKNeqY0-z4/edit?usp=sharing) 2016-08-26 | |
| 137 * Web Bluetooth through Android implementation details, class diagram and | |
| 138 call flow. | |
| OLD | NEW |