Skip to content

Commit

Permalink
bluetooth: FakeBluetoothChooser stub impl.
Browse files Browse the repository at this point in the history
This change adds a new FakeBluetoothChooser interface stub to expand on.
The design for this class is detailed in the following document:
https://docs.google.com/document/d/1XFl_4ZAgO8ddM6U53A9AfUuZeWgJnlYD5wtbXqEpzeg

BUG=719827

Change-Id: I34169ce62dd5b35796639b7643d899b8315cc4c7
  • Loading branch information
odejesush authored and chromium-wpt-export-bot committed Mar 9, 2018
1 parent de0c4ad commit b523463
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
4 changes: 4 additions & 0 deletions bluetooth/resources/bluetooth-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ function performChromiumSetup() {
prefix = `${root}/external/wpt/resources/chromium`;
extra = [
`${root}/resources/bluetooth/bluetooth-fake-adapter.js`,
// TODO(https://crbug.com/719827): Once this interface has been completed,
// migrate this file to external/wpt/resources/chromium/ and remove this
// line.
`${root}/resources/bluetooth/fake_bluetooth_chooser.mojom.js`,
];
} else if (window.location.pathname.startsWith('/bluetooth/https/')) {
extra = [
Expand Down
22 changes: 21 additions & 1 deletion resources/chromium/web-bluetooth-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class FakeBluetooth {
constructor() {
this.fake_bluetooth_ptr_ = new bluetooth.mojom.FakeBluetoothPtr();
Mojo.bindInterface(bluetooth.mojom.FakeBluetooth.name,
mojo.makeRequest(this.fake_bluetooth_ptr_).handle, "process");
mojo.makeRequest(this.fake_bluetooth_ptr_).handle, 'process');
}

// Set it to indicate whether the platform supports BLE. For example,
Expand Down Expand Up @@ -102,6 +102,15 @@ class FakeBluetooth {
let {consumed} = await this.fake_bluetooth_ptr_.allResponsesConsumed();
return consumed;
}

// Returns a promise that resolves with a FakeChooser that clients can use to
// simulate chooser events.
async getManualChooser() {
if (typeof this.fake_chooser_ === 'undefined') {
this.fake_chooser_ = new FakeChooser();
}
return this.fake_chooser_;
}
}

// FakeCentral allows clients to simulate events that a device in the
Expand Down Expand Up @@ -433,6 +442,17 @@ class FakeRemoteGATTDescriptor {
}
}

// FakeChooser allows clients to simulate events that a user would trigger when
// using the Bluetooth chooser, and monitor the events that are produced.
class FakeChooser {
constructor() {
this.fake_bluetooth_chooser_ptr_ =
new content.mojom.FakeBluetoothChooserPtr();
Mojo.bindInterface(content.mojom.FakeBluetoothChooser.name,
mojo.makeRequest(this.fake_bluetooth_chooser_ptr_).handle, 'process');
}
}

// If this line fails, it means that current environment does not support the
// Web Bluetooth Test API.
try {
Expand Down

0 comments on commit b523463

Please sign in to comment.