| 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> | |
| 4 <script src="../resources/testharnessreport.js"></script> | 3 <script src="../resources/testharnessreport.js"></script> |
| 5 <script src="resources/bluetooth-helpers.js"></script> | 4 <script src="resources/bluetooth-helpers.js"></script> |
| 6 <script> | 5 <script> |
| 7 'use strict'; | 6 'use strict'; |
| 8 | 7 |
| 9 test(t => { assert_true(window.testRunner instanceof Object); t.done(); }, | 8 test(t => { assert_true(window.testRunner instanceof Object); t.done(); }, |
| 10 'window.testRunner is required for the following tests.'); | 9 'window.testRunner is required for the following tests.'); |
| 11 | 10 |
| 12 sequential_promise_test(() => { | 11 promise_test(() => { |
| 13 testRunner.setBluetoothMockDataSet('GenericAccessAdapter'); | 12 testRunner.setBluetoothMockDataSet('GenericAccessAdapter'); |
| 14 return requestDeviceWithKeyDown({filters: [{services: ['generic_access']}]}) | 13 return requestDeviceWithKeyDown({filters: [{services: ['generic_access']}]}) |
| 15 .then(device => { | 14 .then(device => { |
| 16 testRunner.setBluetoothMockDataSet('EmptyAdapter'); | 15 testRunner.setBluetoothMockDataSet('EmptyAdapter'); |
| 17 return assert_promise_rejects_with_message( | 16 return assert_promise_rejects_with_message( |
| 18 device.connectGATT(),{ | 17 device.connectGATT(),{ |
| 19 name: 'NetworkError', | 18 name: 'NetworkError', |
| 20 message: 'Bluetooth Device is no longer in range.' | 19 message: 'Bluetooth Device is no longer in range.' |
| 21 }, 'Device went out of range.'); | 20 }, 'Device went out of range.'); |
| 22 }); | 21 }); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 message: 'Authentication timeout.' | 79 message: 'Authentication timeout.' |
| 81 } | 80 } |
| 82 }, { | 81 }, { |
| 83 testName: 'Tried to connect to an unsupported device.', | 82 testName: 'Tried to connect to an unsupported device.', |
| 84 uuid: errorUUID(0x7), | 83 uuid: errorUUID(0x7), |
| 85 error: { | 84 error: { |
| 86 name: 'NetworkError', | 85 name: 'NetworkError', |
| 87 message: 'Unsupported device.' | 86 message: 'Unsupported device.' |
| 88 } | 87 } |
| 89 }].forEach(testSpec => { | 88 }].forEach(testSpec => { |
| 90 sequential_promise_test(() => { | 89 promise_test(() => { |
| 91 testRunner.setBluetoothMockDataSet('FailingConnectionsAdapter'); | 90 testRunner.setBluetoothMockDataSet('FailingConnectionsAdapter'); |
| 92 return requestDeviceWithKeyDown({filters: [{services: [testSpec.uuid]}]}) | 91 return requestDeviceWithKeyDown({filters: [{services: [testSpec.uuid]}]}) |
| 93 .then(device => { | 92 .then(device => { |
| 94 assert_promise_rejects_with_message( | 93 assert_promise_rejects_with_message( |
| 95 device.connectGATT(), | 94 device.connectGATT(), |
| 96 testSpec.error, | 95 testSpec.error, |
| 97 'Adapter failed to connect to device.'); | 96 'Adapter failed to connect to device.'); |
| 98 }); | 97 }); |
| 99 }, testSpec.testName); | 98 }, testSpec.testName); |
| 100 }); | 99 }); |
| 101 | 100 |
| 102 sequential_promise_test(() => { | 101 promise_test(() => { |
| 103 testRunner.setBluetoothMockDataSet('GenericAccessAdapter'); | 102 testRunner.setBluetoothMockDataSet('GenericAccessAdapter'); |
| 104 return requestDeviceWithKeyDown({filters: [{services: ['generic_access']}]}) | 103 return requestDeviceWithKeyDown({filters: [{services: ['generic_access']}]}) |
| 105 .then(device => device.connectGATT()) | 104 .then(device => device.connectGATT()) |
| 106 .then(gattServer => assert_true(gattServer.connected)); | 105 .then(gattServer => assert_true(gattServer.connected)); |
| 107 }, 'Device will connect'); | 106 }, 'Device will connect'); |
| 108 </script> | 107 </script> |
| OLD | NEW |