Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(213)

Unified Diff: device/bluetooth/test/fake_central.cc

Issue 2858803003: bluetooth: Implement simulatePreconnectedPeripheral. (Closed)
Patch Set: Merge branch 'master' into bluetooth-simulate-preconnected Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « device/bluetooth/test/fake_central.h ('k') | device/bluetooth/test/fake_peripheral.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/bluetooth/test/fake_central.cc
diff --git a/device/bluetooth/test/fake_central.cc b/device/bluetooth/test/fake_central.cc
index 1236615f2a18808c1d0cf497fd45d2ecf931ce97..81ec17302480f44ec2ac2c27b3b7f3cd494acfe0 100644
--- a/device/bluetooth/test/fake_central.cc
+++ b/device/bluetooth/test/fake_central.cc
@@ -10,6 +10,7 @@
#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 {
@@ -17,7 +18,26 @@ 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,
+ SimulatePreconnectedPeripheralCallback callback) {
+ auto device_iter = devices_.find(address);
+ if (device_iter == devices_.end()) {
+ auto 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);
+ fake_peripheral->SetGattConnected(true);
+
+ std::move(callback).Run();
+}
std::string FakeCentral::GetAddress() const {
NOTREACHED();
@@ -158,4 +178,6 @@ void FakeCentral::RemovePairingDelegateInternal(
NOTREACHED();
}
+FakeCentral::~FakeCentral() {}
+
} // namespace bluetooth
« no previous file with comments | « device/bluetooth/test/fake_central.h ('k') | device/bluetooth/test/fake_peripheral.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698