Chromium Code Reviews| Index: device/bluetooth/test/fake_central.cc |
| diff --git a/device/bluetooth/test/fake_central.cc b/device/bluetooth/test/fake_central.cc |
| index 1236615f2a18808c1d0cf497fd45d2ecf931ce97..7a3798eadd806e099c7cbd98e1239d6b912d1c28 100644 |
| --- a/device/bluetooth/test/fake_central.cc |
| +++ b/device/bluetooth/test/fake_central.cc |
| @@ -10,6 +10,7 @@ |
| #include "device/bluetooth/bluetooth_discovery_filter.h" |
| #include "device/bluetooth/public/interfaces/test/fake_bluetooth.mojom.h" |
| +#include "device/bluetooth/test/fake_peripheral.h" |
| namespace bluetooth { |
| @@ -17,7 +18,27 @@ FakeCentral::FakeCentral(mojom::CentralState state, |
| mojom::FakeCentralRequest request) |
| : state_(state), binding_(this, std::move(request)) {} |
| -FakeCentral::~FakeCentral() {} |
| +void FakeCentral::SimulatePreconnectedPeripheral( |
| + const std::string& address, |
| + const std::string& name, |
| + const SimulatePreconnectedPeripheralCallback& callback) { |
| + auto device_iter = devices_.find(address); |
| + if (device_iter == devices_.end()) { |
| + std::unique_ptr<FakePeripheral> fake_peripheral = |
| + base::MakeUnique<FakePeripheral>(this, address); |
|
dcheng
2017/05/05 06:18:48
Nit: it's OK to omit the variable type and just us
ortuno
2017/05/08 01:08:13
Good catch. Done.
|
| + |
| + auto insert_iter = devices_.emplace(address, std::move(fake_peripheral)); |
| + DCHECK(insert_iter.second); |
| + device_iter = insert_iter.first; |
| + } |
| + |
| + FakePeripheral* fake_peripheral = |
| + static_cast<FakePeripheral*>(device_iter->second.get()); |
| + fake_peripheral->SetName(name); |
| + fake_peripheral->SetGattConnected(true); |
| + |
| + callback.Run(); |
| +} |
| std::string FakeCentral::GetAddress() const { |
| NOTREACHED(); |
| @@ -158,4 +179,6 @@ void FakeCentral::RemovePairingDelegateInternal( |
| NOTREACHED(); |
| } |
| +FakeCentral::~FakeCentral() {} |
| + |
| } // namespace bluetooth |