| 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; |
| 34 bool DenyPermission() override; | 33 bool DenyPermission() override; |
| 34 void RunUntilIdle() override; |
| 35 void StartLowEnergyDiscoverySession() override; | 35 void StartLowEnergyDiscoverySession() override; |
| 36 BluetoothDevice* DiscoverLowEnergyDevice(int device_ordinal) override; | 36 BluetoothDevice* DiscoverLowEnergyDevice(int device_ordinal) override; |
| 37 void SimulateGattConnection(BluetoothDevice* device) override; | 37 void SimulateGattConnection(BluetoothDevice* device) override; |
| 38 void SimulateGattServicesDiscovered( | 38 void SimulateGattServicesDiscovered( |
| 39 BluetoothDevice* device, | 39 BluetoothDevice* device, |
| 40 const std::vector<std::string>& uuids) override; | 40 const std::vector<std::string>& uuids) override; |
| 41 void SimulateGattServiceRemoved(BluetoothGattService* service) override; | 41 void SimulateGattServiceRemoved(BluetoothGattService* service) override; |
| 42 void SimulateGattCharacteristic(BluetoothGattService* service, | 42 void SimulateGattCharacteristic(BluetoothGattService* service, |
| 43 const std::string& uuid, | 43 const std::string& uuid, |
| 44 int properties) override; | 44 int properties) override; |
| 45 void SimulateGattCharacteristicRemoved( | 45 void SimulateGattCharacteristicRemoved( |
| 46 BluetoothGattService* service, | 46 BluetoothGattService* service, |
| 47 BluetoothGattCharacteristic* characteristic) override; | 47 BluetoothGattCharacteristic* characteristic) override; |
| 48 void RememberCharacteristicForSubsequentAction( | 48 void RememberCharacteristicForSubsequentAction( |
| 49 BluetoothGattCharacteristic* characteristic) override; | 49 BluetoothGattCharacteristic* characteristic) override; |
| 50 void SimulateGattCharacteristicRead( | 50 void SimulateGattCharacteristicRead( |
| 51 BluetoothGattCharacteristic* characteristic, | 51 BluetoothGattCharacteristic* characteristic, |
| 52 const std::vector<uint8_t>& value) override; | 52 const std::vector<uint8_t>& value) override; |
| 53 void SimulateGattCharacteristicReadError( | 53 void SimulateGattCharacteristicReadError( |
| 54 BluetoothGattCharacteristic* characteristic, | 54 BluetoothGattCharacteristic* characteristic, |
| 55 BluetoothGattService::GattErrorCode error_code) override; | 55 BluetoothGattService::GattErrorCode error_code) override; |
| 56 void SimulateGattCharacteristicWrite( | 56 void SimulateGattCharacteristicWrite( |
| 57 BluetoothGattCharacteristic* characteristic) override; | 57 BluetoothGattCharacteristic* characteristic) override; |
| 58 void SimulateGattCharacteristicWriteError( | 58 void SimulateGattCharacteristicWriteError( |
| 59 BluetoothGattCharacteristic* characteristic, | 59 BluetoothGattCharacteristic* characteristic, |
| 60 BluetoothGattService::GattErrorCode error_code) override; | 60 BluetoothGattService::GattErrorCode error_code) override; |
| 61 virtual void SimulateGattCharacteristicSetNotifyWillFailSynchronouslyOnce( |
| 62 BluetoothGattCharacteristic* characteristic) override; |
| 61 void DeleteDevice(BluetoothDevice* device) override; | 63 void DeleteDevice(BluetoothDevice* device) override; |
| 62 void SimulateGattDescriptor(BluetoothGattCharacteristic* characteristic, | 64 void SimulateGattDescriptor(BluetoothGattCharacteristic* characteristic, |
| 63 const std::string& uuid) override; | 65 const std::string& uuid) override; |
| 64 | 66 void SimulateGattDescriptorWriteWillFailSynchronouslyOnce( |
| 65 // BluetoothTaskManagerWin::Observer overrides. | 67 BluetoothGattDescriptor* descriptor) override; |
| 66 void OnAttemptReadGattCharacteristic() override; | 68 void SimulateGattNotifySessionStarted( |
| 67 void OnAttemptWriteGattCharacteristic() override; | 69 BluetoothGattCharacteristic* characteristic) override; |
| 70 void SimulateGattCharacteristicChanged( |
| 71 BluetoothGattCharacteristic* characteristic, |
| 72 const std::vector<uint8_t>& value) override; |
| 68 | 73 |
| 69 // win::BluetoothLowEnergyWrapperFake::Observer overrides. | 74 // win::BluetoothLowEnergyWrapperFake::Observer overrides. |
| 70 void onWriteGattCharacteristicValue( | 75 void OnReadGattCharacteristicValue() override; |
| 76 void OnWriteGattCharacteristicValue( |
| 71 const PBTH_LE_GATT_CHARACTERISTIC_VALUE value) override; | 77 const PBTH_LE_GATT_CHARACTERISTIC_VALUE value) override; |
| 78 void OnWriteGattDescriptorValue( |
| 79 const PBTH_LE_GATT_DESCRIPTOR_VALUE value) override; |
| 80 void OnStartCharacteristicNotification() override; |
| 72 | 81 |
| 73 private: | 82 private: |
| 74 scoped_refptr<base::TestSimpleTaskRunner> ui_task_runner_; | 83 scoped_refptr<base::TestSimpleTaskRunner> ui_task_runner_; |
| 75 scoped_refptr<base::TestSimpleTaskRunner> bluetooth_task_runner_; | 84 scoped_refptr<base::TestSimpleTaskRunner> bluetooth_task_runner_; |
| 76 BluetoothAdapterWin* adapter_win_; | 85 BluetoothAdapterWin* adapter_win_; |
| 77 | 86 |
| 78 win::BluetoothClassicWrapperFake* fake_bt_classic_wrapper_; | 87 win::BluetoothClassicWrapperFake* fake_bt_classic_wrapper_; |
| 79 win::BluetoothLowEnergyWrapperFake* fake_bt_le_wrapper_; | 88 win::BluetoothLowEnergyWrapperFake* fake_bt_le_wrapper_; |
| 80 | 89 |
| 81 BluetoothRemoteGattCharacteristicWin* remembered_characteristic_; | 90 BluetoothRemoteGattCharacteristicWin* remembered_characteristic_; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 92 void ForceRefreshDevice(); | 101 void ForceRefreshDevice(); |
| 93 void FinishPendingTasks(); | 102 void FinishPendingTasks(); |
| 94 }; | 103 }; |
| 95 | 104 |
| 96 // Defines common test fixture name. Use TEST_F(BluetoothTest, YourTestName). | 105 // Defines common test fixture name. Use TEST_F(BluetoothTest, YourTestName). |
| 97 typedef BluetoothTestWin BluetoothTest; | 106 typedef BluetoothTestWin BluetoothTest; |
| 98 | 107 |
| 99 } // namespace device | 108 } // namespace device |
| 100 | 109 |
| 101 #endif // DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_WIN_H_ | 110 #endif // DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_WIN_H_ |
| OLD | NEW |