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

Side by Side Diff: LayoutTests/bluetooth/requestDevice.html

Issue 1293593003: Add errors for various chooser failure modes, and remove assertions that are about to change. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@pinned
Patch Set: Sync Created 5 years, 4 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 unified diff | Download patch
« no previous file with comments | « no previous file | LayoutTests/bluetooth/resources/bluetooth-helpers.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <script src="../resources/testharness.js"></script> 2 <script src="../resources/testharness.js"></script>
3 <script src="../resources/testharness-helpers.js"></script> 3 <script src="../resources/testharness-helpers.js"></script>
4 <script src="../resources/testharnessreport.js"></script> 4 <script src="../resources/testharnessreport.js"></script>
5 <script src="resources/bluetooth-helpers.js"></script> 5 <script src="resources/bluetooth-helpers.js"></script>
6 <script> 6 <script>
7 'use strict'; 7 'use strict';
8 8
9 test(function(t) { assert_true(window.testRunner instanceof Object); t.done(); } , 9 test(function(t) { assert_true(window.testRunner instanceof Object); t.done(); } ,
10 'window.testRunner is required for the following tests.'); 10 'window.testRunner is required for the following tests.');
11 11
12 promise_test(() => { 12 promise_test(() => {
13 testRunner.setBluetoothMockDataSet('EmptyAdapter'); 13 testRunner.setBluetoothMockDataSet('EmptyAdapter');
14 return assert_promise_rejects(requestDeviceWithKeyDown(), 14 return assert_promise_rejects(requestDeviceWithKeyDown(),
15 new TypeError()); 15 new TypeError());
16 }, 'Requires an argument.'); 16 }, 'Requires an argument.');
17 17
18 promise_test(() => { 18 promise_test(() => {
19 testRunner.setBluetoothMockDataSet('EmptyAdapter'); 19 testRunner.setBluetoothMockDataSet('EmptyAdapter');
20 return assert_promise_rejects(requestDeviceWithKeyDown({}), 20 return assert_promise_rejects(requestDeviceWithKeyDown({}),
21 new TypeError()); 21 new TypeError());
22 }, 'RequestDeviceOptions requires a |filters| member.'); 22 }, 'RequestDeviceOptions requires a |filters| member.');
23 23
24 // TODO(jyasskin): Add a test that the chooser is informed of a failed discovery
25 // session.
24 promise_test(() => { 26 promise_test(() => {
25 testRunner.setBluetoothMockDataSet('FailStartDiscoveryAdapter'); 27 testRunner.setBluetoothMockDataSet('FailStartDiscoveryAdapter');
26 return assert_promise_rejects_with_message( 28 return assert_promise_rejects_with_message(
27 requestDeviceWithKeyDown({filters: [{services: ['generic_access']}]}), 29 requestDeviceWithKeyDown({filters: [{services: ['generic_access']}]}),
28 {name: 'NotFoundError', message: 'Couldn\'t start discovery session.'}, 30 // TODO(jyasskin): Uncomment the message when it's changed on the Chrome sid e.
31 {name: 'NotFoundError', /*message: 'User cancelled the requestDevice() choos er.'*/},
29 'The adapter failed to start a discovery session.'); 32 'The adapter failed to start a discovery session.');
30 }, 'Discovery session fails to start.'); 33 }, 'Discovery session fails to start.');
31 34
32 promise_test(() => { 35 promise_test(() => {
33 testRunner.setBluetoothMockDataSet('NotPresentAdapter'); 36 testRunner.setBluetoothMockDataSet('NotPresentAdapter');
34 return assert_promise_rejects_with_message( 37 return assert_promise_rejects_with_message(
35 requestDeviceWithKeyDown({filters: [{services: ['generic_access']}]}), 38 requestDeviceWithKeyDown({filters: [{services: ['generic_access']}]}),
36 {name: 'NotFoundError', message: 'Bluetooth adapter not available.'}, 39 {name: 'NotFoundError', message: 'Bluetooth adapter not available.'},
37 'Bluetooth adapter is not present.'); 40 'Bluetooth adapter is not present.');
38 }, 'Reject with NotFoundError if the adapter is not present.'); 41 }, 'Reject with NotFoundError if the adapter is not present.');
39 42
43 // TODO(jyasskin): Add a test that the chooser is informed of a disabled
44 // Bluetooth adapter.
40 promise_test(() => { 45 promise_test(() => {
41 testRunner.setBluetoothMockDataSet('NotPoweredAdapter'); 46 testRunner.setBluetoothMockDataSet('NotPoweredAdapter');
42 return assert_promise_rejects_with_message( 47 return assert_promise_rejects_with_message(
43 requestDeviceWithKeyDown({filters: [{services: ['generic_access']}]}), 48 requestDeviceWithKeyDown({filters: [{services: ['generic_access']}]}),
44 {name: 'NotFoundError', message: 'Bluetooth adapter is off.'}, 49 // TODO(jyasskin): Uncomment the message when it's changed on the Chrome sid e.
50 {name: 'NotFoundError', /*message: 'User cancelled the requestDevice() choos er.'*/},
45 'Bluetooth adapter is not powered.'); 51 'Bluetooth adapter is not powered.');
46 }, 'Reject with NotFoundError if the adapter is off.'); 52 }, 'Reject with NotFoundError if the adapter is off.');
47 53
54 // TODO(jyasskin): Add a test that the chooser gets a full list of found
55 // devices.
48 promise_test(() => { 56 promise_test(() => {
49 testRunner.setBluetoothMockDataSet('EmptyAdapter'); 57 testRunner.setBluetoothMockDataSet('EmptyAdapter');
50 return assert_promise_rejects_with_message( 58 return assert_promise_rejects_with_message(
51 requestDeviceWithKeyDown({filters: [{services: ['generic_access']}]}), 59 requestDeviceWithKeyDown({filters: [{services: ['generic_access']}]}),
52 {name: 'NotFoundError', message: 'No Bluetooth devices in range.'}, 60 // TODO(jyasskin): Uncomment the message when it's changed on the Chrome sid e.
61 {name: 'NotFoundError', /*message: 'User cancelled the requestDevice() choos er.'*/},
53 'No Bluetooth devices in range.'); 62 'No Bluetooth devices in range.');
54 }, 'Reject with NotFoundError if there are no devices around.'); 63 }, 'Reject with NotFoundError if there are no devices around.');
55 64
56 promise_test(() => { 65 promise_test(() => {
57 testRunner.setBluetoothMockDataSet('GenericAccessAdapter'); 66 testRunner.setBluetoothMockDataSet('GenericAccessAdapter');
58 return Promise.all([ 67 return Promise.all([
59 requestDeviceWithKeyDown({filters: [{services: [generic_access.alias]}]}), 68 requestDeviceWithKeyDown({filters: [{services: [generic_access.alias]}]}),
60 requestDeviceWithKeyDown({filters: [{services: [generic_access.name]}]}), 69 requestDeviceWithKeyDown({filters: [{services: [generic_access.name]}]}),
61 requestDeviceWithKeyDown({filters: [{services: [generic_access.uuid]}]}) 70 requestDeviceWithKeyDown({filters: [{services: [generic_access.uuid]}]})
62 ]).then(devices => { 71 ]).then(devices => {
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 promise_test(() => { 148 promise_test(() => {
140 testRunner.setBluetoothMockDataSet('GlucoseHeartRateAdapter'); 149 testRunner.setBluetoothMockDataSet('GlucoseHeartRateAdapter');
141 // Both devices support the Generic Access service, but things need to 150 // Both devices support the Generic Access service, but things need to
142 // support both services to pass the filter, and neither has a Battery 151 // support both services to pass the filter, and neither has a Battery
143 // service. 152 // service.
144 return assert_promise_rejects(requestDeviceWithKeyDown({ 153 return assert_promise_rejects(requestDeviceWithKeyDown({
145 filters: [{services: ['generic_access', 'battery_service']}] 154 filters: [{services: ['generic_access', 'battery_service']}]
146 }), 'NotFoundError'); 155 }), 'NotFoundError');
147 }, 'Too-strict filters do prevent matching.'); 156 }, 'Too-strict filters do prevent matching.');
148 </script> 157 </script>
OLDNEW
« 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