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

Side by Side Diff: third_party/WebKit/LayoutTests/resources/bluetooth/bluetooth-helpers.js

Issue 1991063002: Implement the gattserverdisconnected event. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@rename-web-bluetooth-device
Patch Set: Created 4 years, 7 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
1 'use strict'; 1 'use strict';
2 2
3 // Bluetooth UUID constants: 3 // Bluetooth UUID constants:
4 // Services: 4 // Services:
5 var blacklist_test_service_uuid = "611c954a-263b-4f4a-aab6-01ddb953f985"; 5 var blacklist_test_service_uuid = "611c954a-263b-4f4a-aab6-01ddb953f985";
6 var request_disconnection_service_uuid = "01d7d889-7451-419f-aeb8-d65e7b9277af";
6 // Characteristics: 7 // Characteristics:
7 var blacklist_exclude_reads_characteristic_uuid = 8 var blacklist_exclude_reads_characteristic_uuid =
8 "bad1c9a2-9a5b-4015-8b60-1579bbbf2135"; 9 "bad1c9a2-9a5b-4015-8b60-1579bbbf2135";
9 10
10 // Sometimes we need to test that using either the name, alias, or UUID 11 // Sometimes we need to test that using either the name, alias, or UUID
11 // produces the same result. The following objects help us do that. 12 // produces the same result. The following objects help us do that.
12 var generic_access = { 13 var generic_access = {
13 alias: 0x1800, 14 alias: 0x1800,
14 name: 'generic_access', 15 name: 'generic_access',
15 uuid: '00001800-0000-1000-8000-00805f9b34fb' 16 uuid: '00001800-0000-1000-8000-00805f9b34fb'
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 function runGarbageCollection() 210 function runGarbageCollection()
210 { 211 {
211 // Run gc() as a promise. 212 // Run gc() as a promise.
212 return new Promise( 213 return new Promise(
213 function(resolve, reject) { 214 function(resolve, reject) {
214 GCController.collect(); 215 GCController.collect();
215 setTimeout(resolve, 0); 216 setTimeout(resolve, 0);
216 }); 217 });
217 } 218 }
218 219
220 function eventPromise(target, type, options) {
221 return new Promise(resolve => {
222 let wrapper = function(event) {
223 target.removeEventListener(type, wrapper);
224 resolve(event);
225 };
226 target.addEventListener(type, wrapper, options);
227 });
228 }
229
219 // Creates |num_listeners| promises. Each adds an event listener 230 // Creates |num_listeners| promises. Each adds an event listener
220 // to object. The promises resolve once the object fires |event| but 231 // to object. The promises resolve once the object fires |event| but
221 // reject if the event is fired before |object|.|func|() resolves. 232 // reject if the event is fired before |object|.|func|() resolves.
222 // Returns a promise that fulfills with the result of |object|.|func()| 233 // Returns a promise that fulfills with the result of |object|.|func()|
223 // and |event.target.value| of each of the other promises. 234 // and |event.target.value| of each of the other promises.
224 function assert_event_fires_after_promise(object, func, event, num_listeners) { 235 function assert_event_fires_after_promise(object, func, event, num_listeners) {
225 num_listeners = num_listeners !== undefined ? num_listeners : 1; 236 num_listeners = num_listeners !== undefined ? num_listeners : 1;
226 237
227 if (object[func] === undefined) { 238 if (object[func] === undefined) {
228 return Promise.reject('Function \'' + func + '\' not available in object.'); 239 return Promise.reject('Function \'' + func + '\' not available in object.');
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 } 341 }
331 342
332 // Bluetooth tests sometimes have left-over state that could leak into the 343 // Bluetooth tests sometimes have left-over state that could leak into the
333 // next test. add_result_callback which is exposed by testharness.js allows us 344 // next test. add_result_callback which is exposed by testharness.js allows us
334 // to clean up this state after each test. Once the move to Mojo is complete 345 // to clean up this state after each test. Once the move to Mojo is complete
335 // we will no longer need to clean up the state manually. 346 // we will no longer need to clean up the state manually.
336 // https://crbug.com/508771 347 // https://crbug.com/508771
337 add_result_callback(() => { 348 add_result_callback(() => {
338 setBluetoothFakeAdapter(''); 349 setBluetoothFakeAdapter('');
339 }); 350 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698