Chromium Code Reviews| 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 DCHECK(device_iter != devices_.end()); | |
|
dcheng
2017/06/02 16:07:35
Might be worth handling this: otherwise, I suspect
ortuno
2017/06/05 01:36:09
Ah good catch. Done.
| |
| 53 | |
| 54 FakePeripheral* fake_peripheral = | |
| 55 static_cast<FakePeripheral*>(device_iter->second.get()); | |
| 56 fake_peripheral->SetNextGATTConnectionResponse(code); | |
| 57 std::move(callback).Run(); | |
| 58 } | |
| 59 | |
| 47 std::string FakeCentral::GetAddress() const { | 60 std::string FakeCentral::GetAddress() const { |
| 48 NOTREACHED(); | 61 NOTREACHED(); |
| 49 return std::string(); | 62 return std::string(); |
| 50 } | 63 } |
| 51 | 64 |
| 52 std::string FakeCentral::GetName() const { | 65 std::string FakeCentral::GetName() const { |
| 53 NOTREACHED(); | 66 NOTREACHED(); |
| 54 return std::string(); | 67 return std::string(); |
| 55 } | 68 } |
| 56 | 69 |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 179 } | 192 } |
| 180 | 193 |
| 181 void FakeCentral::RemovePairingDelegateInternal( | 194 void FakeCentral::RemovePairingDelegateInternal( |
| 182 device::BluetoothDevice::PairingDelegate* pairing_delegate) { | 195 device::BluetoothDevice::PairingDelegate* pairing_delegate) { |
| 183 NOTREACHED(); | 196 NOTREACHED(); |
| 184 } | 197 } |
| 185 | 198 |
| 186 FakeCentral::~FakeCentral() {} | 199 FakeCentral::~FakeCentral() {} |
| 187 | 200 |
| 188 } // namespace bluetooth | 201 } // namespace bluetooth |
| OLD | NEW |