| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_WIN_H_ | 5 #ifndef DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_WIN_H_ |
| 6 #define DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_WIN_H_ | 6 #define DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_WIN_H_ |
| 7 | 7 |
| 8 #include "device/bluetooth/test/bluetooth_test.h" | 8 #include "device/bluetooth/test/bluetooth_test.h" |
| 9 | 9 |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "base/test/test_pending_task.h" | 11 #include "base/test/test_pending_task.h" |
| 12 #include "base/test/test_simple_task_runner.h" | 12 #include "base/test/test_simple_task_runner.h" |
| 13 #include "device/bluetooth/bluetooth_classic_win_fake.h" | 13 #include "device/bluetooth/bluetooth_classic_win_fake.h" |
| 14 #include "device/bluetooth/bluetooth_low_energy_win_fake.h" | 14 #include "device/bluetooth/bluetooth_low_energy_win_fake.h" |
| 15 #include "device/bluetooth/bluetooth_task_manager_win.h" | 15 #include "device/bluetooth/bluetooth_task_manager_win.h" |
| 16 | 16 |
| 17 namespace device { | 17 namespace device { |
| 18 class BluetoothAdapterWin; | 18 class BluetoothAdapterWin; |
| 19 class BluetoothRemoteGattCharacteristicWin; | 19 class BluetoothRemoteGattCharacteristicWin; |
| 20 | 20 |
| 21 // Windows implementation of BluetoothTestBase. | 21 // Windows implementation of BluetoothTestBase. |
| 22 class BluetoothTestWin : public BluetoothTestBase, | 22 class BluetoothTestWin : public BluetoothTestBase, |
| 23 public BluetoothTaskManagerWin::Observer, | |
| 24 public win::BluetoothLowEnergyWrapperFake::Observer { | 23 public win::BluetoothLowEnergyWrapperFake::Observer { |
| 25 public: | 24 public: |
| 26 BluetoothTestWin(); | 25 BluetoothTestWin(); |
| 27 ~BluetoothTestWin() override; | 26 ~BluetoothTestWin() override; |
| 28 | 27 |
| 29 // BluetoothTestBase overrides | 28 // BluetoothTestBase overrides |
| 30 bool PlatformSupportsLowEnergy() override; | 29 bool PlatformSupportsLowEnergy() override; |
| 31 void InitWithDefaultAdapter() override; | 30 void InitWithDefaultAdapter() override; |
| 32 void InitWithoutDefaultAdapter() override; | 31 void InitWithoutDefaultAdapter() override; |
| 33 void InitWithFakeAdapter() override; | 32 void InitWithFakeAdapter() override; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 54 BluetoothGattCharacteristic* characteristic, | 53 BluetoothGattCharacteristic* characteristic, |
| 55 BluetoothGattService::GattErrorCode error_code) override; | 54 BluetoothGattService::GattErrorCode error_code) override; |
| 56 void SimulateGattCharacteristicWrite( | 55 void SimulateGattCharacteristicWrite( |
| 57 BluetoothGattCharacteristic* characteristic) override; | 56 BluetoothGattCharacteristic* characteristic) override; |
| 58 void SimulateGattCharacteristicWriteError( | 57 void SimulateGattCharacteristicWriteError( |
| 59 BluetoothGattCharacteristic* characteristic, | 58 BluetoothGattCharacteristic* characteristic, |
| 60 BluetoothGattService::GattErrorCode error_code) override; | 59 BluetoothGattService::GattErrorCode error_code) override; |
| 61 void DeleteDevice(BluetoothDevice* device) override; | 60 void DeleteDevice(BluetoothDevice* device) override; |
| 62 void SimulateGattDescriptor(BluetoothGattCharacteristic* characteristic, | 61 void SimulateGattDescriptor(BluetoothGattCharacteristic* characteristic, |
| 63 const std::string& uuid) override; | 62 const std::string& uuid) override; |
| 64 | 63 void SimulateGattNotifySessionStarted( |
| 65 // BluetoothTaskManagerWin::Observer overrides. | 64 BluetoothGattCharacteristic* characteristic) override; |
| 66 void OnAttemptReadGattCharacteristic() override; | 65 void SimulateGattCharacteristicChanged( |
| 67 void OnAttemptWriteGattCharacteristic() override; | 66 BluetoothGattCharacteristic* characteristic, |
| 67 const std::vector<uint8_t>& value) override; |
| 68 | 68 |
| 69 // win::BluetoothLowEnergyWrapperFake::Observer overrides. | 69 // win::BluetoothLowEnergyWrapperFake::Observer overrides. |
| 70 void onWriteGattCharacteristicValue( | 70 void OnReadGattCharacteristicValue() override; |
| 71 void OnWriteGattCharacteristicValue( |
| 71 const PBTH_LE_GATT_CHARACTERISTIC_VALUE value) override; | 72 const PBTH_LE_GATT_CHARACTERISTIC_VALUE value) override; |
| 73 void OnStartCharacteristicNotification() override; |
| 74 void OnWriteGattDescriptorValue(const std::vector<uint8_t>& value) override; |
| 72 | 75 |
| 73 private: | 76 private: |
| 74 scoped_refptr<base::TestSimpleTaskRunner> ui_task_runner_; | 77 scoped_refptr<base::TestSimpleTaskRunner> ui_task_runner_; |
| 75 scoped_refptr<base::TestSimpleTaskRunner> bluetooth_task_runner_; | 78 scoped_refptr<base::TestSimpleTaskRunner> bluetooth_task_runner_; |
| 76 BluetoothAdapterWin* adapter_win_; | 79 BluetoothAdapterWin* adapter_win_; |
| 77 | 80 |
| 78 win::BluetoothClassicWrapperFake* fake_bt_classic_wrapper_; | 81 win::BluetoothClassicWrapperFake* fake_bt_classic_wrapper_; |
| 79 win::BluetoothLowEnergyWrapperFake* fake_bt_le_wrapper_; | 82 win::BluetoothLowEnergyWrapperFake* fake_bt_le_wrapper_; |
| 80 | 83 |
| 81 BluetoothRemoteGattCharacteristicWin* remembered_characteristic_; | |
| 82 | |
| 83 void AdapterInitCallback(); | 84 void AdapterInitCallback(); |
| 84 win::GattService* GetSimulatedService(win::BLEDevice* device, | 85 win::GattService* GetSimulatedService(win::BLEDevice* device, |
| 85 BluetoothGattService* service); | 86 BluetoothGattService* service); |
| 86 win::GattCharacteristic* GetSimulatedCharacteristic( | 87 win::GattCharacteristic* GetSimulatedCharacteristic( |
| 87 BluetoothGattCharacteristic* characteristic); | 88 BluetoothGattCharacteristic* characteristic); |
| 88 | 89 |
| 89 // Run pending Bluetooth tasks until the first callback that the test fixture | 90 // Run pending Bluetooth tasks until the first callback that the test fixture |
| 90 // tracks is called. | 91 // tracks is called. |
| 91 void RunPendingTasksUntilCallback(); | 92 void RunPendingTasksUntilCallback(); |
| 92 void ForceRefreshDevice(); | 93 void ForceRefreshDevice(); |
| 93 void FinishPendingTasks(); | 94 void FinishPendingTasks(); |
| 94 }; | 95 }; |
| 95 | 96 |
| 96 // Defines common test fixture name. Use TEST_F(BluetoothTest, YourTestName). | 97 // Defines common test fixture name. Use TEST_F(BluetoothTest, YourTestName). |
| 97 typedef BluetoothTestWin BluetoothTest; | 98 typedef BluetoothTestWin BluetoothTest; |
| 98 | 99 |
| 99 } // namespace device | 100 } // namespace device |
| 100 | 101 |
| 101 #endif // DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_WIN_H_ | 102 #endif // DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_WIN_H_ |
| OLD | NEW |