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

Side by Side Diff: third_party/WebKit/LayoutTests/bluetooth/script-tests/characteristic-device-disconnects-invalidates-objects.js

Issue 2476173002: bluetooth: Invalidate characteristics when disconnecting (Closed)
Patch Set: Fix test expectations Created 4 years, 1 month 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 <!-- Generated by //third_party/WebKit/LayoutTests/bluetooth/generate.py -->
2 <!DOCTYPE html>
3 <script src="../../resources/testharness.js"></script>
4 <script src="../../resources/testharnessreport.js"></script>
5 <script src="../../resources/bluetooth/bluetooth-helpers.js"></script>
6 <script>
7 'use strict'; 1 'use strict';
8 promise_test(() => { 2 promise_test(() => {
9 return setBluetoothFakeAdapter('DisconnectingHealthThermometerAdapter') 3 return setBluetoothFakeAdapter('DisconnectingHealthThermometerAdapter')
10 .then(() => requestDeviceWithKeyDown({ 4 .then(() => requestDeviceWithKeyDown({
11 filters: [{services: ['health_thermometer']}], 5 filters: [{services: ['health_thermometer']}],
12 optionalServices: [request_disconnection_service_uuid]})) 6 optionalServices: [request_disconnection_service_uuid]}))
13 .then(device => device.gatt.connect()) 7 .then(device => device.gatt.connect())
14 .then(gattServer => { 8 .then(gattServer => {
15 let services; 9 let characteristics;
16 return gattServer 10 return gattServer.getPrimaryService('health_thermometer')
17 .getPrimaryServices() 11 .then(service => service.CALLS([
18 .then(s => { 12 getCharacteristic('measurement_interval')|
13 getCharacteristics()|
14 getCharacteristics('measurement_interval')[UUID]]))
15 .then(c => {
19 // Convert to array if necessary. 16 // Convert to array if necessary.
20 services = [].concat(s); 17 characteristics = [].concat(c);
21 return get_request_disconnection(gattServer); 18 return get_request_disconnection(gattServer);
22 }) 19 })
23 .then(requestDisconnection => requestDisconnection()) 20 .then(requestDisconnection => requestDisconnection())
24 .then(() => gattServer.connect()) 21 .then(() => gattServer.connect())
25 .then(() => services); 22 .then(() => characteristics);
26 }) 23 })
27 .then(services => { 24 .then(characteristics => {
28 let promises = Promise.resolve(); 25 let promises = Promise.resolve();
29 for (let service of services) { 26 for (let characteristic of characteristics) {
30 if (service.uuid == request_disconnection_service_uuid) {
31 continue;
32 }
33 let error = new DOMException( 27 let error = new DOMException(
34 'Service is no longer valid. Remember to retrieve the service ' + 28 'Characteristic is no longer valid. Remember to retrieve the ' +
35 'again after reconnecting.', 29 'characteristic again after reconnecting.',
36 'InvalidStateError'); 30 'InvalidStateError');
37 promises = promises.then(() => 31 promises = promises.then(() =>
38 assert_promise_rejects_with_message( 32 assert_promise_rejects_with_message(
39 service.getCharacteristic('measurement_interval'), 33 characteristic.readValue(),
40 error)); 34 error));
41 promises = promises.then(() => 35 promises = promises.then(() =>
42 assert_promise_rejects_with_message( 36 assert_promise_rejects_with_message(
43 service.getCharacteristics(), 37 characteristic.writeValue(new Uint8Array([1])),
44 error)); 38 error));
45 promises = promises.then(() => 39 promises = promises.then(() =>
46 assert_promise_rejects_with_message( 40 assert_promise_rejects_with_message(
47 service.getCharacteristics('measurement_interval'), 41 characteristic.startNotifications(),
42 error));
43 promises = promises.then(() =>
44 assert_promise_rejects_with_message(
45 characteristic.stopNotifications(),
48 error)); 46 error));
49 } 47 }
50 return promises; 48 return promises;
51 }); 49 });
52 }, 'Calls on services after device disconnects and we reconnect. ' + 50 }, 'Calls on characteristics after device disconnects and we reconnect. ' +
53 'Should reject with InvalidStateError.'); 51 'Should reject with InvalidStateError.');
54
55 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698