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

Unified Diff: third_party/WebKit/LayoutTests/resources/bluetooth/bluetooth-helpers.js

Issue 2441313002: bluetooth: Introduce helper function for requesting a disconnection (Closed)
Patch Set: Add example to function Created 4 years, 2 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/bluetooth/script-tests/service-device-disconnects-before.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/resources/bluetooth/bluetooth-helpers.js
diff --git a/third_party/WebKit/LayoutTests/resources/bluetooth/bluetooth-helpers.js b/third_party/WebKit/LayoutTests/resources/bluetooth/bluetooth-helpers.js
index fd9719a503127e16868524ab3d36bc68be4464de..bc1e607c11cdd06824070dc647ec4c606f08a13f 100644
--- a/third_party/WebKit/LayoutTests/resources/bluetooth/bluetooth-helpers.js
+++ b/third_party/WebKit/LayoutTests/resources/bluetooth/bluetooth-helpers.js
@@ -318,6 +318,22 @@ class EventCatcher {
}
}
+// Returns a function that when called returns a promise that resolves when
+// the device has disconnected. Example:
+// device.gatt.connect()
+// .then(gatt => get_request_disconnection(gatt))
+// .then(requestDisconnection => requestDisconnection())
+// .then(() => // device is now disconnected)
+function get_request_disconnection(gattServer) {
+ return gattServer.getPrimaryService(request_disconnection_service_uuid)
+ .then(service => service.getCharacteristic(request_disconnection_characteristic_uuid))
+ .then(characteristic => {
+ // TODO(crbug.com/543466): Wrap in assert_promise_rejects_with_message()
+ // once connection is required for writeValue to succeed.
+ return () => characteristic.writeValue(new Uint8Array([0]));
+ });
+}
+
function generateRequestDeviceArgsWithServices(services = ['heart_rate']) {
return [{
filters: [{ services: services }]
« no previous file with comments | « third_party/WebKit/LayoutTests/bluetooth/script-tests/service-device-disconnects-before.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698