blob: 0c6b43805c625ef101b29111d3e6c3903054dcfa [file] [log] [blame]
<!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="../../../external/wpt/bluetooth/resources/bluetooth-helpers.js"></script>
<script>
'use strict';
const test_desc = 'A regular write request to a writable characteristic ' +
'should update value.';
const newValue = new TextEncoder().encode('foo');
let characteristic, fake_characteristic;
bluetooth_test(() => getMeasurementIntervalCharacteristic()
.then(_ => ({characteristic, fake_characteristic} = _))
.then(() => assert_equals(characteristic.value, null))
.then(() => fake_characteristic.setNextWriteResponse({GATT_SUCCESS}))
.then(() => characteristic.writeValue(newValue))
.then(() => assert_array_equals(
new Uint8Array(characteristic.value.buffer), newValue))
.then(() => fake_characteristic.getLastWrittenValue())
.then(lastValue => assert_array_equals(lastValue, newValue)),
test_desc);
</script>