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

Side by Side 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 unified diff | Download patch
OLDNEW
(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 let start_promise;
13 return requestDeviceWithKeyDown({filters: [{services: ['heart_rate']}]})
14 .then(device => device.connectGATT())
15 .then(gattServer => gattServer.getPrimaryService('heart_rate'))
16 .then(service => service.getCharacteristic('heart_rate_measurement'))
17 .then(characteristic => {
18 start_promise = characteristic.startNotifications();
19 // We itentionally don't return the promise so that 'characteristic' goes
20 // out of scope while the request is still pending.
21 }).then(() => runGarbageCollection())
22 .then(() => start_promise);
23 }, 'Object gets garbage collected while start request is pending.');
24
25 promise_test(() => {
26 testRunner.setBluetoothMockDataSet('HeartRateAdapter');
27 let stop_promise;
28 return requestDeviceWithKeyDown({filters: [{services: ['heart_rate']}]})
29 .then(device => device.connectGATT())
30 .then(gattServer => gattServer.getPrimaryService('heart_rate'))
31 .then(service => service.getCharacteristic('heart_rate_measurement'))
32 .then(characteristic => {
33 return characteristic.startNotifications().then(() => {
34 stop_promise = characteristic.stopNotifications();
35 // We itentionally don't return the promise so that 'characteristic' goes
36 // out of scope while the request is still pending.
37 });
38 }).then(() => runGarbageCollection())
39 .then(() => stop_promise);
40 }, 'Object gets garbage collected while stop request is pending.');
41
42 promise_test(() => {
43 testRunner.setBluetoothMockDataSet('HeartRateAdapter');
44 return requestDeviceWithKeyDown({filters: [{services: ['heart_rate']}]})
45 .then(device => device.connectGATT())
46 .then(gattServer => gattServer.getPrimaryService('heart_rate'))
47 .then(service => service.getCharacteristic('heart_rate_measurement'))
48 .then(characteristic => {
49 return characteristic.startNotifications()
50 .then(() => characteristic.stopNotifications());
51 }).then(() => runGarbageCollection());
52 }, 'Single start notifications succeeds.');
53
54
55 promise_test(() => {
56 testRunner.setBluetoothMockDataSet('HeartRateAdapter');
57 return requestDeviceWithKeyDown({filters: [{services: ['heart_rate']}]})
58 .then(device => device.connectGATT())
59 .then(gattServer => gattServer.getPrimaryService('heart_rate'))
60 .then(service => service.getCharacteristic('heart_rate_measurement'))
61 .then(characteristic => {
62 return characteristic.startNotifications().then(() => {
63 return characteristic.startNotifications()
64 .then(() => characteristic.stopNotifications());
65 });
66 }).then(() => runGarbageCollection());
67 }, 'Start notifications after succesfully starting before.');
68
69 promise_test(() => {
70 testRunner.setBluetoothMockDataSet('HeartRateAdapter');
71 return requestDeviceWithKeyDown({filters: [{services: ['heart_rate']}]})
72 .then(device => device.connectGATT())
73 .then(gattServer => gattServer.getPrimaryService('heart_rate'))
74 .then(service => service.getCharacteristic('heart_rate_measurement'))
75 .then(characteristic => {
76 return characteristic.startNotifications()
77 .then(() => characteristic.stopNotifications())
78 .then(() => characteristic.startNotifications())
79 .then(() => characteristic.stopNotifications());
80 }).then(() => runGarbageCollection());
81 }, 'Start -> stop -> start -> stop.');
82
83 promise_test(() => {
84 testRunner.setBluetoothMockDataSet('HeartRateAdapter');
85 return requestDeviceWithKeyDown({filters: [{services: ['heart_rate']}]})
86 .then(device => device.connectGATT())
87 .then(gattServer => gattServer.getPrimaryService('heart_rate'))
88 .then(service => service.getCharacteristic('heart_rate_measurement'))
89 .then(characteristic => {
90 return Promise.all([characteristic.startNotifications(),
91 characteristic.startNotifications(),
92 characteristic.startNotifications()])
93 .then(() => characteristic.stopNotifications());
94 }).then(() => runGarbageCollection());
95 }, 'Multiple starts in a row.');
96
97 promise_test(() => {
98 testRunner.setBluetoothMockDataSet('HeartRateAdapter');
99 return requestDeviceWithKeyDown({filters: [{services: ['heart_rate']}]})
100 .then(device => device.connectGATT())
101 .then(gattServer => gattServer.getPrimaryService('heart_rate'))
102 .then(service => service.getCharacteristic('heart_rate_measurement'))
103 .then(characteristic => {
104 return Promise.all([characteristic.startNotifications(),
105 characteristic.stopNotifications()]);
106 }).then(() => runGarbageCollection());
107 }, "Parallel start and stop.");
108
109 promise_test(() => {
110 testRunner.setBluetoothMockDataSet('HeartRateAdapter');
111 return requestDeviceWithKeyDown({filters: [{services: ['heart_rate']}]})
112 .then(device => device.connectGATT())
113 .then(gattServer => gattServer.getPrimaryService('heart_rate'))
114 .then(service => service.getCharacteristic('heart_rate_measurement'))
115 .then(characteristic => {
116 return characteristic.startNotifications().then(() => {
117 return Promise.all([characteristic.stopNotifications(),
118 characteristic.stopNotifications()]);
119 });
120 }).then(() => runGarbageCollection());
121 }, "Concurrent stop requests.");
122
123 promise_test(() => {
124 testRunner.setBluetoothMockDataSet('HeartRateAdapter');
125 return requestDeviceWithKeyDown({filters: [{services: ['heart_rate']}]})
126 .then(device => device.connectGATT())
127 .then(gattServer => gattServer.getPrimaryService('heart_rate'))
128 .then(service => service.getCharacteristic('heart_rate_measurement'))
129 .then(characteristic => {
130 return characteristic.startNotifications()
131 .then(() => characteristic.stopNotifications())
132 .then(() => characteristic.stopNotifications());
133 }).then(() => runGarbageCollection());
134 }, "Stopping twice.");
135
136 promise_test(() => {
137 testRunner.setBluetoothMockDataSet('HeartRateAdapter');
138 return requestDeviceWithKeyDown({filters: [{services: ['heart_rate']}]})
139 .then(device => device.connectGATT())
140 .then(gattServer => gattServer.getPrimaryService('heart_rate'))
141 .then(service => service.getCharacteristic('heart_rate_measurement'))
142 .then(characteristic => {
143 return characteristic.startNotifications().then(() => {
144 return Promise.all([characteristic.stopNotifications(),
145 characteristic.startNotifications()]);
146 }).then(() => characteristic.stopNotifications());
147 }).then(() => runGarbageCollection());
148 }, "Start request before stop request resolves");
149
150 promise_test(() => {
151 testRunner.setBluetoothMockDataSet('HeartRateAdapter');
152 return requestDeviceWithKeyDown({filters: [{services: ['heart_rate']}]})
153 .then(device => device.connectGATT())
154 .then(gattServer => gattServer.getPrimaryService('heart_rate'))
155 .then(service => service.getCharacteristic('heart_rate_measurement'))
156 .then(characteristic => characteristic.stopNotifications())
157 .then(() => runGarbageCollection());
158 }, "Stop without starting.");
159 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698