Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/bluetooth/gattserverdisconnected-event/reconnect-during-disconnected-event.html |
| diff --git a/third_party/WebKit/LayoutTests/bluetooth/gattserverdisconnected-event/one-event-per-disconnection.html b/third_party/WebKit/LayoutTests/bluetooth/gattserverdisconnected-event/reconnect-during-disconnected-event.html |
| similarity index 54% |
| copy from third_party/WebKit/LayoutTests/bluetooth/gattserverdisconnected-event/one-event-per-disconnection.html |
| copy to third_party/WebKit/LayoutTests/bluetooth/gattserverdisconnected-event/reconnect-during-disconnected-event.html |
| index ecf15177bc44ac13a1fc72f6f7f55609ced4c081..aa3fd5831c2300120d0e18c618a0693fc058b303 100644 |
| --- a/third_party/WebKit/LayoutTests/bluetooth/gattserverdisconnected-event/one-event-per-disconnection.html |
| +++ b/third_party/WebKit/LayoutTests/bluetooth/gattserverdisconnected-event/reconnect-during-disconnected-event.html |
| @@ -15,20 +15,24 @@ |
| .then(gattServer => gattServer.getPrimaryService(request_disconnection_service_uuid)) |
| .then(service => service.getCharacteristic(request_disconnection_characteristic_uuid)) |
| .then(requestDisconnection => { |
| - let numEvents = 0; |
| - let eventCounter = () => { numEvents++; }; |
| - device.addEventListener('gattserverdisconnected', eventCounter); |
| + // 1. Attach a listener that tries to reconnect. |
| + let reconnection = new Promise(resolve => { |
| + let wrapper = function(event) { |
| + device.removeEventListener('gattserverdisconnected', wrapper); |
| + device.gatt.connect().then(resolve); |
| + }; |
| + device.addEventListener('gattserverdisconnected', wrapper); |
| + }); |
| + // 2. Disconnect. |
| requestDisconnection.writeValue(new Uint8Array([0])); |
| - device.gatt.disconnect(); |
| - device.gatt.disconnect(); |
| - return new Promise(resolve => { |
| - setTimeout(() => { |
| - device.removeEventListener('gattserverdisconnected', eventCounter); |
| - resolve(numEvents); |
| - }, 100); |
| + return reconnection.then(() => { |
| + // Resolves after disconnected event. |
| + let disconnected = eventPromise(device, 'gattserverdisconnected'); |
| + // 3. Disconnect after reconnecting. |
| + requestDisconnection.writeValue(new Uint8Array([0])); |
| + return disconnected; |
| }); |
| - }).then(numEvents => assert_equals(numEvents, 1)); |
| + }); |
| }); |
| - }, 'If a site disconnects from a device while the platform is disconnecting ' + |
| - 'that device, only one gattserverdisconnected event should fire.'); |
| + }, 'A device disconnecting while connected should fire the gattserverdisconnected event.'); |
|
Jeffrey Yasskin
2016/06/18 05:03:56
This isn't the right title for this test.
ortuno
2016/06/18 20:01:20
Done.
|
| </script> |