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 @@
<script src="../../../resources/bluetooth/bluetooth-helpers.js"></script>
<script>
'use strict';
bluetooth_test(() => {
return setBluetoothFakeAdapter('HeartRateAdapter')
.then(() => requestDeviceWithTrustedClick({
filters: [{services: ['heart_rate']}]}))
.then(device => device.gatt.connect())
.then(gattService => gattService.getPrimaryService('heart_rate'))
.then(service => service.getCharacteristic('heart_rate_measurement'))
.then(characteristic => {
return setBluetoothFakeAdapter('MissingCharacteristicHeartRateAdapter')
.then(() => assert_promise_rejects_with_message(
characteristic.startNotifications(),
new DOMException('GATT Characteristic no longer exists.',
'InvalidStateError'),
'Characteristic got removed.'));
});
}, 'Characteristic is removed. Reject with InvalidStateError.');
const test_desc = 'Characteristic is removed. Reject with InvalidStateError.';
let characteristic, fake_characteristic;
bluetooth_test(() => getMeasurementIntervalCharacteristic()
.then(_ => ({characteristic, fake_characteristic} = _))
.then(() => fake_characteristic.remove())
.then(() => assert_promise_rejects_with_message(
characteristic.startNotifications(),
new DOMException('GATT Characteristic no longer exists.',
'InvalidStateError'),
'Characteristic got removed.')),
test_desc);
</script>
......@@ -6,22 +6,17 @@
<script src="../../../resources/bluetooth/bluetooth-helpers.js"></script>
<script>
'use strict';
bluetooth_test(() => {
return setBluetoothFakeAdapter('HeartRateAdapter')
.then(() => requestDeviceWithTrustedClick({
filters: [{services: ['heart_rate']}],
optionalServices: ['generic_access']}))
.then(device => device.gatt.connect())
.then(gattServer => gattServer.getPrimaryService('generic_access'))
.then(service => service.getCharacteristic('gap.device_name'))
.then(characteristic => {
return setBluetoothFakeAdapter('MissingCharacteristicHeartRateAdapter')
.then(() => assert_promise_rejects_with_message(
characteristic.readValue(),
new DOMException(
'GATT Characteristic no longer exists.',
'InvalidStateError'),
'Characteristic got removed.'));
});
}, 'Characteristic gets removed. Reject with InvalidStateError.');
const test_desc = 'Characteristic gets removed. Reject with InvalidStateError.';
let characteristic, fake_characteristic;
bluetooth_test(() => getMeasurementIntervalCharacteristic()
.then(_ => ({characteristic, fake_characteristic} = _))
.then(() => fake_characteristic.remove())
.then(() => assert_promise_rejects_with_message(
characteristic.readValue(),
new DOMException(
'GATT Characteristic no longer exists.',
'InvalidStateError'),
'Characteristic got removed.')),
test_desc);
</script>
......@@ -6,21 +6,16 @@
<script src="../../../resources/bluetooth/bluetooth-helpers.js"></script>
<script>
'use strict';
bluetooth_test(() => {
return setBluetoothFakeAdapter('HeartRateAdapter')
.then(() => requestDeviceWithTrustedClick({
filters: [{services: ['heart_rate']}],
optionalServices: ['generic_access']}))
.then(device => device.gatt.connect())
.then(gattServer => gattServer.getPrimaryService('generic_access'))
.then(service => service.getCharacteristic('gap.device_name'))
.then(characteristic => {
return setBluetoothFakeAdapter('MissingCharacteristicHeartRateAdapter')
.then(() => assert_promise_rejects_with_message(
characteristic.writeValue(new ArrayBuffer(1 /* length */)),
new DOMException(
'GATT Characteristic no longer exists.', 'InvalidStateError'),
'Characteristic got removed.'));
});
}, 'Characteristic gets removed. Reject with InvalidStateError.');
const test_desc = 'Characteristic gets removed. Reject with InvalidStateError.';
let characteristic, fake_characteristic;
bluetooth_test(() => getMeasurementIntervalCharacteristic()
.then(_ => ({characteristic, fake_characteristic} = _))
.then(() => fake_characteristic.remove())
.then(() => assert_promise_rejects_with_message(
characteristic.writeValue(new ArrayBuffer(1 /* length */)),
new DOMException(
'GATT Characteristic no longer exists.', 'InvalidStateError'),
'Characteristic got removed.')),
test_desc);
</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