blob: 618e2c331247ffcc2a2c5ac6d6cc96cdbee69cc1 [file] [log] [blame]
<!DOCTYPE html>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<script src="../../../resources/bluetooth/bluetooth-helpers.js"></script>
<script>
'use strict';
bluetooth_test(() => {
return setBluetoothFakeAdapter('HeartRateAdapter')
.then(() => requestDeviceWithKeyDown({
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 => {
assert_equals(characteristic.value, null);
let textEncoder = new TextEncoder();
let newValue = textEncoder.encode('foo');
return characteristic.writeValue(newValue).then(() => {
assert_array_equals(new Uint8Array(characteristic.value.buffer),
new Uint8Array(newValue.buffer));
});
});
}, 'A regular write request to a writable characteristic should update value.');
</script>