Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(291)

Side by Side Diff: device/bluetooth/test/fake_central.cc

Issue 2858803003: bluetooth: Implement simulatePreconnectedPeripheral. (Closed)
Patch Set: Merge branch 'master' into bluetooth-simulate-preconnected Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « device/bluetooth/test/fake_central.h ('k') | device/bluetooth/test/fake_peripheral.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 SimulatePreconnectedPeripheralCallback callback) {
25 auto device_iter = devices_.find(address);
26 if (device_iter == devices_.end()) {
27 auto fake_peripheral = base::MakeUnique<FakePeripheral>(this, address);
28
29 auto insert_iter = devices_.emplace(address, std::move(fake_peripheral));
30 DCHECK(insert_iter.second);
31 device_iter = insert_iter.first;
32 }
33
34 FakePeripheral* fake_peripheral =
35 static_cast<FakePeripheral*>(device_iter->second.get());
36 fake_peripheral->SetName(name);
37 fake_peripheral->SetGattConnected(true);
38
39 std::move(callback).Run();
40 }
21 41
22 std::string FakeCentral::GetAddress() const { 42 std::string FakeCentral::GetAddress() const {
23 NOTREACHED(); 43 NOTREACHED();
24 return std::string(); 44 return std::string();
25 } 45 }
26 46
27 std::string FakeCentral::GetName() const { 47 std::string FakeCentral::GetName() const {
28 NOTREACHED(); 48 NOTREACHED();
29 return std::string(); 49 return std::string();
30 } 50 }
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 const base::Closure& callback, 171 const base::Closure& callback,
152 const DiscoverySessionErrorCallback& error_callback) { 172 const DiscoverySessionErrorCallback& error_callback) {
153 NOTREACHED(); 173 NOTREACHED();
154 } 174 }
155 175
156 void FakeCentral::RemovePairingDelegateInternal( 176 void FakeCentral::RemovePairingDelegateInternal(
157 device::BluetoothDevice::PairingDelegate* pairing_delegate) { 177 device::BluetoothDevice::PairingDelegate* pairing_delegate) {
158 NOTREACHED(); 178 NOTREACHED();
159 } 179 }
160 180
181 FakeCentral::~FakeCentral() {}
182
161 } // namespace bluetooth 183 } // namespace bluetooth
OLDNEW
« no previous file with comments | « device/bluetooth/test/fake_central.h ('k') | device/bluetooth/test/fake_peripheral.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698