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(characteristic => {
return setBluetoothFakeAdapter('MissingCharacteristicHeartRateAdapter')
.then(() => assert_promise_rejects_with_message( .then(() => assert_promise_rejects_with_message(
characteristic.startNotifications(), characteristic.startNotifications(),
new DOMException('GATT Characteristic no longer exists.', new DOMException('GATT Characteristic no longer exists.',
'InvalidStateError'), 'InvalidStateError'),
'Characteristic got removed.')); 'Characteristic got removed.')),
}); test_desc);
}, '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(service => service.getCharacteristic('gap.device_name'))
.then(characteristic => {
return setBluetoothFakeAdapter('MissingCharacteristicHeartRateAdapter')
.then(() => assert_promise_rejects_with_message( .then(() => assert_promise_rejects_with_message(
characteristic.readValue(), characteristic.readValue(),
new DOMException( new DOMException(
'GATT Characteristic no longer exists.', 'GATT Characteristic no longer exists.',
'InvalidStateError'), 'InvalidStateError'),
'Characteristic got removed.')); 'Characteristic got removed.')),
}); test_desc);
}, '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(service => service.getCharacteristic('gap.device_name'))
.then(characteristic => {
return setBluetoothFakeAdapter('MissingCharacteristicHeartRateAdapter')
.then(() => assert_promise_rejects_with_message( .then(() => assert_promise_rejects_with_message(
characteristic.writeValue(new ArrayBuffer(1 /* length */)), characteristic.writeValue(new ArrayBuffer(1 /* length */)),
new DOMException( new DOMException(
'GATT Characteristic no longer exists.', 'InvalidStateError'), 'GATT Characteristic no longer exists.', 'InvalidStateError'),
'Characteristic got removed.')); 'Characteristic got removed.')),
}); test_desc);
}, '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