OLD | NEW |
---|---|
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 #include "device/bluetooth/test/fake_central.h" | 5 #include "device/bluetooth/test/fake_central.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
11 #include "device/bluetooth/bluetooth_discovery_filter.h" | 11 #include "device/bluetooth/bluetooth_discovery_filter.h" |
12 #include "device/bluetooth/public/interfaces/test/fake_bluetooth.mojom.h" | 12 #include "device/bluetooth/public/interfaces/test/fake_bluetooth.mojom.h" |
13 #include "device/bluetooth/test/fake_peripheral.h" | |
13 | 14 |
14 namespace bluetooth { | 15 namespace bluetooth { |
15 | 16 |
16 FakeCentral::FakeCentral(mojom::CentralState state, | 17 FakeCentral::FakeCentral(mojom::CentralState state, |
17 mojom::FakeCentralRequest request) | 18 mojom::FakeCentralRequest request) |
18 : state_(state), binding_(this, std::move(request)) {} | 19 : state_(state), binding_(this, std::move(request)) {} |
19 | 20 |
20 FakeCentral::~FakeCentral() {} | 21 void FakeCentral::SimulatePreconnectedPeripheral( |
22 const std::string& address, | |
23 const std::string& name, | |
24 const SimulatePreconnectedPeripheralCallback& callback) { | |
25 auto device_iter = devices_.find(address); | |
26 if (device_iter == devices_.end()) { | |
27 std::unique_ptr<FakePeripheral> fake_peripheral = | |
28 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.
| |
29 | |
30 auto insert_iter = devices_.emplace(address, std::move(fake_peripheral)); | |
31 DCHECK(insert_iter.second); | |
32 device_iter = insert_iter.first; | |
33 } | |
34 | |
35 FakePeripheral* fake_peripheral = | |
36 static_cast<FakePeripheral*>(device_iter->second.get()); | |
37 fake_peripheral->SetName(name); | |
38 fake_peripheral->SetGattConnected(true); | |
39 | |
40 callback.Run(); | |
41 } | |
21 | 42 |
22 std::string FakeCentral::GetAddress() const { | 43 std::string FakeCentral::GetAddress() const { |
23 NOTREACHED(); | 44 NOTREACHED(); |
24 return std::string(); | 45 return std::string(); |
25 } | 46 } |
26 | 47 |
27 std::string FakeCentral::GetName() const { | 48 std::string FakeCentral::GetName() const { |
28 NOTREACHED(); | 49 NOTREACHED(); |
29 return std::string(); | 50 return std::string(); |
30 } | 51 } |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
151 const base::Closure& callback, | 172 const base::Closure& callback, |
152 const DiscoverySessionErrorCallback& error_callback) { | 173 const DiscoverySessionErrorCallback& error_callback) { |
153 NOTREACHED(); | 174 NOTREACHED(); |
154 } | 175 } |
155 | 176 |
156 void FakeCentral::RemovePairingDelegateInternal( | 177 void FakeCentral::RemovePairingDelegateInternal( |
157 device::BluetoothDevice::PairingDelegate* pairing_delegate) { | 178 device::BluetoothDevice::PairingDelegate* pairing_delegate) { |
158 NOTREACHED(); | 179 NOTREACHED(); |
159 } | 180 } |
160 | 181 |
182 FakeCentral::~FakeCentral() {} | |
183 | |
161 } // namespace bluetooth | 184 } // namespace bluetooth |
OLD | NEW |