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