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> | |
8 #include <string> | |
9 #include <utility> | |
10 | |
11 #include "base/bind_helpers.h" | |
12 #include "base/stl_util.h" | |
13 #include "base/threading/thread_task_runner_handle.h" | |
7 #include "device/bluetooth/bluetooth_discovery_filter.h" | 14 #include "device/bluetooth/bluetooth_discovery_filter.h" |
8 #include "device/bluetooth/public/interfaces/test/fake_bluetooth.mojom.h" | 15 #include "device/bluetooth/public/interfaces/test/fake_bluetooth.mojom.h" |
16 #include "device/bluetooth/test/fake_peripheral.h" | |
9 | 17 |
10 namespace bluetooth { | 18 namespace bluetooth { |
11 | 19 |
12 FakeCentral::FakeCentral(mojom::CentralState state, | 20 FakeCentral::FakeCentral(mojom::CentralState state, |
13 mojom::FakeCentralRequest request) | 21 mojom::FakeCentralRequest request) |
14 : state_(state), binding_(this, std::move(request)) {} | 22 : state_(state), binding_(this, std::move(request)) {} |
15 | 23 |
16 FakeCentral::~FakeCentral() {} | 24 void FakeCentral::SimulatePreconnectedPeripheral( |
25 const std::string& address, | |
26 const std::string& name, | |
27 const SimulatePreconnectedPeripheralCallback& callback) { | |
28 auto device_iter = devices_.find(address); | |
29 if (device_iter == devices_.end()) { | |
30 std::unique_ptr<FakePeripheral> fake_peripheral = | |
31 base::MakeUnique<FakePeripheral>(this, address); | |
32 | |
33 auto insert_iter = devices_.emplace(address, std::move(fake_peripheral)); | |
34 DCHECK(insert_iter.second); | |
35 device_iter = insert_iter.first; | |
36 } | |
37 | |
38 FakePeripheral* fake_peripheral = | |
39 static_cast<FakePeripheral*>(device_iter->second.get()); | |
40 fake_peripheral->SetName(name); | |
scheib
2017/05/04 05:14:45
Here it is, I missed it.
ortuno
2017/05/04 07:02:21
:)
As discussed leaving the logic as is. I don't
| |
41 fake_peripheral->SetGattConnected(true); | |
42 | |
43 callback.Run(fake_peripheral->GetIdentifier()); | |
44 } | |
17 | 45 |
18 std::string FakeCentral::GetAddress() const { | 46 std::string FakeCentral::GetAddress() const { |
19 NOTREACHED(); | 47 NOTREACHED(); |
20 return ""; | 48 return ""; |
21 } | 49 } |
22 | 50 |
23 std::string FakeCentral::GetName() const { | 51 std::string FakeCentral::GetName() const { |
24 NOTREACHED(); | 52 NOTREACHED(); |
25 return ""; | 53 return ""; |
26 } | 54 } |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
147 const base::Closure& callback, | 175 const base::Closure& callback, |
148 const DiscoverySessionErrorCallback& error_callback) { | 176 const DiscoverySessionErrorCallback& error_callback) { |
149 NOTREACHED(); | 177 NOTREACHED(); |
150 } | 178 } |
151 | 179 |
152 void FakeCentral::RemovePairingDelegateInternal( | 180 void FakeCentral::RemovePairingDelegateInternal( |
153 device::BluetoothDevice::PairingDelegate* pairing_delegate) { | 181 device::BluetoothDevice::PairingDelegate* pairing_delegate) { |
154 NOTREACHED(); | 182 NOTREACHED(); |
155 } | 183 } |
156 | 184 |
185 FakeCentral::~FakeCentral() {} | |
186 | |
157 } // namespace bluetooth | 187 } // namespace bluetooth |
OLD | NEW |