| 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 // macOS is the only platform for which we need to discover each set of |
| 92 // attributes individually so we need a method to simulate discovering each |
| 93 // set of attributes. |
| 94 void SimulateDidDiscoverServices(BluetoothDevice* device, |
| 95 const std::vector<std::string>& uuids); |
| 96 |
| 91 // Callback for the bluetooth central manager mock. | 97 // Callback for the bluetooth central manager mock. |
| 92 void OnFakeBluetoothDeviceConnectGattCalled(); | 98 void OnFakeBluetoothDeviceConnectGattCalled(); |
| 93 void OnFakeBluetoothGattDisconnect(); | 99 void OnFakeBluetoothGattDisconnect(); |
| 94 | 100 |
| 95 // Callback for the bluetooth peripheral mock. | 101 // Callback for the bluetooth peripheral mock. |
| 96 void OnFakeBluetoothServiceDiscovery(); | 102 void OnFakeBluetoothServiceDiscovery(); |
| 103 void OnFakeBluetoothCharacteristicDiscovery(); |
| 97 void OnFakeBluetoothCharacteristicReadValue(); | 104 void OnFakeBluetoothCharacteristicReadValue(); |
| 98 void OnFakeBluetoothCharacteristicWriteValue(std::vector<uint8_t> value); | 105 void OnFakeBluetoothCharacteristicWriteValue(std::vector<uint8_t> value); |
| 99 void OnFakeBluetoothGattSetCharacteristicNotification(bool notify_value); | 106 void OnFakeBluetoothGattSetCharacteristicNotification(bool notify_value); |
| 100 | 107 |
| 101 // Returns the service UUIDs used to retrieve connected peripherals. | 108 // Returns the service UUIDs used to retrieve connected peripherals. |
| 102 BluetoothDevice::UUIDSet RetrieveConnectedPeripheralServiceUUIDs(); | 109 BluetoothDevice::UUIDSet RetrieveConnectedPeripheralServiceUUIDs(); |
| 103 // Reset RetrieveConnectedPeripheralServiceUUIDs set. | 110 // Reset RetrieveConnectedPeripheralServiceUUIDs set. |
| 104 void ResetRetrieveConnectedPeripheralServiceUUIDs(); | 111 void ResetRetrieveConnectedPeripheralServiceUUIDs(); |
| 105 | 112 |
| 106 protected: | 113 protected: |
| (...skipping 10 matching lines...) Expand all Loading... |
| 117 BluetoothRemoteGattCharacteristic* characteristic) const; | 124 BluetoothRemoteGattCharacteristic* characteristic) const; |
| 118 | 125 |
| 119 // Utility function for finding CBUUIDs with relatively nice SHA256 hashes. | 126 // Utility function for finding CBUUIDs with relatively nice SHA256 hashes. |
| 120 std::string FindCBUUIDForHashTarget(); | 127 std::string FindCBUUIDForHashTarget(); |
| 121 | 128 |
| 122 BluetoothAdapterMac* adapter_mac_ = nullptr; | 129 BluetoothAdapterMac* adapter_mac_ = nullptr; |
| 123 std::unique_ptr<ScopedMockCentralManager> mock_central_manager_; | 130 std::unique_ptr<ScopedMockCentralManager> mock_central_manager_; |
| 124 | 131 |
| 125 // Value set by -[CBPeripheral setNotifyValue:forCharacteristic:] call. | 132 // Value set by -[CBPeripheral setNotifyValue:forCharacteristic:] call. |
| 126 bool last_notify_value_ = false; | 133 bool last_notify_value_ = false; |
| 134 int gatt_characteristic_discovery_attempts_ = 0; |
| 127 }; | 135 }; |
| 128 | 136 |
| 129 // Defines common test fixture name. Use TEST_F(BluetoothTest, YourTestName). | 137 // Defines common test fixture name. Use TEST_F(BluetoothTest, YourTestName). |
| 130 typedef BluetoothTestMac BluetoothTest; | 138 typedef BluetoothTestMac BluetoothTest; |
| 131 | 139 |
| 132 } // namespace device | 140 } // namespace device |
| 133 | 141 |
| 134 #endif // DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_MAC_H_ | 142 #endif // DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_MAC_H_ |
| OLD | NEW |