OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <script src="../resources/testharness.js"></script> |
| 3 <script src="../resources/testharnessreport.js"></script> |
| 4 <script src="resources/bluetooth-helpers.js"></script> |
| 5 <script> |
| 6 'use strict'; |
| 7 test(t => { assert_true(window.testRunner instanceof Object); t.done(); }, |
| 8 'window.testRunner is required for the following tests.'); |
| 9 |
| 10 promise_test(() => { |
| 11 testRunner.setBluetoothMockDataSet('HeartRateAdapter'); |
| 12 return requestDeviceWithKeyDown({filters: [{services: ['heart_rate']}]}) |
| 13 .then(device => device.connectGATT()) |
| 14 .then(gattServer => gattServer.getPrimaryService('heart_rate')) |
| 15 .then(service => service.getCharacteristic('heart_rate_measurement')) |
| 16 .then(characteristic => { |
| 17 return characteristic.startNotifications() |
| 18 .then(() => characteristic.stopNotifications()); |
| 19 }); |
| 20 }, 'Single start notifications succeeds.'); |
| 21 |
| 22 |
| 23 promise_test(() => { |
| 24 testRunner.setBluetoothMockDataSet('HeartRateAdapter'); |
| 25 return requestDeviceWithKeyDown({filters: [{services: ['heart_rate']}]}) |
| 26 .then(device => device.connectGATT()) |
| 27 .then(gattServer => gattServer.getPrimaryService('heart_rate')) |
| 28 .then(service => service.getCharacteristic('heart_rate_measurement')) |
| 29 .then(characteristic => { |
| 30 return characteristic.startNotifications().then(() => { |
| 31 return characteristic.startNotifications() |
| 32 .then(() => characteristic.stopNotifications()); |
| 33 }); |
| 34 }); |
| 35 }, 'Start notifications after succesfully starting before.'); |
| 36 |
| 37 promise_test(() => { |
| 38 testRunner.setBluetoothMockDataSet('HeartRateAdapter'); |
| 39 return requestDeviceWithKeyDown({filters: [{services: ['heart_rate']}]}) |
| 40 .then(device => device.connectGATT()) |
| 41 .then(gattServer => gattServer.getPrimaryService('heart_rate')) |
| 42 .then(service => service.getCharacteristic('heart_rate_measurement')) |
| 43 .then(characteristic => { |
| 44 return characteristic.startNotifications() |
| 45 .then(() => characteristic.stopNotifications()) |
| 46 .then(() => characteristic.startNotifications()) |
| 47 .then(() => characteristic.stopNotifications()); |
| 48 }); |
| 49 }, 'Start -> stop -> start -> stop.'); |
| 50 |
| 51 promise_test(() => { |
| 52 testRunner.setBluetoothMockDataSet('HeartRateAdapter'); |
| 53 return requestDeviceWithKeyDown({filters: [{services: ['heart_rate']}]}) |
| 54 .then(device => device.connectGATT()) |
| 55 .then(gattServer => gattServer.getPrimaryService('heart_rate')) |
| 56 .then(service => service.getCharacteristic('heart_rate_measurement')) |
| 57 .then(characteristic => { |
| 58 return Promise.all([characteristic.startNotifications(), |
| 59 characteristic.startNotifications(), |
| 60 characteristic.startNotifications()]) |
| 61 .then(() => characteristic.stopNotifications()); |
| 62 }); |
| 63 }, 'Multiple starts in a row.'); |
| 64 |
| 65 promise_test(() => { |
| 66 testRunner.setBluetoothMockDataSet('HeartRateAdapter'); |
| 67 return requestDeviceWithKeyDown({filters: [{services: ['heart_rate']}]}) |
| 68 .then(device => device.connectGATT()) |
| 69 .then(gattServer => gattServer.getPrimaryService('heart_rate')) |
| 70 .then(service => service.getCharacteristic('heart_rate_measurement')) |
| 71 .then(characteristic => { |
| 72 return Promise.all([characteristic.startNotifications(), |
| 73 characteristic.stopNotifications()]); |
| 74 }); |
| 75 }, "Parallel start and stop."); |
| 76 |
| 77 promise_test(() => { |
| 78 testRunner.setBluetoothMockDataSet('HeartRateAdapter'); |
| 79 return requestDeviceWithKeyDown({filters: [{services: ['heart_rate']}]}) |
| 80 .then(device => device.connectGATT()) |
| 81 .then(gattServer => gattServer.getPrimaryService('heart_rate')) |
| 82 .then(service => service.getCharacteristic('heart_rate_measurement')) |
| 83 .then(characteristic => { |
| 84 return characteristic.startNotifications().then(() => { |
| 85 return Promise.all([characteristic.stopNotifications(), |
| 86 characteristic.stopNotifications()]); |
| 87 }); |
| 88 }); |
| 89 }, "Concurrent stop requests."); |
| 90 |
| 91 promise_test(() => { |
| 92 testRunner.setBluetoothMockDataSet('HeartRateAdapter'); |
| 93 return requestDeviceWithKeyDown({filters: [{services: ['heart_rate']}]}) |
| 94 .then(device => device.connectGATT()) |
| 95 .then(gattServer => gattServer.getPrimaryService('heart_rate')) |
| 96 .then(service => service.getCharacteristic('heart_rate_measurement')) |
| 97 .then(characteristic => { |
| 98 return characteristic.startNotifications() |
| 99 .then(() => characteristic.stopNotifications()) |
| 100 .then(() => characteristic.stopNotifications()); |
| 101 }); |
| 102 }, "Stopping twice."); |
| 103 |
| 104 promise_test(() => { |
| 105 testRunner.setBluetoothMockDataSet('HeartRateAdapter'); |
| 106 return requestDeviceWithKeyDown({filters: [{services: ['heart_rate']}]}) |
| 107 .then(device => device.connectGATT()) |
| 108 .then(gattServer => gattServer.getPrimaryService('heart_rate')) |
| 109 .then(service => service.getCharacteristic('heart_rate_measurement')) |
| 110 .then(characteristic => { |
| 111 return characteristic.startNotifications().then(() => { |
| 112 return Promise.all([characteristic.stopNotifications(), |
| 113 characteristic.startNotifications()]); |
| 114 }).then(() => characteristic.stopNotifications()); |
| 115 }); |
| 116 }, "Start request before stop request resolves"); |
| 117 |
| 118 promise_test(() => { |
| 119 testRunner.setBluetoothMockDataSet('HeartRateAdapter'); |
| 120 return requestDeviceWithKeyDown({filters: [{services: ['heart_rate']}]}) |
| 121 .then(device => device.connectGATT()) |
| 122 .then(gattServer => gattServer.getPrimaryService('heart_rate')) |
| 123 .then(service => service.getCharacteristic('heart_rate_measurement')) |
| 124 .then(characteristic => characteristic.stopNotifications()); |
| 125 }, "Stop without starting."); |
| 126 </script> |
OLD | NEW |