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

Unified Diff: third_party/WebKit/LayoutTests/resources/bluetooth/web-bluetooth-test.js

Issue 2858803003: bluetooth: Implement simulatePreconnectedPeripheral. (Closed)
Patch Set: Address moar feedback Created 3 years, 8 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
Index: third_party/WebKit/LayoutTests/resources/bluetooth/web-bluetooth-test.js
diff --git a/third_party/WebKit/LayoutTests/resources/bluetooth/web-bluetooth-test.js b/third_party/WebKit/LayoutTests/resources/bluetooth/web-bluetooth-test.js
index 7cf767f905a944bccf6d7cbf305fab0004d65d97..37609818ca1d7fb85f3bbf125fdc5f9b02afdb63 100644
--- a/third_party/WebKit/LayoutTests/resources/bluetooth/web-bluetooth-test.js
+++ b/third_party/WebKit/LayoutTests/resources/bluetooth/web-bluetooth-test.js
@@ -106,7 +106,36 @@
// performed by the device in the Central/Observer role.
class FakeCentral {
constructor(fake_central_ptr) {
- this.fake_central_ptr = fake_central_ptr;
+ this.fake_central_ptr_ = fake_central_ptr;
+ this.peripherals_ = new Map();
+ }
+
+ // Simulates a peripheral with |address| and |name| that has already
+ // been connected to the system. If the peripheral existed already it
+ // updates its name.
+ //
+ // Platforms offer methods to retrieve devices that have already been
+ // connected to the system or weren't connected through the UA e.g. a
+ // user connected a peripheral through the system's settings. This method is
+ // intended to simulate peripherals that those methods would return.
+ async simulatePreconnectedPeripheral({address, name}) {
+ await this.fake_central_ptr_.simulatePreconnectedPeripheral(
+ address, name);
+
+ let peripheral = this.peripherals_.get(address);
+ if (peripheral === undefined) {
+ peripheral = new FakePeripheral(address, this);
+ this.peripherals_.set(address, peripheral);
+ }
+
+ return peripheral;
+ }
+ }
+
+ class FakePeripheral {
+ constructor(address, fake_central) {
+ this.address = address;
+ this.fake_central_ = fake_central;
}
}

Powered by Google App Engine
This is Rietveld 408576698