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

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

Issue 1910933002: bluetooth: Separate requestDevice tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bluetooth-mojo-gatt-connect
Patch Set: Merge 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 // Characteristics: 6 // Characteristics:
7 var blacklist_exclude_reads_characteristic_uuid = 7 var blacklist_exclude_reads_characteristic_uuid =
8 "bad1c9a2-9a5b-4015-8b60-1579bbbf2135"; 8 "bad1c9a2-9a5b-4015-8b60-1579bbbf2135";
9 9
10 // Sometimes we need to test that using either the name, alias, or UUID 10 // Sometimes we need to test that using either the name, alias, or UUID
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 constructor(object, event) { 298 constructor(object, event) {
299 this.eventFired = false; 299 this.eventFired = false;
300 let event_listener = e => { 300 let event_listener = e => {
301 object.removeEventListener(event, event_listener); 301 object.removeEventListener(event, event_listener);
302 this.eventFired = true; 302 this.eventFired = true;
303 } 303 }
304 object.addEventListener(event, event_listener); 304 object.addEventListener(event, event_listener);
305 } 305 }
306 } 306 }
307 307
308 function generateRequestDeviceArgsWithServices(services) {
309 services = (services === undefined) ? ['heart_rate'] : services;
Jeffrey Yasskin 2016/05/09 22:09:58 Make this an if statement: if (services === undef
ortuno 2016/05/11 19:29:39 Used default argument instead.
Jeffrey Yasskin 2016/05/11 20:27:17 Oh, cool. Yay for new Javascript features.
310 return [{
311 filters: [{ services: services}]
Jeffrey Yasskin 2016/05/09 22:09:58 Nit: Be symmetric with the spaces inside {}s: prob
ortuno 2016/05/11 19:29:39 Done.
312 }, {
313 filters: [{ services: services, name: 'Name'}]
314 }, {
315 filters: [{ services: services, namePrefix: 'Pre'}]
316 }, {
317 filters: [{ services: services, name: 'Name', namePrefix: 'Pre'}]
318 }, {
319 filters: [{ services: services}],
320 optionalServices: ['heart_rate']
321 }, {
322 filters: [{ services: services, name: 'Name'}],
323 optionalServices: ['heart_rate']
324 }, {
325 filters: [{ services: services, namePrefix: 'Pre'}],
326 optionalServices: ['heart_rate']
327 }, {
328 filters: [{ services: services, name: 'Name', namePrefix: 'Pre'}],
329 optionalServices: ['heart_rate']
330 }];
331 }
332
308 // Bluetooth tests sometimes have left-over state that could leak into the 333 // Bluetooth tests sometimes have left-over state that could leak into the
309 // next test. add_result_callback which is exposed by testharness.js allows us 334 // next test. add_result_callback which is exposed by testharness.js allows us
310 // to clean up this state after each test. In the future we will split tests 335 // to clean up this state after each test. Once the move to Mojo is complete
Jeffrey Yasskin 2016/05/09 22:09:58 If this is the last change to split up tests, remo
ortuno 2016/05/11 19:29:39 We can't get rid of the adapter one yet because ou
Jeffrey Yasskin 2016/05/11 20:27:17 SG
311 // into separate files so that we don't have to add this callback ourselves. 336 // we will no longer need to clean up the state manually.
312 // TODO(ortuno): Split tests into separate files. 337 // https://crbug.com/508771
313 // https://crbug.com/554240
314 add_result_callback(() => { 338 add_result_callback(() => {
315 // At the end of each test we clean up all the leftover data in the browser,
316 // including revoking permissions. This happens before the test document is
317 // detached. Once the document is detached any device that connected tries
318 // to disconnect but by then the document no longer has permission to
319 // interact with the device. So before we clean up the browser data
320 // we change the visibility which results in all devices disconnecing.
321 // TODO(ortuno): Remove setPageVisibility hack. In the future, the browser
322 // will notify the renderer that the device disconnected so we won't need
323 // this hack.
324 // https://crbug.com/581855
325 testRunner.setBluetoothManualChooser(false);
326 setBluetoothFakeAdapter(''); 339 setBluetoothFakeAdapter('');
327 }); 340 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698