Commit fd965c94 authored by Ovidio Henriquez's avatar Ovidio Henriquez Committed by Commit Bot

bluetooth: web: test: Update characteristic removed tests

This change updates a few characteristic removed tests to use the new
test API. This will allow the tests to be migrated into the wpt/
directory.

BUG=509038

Change-Id: I7ee5735d4052168f380437e9389546cd4d29a72f
Reviewed-on: https://chromium-review.googlesource.com/822522Reviewed-by: default avatarConley Owens <cco3@chromium.org>
Reviewed-by: default avatarVincent Scheib <scheib@chromium.org>
Commit-Queue: Vincent Scheib <scheib@chromium.org>
Cr-Commit-Position: refs/heads/master@{#524537}
parent 546e8cff
...@@ -6,20 +6,16 @@ ...@@ -6,20 +6,16 @@
<script src="../../../resources/bluetooth/bluetooth-helpers.js"></script> <script src="../../../resources/bluetooth/bluetooth-helpers.js"></script>
<script> <script>
'use strict'; 'use strict';
bluetooth_test(() => { const test_desc = 'Characteristic is removed. Reject with InvalidStateError.';
return setBluetoothFakeAdapter('HeartRateAdapter') let characteristic, fake_characteristic;
.then(() => requestDeviceWithTrustedClick({
filters: [{services: ['heart_rate']}]})) bluetooth_test(() => getMeasurementIntervalCharacteristic()
.then(device => device.gatt.connect()) .then(_ => ({characteristic, fake_characteristic} = _))
.then(gattService => gattService.getPrimaryService('heart_rate')) .then(() => fake_characteristic.remove())
.then(service => service.getCharacteristic('heart_rate_measurement')) .then(() => assert_promise_rejects_with_message(
.then(characteristic => { characteristic.startNotifications(),
return setBluetoothFakeAdapter('MissingCharacteristicHeartRateAdapter') new DOMException('GATT Characteristic no longer exists.',
.then(() => assert_promise_rejects_with_message( 'InvalidStateError'),
characteristic.startNotifications(), 'Characteristic got removed.')),
new DOMException('GATT Characteristic no longer exists.', test_desc);
'InvalidStateError'),
'Characteristic got removed.'));
});
}, 'Characteristic is removed. Reject with InvalidStateError.');
</script> </script>
...@@ -6,22 +6,17 @@ ...@@ -6,22 +6,17 @@
<script src="../../../resources/bluetooth/bluetooth-helpers.js"></script> <script src="../../../resources/bluetooth/bluetooth-helpers.js"></script>
<script> <script>
'use strict'; 'use strict';
bluetooth_test(() => { const test_desc = 'Characteristic gets removed. Reject with InvalidStateError.';
return setBluetoothFakeAdapter('HeartRateAdapter') let characteristic, fake_characteristic;
.then(() => requestDeviceWithTrustedClick({
filters: [{services: ['heart_rate']}], bluetooth_test(() => getMeasurementIntervalCharacteristic()
optionalServices: ['generic_access']})) .then(_ => ({characteristic, fake_characteristic} = _))
.then(device => device.gatt.connect()) .then(() => fake_characteristic.remove())
.then(gattServer => gattServer.getPrimaryService('generic_access')) .then(() => assert_promise_rejects_with_message(
.then(service => service.getCharacteristic('gap.device_name')) characteristic.readValue(),
.then(characteristic => { new DOMException(
return setBluetoothFakeAdapter('MissingCharacteristicHeartRateAdapter') 'GATT Characteristic no longer exists.',
.then(() => assert_promise_rejects_with_message( 'InvalidStateError'),
characteristic.readValue(), 'Characteristic got removed.')),
new DOMException( test_desc);
'GATT Characteristic no longer exists.',
'InvalidStateError'),
'Characteristic got removed.'));
});
}, 'Characteristic gets removed. Reject with InvalidStateError.');
</script> </script>
...@@ -6,21 +6,16 @@ ...@@ -6,21 +6,16 @@
<script src="../../../resources/bluetooth/bluetooth-helpers.js"></script> <script src="../../../resources/bluetooth/bluetooth-helpers.js"></script>
<script> <script>
'use strict'; 'use strict';
bluetooth_test(() => { const test_desc = 'Characteristic gets removed. Reject with InvalidStateError.';
return setBluetoothFakeAdapter('HeartRateAdapter') let characteristic, fake_characteristic;
.then(() => requestDeviceWithTrustedClick({
filters: [{services: ['heart_rate']}], bluetooth_test(() => getMeasurementIntervalCharacteristic()
optionalServices: ['generic_access']})) .then(_ => ({characteristic, fake_characteristic} = _))
.then(device => device.gatt.connect()) .then(() => fake_characteristic.remove())
.then(gattServer => gattServer.getPrimaryService('generic_access')) .then(() => assert_promise_rejects_with_message(
.then(service => service.getCharacteristic('gap.device_name')) characteristic.writeValue(new ArrayBuffer(1 /* length */)),
.then(characteristic => { new DOMException(
return setBluetoothFakeAdapter('MissingCharacteristicHeartRateAdapter') 'GATT Characteristic no longer exists.', 'InvalidStateError'),
.then(() => assert_promise_rejects_with_message( 'Characteristic got removed.')),
characteristic.writeValue(new ArrayBuffer(1 /* length */)), test_desc);
new DOMException(
'GATT Characteristic no longer exists.', 'InvalidStateError'),
'Characteristic got removed.'));
});
}, 'Characteristic gets removed. Reject with InvalidStateError.');
</script> </script>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment