Chromium Code Reviews| Index: device/bluetooth/test/fake_peripheral.cc |
| diff --git a/device/bluetooth/test/fake_peripheral.cc b/device/bluetooth/test/fake_peripheral.cc |
| index 1515e991b9f194914b363e65f15705cd27e11c72..855f2b3376ae2289e0c39780dc24bc27d77b4a97 100644 |
| --- a/device/bluetooth/test/fake_peripheral.cc |
| +++ b/device/bluetooth/test/fake_peripheral.cc |
| @@ -4,6 +4,8 @@ |
| #include "device/bluetooth/test/fake_peripheral.h" |
| +#include "device/bluetooth/bluetooth_gatt_connection.h" |
| + |
| namespace bluetooth { |
| FakePeripheral::FakePeripheral(FakeCentral* fake_central, |
| @@ -26,6 +28,22 @@ void FakePeripheral::SetServiceUUIDs(UUIDSet service_uuids) { |
| service_uuids_ = std::move(service_uuids); |
| } |
| +void FakePeripheral::SimulateGATTConnectionResponse(uint16_t code) { |
| + CreateGattConnectionCallbacks callbacks = |
|
scheib
2017/05/12 05:43:55
Call up to BluetoothDevice::DidConnectGatt DidFail
ortuno
2017/05/15 07:01:30
Happy to change it but I would like to understand
|
| + create_gatt_connection_callbacks_.front(); |
| + create_gatt_connection_callbacks_.pop(); |
| + if (code == mojom::kHCISuccess) { |
| + gatt_connected_ = true; |
| + callbacks.first.Run( |
| + base::MakeUnique<device::BluetoothGattConnection>(adapter_, address_)); |
| + adapter_->NotifyDeviceChanged(this); |
| + } else if (code == mojom::kHCIConnectionTimeout) { |
| + callbacks.second.Run(ERROR_FAILED); |
| + } else { |
| + callbacks.second.Run(ERROR_UNKNOWN); |
| + } |
| +} |
| + |
| uint32_t FakePeripheral::GetBluetoothClass() const { |
| NOTREACHED(); |
| return 0; |
| @@ -178,11 +196,16 @@ void FakePeripheral::ConnectToServiceInsecurely( |
| NOTREACHED(); |
| } |
| +void FakePeripheral::CreateGattConnection( |
| + const GattConnectionCallback& callback, |
| + const ConnectErrorCallback& error_callback) { |
| + create_gatt_connection_callbacks_.push({callback, error_callback}); |
| +} |
| + |
| void FakePeripheral::CreateGattConnectionImpl() { |
| NOTREACHED(); |
| } |
| void FakePeripheral::DisconnectGatt() { |
| - NOTREACHED(); |
| } |
| } // namespace bluetooth |