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_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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 81 BluetoothRemoteGattService::GattErrorCode error_code) override; | 81 BluetoothRemoteGattService::GattErrorCode error_code) override; |
| 82 void SimulateGattCharacteristicChanged( | 82 void SimulateGattCharacteristicChanged( |
| 83 BluetoothRemoteGattCharacteristic* characteristic, | 83 BluetoothRemoteGattCharacteristic* characteristic, |
| 84 const std::vector<uint8_t>& value) override; | 84 const std::vector<uint8_t>& value) override; |
| 85 void SimulateGattCharacteristicRemoved( | 85 void SimulateGattCharacteristicRemoved( |
| 86 BluetoothRemoteGattService* service, | 86 BluetoothRemoteGattService* service, |
| 87 BluetoothRemoteGattCharacteristic* characteristic) override; | 87 BluetoothRemoteGattCharacteristic* characteristic) override; |
| 88 void ExpectedChangeNotifyValueAttempts(int attempts) override; | 88 void ExpectedChangeNotifyValueAttempts(int attempts) override; |
| 89 void ExpectedNotifyValue(NotifyValueState expected_value_state) override; | 89 void ExpectedNotifyValue(NotifyValueState expected_value_state) override; |
| 90 | 90 |
| 91 // Simulate -[id<CBPeripheralDelegate peripheral:didDiscoverServices:] | |
| 92 void SimulateDidDiscoverServices(BluetoothDevice* device, | |
|
ortuno
2017/03/06 09:49:55
Explain why this is specific to macOS e.g.:
macOS
jlebel
2017/03/06 22:13:20
Done.
| |
| 93 const std::vector<std::string>& uuids); | |
| 94 | |
| 91 // Callback for the bluetooth central manager mock. | 95 // Callback for the bluetooth central manager mock. |
| 92 void OnFakeBluetoothDeviceConnectGattCalled(); | 96 void OnFakeBluetoothDeviceConnectGattCalled(); |
| 93 void OnFakeBluetoothGattDisconnect(); | 97 void OnFakeBluetoothGattDisconnect(); |
| 94 | 98 |
| 95 // Callback for the bluetooth peripheral mock. | 99 // Callback for the bluetooth peripheral mock. |
| 96 void OnFakeBluetoothServiceDiscovery(); | 100 void OnFakeBluetoothServiceDiscovery(); |
| 101 void OnFakeBluetoothCharacteristicDiscovery(); | |
| 97 void OnFakeBluetoothCharacteristicReadValue(); | 102 void OnFakeBluetoothCharacteristicReadValue(); |
| 98 void OnFakeBluetoothCharacteristicWriteValue(std::vector<uint8_t> value); | 103 void OnFakeBluetoothCharacteristicWriteValue(std::vector<uint8_t> value); |
| 99 void OnFakeBluetoothGattSetCharacteristicNotification(bool notify_value); | 104 void OnFakeBluetoothGattSetCharacteristicNotification(bool notify_value); |
| 100 | 105 |
| 101 // Returns the service UUIDs used to retrieve connected peripherals. | 106 // Returns the service UUIDs used to retrieve connected peripherals. |
| 102 BluetoothDevice::UUIDSet RetrieveConnectedPeripheralServiceUUIDs(); | 107 BluetoothDevice::UUIDSet RetrieveConnectedPeripheralServiceUUIDs(); |
| 103 // Reset RetrieveConnectedPeripheralServiceUUIDs set. | 108 // Reset RetrieveConnectedPeripheralServiceUUIDs set. |
| 104 void ResetRetrieveConnectedPeripheralServiceUUIDs(); | 109 void ResetRetrieveConnectedPeripheralServiceUUIDs(); |
| 105 | 110 |
| 106 protected: | 111 protected: |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 117 BluetoothRemoteGattCharacteristic* characteristic) const; | 122 BluetoothRemoteGattCharacteristic* characteristic) const; |
| 118 | 123 |
| 119 // Utility function for finding CBUUIDs with relatively nice SHA256 hashes. | 124 // Utility function for finding CBUUIDs with relatively nice SHA256 hashes. |
| 120 std::string FindCBUUIDForHashTarget(); | 125 std::string FindCBUUIDForHashTarget(); |
| 121 | 126 |
| 122 BluetoothAdapterMac* adapter_mac_ = nullptr; | 127 BluetoothAdapterMac* adapter_mac_ = nullptr; |
| 123 std::unique_ptr<ScopedMockCentralManager> mock_central_manager_; | 128 std::unique_ptr<ScopedMockCentralManager> mock_central_manager_; |
| 124 | 129 |
| 125 // Value set by -[CBPeripheral setNotifyValue:forCharacteristic:] call. | 130 // Value set by -[CBPeripheral setNotifyValue:forCharacteristic:] call. |
| 126 bool last_notify_value_ = false; | 131 bool last_notify_value_ = false; |
| 132 int gatt_characteristic_discovery_attempts_ = 0; | |
| 127 }; | 133 }; |
| 128 | 134 |
| 129 // Defines common test fixture name. Use TEST_F(BluetoothTest, YourTestName). | 135 // Defines common test fixture name. Use TEST_F(BluetoothTest, YourTestName). |
| 130 typedef BluetoothTestMac BluetoothTest; | 136 typedef BluetoothTestMac BluetoothTest; |
| 131 | 137 |
| 132 } // namespace device | 138 } // namespace device |
| 133 | 139 |
| 134 #endif // DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_MAC_H_ | 140 #endif // DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_MAC_H_ |
| OLD | NEW |