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 |
(...skipping 19 matching lines...) Expand all Loading... |
30 auto fake_peripheral = base::MakeUnique<FakePeripheral>(this, address); | 30 auto fake_peripheral = base::MakeUnique<FakePeripheral>(this, address); |
31 | 31 |
32 auto insert_iter = devices_.emplace(address, std::move(fake_peripheral)); | 32 auto insert_iter = devices_.emplace(address, std::move(fake_peripheral)); |
33 DCHECK(insert_iter.second); | 33 DCHECK(insert_iter.second); |
34 device_iter = insert_iter.first; | 34 device_iter = insert_iter.first; |
35 } | 35 } |
36 | 36 |
37 FakePeripheral* fake_peripheral = | 37 FakePeripheral* fake_peripheral = |
38 static_cast<FakePeripheral*>(device_iter->second.get()); | 38 static_cast<FakePeripheral*>(device_iter->second.get()); |
39 fake_peripheral->SetName(name); | 39 fake_peripheral->SetName(name); |
40 fake_peripheral->SetSystemConnected(true); | 40 fake_peripheral->SetGattConnected(true); |
41 fake_peripheral->SetServiceUUIDs(device::BluetoothDevice::UUIDSet( | 41 fake_peripheral->SetServiceUUIDs(device::BluetoothDevice::UUIDSet( |
42 known_service_uuids.begin(), known_service_uuids.end())); | 42 known_service_uuids.begin(), known_service_uuids.end())); |
43 | 43 |
44 std::move(callback).Run(); | 44 std::move(callback).Run(); |
45 } | 45 } |
46 | 46 |
47 void FakeCentral::SetNextGATTConnectionResponse( | |
48 const std::string& address, | |
49 uint16_t code, | |
50 SetNextGATTConnectionResponseCallback callback) { | |
51 auto device_iter = devices_.find(address); | |
52 if (device_iter == devices_.end()) { | |
53 std::move(callback).Run(false); | |
54 return; | |
55 } | |
56 | |
57 FakePeripheral* fake_peripheral = | |
58 static_cast<FakePeripheral*>(device_iter->second.get()); | |
59 fake_peripheral->SetNextGATTConnectionResponse(code); | |
60 std::move(callback).Run(true); | |
61 } | |
62 | |
63 std::string FakeCentral::GetAddress() const { | 47 std::string FakeCentral::GetAddress() const { |
64 NOTREACHED(); | 48 NOTREACHED(); |
65 return std::string(); | 49 return std::string(); |
66 } | 50 } |
67 | 51 |
68 std::string FakeCentral::GetName() const { | 52 std::string FakeCentral::GetName() const { |
69 NOTREACHED(); | 53 NOTREACHED(); |
70 return std::string(); | 54 return std::string(); |
71 } | 55 } |
72 | 56 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 } | 179 } |
196 | 180 |
197 void FakeCentral::RemovePairingDelegateInternal( | 181 void FakeCentral::RemovePairingDelegateInternal( |
198 device::BluetoothDevice::PairingDelegate* pairing_delegate) { | 182 device::BluetoothDevice::PairingDelegate* pairing_delegate) { |
199 NOTREACHED(); | 183 NOTREACHED(); |
200 } | 184 } |
201 | 185 |
202 FakeCentral::~FakeCentral() {} | 186 FakeCentral::~FakeCentral() {} |
203 | 187 |
204 } // namespace bluetooth | 188 } // namespace bluetooth |
OLD | NEW |