| 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 23 matching lines...) Expand all Loading... |
| 34 | 34 |
| 35 // A test fixture for Bluetooth that abstracts platform specifics for creating | 35 // A test fixture for Bluetooth that abstracts platform specifics for creating |
| 36 // and controlling fake low level objects. | 36 // and controlling fake low level objects. |
| 37 // | 37 // |
| 38 // Subclasses on each platform implement this, and are then typedef-ed to | 38 // Subclasses on each platform implement this, and are then typedef-ed to |
| 39 // BluetoothTest. | 39 // BluetoothTest. |
| 40 class BluetoothTestBase : public testing::Test { | 40 class BluetoothTestBase : public testing::Test { |
| 41 public: | 41 public: |
| 42 enum class Call { EXPECTED, NOT_EXPECTED }; | 42 enum class Call { EXPECTED, NOT_EXPECTED }; |
| 43 | 43 |
| 44 struct NotificationType { |
| 45 NotificationType(); |
| 46 NotificationType(std::string device_path, |
| 47 std::vector<uint8_t> value, |
| 48 bool indicate); |
| 49 NotificationType(const NotificationType& obj); |
| 50 ~NotificationType(); |
| 51 |
| 52 std::string device_path; |
| 53 std::vector<uint8_t> value; |
| 54 bool indicate; |
| 55 }; |
| 56 |
| 44 static const std::string kTestAdapterName; | 57 static const std::string kTestAdapterName; |
| 45 static const std::string kTestAdapterAddress; | 58 static const std::string kTestAdapterAddress; |
| 46 | 59 |
| 47 static const std::string kTestDeviceName; | 60 static const std::string kTestDeviceName; |
| 48 static const std::string kTestDeviceNameEmpty; | 61 static const std::string kTestDeviceNameEmpty; |
| 49 | 62 |
| 50 static const std::string kTestDeviceAddress1; | 63 static const std::string kTestDeviceAddress1; |
| 51 static const std::string kTestDeviceAddress2; | 64 static const std::string kTestDeviceAddress2; |
| 52 | 65 |
| 53 static const std::string kTestUUIDGenericAccess; | 66 static const std::string kTestUUIDGenericAccess; |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 | 269 |
| 257 // Simulates starting or stopping a notification session for a locally | 270 // Simulates starting or stopping a notification session for a locally |
| 258 // hosted GATT characteristic by a remote device. Returns false if we were | 271 // hosted GATT characteristic by a remote device. Returns false if we were |
| 259 // not able to start or stop notifications. | 272 // not able to start or stop notifications. |
| 260 virtual bool SimulateLocalGattCharacteristicNotificationsRequest( | 273 virtual bool SimulateLocalGattCharacteristicNotificationsRequest( |
| 261 BluetoothLocalGattCharacteristic* characteristic, | 274 BluetoothLocalGattCharacteristic* characteristic, |
| 262 bool start); | 275 bool start); |
| 263 | 276 |
| 264 // Returns the value for the last notification that was sent on this | 277 // Returns the value for the last notification that was sent on this |
| 265 // characteristic. | 278 // characteristic. |
| 266 virtual std::vector<uint8_t> LastNotifactionValueForCharacteristic( | 279 virtual NotificationType LastNotifactionValueForCharacteristic( |
| 267 BluetoothLocalGattCharacteristic* characteristic); | 280 BluetoothLocalGattCharacteristic* characteristic); |
| 268 | 281 |
| 269 // Remembers |descriptor|'s platform specific object to be used in a | 282 // Remembers |descriptor|'s platform specific object to be used in a |
| 270 // subsequent call to methods such as SimulateGattDescriptorRead that | 283 // subsequent call to methods such as SimulateGattDescriptorRead that |
| 271 // accept a nullptr value to select this remembered descriptor. This | 284 // accept a nullptr value to select this remembered descriptor. This |
| 272 // enables tests where the platform attempts to reference descriptor | 285 // enables tests where the platform attempts to reference descriptor |
| 273 // objects after the Chrome objects have been deleted, e.g. with DeleteDevice. | 286 // objects after the Chrome objects have been deleted, e.g. with DeleteDevice. |
| 274 virtual void RememberDescriptorForSubsequentAction( | 287 virtual void RememberDescriptorForSubsequentAction( |
| 275 BluetoothRemoteGattDescriptor* descriptor) {} | 288 BluetoothRemoteGattDescriptor* descriptor) {} |
| 276 | 289 |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 int actual_error_callback_calls_ = 0; | 410 int actual_error_callback_calls_ = 0; |
| 398 bool unexpected_success_callback_ = false; | 411 bool unexpected_success_callback_ = false; |
| 399 bool unexpected_error_callback_ = false; | 412 bool unexpected_error_callback_ = false; |
| 400 | 413 |
| 401 base::WeakPtrFactory<BluetoothTestBase> weak_factory_; | 414 base::WeakPtrFactory<BluetoothTestBase> weak_factory_; |
| 402 }; | 415 }; |
| 403 | 416 |
| 404 } // namespace device | 417 } // namespace device |
| 405 | 418 |
| 406 #endif // DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_H_ | 419 #endif // DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_H_ |
| OLD | NEW |