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

Side by Side Diff: third_party/WebKit/LayoutTests/bluetooth/getCharacteristics/gen-characteristic-device-disconnects-invalidates-objects.html

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 --> 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 return setBluetoothFakeAdapter('DisconnectingHealthThermometerAdapter') 9 return setBluetoothFakeAdapter('DisconnectingHealthThermometerAdapter')
10 .then(() => requestDeviceWithKeyDown({ 10 .then(() => requestDeviceWithKeyDown({
11 filters: [{services: ['health_thermometer']}], 11 filters: [{services: ['health_thermometer']}],
12 optionalServices: [request_disconnection_service_uuid]})) 12 optionalServices: [request_disconnection_service_uuid]}))
13 .then(device => device.gatt.connect()) 13 .then(device => device.gatt.connect())
14 .then(gattServer => { 14 .then(gattServer => {
15 let services; 15 let characteristics;
16 return gattServer 16 return gattServer.getPrimaryService('health_thermometer')
17 .getPrimaryService('health_thermometer') 17 .then(service => service.getCharacteristics())
18 .then(s => { 18 .then(c => {
19 // Convert to array if necessary. 19 // Convert to array if necessary.
20 services = [].concat(s); 20 characteristics = [].concat(c);
21 return get_request_disconnection(gattServer); 21 return get_request_disconnection(gattServer);
22 }) 22 })
23 .then(requestDisconnection => requestDisconnection()) 23 .then(requestDisconnection => requestDisconnection())
24 .then(() => gattServer.connect()) 24 .then(() => gattServer.connect())
25 .then(() => services); 25 .then(() => characteristics);
26 }) 26 })
27 .then(services => { 27 .then(characteristics => {
28 let promises = Promise.resolve(); 28 let promises = Promise.resolve();
29 for (let service of services) { 29 for (let characteristic of characteristics) {
30 if (service.uuid == request_disconnection_service_uuid) {
31 continue;
32 }
33 let error = new DOMException( 30 let error = new DOMException(
34 'Service is no longer valid. Remember to retrieve the service ' + 31 'Characteristic is no longer valid. Remember to retrieve the ' +
35 'again after reconnecting.', 32 'characteristic again after reconnecting.',
36 'InvalidStateError'); 33 'InvalidStateError');
37 promises = promises.then(() => 34 promises = promises.then(() =>
38 assert_promise_rejects_with_message( 35 assert_promise_rejects_with_message(
39 service.getCharacteristic('measurement_interval'), 36 characteristic.readValue(),
40 error)); 37 error));
41 promises = promises.then(() => 38 promises = promises.then(() =>
42 assert_promise_rejects_with_message( 39 assert_promise_rejects_with_message(
43 service.getCharacteristics(), 40 characteristic.writeValue(new Uint8Array([1])),
44 error)); 41 error));
45 promises = promises.then(() => 42 promises = promises.then(() =>
46 assert_promise_rejects_with_message( 43 assert_promise_rejects_with_message(
47 service.getCharacteristics('measurement_interval'), 44 characteristic.startNotifications(),
45 error));
46 promises = promises.then(() =>
47 assert_promise_rejects_with_message(
48 characteristic.stopNotifications(),
48 error)); 49 error));
49 } 50 }
50 return promises; 51 return promises;
51 }); 52 });
52 }, 'Calls on services after device disconnects and we reconnect. ' + 53 }, 'Calls on characteristics after device disconnects and we reconnect. ' +
53 'Should reject with InvalidStateError.'); 54 'Should reject with InvalidStateError.');
54 55
55 </script> 56 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698