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 "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 // Simulates a Characteristic Write operation failing synchronously once for | 174 // Simulates a Characteristic Write operation failing synchronously once for |
175 // an unknown reason. | 175 // an unknown reason. |
176 virtual void SimulateGattCharacteristicWriteWillFailSynchronouslyOnce( | 176 virtual void SimulateGattCharacteristicWriteWillFailSynchronouslyOnce( |
177 BluetoothGattCharacteristic* characteristic) {} | 177 BluetoothGattCharacteristic* characteristic) {} |
178 | 178 |
179 // Simulates a Descriptor on a service. | 179 // Simulates a Descriptor on a service. |
180 virtual void SimulateGattDescriptor( | 180 virtual void SimulateGattDescriptor( |
181 BluetoothGattCharacteristic* characteristic, | 181 BluetoothGattCharacteristic* characteristic, |
182 const std::string& uuid) {} | 182 const std::string& uuid) {} |
183 | 183 |
| 184 // Remembers |descriptor|'s platform specific object to be used in a |
| 185 // subsequent call to methods such as SimulateGattDescriptorRead that |
| 186 // accept a nullptr value to select this remembered descriptor. This |
| 187 // enables tests where the platform attempts to reference descriptor |
| 188 // objects after the Chrome objects have been deleted, e.g. with DeleteDevice. |
| 189 virtual void RememberDescriptorForSubsequentAction( |
| 190 BluetoothGattDescriptor* descriptor) {} |
| 191 |
| 192 // Simulates a Descriptor Read operation succeeding, returning |value|. |
| 193 // If |descriptor| is null, acts upon the descriptor provided to |
| 194 // RememberDescriptorForSubsequentAction. |
| 195 virtual void SimulateGattDescriptorRead(BluetoothGattDescriptor* descriptor, |
| 196 const std::vector<uint8_t>& value) {} |
| 197 |
| 198 // Simulates a Descriptor Read operation failing with a GattErrorCode. |
| 199 virtual void SimulateGattDescriptorReadError( |
| 200 BluetoothGattDescriptor* descriptor, |
| 201 BluetoothGattService::GattErrorCode) {} |
| 202 |
| 203 // Simulates a Descriptor Read operation failing synchronously once for an |
| 204 // unknown reason. |
| 205 virtual void SimulateGattDescriptorReadWillFailSynchronouslyOnce( |
| 206 BluetoothGattDescriptor* descriptor) {} |
| 207 |
| 208 // Simulates a Descriptor Write operation succeeding, returning |value|. |
| 209 // If |descriptor| is null, acts upon the descriptor provided to |
| 210 // RememberDescriptorForSubsequentAction. |
| 211 virtual void SimulateGattDescriptorWrite( |
| 212 BluetoothGattDescriptor* descriptor) {} |
| 213 |
| 214 // Simulates a Descriptor Write operation failing with a GattErrorCode. |
| 215 virtual void SimulateGattDescriptorWriteError( |
| 216 BluetoothGattDescriptor* descriptor, |
| 217 BluetoothGattService::GattErrorCode) {} |
| 218 |
184 // Simulates a Descriptor Write operation failing synchronously once for | 219 // Simulates a Descriptor Write operation failing synchronously once for |
185 // an unknown reason. | 220 // an unknown reason. |
186 virtual void SimulateGattDescriptorWriteWillFailSynchronouslyOnce( | 221 virtual void SimulateGattDescriptorWriteWillFailSynchronouslyOnce( |
187 BluetoothGattDescriptor* descriptor) {} | 222 BluetoothGattDescriptor* descriptor) {} |
188 | 223 |
189 // Removes the device from the adapter and deletes it. | 224 // Removes the device from the adapter and deletes it. |
190 virtual void DeleteDevice(BluetoothDevice* device); | 225 virtual void DeleteDevice(BluetoothDevice* device); |
191 | 226 |
192 // Callbacks that increment |callback_count_|, |error_callback_count_|: | 227 // Callbacks that increment |callback_count_|, |error_callback_count_|: |
193 void Callback(Call expected); | 228 void Callback(Call expected); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 BluetoothGattService::GattErrorCode last_gatt_error_code_; | 270 BluetoothGattService::GattErrorCode last_gatt_error_code_; |
236 | 271 |
237 int callback_count_ = 0; | 272 int callback_count_ = 0; |
238 int error_callback_count_ = 0; | 273 int error_callback_count_ = 0; |
239 int gatt_connection_attempts_ = 0; | 274 int gatt_connection_attempts_ = 0; |
240 int gatt_disconnection_attempts_ = 0; | 275 int gatt_disconnection_attempts_ = 0; |
241 int gatt_discovery_attempts_ = 0; | 276 int gatt_discovery_attempts_ = 0; |
242 int gatt_notify_characteristic_attempts_ = 0; | 277 int gatt_notify_characteristic_attempts_ = 0; |
243 int gatt_read_characteristic_attempts_ = 0; | 278 int gatt_read_characteristic_attempts_ = 0; |
244 int gatt_write_characteristic_attempts_ = 0; | 279 int gatt_write_characteristic_attempts_ = 0; |
| 280 int gatt_read_descriptor_attempts_ = 0; |
245 int gatt_write_descriptor_attempts_ = 0; | 281 int gatt_write_descriptor_attempts_ = 0; |
246 | 282 |
247 // The following values are used to make sure the correct callbacks | 283 // The following values are used to make sure the correct callbacks |
248 // have been called. They are not reset when calling ResetEventCounts(). | 284 // have been called. They are not reset when calling ResetEventCounts(). |
249 int expected_success_callback_calls_ = 0; | 285 int expected_success_callback_calls_ = 0; |
250 int expected_error_callback_calls_ = 0; | 286 int expected_error_callback_calls_ = 0; |
251 int actual_success_callback_calls_ = 0; | 287 int actual_success_callback_calls_ = 0; |
252 int actual_error_callback_calls_ = 0; | 288 int actual_error_callback_calls_ = 0; |
253 bool unexpected_success_callback_ = false; | 289 bool unexpected_success_callback_ = false; |
254 bool unexpected_error_callback_ = false; | 290 bool unexpected_error_callback_ = false; |
255 | 291 |
256 base::WeakPtrFactory<BluetoothTestBase> weak_factory_; | 292 base::WeakPtrFactory<BluetoothTestBase> weak_factory_; |
257 }; | 293 }; |
258 | 294 |
259 } // namespace device | 295 } // namespace device |
260 | 296 |
261 #endif // DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_H_ | 297 #endif // DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_H_ |
OLD | NEW |