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

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

Issue 2858803003: bluetooth: Implement simulatePreconnectedPeripheral. (Closed)
Patch Set: small cleanup 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
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>
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::SimulateSystemConnectedPeripheral(
25 const std::string& address,
26 const std::string& name,
27 const SimulateSystemConnectedPeripheralCallback& callback) {
28 auto device_iter = devices_.find(address);
29 if (device_iter == devices_.end()) {
scheib 2017/05/03 20:38:49 If called with the same address but a new name thi
ortuno 2017/05/04 04:16:21 Good catch. This is at the JS API level right? A p
scheib 2017/05/04 04:54:20 Even with your update the logic sets the name if t
30 std::unique_ptr<FakePeripheral> fake_peripheral =
31 base::MakeUnique<FakePeripheral>(this, address, name);
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->SetGattConnected(true);
41
42 callback.Run(fake_peripheral->GetIdentifier());
43 }
17 44
18 std::string FakeCentral::GetAddress() const { 45 std::string FakeCentral::GetAddress() const {
19 NOTREACHED(); 46 NOTREACHED();
20 return ""; 47 return "";
21 } 48 }
22 49
23 std::string FakeCentral::GetName() const { 50 std::string FakeCentral::GetName() const {
24 NOTREACHED(); 51 NOTREACHED();
25 return ""; 52 return "";
26 } 53 }
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 const base::Closure& callback, 174 const base::Closure& callback,
148 const DiscoverySessionErrorCallback& error_callback) { 175 const DiscoverySessionErrorCallback& error_callback) {
149 NOTREACHED(); 176 NOTREACHED();
150 } 177 }
151 178
152 void FakeCentral::RemovePairingDelegateInternal( 179 void FakeCentral::RemovePairingDelegateInternal(
153 device::BluetoothDevice::PairingDelegate* pairing_delegate) { 180 device::BluetoothDevice::PairingDelegate* pairing_delegate) {
154 NOTREACHED(); 181 NOTREACHED();
155 } 182 }
156 183
184 FakeCentral::~FakeCentral() {}
185
157 } // namespace bluetooth 186 } // namespace bluetooth
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698