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

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

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 | « third_party/WebKit/LayoutTests/resources/bluetooth/bluetooth-helpers.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 59e5d5a56c234eae39a86db85ecdb516336b603b..4ff126f700c4495d0dc470b3101db2cc936a94bf 100644
--- a/third_party/WebKit/LayoutTests/resources/bluetooth/web-bluetooth-test.js
+++ b/third_party/WebKit/LayoutTests/resources/bluetooth/web-bluetooth-test.js
@@ -116,7 +116,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;
}
}
« no previous file with comments | « third_party/WebKit/LayoutTests/resources/bluetooth/bluetooth-helpers.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698