| OLD | NEW |
| 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 Loading... |
| 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 = ['heart_rate']) { |
| 309 return [{ |
| 310 filters: [{ services: services }] |
| 311 }, { |
| 312 filters: [{ services: services, name: 'Name' }] |
| 313 }, { |
| 314 filters: [{ services: services, namePrefix: 'Pre' }] |
| 315 }, { |
| 316 filters: [{ services: services, name: 'Name', namePrefix: 'Pre' }] |
| 317 }, { |
| 318 filters: [{ services: services }], |
| 319 optionalServices: ['heart_rate'] |
| 320 }, { |
| 321 filters: [{ services: services, name: 'Name' }], |
| 322 optionalServices: ['heart_rate'] |
| 323 }, { |
| 324 filters: [{ services: services, namePrefix: 'Pre' }], |
| 325 optionalServices: ['heart_rate'] |
| 326 }, { |
| 327 filters: [{ services: services, name: 'Name', namePrefix: 'Pre' }], |
| 328 optionalServices: ['heart_rate'] |
| 329 }]; |
| 330 } |
| 331 |
| 308 // Bluetooth tests sometimes have left-over state that could leak into the | 332 // 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 | 333 // 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 | 334 // to clean up this state after each test. Once the move to Mojo is complete |
| 311 // into separate files so that we don't have to add this callback ourselves. | 335 // we will no longer need to clean up the state manually. |
| 312 // TODO(ortuno): Split tests into separate files. | 336 // https://crbug.com/508771 |
| 313 // https://crbug.com/554240 | |
| 314 add_result_callback(() => { | 337 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(''); | 338 setBluetoothFakeAdapter(''); |
| 327 }); | 339 }); |
| OLD | NEW |