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

Side by Side Diff: third_party/WebKit/LayoutTests/bluetooth/characteristicvaluechanged.html

Issue 1858103004: bluetooth: Separate notification tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bluetooth-mojo-notifications
Patch Set: Merge Created 4 years, 8 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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/bluetooth/notifications/add-listener-after-promise.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <script src="../resources/testharness.js"></script> 2 <script src="../resources/testharness.js"></script>
3 <script src="../resources/testharnessreport.js"></script> 3 <script src="../resources/testharnessreport.js"></script>
4 <script src="../resources/bluetooth/bluetooth-helpers.js"></script> 4 <script src="../resources/bluetooth/bluetooth-helpers.js"></script>
5 <script> 5 <script>
6 'use strict'; 6 'use strict';
7 test(t => { assert_true(window.testRunner instanceof Object); t.done(); }, 7 test(t => { assert_true(window.testRunner instanceof Object); t.done(); },
8 'window.testRunner is required for the following tests.'); 8 'window.testRunner is required for the following tests.');
9 9
10 // WebBluetoothServiceImpl is in charge of sending characteristicvaluechanged 10 // WebBluetoothServiceImpl is in charge of sending characteristicvaluechanged
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 // TODO(ortuno): The DataView used to resolve the promise 57 // TODO(ortuno): The DataView used to resolve the promise
58 // should be the same DataView as the one saved in the 58 // should be the same DataView as the one saved in the
59 // characteristic. 59 // characteristic.
60 // http://crbug.com/543347 60 // http://crbug.com/543347
61 // assert_equals(event.target.value, value); 61 // assert_equals(event.target.value, value);
62 assert_array_equals(event_value, read_value); 62 assert_array_equals(event_value, read_value);
63 } 63 }
64 }); 64 });
65 }, 'Add multiple event listeners then readValue().'); 65 }, 'Add multiple event listeners then readValue().');
66 } 66 }
67
68 promise_test(() => {
69 let char;
70 return setBluetoothFakeAdapter('HeartRateAdapter')
71 .then(() => requestDeviceWithKeyDown({
72 filters: [{services: ['heart_rate']}]}))
73 .then(device => device.gatt.connect())
74 .then(gattServer => gattServer.getPrimaryService('heart_rate'))
75 .then(service => service.getCharacteristic('heart_rate_measurement'))
76 .then(characteristic => {
77 char = characteristic;
78 return assert_event_fires_after_promise(characteristic,
79 'startNotifications',
80 'characteristicvaluechanged');
81 })
82 .then(() => char.stopNotifications())
83 .then(() => assert_no_events(char, 'characteristicvaluechanged'));
84 }, 'Starting notifications should fire an event.');
85
86 promise_test(() => {
87 let char;
88 return setBluetoothFakeAdapter('HeartRateAdapter')
89 .then(() => requestDeviceWithKeyDown({
90 filters: [{services: ['heart_rate']}]}))
91 .then(device => device.gatt.connect())
92 .then(gattServer => gattServer.getPrimaryService('heart_rate'))
93 .then(service => service.getCharacteristic('heart_rate_measurement'))
94 .then(characteristic => {
95 char = characteristic;
96 return characteristic.startNotifications()
97 .then(() => new Promise(resolve => {
98 let event_listener = e => {
99 characteristic.removeEventListener('characteristicvaluechanged',
100 event_listener);
101 resolve();
102 };
103 characteristic.addEventListener('characteristicvaluechanged',
104 event_listener);
105 }));
106 })
107 .then(() => char.stopNotifications())
108 .then(() => assert_no_events(char, 'characteristicvaluechanged'));
109 }, 'Registering after the promise resolves shouldn\'t result in events ' +
110 'getting dropped.');
111
112 promise_test(() => {
113 let char;
114 return setBluetoothFakeAdapter('HeartRateAdapter')
115 .then(() => requestDeviceWithKeyDown({
116 filters: [{services: ['heart_rate']}]}))
117 .then(device => device.gatt.connect())
118 .then(gattServer => gattServer.getPrimaryService('heart_rate'))
119 .then(service => service.getCharacteristic('heart_rate_measurement'))
120 .then(characteristic => {
121 char = characteristic;
122 return assert_event_fires_after_promise(characteristic,
123 'startNotifications',
124 'characteristicvaluechanged',
125 3 /* add 3 listeners */);
126 })
127 .then(() => char.stopNotifications())
128 .then(() => assert_no_events(char, 'characteristicvaluechanged'));
129 }, 'Add multiple event listeners then startNotifications().');
130 </script> 67 </script>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/bluetooth/notifications/add-listener-after-promise.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698