OLD | NEW |
1 <!-- Generated by //third_party/WebKit/LayoutTests/bluetooth/generate.py --> | 1 <!-- Generated by //third_party/WebKit/LayoutTests/bluetooth/generate.py --> |
2 <!DOCTYPE html> | 2 <!DOCTYPE html> |
3 <script src="../../../resources/testharness.js"></script> | 3 <script src="../../../resources/testharness.js"></script> |
4 <script src="../../../resources/testharnessreport.js"></script> | 4 <script src="../../../resources/testharnessreport.js"></script> |
5 <script src="../../../resources/bluetooth/bluetooth-helpers.js"></script> | 5 <script src="../../../resources/bluetooth/bluetooth-helpers.js"></script> |
6 <script> | 6 <script> |
7 'use strict'; | 7 'use strict'; |
8 promise_test(() => { | 8 promise_test(() => { |
9 let promise; | 9 let promise; |
10 return setBluetoothFakeAdapter('TwoHeartRateServicesAdapter') | 10 return setBluetoothFakeAdapter('TwoHeartRateServicesAdapter') |
11 .then(() => requestDeviceWithKeyDown({ | 11 .then(() => requestDeviceWithKeyDown({ |
12 filters: [{services: ['heart_rate']}]})) | 12 filters: [{services: ['heart_rate']}]})) |
13 .then(device => device.gatt.connect()) | 13 .then(device => device.gatt.connect()) |
14 .then(gattServer => { | 14 .then(gattServer => { |
15 return gattServer | 15 return gattServer |
16 .getPrimaryServices() | 16 .getPrimaryServices() |
17 // Convert to array if necessary. | 17 // Convert to array if necessary. |
18 .then(s => { | 18 .then(s => { |
19 let services = [].concat(s); | 19 let services = [].concat(s); |
20 gattServer.disconnect(); | 20 gattServer.disconnect(); |
21 return gattServer.connect() | 21 return gattServer.connect() |
22 .then(() => services); | 22 .then(() => services); |
23 }); | 23 }); |
24 }) | 24 }) |
25 .then(services => { | 25 .then(services => { |
26 let promises = Promise.resolve(); | 26 let promises = Promise.resolve(); |
27 for (let service of services) { | 27 for (let service of services) { |
28 let error = new DOMException( | 28 let error = new DOMException( |
29 'Service is no longer valid. Remember to retrieve the service ' + | 29 'Service with UUID ' + service.uuid + |
| 30 ' is no longer valid. Remember to retrieve the service ' + |
30 'again after reconnecting.', | 31 'again after reconnecting.', |
31 'InvalidStateError'); | 32 'InvalidStateError'); |
32 promises = promises.then(() => | 33 promises = promises.then(() => |
33 assert_promise_rejects_with_message( | 34 assert_promise_rejects_with_message( |
34 service.getCharacteristic('body_sensor_location'), | 35 service.getCharacteristic('body_sensor_location'), |
35 error)); | 36 error)); |
36 promises = promises.then(() => | 37 promises = promises.then(() => |
37 assert_promise_rejects_with_message( | 38 assert_promise_rejects_with_message( |
38 service.getCharacteristics(), | 39 service.getCharacteristics(), |
39 error)); | 40 error)); |
40 promises = promises.then(() => | 41 promises = promises.then(() => |
41 assert_promise_rejects_with_message( | 42 assert_promise_rejects_with_message( |
42 service.getCharacteristics('body_sensor_location'), | 43 service.getCharacteristics('body_sensor_location'), |
43 error)); | 44 error)); |
44 } | 45 } |
45 return promises; | 46 return promises; |
46 }); | 47 }); |
47 }, 'Calls on services after we disconnect and connect again. '+ | 48 }, 'Calls on services after we disconnect and connect again. '+ |
48 'Should reject with InvalidStateError.'); | 49 'Should reject with InvalidStateError.'); |
49 | 50 |
50 </script> | 51 </script> |
OLD | NEW |