| 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>
|
|
|