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_device.h" |
11 #include "device/bluetooth/bluetooth_discovery_filter.h" | 12 #include "device/bluetooth/bluetooth_discovery_filter.h" |
| 13 #include "device/bluetooth/bluetooth_uuid.h" |
12 #include "device/bluetooth/public/interfaces/test/fake_bluetooth.mojom.h" | 14 #include "device/bluetooth/public/interfaces/test/fake_bluetooth.mojom.h" |
13 #include "device/bluetooth/test/fake_peripheral.h" | 15 #include "device/bluetooth/test/fake_peripheral.h" |
14 | 16 |
15 namespace bluetooth { | 17 namespace bluetooth { |
16 | 18 |
17 FakeCentral::FakeCentral(mojom::CentralState state, | 19 FakeCentral::FakeCentral(mojom::CentralState state, |
18 mojom::FakeCentralRequest request) | 20 mojom::FakeCentralRequest request) |
19 : state_(state), binding_(this, std::move(request)) {} | 21 : state_(state), binding_(this, std::move(request)) {} |
20 | 22 |
21 void FakeCentral::SimulatePreconnectedPeripheral( | 23 void FakeCentral::SimulatePreconnectedPeripheral( |
22 const std::string& address, | 24 const std::string& address, |
23 const std::string& name, | 25 const std::string& name, |
| 26 const std::vector<device::BluetoothUUID>& known_service_uuids, |
24 SimulatePreconnectedPeripheralCallback callback) { | 27 SimulatePreconnectedPeripheralCallback callback) { |
25 auto device_iter = devices_.find(address); | 28 auto device_iter = devices_.find(address); |
26 if (device_iter == devices_.end()) { | 29 if (device_iter == devices_.end()) { |
27 auto fake_peripheral = base::MakeUnique<FakePeripheral>(this, address); | 30 auto fake_peripheral = base::MakeUnique<FakePeripheral>(this, address); |
28 | 31 |
29 auto insert_iter = devices_.emplace(address, std::move(fake_peripheral)); | 32 auto insert_iter = devices_.emplace(address, std::move(fake_peripheral)); |
30 DCHECK(insert_iter.second); | 33 DCHECK(insert_iter.second); |
31 device_iter = insert_iter.first; | 34 device_iter = insert_iter.first; |
32 } | 35 } |
33 | 36 |
34 FakePeripheral* fake_peripheral = | 37 FakePeripheral* fake_peripheral = |
35 static_cast<FakePeripheral*>(device_iter->second.get()); | 38 static_cast<FakePeripheral*>(device_iter->second.get()); |
36 fake_peripheral->SetName(name); | 39 fake_peripheral->SetName(name); |
37 fake_peripheral->SetGattConnected(true); | 40 fake_peripheral->SetGattConnected(true); |
| 41 fake_peripheral->SetServiceUUIDs(device::BluetoothDevice::UUIDSet( |
| 42 known_service_uuids.begin(), known_service_uuids.end())); |
38 | 43 |
39 std::move(callback).Run(); | 44 std::move(callback).Run(); |
40 } | 45 } |
41 | 46 |
42 std::string FakeCentral::GetAddress() const { | 47 std::string FakeCentral::GetAddress() const { |
43 NOTREACHED(); | 48 NOTREACHED(); |
44 return std::string(); | 49 return std::string(); |
45 } | 50 } |
46 | 51 |
47 std::string FakeCentral::GetName() const { | 52 std::string FakeCentral::GetName() const { |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 } | 179 } |
175 | 180 |
176 void FakeCentral::RemovePairingDelegateInternal( | 181 void FakeCentral::RemovePairingDelegateInternal( |
177 device::BluetoothDevice::PairingDelegate* pairing_delegate) { | 182 device::BluetoothDevice::PairingDelegate* pairing_delegate) { |
178 NOTREACHED(); | 183 NOTREACHED(); |
179 } | 184 } |
180 | 185 |
181 FakeCentral::~FakeCentral() {} | 186 FakeCentral::~FakeCentral() {} |
182 | 187 |
183 } // namespace bluetooth | 188 } // namespace bluetooth |
OLD | NEW |