 Chromium Code Reviews
 Chromium Code Reviews Issue 1382743002:
  bluetooth: Add characteristicvaluechanged event  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@bluetooth-notifications-1
    
  
    Issue 1382743002:
  bluetooth: Add characteristicvaluechanged event  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@bluetooth-notifications-1| OLD | NEW | 
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <script src="../resources/testharness.js"></script> | |
| 3 <script src="../resources/testharnessreport.js"></script> | |
| 4 <script src="resources/bluetooth-helpers.js"></script> | |
| 5 <script> | |
| 6 'use strict'; | |
| 7 test(t => { assert_true(window.testRunner instanceof Object); t.done(); }, | |
| 8 'window.testRunner is required for the following tests.'); | |
| 9 | |
| 10 promise_test(() => { | |
| 11 let char; | |
| 12 testRunner.setBluetoothMockDataSet('HeartRateAdapter'); | |
| 13 return requestDeviceWithKeyDown({filters: [{services: ['heart_rate']}]}) | |
| 14 .then(device => device.connectGATT()) | |
| 15 .then(gattServer => gattServer.getPrimaryService('heart_rate')) | |
| 16 .then(service => service.getCharacteristic('body_sensor_location')) | |
| 17 .then(characteristic => { | |
| 18 return event_after_promise(characteristic, | |
| 19 'readValue', | |
| 20 'characteristicvaluechanged'); | |
| 
Jeffrey Yasskin
2015/10/15 23:00:51
Add another test that registers 2 'characteristicv
 
ortuno
2015/10/16 01:24:21
Done. It adds 3!
 | |
| 21 }).then(results => { | |
| 22 let event_value = new Uint8Array(results[0]); | |
| 23 let read_value = new Uint8Array(results[1]); | |
| 24 // TODO(ortuno): The Arraybuffer used to resolve the promise | |
| 
Jeffrey Yasskin
2015/10/15 23:00:51
s/Arraybuffer/ArrayBuffer/
 
ortuno
2015/10/16 01:24:21
Done.
 | |
| 25 // should be the same ArrayBuffer than the one saved in the | |
| 26 // characteristic. | |
| 27 // http://crbug.com/543347 | |
| 28 // assert_equals(event.target.value, value); | |
| 29 assert_array_equals(event_value, read_value); | |
| 30 }); | |
| 31 }, 'Reading a characteristic should dispatch an event as well.'); | |
| 32 | |
| 33 promise_test(() => { | |
| 34 testRunner.setBluetoothMockDataSet('HeartRateAdapter'); | |
| 35 let char; | |
| 36 return requestDeviceWithKeyDown({filters: [{services: ['heart_rate']}]}) | |
| 37 .then(device => device.connectGATT()) | |
| 38 .then(gattServer => gattServer.getPrimaryService('heart_rate')) | |
| 39 .then(service => service.getCharacteristic('heart_rate_measurement')) | |
| 40 .then(characteristic => { | |
| 41 char = characteristic; | |
| 42 return event_after_promise(characteristic, | |
| 43 'startNotifications', | |
| 44 'characteristicvaluechanged'); | |
| 45 }).then(() => char.stopNotifications()) | |
| 46 .then(() => assert_no_events(char, 'characteristicvaluechanged')); | |
| 47 }, 'Starting a notification should dispatch an event.'); | |
| 48 </script> | |
| OLD | NEW |