| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_H_ | 5 #ifndef DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_H_ |
| 6 #define DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_H_ | 6 #define DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 static const std::string kTestAdapterName; | 44 static const std::string kTestAdapterName; |
| 45 static const std::string kTestAdapterAddress; | 45 static const std::string kTestAdapterAddress; |
| 46 | 46 |
| 47 static const std::string kTestDeviceName; | 47 static const std::string kTestDeviceName; |
| 48 static const std::string kTestDeviceNameEmpty; | 48 static const std::string kTestDeviceNameEmpty; |
| 49 | 49 |
| 50 static const std::string kTestDeviceAddress1; | 50 static const std::string kTestDeviceAddress1; |
| 51 static const std::string kTestDeviceAddress2; | 51 static const std::string kTestDeviceAddress2; |
| 52 static const std::string kTestDeviceAddress3; | 52 static const std::string kTestDeviceAddress3; |
| 53 | 53 |
| 54 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.device.bluetooth.test |
| 55 enum class TestRSSI { |
| 56 LOWEST = -81, |
| 57 LOWER = -61, |
| 58 LOW = -41, |
| 59 MEDIUM = -21, |
| 60 HIGH = -1, |
| 61 }; |
| 62 |
| 63 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.device.bluetooth.test |
| 64 enum class TestTxPower { |
| 65 LOWEST = -40, |
| 66 LOWER = -20, |
| 67 }; |
| 68 |
| 54 static const std::string kTestUUIDGenericAccess; | 69 static const std::string kTestUUIDGenericAccess; |
| 55 static const std::string kTestUUIDGenericAttribute; | 70 static const std::string kTestUUIDGenericAttribute; |
| 56 static const std::string kTestUUIDImmediateAlert; | 71 static const std::string kTestUUIDImmediateAlert; |
| 57 static const std::string kTestUUIDLinkLoss; | 72 static const std::string kTestUUIDLinkLoss; |
| 58 static const std::string kTestUUIDHeartRate; | 73 static const std::string kTestUUIDHeartRate; |
| 59 | 74 |
| 60 BluetoothTestBase(); | 75 BluetoothTestBase(); |
| 61 ~BluetoothTestBase() override; | 76 ~BluetoothTestBase() override; |
| 62 | 77 |
| 63 // Checks that no unexpected calls have been made to callbacks. | 78 // Checks that no unexpected calls have been made to callbacks. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 88 // Initializes the BluetoothAdapter |adapter_| with a fake adapter that can be | 103 // Initializes the BluetoothAdapter |adapter_| with a fake adapter that can be |
| 89 // controlled by this test fixture. | 104 // controlled by this test fixture. |
| 90 virtual void InitWithFakeAdapter() {} | 105 virtual void InitWithFakeAdapter() {} |
| 91 | 106 |
| 92 // Configures the fake adapter to lack the necessary permissions to scan for | 107 // Configures the fake adapter to lack the necessary permissions to scan for |
| 93 // devices. Returns false if the current platform always has permission. | 108 // devices. Returns false if the current platform always has permission. |
| 94 virtual bool DenyPermission(); | 109 virtual bool DenyPermission(); |
| 95 | 110 |
| 96 // Create a fake Low Energy device and discover it. | 111 // Create a fake Low Energy device and discover it. |
| 97 // |device_ordinal| selects between multiple fake device data sets to produce: | 112 // |device_ordinal| selects between multiple fake device data sets to produce: |
| 98 // 1: kTestDeviceName with advertised UUIDs kTestUUIDGenericAccess, | 113 // 1: Name: kTestDeviceName |
| 99 // kTestUUIDGenericAttribute, address kTestDeviceAddress1 and service | 114 // Address: kTestDeviceAddress1 |
| 100 // data of {kTestUUIDHeartRate: [1]}. | 115 // RSSI: kTestRSSI1 |
| 101 // 2: kTestDeviceName with advertised UUIDs kTestUUIDImmediateAlert, | 116 // Advertised UUIDs: {kTestUUIDGenericAccess, kTestUUIDGenericAttribute} |
| 102 // kTestUUIDLinkLoss, address kTestDeviceAddress1 and service data of | 117 // Service Data: {kTestUUIDHeartRate: [1]} |
| 103 // {kTestUUIDHeartRate: [2], kTestUUIDImmediateAlert: [0]}. | 118 // Tx Power: kTestTxPower1 |
| 104 // 3: kTestDeviceNameEmpty with no advertised UUIDs and address | 119 // 2: Name: kTestDeviceName |
| 105 // kTestDeviceAddress1. | 120 // Address: kTestDeviceAddress1 |
| 106 // 4: kTestDeviceNameEmpty with no advertised UUIDs and address | 121 // RSSI: kTestRSSI2 |
| 107 // kTestDeviceAddress2. | 122 // Advertised UUIDs: {kTestUUIDImmediateAlert, kTestUUIDLinkLoss} |
| 108 // 5: Device with no name, with no advertised UUIDs and address | 123 // Service Data: {kTestUUIDHeartRate: [2], |
| 109 // kTestDeviceAddress1. | 124 // kTestUUIDImmediateAlert: [0]} |
| 110 // 6: kTestDeviceName with no advertised UUIDs and address | 125 // Tx Power: kTestTxPower2 |
| 111 // kTestDeviceAddress2, but which also supports BR/EDR. | 126 // 3: Name: kTestDeviceNameEmpty |
| 127 // Address: kTestDeviceAddress1 |
| 128 // RSSI: kTestRSSI3 |
| 129 // No Advertised UUIDs |
| 130 // No Service Data |
| 131 // No Tx Power |
| 132 // 4: Name: kTestDeviceNameEmpty |
| 133 // Address: kTestDeviceAddress2 |
| 134 // RSSI: kTestRSSI4 |
| 135 // No Advertised UUIDs |
| 136 // No Service Data |
| 137 // No Tx Power |
| 138 // 5: No name device |
| 139 // Address: kTestDeviceAddress1 |
| 140 // RSSI: kTestRSSI5 |
| 141 // No Advertised UUIDs |
| 142 // No Service Data |
| 143 // No Tx Power |
| 144 // 6: Name: kTestDeviceName |
| 145 // Address: kTestDeviceAddress2 |
| 146 // RSSI: kTestRSSI1, |
| 147 // No Advertised UUIDs |
| 148 // No Service Data |
| 149 // No Tx Power |
| 150 // Supports BR/EDR and LE. |
| 112 virtual BluetoothDevice* SimulateLowEnergyDevice(int device_ordinal); | 151 virtual BluetoothDevice* SimulateLowEnergyDevice(int device_ordinal); |
| 113 | 152 |
| 114 // Create a fake classic device and discover it. The device will have | 153 // Create a fake classic device and discover it. The device will have |
| 115 // name kTestDeviceName, no advertised UUIDs and address kTestDeviceAddress3. | 154 // name kTestDeviceName, no advertised UUIDs and address kTestDeviceAddress3. |
| 116 virtual BluetoothDevice* SimulateClassicDevice(); | 155 virtual BluetoothDevice* SimulateClassicDevice(); |
| 117 | 156 |
| 118 // Remembers |device|'s platform specific object to be used in a | 157 // Remembers |device|'s platform specific object to be used in a |
| 119 // subsequent call to methods such as SimulateGattServicesDiscovered that | 158 // subsequent call to methods such as SimulateGattServicesDiscovered that |
| 120 // accept a nullptr value to select this remembered characteristic. This | 159 // accept a nullptr value to select this remembered characteristic. This |
| 121 // enables tests where the platform attempts to reference device | 160 // enables tests where the platform attempts to reference device |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 int actual_error_callback_calls_ = 0; | 482 int actual_error_callback_calls_ = 0; |
| 444 bool unexpected_success_callback_ = false; | 483 bool unexpected_success_callback_ = false; |
| 445 bool unexpected_error_callback_ = false; | 484 bool unexpected_error_callback_ = false; |
| 446 | 485 |
| 447 base::WeakPtrFactory<BluetoothTestBase> weak_factory_; | 486 base::WeakPtrFactory<BluetoothTestBase> weak_factory_; |
| 448 }; | 487 }; |
| 449 | 488 |
| 450 } // namespace device | 489 } // namespace device |
| 451 | 490 |
| 452 #endif // DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_H_ | 491 #endif // DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_H_ |
| OLD | NEW |