Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/bluetooth/notifications.html |
| diff --git a/third_party/WebKit/LayoutTests/bluetooth/notifications.html b/third_party/WebKit/LayoutTests/bluetooth/notifications.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..dc9052533e9684bedf81eeee24f62f654f102cd4 |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/bluetooth/notifications.html |
| @@ -0,0 +1,126 @@ |
| +<!DOCTYPE html> |
| +<script src="../resources/testharness.js"></script> |
| +<script src="../resources/testharnessreport.js"></script> |
| +<script src="resources/bluetooth-helpers.js"></script> |
| +<script> |
| +'use strict'; |
| +test(t => { assert_true(window.testRunner instanceof Object); t.done(); }, |
| + 'window.testRunner is required for the following tests.'); |
| + |
| +promise_test(() => { |
| + testRunner.setBluetoothMockDataSet('HeartRateAdapter'); |
| + return requestDeviceWithKeyDown({filters: [{services: ['heart_rate']}]}) |
| + .then(device => device.connectGATT()) |
| + .then(gattServer => gattServer.getPrimaryService('heart_rate')) |
| + .then(service => service.getCharacteristic('heart_rate_measurement')) |
| + .then(characteristic => { |
| + return characteristic.startNotifications() |
| + .then(() => characteristic.stopNotifications()); |
| + }); |
| +}, 'Single start notifications succeeds.'); |
| + |
| + |
| +promise_test(() => { |
| + testRunner.setBluetoothMockDataSet('HeartRateAdapter'); |
| + return requestDeviceWithKeyDown({filters: [{services: ['heart_rate']}]}) |
| + .then(device => device.connectGATT()) |
| + .then(gattServer => gattServer.getPrimaryService('heart_rate')) |
| + .then(service => service.getCharacteristic('heart_rate_measurement')) |
| + .then(characteristic => { |
| + return characteristic.startNotifications().then(() => { |
| + return characteristic.startNotifications() |
| + .then(() => characteristic.stopNotifications()); |
| + }); |
| + }); |
| +}, 'Start notifications after succesfully starting before.'); |
| + |
| +promise_test(() => { |
| + testRunner.setBluetoothMockDataSet('HeartRateAdapter'); |
| + return requestDeviceWithKeyDown({filters: [{services: ['heart_rate']}]}) |
| + .then(device => device.connectGATT()) |
| + .then(gattServer => gattServer.getPrimaryService('heart_rate')) |
| + .then(service => service.getCharacteristic('heart_rate_measurement')) |
| + .then(characteristic => { |
| + return characteristic.startNotifications() |
| + .then(() => characteristic.stopNotifications()) |
| + .then(() => characteristic.startNotifications()) |
| + .then(() => characteristic.stopNotifications()); |
| + }); |
| +}, 'Start -> stop -> start -> stop.'); |
| + |
| +promise_test(() => { |
| + testRunner.setBluetoothMockDataSet('HeartRateAdapter'); |
| + return requestDeviceWithKeyDown({filters: [{services: ['heart_rate']}]}) |
| + .then(device => device.connectGATT()) |
| + .then(gattServer => gattServer.getPrimaryService('heart_rate')) |
| + .then(service => service.getCharacteristic('heart_rate_measurement')) |
| + .then(characteristic => { |
| + return Promise.all([characteristic.startNotifications(), |
| + characteristic.startNotifications(), |
| + characteristic.startNotifications()]) |
| + .then(() => characteristic.stopNotifications()); |
| + }); |
| +}, 'Multiple starts in a row.'); |
| + |
| +promise_test(() => { |
| + testRunner.setBluetoothMockDataSet('HeartRateAdapter'); |
| + return requestDeviceWithKeyDown({filters: [{services: ['heart_rate']}]}) |
| + .then(device => device.connectGATT()) |
| + .then(gattServer => gattServer.getPrimaryService('heart_rate')) |
| + .then(service => service.getCharacteristic('heart_rate_measurement')) |
| + .then(characteristic => { |
| + return Promise.all([characteristic.startNotifications(), |
| + characteristic.stopNotifications()]); |
| + }); |
| +}, "Parallel start and stop."); |
| + |
| +promise_test(() => { |
| + testRunner.setBluetoothMockDataSet('HeartRateAdapter'); |
| + return requestDeviceWithKeyDown({filters: [{services: ['heart_rate']}]}) |
| + .then(device => device.connectGATT()) |
| + .then(gattServer => gattServer.getPrimaryService('heart_rate')) |
| + .then(service => service.getCharacteristic('heart_rate_measurement')) |
| + .then(characteristic => { |
| + return characteristic.startNotifications().then(() => { |
| + return Promise.all([characteristic.stopNotifications(), |
| + characteristic.stopNotifications()]); |
| + }); |
| + }); |
| +}, "Concurrent stop requests."); |
| + |
| +promise_test(() => { |
| + testRunner.setBluetoothMockDataSet('HeartRateAdapter'); |
| + return requestDeviceWithKeyDown({filters: [{services: ['heart_rate']}]}) |
| + .then(device => device.connectGATT()) |
| + .then(gattServer => gattServer.getPrimaryService('heart_rate')) |
| + .then(service => service.getCharacteristic('heart_rate_measurement')) |
| + .then(characteristic => { |
| + return characteristic.startNotifications() |
| + .then(() => characteristic.stopNotifications()) |
| + .then(() => characteristic.stopNotifications()); |
| + }); |
| +}, "Stopping twice."); |
| + |
| +promise_test(() => { |
| + testRunner.setBluetoothMockDataSet('HeartRateAdapter'); |
| + return requestDeviceWithKeyDown({filters: [{services: ['heart_rate']}]}) |
| + .then(device => device.connectGATT()) |
| + .then(gattServer => gattServer.getPrimaryService('heart_rate')) |
| + .then(service => service.getCharacteristic('heart_rate_measurement')) |
| + .then(characteristic => { |
| + return characteristic.startNotifications().then(() => { |
| + return Promise.all([characteristic.stopNotifications(), |
| + characteristic.startNotifications()]); |
| + }).then(() => characteristic.stopNotifications()); |
| + }); |
| +}, "Start request before stop request resolves"); |
| + |
| +promise_test(() => { |
| + testRunner.setBluetoothMockDataSet('HeartRateAdapter'); |
| + return requestDeviceWithKeyDown({filters: [{services: ['heart_rate']}]}) |
| + .then(device => device.connectGATT()) |
| + .then(gattServer => gattServer.getPrimaryService('heart_rate')) |
| + .then(service => service.getCharacteristic('heart_rate_measurement')) |
| + .then(characteristic => characteristic.stopNotifications()); |
| +}, "Stop without starting."); |
| +</script> |
|
scheib
2015/10/01 22:05:23
No tests here for object deletion. Can it be accom
ortuno
2015/10/03 04:03:04
I checked battery, geolocation, midi, web sockets,
scheib
2015/10/04 01:39:05
I'd feel better if we have an issue for this and a
ortuno
2015/10/06 02:38:43
Done. Added GC tests.
scheib
2015/10/06 05:35:24
YAY. So... I'm not 100% on when we think the chara
ortuno
2015/10/06 17:14:42
Added another test for a stop request pending. htt
|