servo/tests/wpt/web-platform-tests/bluetooth/characteristic/readValue/read-succeeds.https.html

24 lines
886 B
HTML

<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="/bluetooth/resources/bluetooth-helpers.js"></script>
<script>
'use strict';
const test_desc = 'A read request succeeds and returns the characteristic\'s ' +
'value.';
const EXPECTED_VALUE = [0, 1, 2];
let characteristic, fake_characteristic;
bluetooth_test(() => getMeasurementIntervalCharacteristic()
.then(_ => ({characteristic, fake_characteristic} = _))
.then(() => fake_characteristic.setNextReadResponse(
GATT_SUCCESS,
EXPECTED_VALUE))
.then(() => characteristic.readValue())
.then(value => assert_array_equals(
new Uint8Array(value.buffer),
EXPECTED_VALUE)),
test_desc);
</script>