| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <script src="../resources/testharness.js"></script> | 2 <script src="../resources/testharness.js"></script> |
| 3 <script src="../resources/testharnessreport.js"></script> | 3 <script src="../resources/testharnessreport.js"></script> |
| 4 <script src="resources/bluetooth-helpers.js"></script> | 4 <script src="resources/bluetooth-helpers.js"></script> |
| 5 <script> | 5 <script> |
| 6 'use strict'; | 6 'use strict'; |
| 7 | 7 |
| 8 test(t => { assert_exists(window, 'testRunner'); t.done(); }, | 8 test(t => { assert_exists(window, 'testRunner'); t.done(); }, |
| 9 'window.testRunner is required for the following tests.'); | 9 'window.testRunner is required for the following tests.'); |
| 10 | 10 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 testRunner.setBluetoothMockDataSet('HeartRateAdapter'); | 91 testRunner.setBluetoothMockDataSet('HeartRateAdapter'); |
| 92 return requestDeviceWithKeyDown({filters: [{services: ['heart_rate']}]}) | 92 return requestDeviceWithKeyDown({filters: [{services: ['heart_rate']}]}) |
| 93 .then(device => device.connectGATT()) | 93 .then(device => device.connectGATT()) |
| 94 .then(gattServer => gattServer.getPrimaryService('generic_access')) | 94 .then(gattServer => gattServer.getPrimaryService('generic_access')) |
| 95 .then(service => service.getCharacteristic('gap.device_name')) | 95 .then(service => service.getCharacteristic('gap.device_name')) |
| 96 .then(characteristic => Promise.all( | 96 .then(characteristic => Promise.all( |
| 97 [characteristic.writeValue(new Uint8Array(1 /* length */)), | 97 [characteristic.writeValue(new Uint8Array(1 /* length */)), |
| 98 characteristic.writeValue(new ArrayBuffer(1 /* length */)), | 98 characteristic.writeValue(new ArrayBuffer(1 /* length */)), |
| 99 characteristic.writeValue(new DataView(new ArrayBuffer(1 /* length */)))]
)); | 99 characteristic.writeValue(new DataView(new ArrayBuffer(1 /* length */)))]
)); |
| 100 }, 'A regular write request to a writable characteristic should succeed.'); | 100 }, 'A regular write request to a writable characteristic should succeed.'); |
| 101 |
| 102 promise_test(() => { |
| 103 testRunner.setBluetoothMockDataSet('HeartRateAdapter'); |
| 104 return requestDeviceWithKeyDown({filters: [{services: ['heart_rate']}]}) |
| 105 .then(device => device.connectGATT()) |
| 106 .then(gattServer => gattServer.getPrimaryService('generic_access')) |
| 107 .then(service => service.getCharacteristic('gap.device_name')) |
| 108 .then(characteristic => { |
| 109 assert_equals(characteristic.value, null); |
| 110 let textEncoder = new TextEncoder(); |
| 111 let newValue = textEncoder.encode('foo'); |
| 112 return characteristic.writeValue(newValue).then(() => { |
| 113 assert_array_equals(characteristic.value.buffer, newValue.buffer); |
| 114 }); |
| 115 }); |
| 116 }, 'A regular write request to a writable characteristic should update value.'); |
| 101 </script> | 117 </script> |
| OLD | NEW |