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

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

Issue 2858803003: bluetooth: Implement simulatePreconnectedPeripheral. (Closed)
Patch Set: MOar fixes 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 7fd297ea003dc779e6376faab3d023bffe31b66a..a4ce13844b4d02410471e1cd35e07e9e0c1a1d08 100644
--- a/third_party/WebKit/LayoutTests/resources/bluetooth/web-bluetooth-test.js
+++ b/third_party/WebKit/LayoutTests/resources/bluetooth/web-bluetooth-test.js
@@ -100,7 +100,35 @@
// 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.
+ //
+ // 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}) {
+ let peripheral_id = await this.fake_central_ptr_
scheib 2017/05/04 04:54:20 Do we have reasons to use 'id' and not just addres
ortuno 2017/05/04 07:02:21 I was trying to get away from our reliance on addr
+ .simulatePreconnectedPeripheral(address, name);
+
+ let peripheral = this.peripherals_.get(peripheral_id);
+ if (peripheral === undefined) {
+ peripheral = new FakePeripheral(peripheral_id, this);
+ this.peripherals_.set(peripheral_id, peripheral);
+ }
+
+ return peripheral;
+ }
+ }
+
+ class FakePeripheral {
+ constructor(peripheral_id, fake_central) {
+ this.peripheral_id = peripheral_id;
+ this.fake_central = fake_central;
}
}

Powered by Google App Engine
This is Rietveld 408576698