Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(411)

Unified Diff: third_party/WebKit/LayoutTests/bluetooth/notifications.html

Issue 1334763002: bluetooth: Subscribe to notifications (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bluetooth-origin
Patch Set: Fix global interface test Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..06950dc640f3ea7015f81a974b9dbd48322beffd
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/bluetooth/notifications.html
@@ -0,0 +1,159 @@
+<!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');
+ let start_promise;
+ 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 => {
+ start_promise = characteristic.startNotifications();
+ // We itentionally don't return the promise so that 'characteristic' goes
+ // out of scope while the request is still pending.
+ }).then(() => runGarbageCollection())
+ .then(() => start_promise);
+}, 'Object gets garbage collected while start request is pending.');
+
+promise_test(() => {
+ testRunner.setBluetoothMockDataSet('HeartRateAdapter');
+ let stop_promise;
+ 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(() => {
+ stop_promise = characteristic.stopNotifications();
+ // We itentionally don't return the promise so that 'characteristic' goes
+ // out of scope while the request is still pending.
+ });
+ }).then(() => runGarbageCollection())
+ .then(() => stop_promise);
+}, 'Object gets garbage collected while stop request is pending.');
+
+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(() => runGarbageCollection());
+}, '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());
+ });
+ }).then(() => runGarbageCollection());
+}, '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());
+ }).then(() => runGarbageCollection());
+}, '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());
+ }).then(() => runGarbageCollection());
+}, '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()]);
+ }).then(() => runGarbageCollection());
+}, "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()]);
+ });
+ }).then(() => runGarbageCollection());
+}, "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());
+ }).then(() => runGarbageCollection());
+}, "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());
+ }).then(() => runGarbageCollection());
+}, "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())
+ .then(() => runGarbageCollection());
+}, "Stop without starting.");
+</script>

Powered by Google App Engine
This is Rietveld 408576698