| 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->SetGattConnected(true); | 40 fake_peripheral->SetSystemConnected(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 |
| 47 std::string FakeCentral::GetAddress() const { | 63 std::string FakeCentral::GetAddress() const { |
| 48 NOTREACHED(); | 64 NOTREACHED(); |
| 49 return std::string(); | 65 return std::string(); |
| 50 } | 66 } |
| 51 | 67 |
| 52 std::string FakeCentral::GetName() const { | 68 std::string FakeCentral::GetName() const { |
| 53 NOTREACHED(); | 69 NOTREACHED(); |
| 54 return std::string(); | 70 return std::string(); |
| 55 } | 71 } |
| 56 | 72 |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 } | 195 } |
| 180 | 196 |
| 181 void FakeCentral::RemovePairingDelegateInternal( | 197 void FakeCentral::RemovePairingDelegateInternal( |
| 182 device::BluetoothDevice::PairingDelegate* pairing_delegate) { | 198 device::BluetoothDevice::PairingDelegate* pairing_delegate) { |
| 183 NOTREACHED(); | 199 NOTREACHED(); |
| 184 } | 200 } |
| 185 | 201 |
| 186 FakeCentral::~FakeCentral() {} | 202 FakeCentral::~FakeCentral() {} |
| 187 | 203 |
| 188 } // namespace bluetooth | 204 } // namespace bluetooth |
| OLD | NEW |