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

Unified Diff: LayoutTests/bluetooth/requestDevice.html

Issue 1304353004: Test that the right events are sent to the Bluetooth chooser. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@pinned
Patch Set: Fix ortuno's comments Created 5 years, 3 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 | « no previous file | LayoutTests/bluetooth/resources/bluetooth-helpers.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/bluetooth/requestDevice.html
diff --git a/LayoutTests/bluetooth/requestDevice.html b/LayoutTests/bluetooth/requestDevice.html
index 834bc70756f228076fc087c42c09e290d99cef8e..34add25206efb0e3d81c218f118a806837d1696b 100644
--- a/LayoutTests/bluetooth/requestDevice.html
+++ b/LayoutTests/bluetooth/requestDevice.html
@@ -21,12 +21,18 @@ promise_test(() => {
new TypeError());
}, 'RequestDeviceOptions requires a |filters| member.');
-// TODO(jyasskin): Add a test that the chooser is informed of a failed discovery
-// session.
promise_test(() => {
testRunner.setBluetoothMockDataSet('FailStartDiscoveryAdapter');
+ testRunner.setBluetoothManualChooser();
+ let requestDevicePromise =
+ requestDeviceWithKeyDown({filters: [{services: ['generic_access']}]});
+ assert_array_equals(testRunner.getBluetoothManualChooserEvents(),
+ ['chooser-opened(file:///)',
+ 'discovering',
+ 'discovery-failed-to-start']);
+ testRunner.sendBluetoothManualChooserEvent('cancelled', '');
return assert_promise_rejects_with_message(
- requestDeviceWithKeyDown({filters: [{services: ['generic_access']}]}),
+ requestDevicePromise,
{name: 'NotFoundError', message: 'User cancelled the requestDevice() chooser.'},
'The adapter failed to start a discovery session.');
}, 'Discovery session fails to start.');
@@ -39,18 +45,21 @@ promise_test(() => {
'Bluetooth adapter is not present.');
}, 'Reject with NotFoundError if the adapter is not present.');
-// TODO(jyasskin): Add a test that the chooser is informed of a disabled
-// Bluetooth adapter.
promise_test(() => {
testRunner.setBluetoothMockDataSet('NotPoweredAdapter');
+ testRunner.setBluetoothManualChooser();
+ let requestDevicePromise =
+ requestDeviceWithKeyDown({filters: [{services: ['generic_access']}]});
+ assert_array_equals(testRunner.getBluetoothManualChooserEvents(),
+ ['chooser-opened(file:///)',
+ 'adapter-disabled']);
+ testRunner.sendBluetoothManualChooserEvent('cancelled', '');
return assert_promise_rejects_with_message(
- requestDeviceWithKeyDown({filters: [{services: ['generic_access']}]}),
+ requestDevicePromise,
{name: 'NotFoundError', message: 'User cancelled the requestDevice() chooser.'},
'Bluetooth adapter is not powered.');
}, 'Reject with NotFoundError if the adapter is off.');
-// TODO(jyasskin): Add a test that the chooser gets a full list of found
-// devices.
promise_test(() => {
testRunner.setBluetoothMockDataSet('EmptyAdapter');
return assert_promise_rejects_with_message(
@@ -123,6 +132,33 @@ promise_test(() => {
promise_test(() => {
testRunner.setBluetoothMockDataSet('GlucoseHeartRateAdapter');
+ testRunner.setBluetoothManualChooser();
+ let requestDevicePromise = requestDeviceWithKeyDown({
+ filters: [{services: ['glucose']},
+ {services: ['heart_rate']}]
+ });
+ let events = testRunner.getBluetoothManualChooserEvents();
+ while (events.length < 5) {
ortuno 2015/09/18 19:56:20 You do something similar in your other test. Have
+ events.push(...testRunner.getBluetoothManualChooserEvents());
+ }
+ assert_equals(events.length, 5, events);
+ assert_equals(events[0], 'chooser-opened(file:///)', 'events[0]');
+ let idsByName = new AddDeviceEventSet();
+ for (let addedDevice of [events[1], events[2]]) {
+ idsByName.assert_add_device_event(addedDevice);
+ }
+ assert_true(idsByName.has('Heart Rate Device'));
+ assert_true(idsByName.has('Glucose Device'));
+ assert_equals(events[3], 'discovering');
+ assert_equals(events[4], 'discovery-idle');
+ testRunner.sendBluetoothManualChooserEvent('selected',
+ idsByName.get('Glucose Device'));
+ return requestDevicePromise
+ .then(device => assert_equals(device.name, 'Glucose Device'));
+}, 'The chooser includes all devices.');
+
+promise_test(() => {
+ testRunner.setBluetoothMockDataSet('GlucoseHeartRateAdapter');
return requestDeviceWithKeyDown({filters: [{services: ['glucose']}]})
.then(device => assert_equals(device.name, 'Glucose Device'));
}, 'Simple filter selects matching device.');
« no previous file with comments | « no previous file | LayoutTests/bluetooth/resources/bluetooth-helpers.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698