| 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_MAC_H_ | 5 #ifndef DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_MAC_H_ |
| 6 #define DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_MAC_H_ | 6 #define DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_MAC_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/test/test_simple_task_runner.h" | 10 #include "base/test/test_simple_task_runner.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 BluetoothRemoteGattCharacteristic* characteristic, | 56 BluetoothRemoteGattCharacteristic* characteristic, |
| 57 const std::vector<uint8_t>& value) override; | 57 const std::vector<uint8_t>& value) override; |
| 58 void SimulateGattCharacteristicReadError( | 58 void SimulateGattCharacteristicReadError( |
| 59 BluetoothRemoteGattCharacteristic* characteristic, | 59 BluetoothRemoteGattCharacteristic* characteristic, |
| 60 BluetoothRemoteGattService::GattErrorCode) override; | 60 BluetoothRemoteGattService::GattErrorCode) override; |
| 61 void SimulateGattCharacteristicWrite( | 61 void SimulateGattCharacteristicWrite( |
| 62 BluetoothRemoteGattCharacteristic* characteristic) override; | 62 BluetoothRemoteGattCharacteristic* characteristic) override; |
| 63 void SimulateGattCharacteristicWriteError( | 63 void SimulateGattCharacteristicWriteError( |
| 64 BluetoothRemoteGattCharacteristic* characteristic, | 64 BluetoothRemoteGattCharacteristic* characteristic, |
| 65 BluetoothRemoteGattService::GattErrorCode error_code) override; | 65 BluetoothRemoteGattService::GattErrorCode error_code) override; |
| 66 void SimulateGattNotifySessionStarted( |
| 67 BluetoothRemoteGattCharacteristic* characteristic) override; |
| 68 void SimulateGattNotifySessionStartError( |
| 69 BluetoothRemoteGattCharacteristic* characteristic, |
| 70 BluetoothRemoteGattService::GattErrorCode error_code) override; |
| 71 void SimulateGattCharacteristicChanged( |
| 72 BluetoothRemoteGattCharacteristic* characteristic, |
| 73 const std::vector<uint8_t>& value) override; |
| 66 void SimulateGattCharacteristicRemoved( | 74 void SimulateGattCharacteristicRemoved( |
| 67 BluetoothRemoteGattService* service, | 75 BluetoothRemoteGattService* service, |
| 68 BluetoothRemoteGattCharacteristic* characteristic) override; | 76 BluetoothRemoteGattCharacteristic* characteristic) override; |
| 69 | 77 |
| 70 // Callback for the bluetooth central manager mock. | 78 // Callback for the bluetooth central manager mock. |
| 71 void OnFakeBluetoothDeviceConnectGattCalled(); | 79 void OnFakeBluetoothDeviceConnectGattCalled(); |
| 72 void OnFakeBluetoothGattDisconnect(); | 80 void OnFakeBluetoothGattDisconnect(); |
| 73 | 81 |
| 74 // Callback for the bluetooth peripheral mock. | 82 // Callback for the bluetooth peripheral mock. |
| 75 void OnFakeBluetoothServiceDiscovery(); | 83 void OnFakeBluetoothServiceDiscovery(); |
| 76 void OnFakeBluetoothCharacteristicReadValue(); | 84 void OnFakeBluetoothCharacteristicReadValue(); |
| 77 void OnFakeBluetoothCharacteristicWriteValue(std::vector<uint8_t> value); | 85 void OnFakeBluetoothCharacteristicWriteValue(std::vector<uint8_t> value); |
| 86 void OnFakeBluetoothGattSetCharacteristicNotification(); |
| 78 | 87 |
| 79 protected: | 88 protected: |
| 80 class ScopedMockCentralManager; | 89 class ScopedMockCentralManager; |
| 81 | 90 |
| 82 // Returns MockCBPeripheral from BluetoothRemoteGattService. | 91 // Returns MockCBPeripheral from BluetoothRemoteGattService. |
| 83 MockCBPeripheral* GetMockCBPeripheral( | 92 MockCBPeripheral* GetMockCBPeripheral( |
| 84 BluetoothRemoteGattService* service) const; | 93 BluetoothRemoteGattService* service) const; |
| 85 // Returns MockCBPeripheral from BluetoothRemoteGattService. | 94 // Returns MockCBPeripheral from BluetoothRemoteGattService. |
| 86 MockCBCharacteristic* GetCBMockCharacteristic( | 95 MockCBCharacteristic* GetCBMockCharacteristic( |
| 87 BluetoothRemoteGattCharacteristic* characteristic) const; | 96 BluetoothRemoteGattCharacteristic* characteristic) const; |
| 88 | 97 |
| 89 // Utility function for finding CBUUIDs with relatively nice SHA256 hashes. | 98 // Utility function for finding CBUUIDs with relatively nice SHA256 hashes. |
| 90 std::string FindCBUUIDForHashTarget(); | 99 std::string FindCBUUIDForHashTarget(); |
| 91 | 100 |
| 92 BluetoothAdapterMac* adapter_mac_ = nullptr; | 101 BluetoothAdapterMac* adapter_mac_ = nullptr; |
| 93 std::unique_ptr<ScopedMockCentralManager> mock_central_manager_; | 102 std::unique_ptr<ScopedMockCentralManager> mock_central_manager_; |
| 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 BluetoothTestMac BluetoothTest; | 106 typedef BluetoothTestMac BluetoothTest; |
| 98 | 107 |
| 99 } // namespace device | 108 } // namespace device |
| 100 | 109 |
| 101 #endif // DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_MAC_H_ | 110 #endif // DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_MAC_H_ |
| OLD | NEW |