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

Unified Diff: third_party/WebKit/LayoutTests/bluetooth/getPrimaryServices/gen-service-disconnect-invalidates-objects.html

Issue 2478013002: bluetooth: Invalidate services upon disconnection (Closed)
Patch Set: Address scheib's comments 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/bluetooth/getPrimaryServices/gen-service-disconnect-invalidates-objects.html
diff --git a/third_party/WebKit/LayoutTests/bluetooth/getPrimaryServices/gen-service-disconnect-invalidates-objects.html b/third_party/WebKit/LayoutTests/bluetooth/getPrimaryServices/gen-service-disconnect-invalidates-objects.html
new file mode 100644
index 0000000000000000000000000000000000000000..439a4601d509369b53f8a41d81379d917cad9330
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/bluetooth/getPrimaryServices/gen-service-disconnect-invalidates-objects.html
@@ -0,0 +1,50 @@
+<!-- Generated by //third_party/WebKit/LayoutTests/bluetooth/generate.py -->
+<!DOCTYPE html>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<script src="../../resources/bluetooth/bluetooth-helpers.js"></script>
+<script>
+'use strict';
+promise_test(() => {
+ let promise;
+ return setBluetoothFakeAdapter('TwoHeartRateServicesAdapter')
+ .then(() => requestDeviceWithKeyDown({
+ filters: [{services: ['heart_rate']}]}))
+ .then(device => device.gatt.connect())
+ .then(gattServer => {
+ return gattServer
+ .getPrimaryServices()
+ // Convert to array if necessary.
+ .then(s => {
+ let services = [].concat(s);
+ gattServer.disconnect();
+ return gattServer.connect()
+ .then(() => services);
+ });
+ })
+ .then(services => {
+ let promises = Promise.resolve();
+ for (let service of services) {
+ let error = new DOMException(
+ 'Service is no longer valid. Remember to retrieve the service ' +
+ 'again after reconnecting.',
+ 'InvalidStateError');
+ promises = promises.then(() =>
+ assert_promise_rejects_with_message(
+ service.getCharacteristic('body_sensor_location'),
+ error));
+ promises = promises.then(() =>
+ assert_promise_rejects_with_message(
+ service.getCharacteristics(),
+ error));
+ promises = promises.then(() =>
+ assert_promise_rejects_with_message(
+ service.getCharacteristics('body_sensor_location'),
+ error));
+ }
+ return promises;
+ });
+}, 'Calls on services after we disconnect and connect again. '+
+ 'Should reject with InvalidStateError.');
+
+</script>

Powered by Google App Engine
This is Rietveld 408576698