| 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" |
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
| 13 #include "device/bluetooth/bluetooth_adapter.h" | 13 #include "device/bluetooth/bluetooth_adapter.h" |
| 14 #include "device/bluetooth/bluetooth_device.h" | 14 #include "device/bluetooth/bluetooth_device.h" |
| 15 #include "device/bluetooth/bluetooth_discovery_session.h" | 15 #include "device/bluetooth/bluetooth_discovery_session.h" |
| 16 #include "device/bluetooth/bluetooth_gatt_characteristic.h" | 16 #include "device/bluetooth/bluetooth_gatt_characteristic.h" |
| 17 #include "device/bluetooth/bluetooth_gatt_connection.h" | 17 #include "device/bluetooth/bluetooth_gatt_connection.h" |
| 18 #include "device/bluetooth/bluetooth_gatt_descriptor.h" |
| 18 #include "device/bluetooth/bluetooth_gatt_notify_session.h" | 19 #include "device/bluetooth/bluetooth_gatt_notify_session.h" |
| 19 #include "device/bluetooth/bluetooth_gatt_service.h" | 20 #include "device/bluetooth/bluetooth_gatt_service.h" |
| 20 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
| 21 | 22 |
| 22 namespace device { | 23 namespace device { |
| 23 | 24 |
| 24 class BluetoothAdapter; | 25 class BluetoothAdapter; |
| 25 class BluetoothDevice; | 26 class BluetoothDevice; |
| 26 | 27 |
| 27 // A test fixture for Bluetooth that abstracts platform specifics for creating | 28 // A test fixture for Bluetooth that abstracts platform specifics for creating |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 // Simulates a Characteristic Write operation failing with a GattErrorCode. | 164 // Simulates a Characteristic Write operation failing with a GattErrorCode. |
| 164 virtual void SimulateGattCharacteristicWriteError( | 165 virtual void SimulateGattCharacteristicWriteError( |
| 165 BluetoothGattCharacteristic* characteristic, | 166 BluetoothGattCharacteristic* characteristic, |
| 166 BluetoothGattService::GattErrorCode) {} | 167 BluetoothGattService::GattErrorCode) {} |
| 167 | 168 |
| 168 // Simulates a Characteristic Write operation failing synchronously once for | 169 // Simulates a Characteristic Write operation failing synchronously once for |
| 169 // an unknown reason. | 170 // an unknown reason. |
| 170 virtual void SimulateGattCharacteristicWriteWillFailSynchronouslyOnce( | 171 virtual void SimulateGattCharacteristicWriteWillFailSynchronouslyOnce( |
| 171 BluetoothGattCharacteristic* characteristic) {} | 172 BluetoothGattCharacteristic* characteristic) {} |
| 172 | 173 |
| 174 // Simulates a Descriptor on a service. |
| 175 virtual void SimulateGattDescriptor( |
| 176 BluetoothGattCharacteristic* characteristic, |
| 177 const std::string& uuid) {} |
| 178 |
| 173 // Removes the device from the adapter and deletes it. | 179 // Removes the device from the adapter and deletes it. |
| 174 virtual void DeleteDevice(BluetoothDevice* device); | 180 virtual void DeleteDevice(BluetoothDevice* device); |
| 175 | 181 |
| 176 // Callbacks that increment |callback_count_|, |error_callback_count_|: | 182 // Callbacks that increment |callback_count_|, |error_callback_count_|: |
| 177 void Callback(Call expected); | 183 void Callback(Call expected); |
| 178 void DiscoverySessionCallback(Call expected, | 184 void DiscoverySessionCallback(Call expected, |
| 179 scoped_ptr<BluetoothDiscoverySession>); | 185 scoped_ptr<BluetoothDiscoverySession>); |
| 180 void GattConnectionCallback(Call expected, | 186 void GattConnectionCallback(Call expected, |
| 181 scoped_ptr<BluetoothGattConnection>); | 187 scoped_ptr<BluetoothGattConnection>); |
| 182 void NotifyCallback(Call expected, scoped_ptr<BluetoothGattNotifySession>); | 188 void NotifyCallback(Call expected, scoped_ptr<BluetoothGattNotifySession>); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 int actual_error_callback_calls_ = 0; | 241 int actual_error_callback_calls_ = 0; |
| 236 bool unexpected_success_callback_ = false; | 242 bool unexpected_success_callback_ = false; |
| 237 bool unexpected_error_callback_ = false; | 243 bool unexpected_error_callback_ = false; |
| 238 | 244 |
| 239 base::WeakPtrFactory<BluetoothTestBase> weak_factory_; | 245 base::WeakPtrFactory<BluetoothTestBase> weak_factory_; |
| 240 }; | 246 }; |
| 241 | 247 |
| 242 } // namespace device | 248 } // namespace device |
| 243 | 249 |
| 244 #endif // DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_H_ | 250 #endif // DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_H_ |
| OLD | NEW |