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 12, 2018
1 parent 284dfe4 commit def88b0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions bluetooth/resources/bluetooth-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ function performChromiumSetup() {
`${prefix}/uuid.mojom.js`,
`${prefix}/fake_bluetooth.mojom.js`,
`${prefix}/web-bluetooth-test.js`,
'file:///gen/content/shell/common/layout_test/fake_bluetooth_chooser.mojom.js',
].concat(extra))
// Call setBluetoothFakeAdapter() to clean up any fake adapters left over
// by legacy tests.
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 @@ -437,6 +446,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 def88b0

Please sign in to comment.