| OLD | NEW |
| 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 | 24 // TODO(jyasskin): Add a test that the chooser is informed of a failed discovery |
| 25 // session. | 25 // session. |
| 26 promise_test(() => { | 26 promise_test(() => { |
| 27 testRunner.setBluetoothMockDataSet('FailStartDiscoveryAdapter'); | 27 testRunner.setBluetoothMockDataSet('FailStartDiscoveryAdapter'); |
| 28 return assert_promise_rejects_with_message( | 28 return assert_promise_rejects_with_message( |
| 29 requestDeviceWithKeyDown({filters: [{services: ['generic_access']}]}), | 29 requestDeviceWithKeyDown({filters: [{services: ['generic_access']}]}), |
| 30 // TODO(jyasskin): Uncomment the message when it's changed on the Chrome sid
e. | 30 {name: 'NotFoundError', message: 'User cancelled the requestDevice() chooser
.'}, |
| 31 {name: 'NotFoundError', /*message: 'User cancelled the requestDevice() choos
er.'*/}, | |
| 32 'The adapter failed to start a discovery session.'); | 31 'The adapter failed to start a discovery session.'); |
| 33 }, 'Discovery session fails to start.'); | 32 }, 'Discovery session fails to start.'); |
| 34 | 33 |
| 35 promise_test(() => { | 34 promise_test(() => { |
| 36 testRunner.setBluetoothMockDataSet('NotPresentAdapter'); | 35 testRunner.setBluetoothMockDataSet('NotPresentAdapter'); |
| 37 return assert_promise_rejects_with_message( | 36 return assert_promise_rejects_with_message( |
| 38 requestDeviceWithKeyDown({filters: [{services: ['generic_access']}]}), | 37 requestDeviceWithKeyDown({filters: [{services: ['generic_access']}]}), |
| 39 {name: 'NotFoundError', message: 'Bluetooth adapter not available.'}, | 38 {name: 'NotFoundError', message: 'Bluetooth adapter not available.'}, |
| 40 'Bluetooth adapter is not present.'); | 39 'Bluetooth adapter is not present.'); |
| 41 }, 'Reject with NotFoundError if the adapter is not present.'); | 40 }, 'Reject with NotFoundError if the adapter is not present.'); |
| 42 | 41 |
| 43 // TODO(jyasskin): Add a test that the chooser is informed of a disabled | 42 // TODO(jyasskin): Add a test that the chooser is informed of a disabled |
| 44 // Bluetooth adapter. | 43 // Bluetooth adapter. |
| 45 promise_test(() => { | 44 promise_test(() => { |
| 46 testRunner.setBluetoothMockDataSet('NotPoweredAdapter'); | 45 testRunner.setBluetoothMockDataSet('NotPoweredAdapter'); |
| 47 return assert_promise_rejects_with_message( | 46 return assert_promise_rejects_with_message( |
| 48 requestDeviceWithKeyDown({filters: [{services: ['generic_access']}]}), | 47 requestDeviceWithKeyDown({filters: [{services: ['generic_access']}]}), |
| 49 // TODO(jyasskin): Uncomment the message when it's changed on the Chrome sid
e. | 48 {name: 'NotFoundError', message: 'User cancelled the requestDevice() chooser
.'}, |
| 50 {name: 'NotFoundError', /*message: 'User cancelled the requestDevice() choos
er.'*/}, | |
| 51 'Bluetooth adapter is not powered.'); | 49 'Bluetooth adapter is not powered.'); |
| 52 }, 'Reject with NotFoundError if the adapter is off.'); | 50 }, 'Reject with NotFoundError if the adapter is off.'); |
| 53 | 51 |
| 54 // TODO(jyasskin): Add a test that the chooser gets a full list of found | 52 // TODO(jyasskin): Add a test that the chooser gets a full list of found |
| 55 // devices. | 53 // devices. |
| 56 promise_test(() => { | 54 promise_test(() => { |
| 57 testRunner.setBluetoothMockDataSet('EmptyAdapter'); | 55 testRunner.setBluetoothMockDataSet('EmptyAdapter'); |
| 58 return assert_promise_rejects_with_message( | 56 return assert_promise_rejects_with_message( |
| 59 requestDeviceWithKeyDown({filters: [{services: ['generic_access']}]}), | 57 requestDeviceWithKeyDown({filters: [{services: ['generic_access']}]}), |
| 60 // TODO(jyasskin): Uncomment the message when it's changed on the Chrome sid
e. | 58 {name: 'NotFoundError', message: 'User cancelled the requestDevice() chooser
.'}, |
| 61 {name: 'NotFoundError', /*message: 'User cancelled the requestDevice() choos
er.'*/}, | |
| 62 'No Bluetooth devices in range.'); | 59 'No Bluetooth devices in range.'); |
| 63 }, 'Reject with NotFoundError if there are no devices around.'); | 60 }, 'Reject with NotFoundError if there are no devices around.'); |
| 64 | 61 |
| 65 promise_test(() => { | 62 promise_test(() => { |
| 66 testRunner.setBluetoothMockDataSet('GenericAccessAdapter'); | 63 testRunner.setBluetoothMockDataSet('GenericAccessAdapter'); |
| 67 return Promise.all([ | 64 return Promise.all([ |
| 68 requestDeviceWithKeyDown({filters: [{services: [generic_access.alias]}]}), | 65 requestDeviceWithKeyDown({filters: [{services: [generic_access.alias]}]}), |
| 69 requestDeviceWithKeyDown({filters: [{services: [generic_access.name]}]}), | 66 requestDeviceWithKeyDown({filters: [{services: [generic_access.name]}]}), |
| 70 requestDeviceWithKeyDown({filters: [{services: [generic_access.uuid]}]}) | 67 requestDeviceWithKeyDown({filters: [{services: [generic_access.uuid]}]}) |
| 71 ]).then(devices => { | 68 ]).then(devices => { |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 promise_test(() => { | 145 promise_test(() => { |
| 149 testRunner.setBluetoothMockDataSet('GlucoseHeartRateAdapter'); | 146 testRunner.setBluetoothMockDataSet('GlucoseHeartRateAdapter'); |
| 150 // Both devices support the Generic Access service, but things need to | 147 // Both devices support the Generic Access service, but things need to |
| 151 // support both services to pass the filter, and neither has a Battery | 148 // support both services to pass the filter, and neither has a Battery |
| 152 // service. | 149 // service. |
| 153 return assert_promise_rejects(requestDeviceWithKeyDown({ | 150 return assert_promise_rejects(requestDeviceWithKeyDown({ |
| 154 filters: [{services: ['generic_access', 'battery_service']}] | 151 filters: [{services: ['generic_access', 'battery_service']}] |
| 155 }), 'NotFoundError'); | 152 }), 'NotFoundError'); |
| 156 }, 'Too-strict filters do prevent matching.'); | 153 }, 'Too-strict filters do prevent matching.'); |
| 157 </script> | 154 </script> |
| OLD | NEW |