Index: device/bluetooth/test/fake_central.cc |
diff --git a/device/bluetooth/test/fake_central.cc b/device/bluetooth/test/fake_central.cc |
index 6c9e10f6bb286fa1410e8badff14a9adac228cea..141f678434066a00440b01be83efa7e9bead0f00 100644 |
--- a/device/bluetooth/test/fake_central.cc |
+++ b/device/bluetooth/test/fake_central.cc |
@@ -4,8 +4,16 @@ |
#include "device/bluetooth/test/fake_central.h" |
+#include <memory> |
+#include <string> |
+#include <utility> |
+ |
+#include "base/bind_helpers.h" |
+#include "base/stl_util.h" |
+#include "base/threading/thread_task_runner_handle.h" |
#include "device/bluetooth/bluetooth_discovery_filter.h" |
#include "device/bluetooth/public/interfaces/test/fake_bluetooth.mojom.h" |
+#include "device/bluetooth/test/fake_peripheral.h" |
namespace bluetooth { |
@@ -13,7 +21,27 @@ FakeCentral::FakeCentral(mojom::CentralState state, |
mojom::FakeCentralRequest request) |
: state_(state), binding_(this, std::move(request)) {} |
-FakeCentral::~FakeCentral() {} |
+void FakeCentral::SimulatePreconnectedPeripheral( |
+ const std::string& address, |
+ const std::string& name, |
+ const SimulatePreconnectedPeripheralCallback& callback) { |
+ auto device_iter = devices_.find(address); |
+ if (device_iter == devices_.end()) { |
+ std::unique_ptr<FakePeripheral> fake_peripheral = |
+ base::MakeUnique<FakePeripheral>(this, address); |
+ |
+ auto insert_iter = devices_.emplace(address, std::move(fake_peripheral)); |
+ DCHECK(insert_iter.second); |
+ device_iter = insert_iter.first; |
+ } |
+ |
+ FakePeripheral* fake_peripheral = |
+ static_cast<FakePeripheral*>(device_iter->second.get()); |
+ fake_peripheral->SetName(name); |
scheib
2017/05/04 05:14:45
Here it is, I missed it.
ortuno
2017/05/04 07:02:21
:)
As discussed leaving the logic as is. I don't
|
+ fake_peripheral->SetGattConnected(true); |
+ |
+ callback.Run(fake_peripheral->GetIdentifier()); |
+} |
std::string FakeCentral::GetAddress() const { |
NOTREACHED(); |
@@ -154,4 +182,6 @@ void FakeCentral::RemovePairingDelegateInternal( |
NOTREACHED(); |
} |
+FakeCentral::~FakeCentral() {} |
+ |
} // namespace bluetooth |