Chromium Code Reviews| 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 // Contains the device id, new value being sent and a flag to indicate if | |
| 45 // this is an indication instead. | |
| 46 using NotificationType = std::tuple<std::string, std::vector<uint8_t>, bool>; | |
|
scheib
2016/06/07 05:10:04
Please use a struct with named members instead of
rkc
2016/06/09 21:08:27
Using a struct raises several complications.
First
scheib
2016/06/09 21:34:35
If not a struct, then named parameters to the meth
rkc
2016/06/12 00:24:28
Done.
| |
| 47 | |
| 44 static const std::string kTestAdapterName; | 48 static const std::string kTestAdapterName; |
| 45 static const std::string kTestAdapterAddress; | 49 static const std::string kTestAdapterAddress; |
| 46 | 50 |
| 47 static const std::string kTestDeviceName; | 51 static const std::string kTestDeviceName; |
| 48 static const std::string kTestDeviceNameEmpty; | 52 static const std::string kTestDeviceNameEmpty; |
| 49 | 53 |
| 50 static const std::string kTestDeviceAddress1; | 54 static const std::string kTestDeviceAddress1; |
| 51 static const std::string kTestDeviceAddress2; | 55 static const std::string kTestDeviceAddress2; |
| 52 | 56 |
| 53 static const std::string kTestUUIDGenericAccess; | 57 static const std::string kTestUUIDGenericAccess; |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 256 | 260 |
| 257 // Simulates starting or stopping a notification session for a locally | 261 // Simulates starting or stopping a notification session for a locally |
| 258 // hosted GATT characteristic by a remote device. Returns false if we were | 262 // hosted GATT characteristic by a remote device. Returns false if we were |
| 259 // not able to start or stop notifications. | 263 // not able to start or stop notifications. |
| 260 virtual bool SimulateLocalGattCharacteristicNotificationsRequest( | 264 virtual bool SimulateLocalGattCharacteristicNotificationsRequest( |
| 261 BluetoothLocalGattCharacteristic* characteristic, | 265 BluetoothLocalGattCharacteristic* characteristic, |
| 262 bool start); | 266 bool start); |
| 263 | 267 |
| 264 // Returns the value for the last notification that was sent on this | 268 // Returns the value for the last notification that was sent on this |
| 265 // characteristic. | 269 // characteristic. |
| 266 virtual std::vector<uint8_t> LastNotifactionValueForCharacteristic( | 270 virtual NotificationType LastNotifactionValueForCharacteristic( |
| 267 BluetoothLocalGattCharacteristic* characteristic); | 271 BluetoothLocalGattCharacteristic* characteristic); |
| 268 | 272 |
| 269 // Remembers |descriptor|'s platform specific object to be used in a | 273 // Remembers |descriptor|'s platform specific object to be used in a |
| 270 // subsequent call to methods such as SimulateGattDescriptorRead that | 274 // subsequent call to methods such as SimulateGattDescriptorRead that |
| 271 // accept a nullptr value to select this remembered descriptor. This | 275 // accept a nullptr value to select this remembered descriptor. This |
| 272 // enables tests where the platform attempts to reference descriptor | 276 // enables tests where the platform attempts to reference descriptor |
| 273 // objects after the Chrome objects have been deleted, e.g. with DeleteDevice. | 277 // objects after the Chrome objects have been deleted, e.g. with DeleteDevice. |
| 274 virtual void RememberDescriptorForSubsequentAction( | 278 virtual void RememberDescriptorForSubsequentAction( |
| 275 BluetoothRemoteGattDescriptor* descriptor) {} | 279 BluetoothRemoteGattDescriptor* descriptor) {} |
| 276 | 280 |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 397 int actual_error_callback_calls_ = 0; | 401 int actual_error_callback_calls_ = 0; |
| 398 bool unexpected_success_callback_ = false; | 402 bool unexpected_success_callback_ = false; |
| 399 bool unexpected_error_callback_ = false; | 403 bool unexpected_error_callback_ = false; |
| 400 | 404 |
| 401 base::WeakPtrFactory<BluetoothTestBase> weak_factory_; | 405 base::WeakPtrFactory<BluetoothTestBase> weak_factory_; |
| 402 }; | 406 }; |
| 403 | 407 |
| 404 } // namespace device | 408 } // namespace device |
| 405 | 409 |
| 406 #endif // DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_H_ | 410 #endif // DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_H_ |
| OLD | NEW |