Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(151)

Unified Diff: third_party/WebKit/LayoutTests/bluetooth/characteristicvaluechanged.html

Issue 1382743002: bluetooth: Add characteristicvaluechanged event (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bluetooth-notifications-1
Patch Set: Final clean up Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/bluetooth/characteristicvaluechanged.html
diff --git a/third_party/WebKit/LayoutTests/bluetooth/characteristicvaluechanged.html b/third_party/WebKit/LayoutTests/bluetooth/characteristicvaluechanged.html
new file mode 100644
index 0000000000000000000000000000000000000000..27461a0542414e764bf619f35e535be61d5106de
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/bluetooth/characteristicvaluechanged.html
@@ -0,0 +1,48 @@
+<!DOCTYPE html>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+<script src="resources/bluetooth-helpers.js"></script>
+<script>
+'use strict';
+test(t => { assert_true(window.testRunner instanceof Object); t.done(); },
+ 'window.testRunner is required for the following tests.');
+
+promise_test(() => {
+ let char;
+ testRunner.setBluetoothMockDataSet('HeartRateAdapter');
+ return requestDeviceWithKeyDown({filters: [{services: ['heart_rate']}]})
+ .then(device => device.connectGATT())
+ .then(gattServer => gattServer.getPrimaryService('heart_rate'))
+ .then(service => service.getCharacteristic('body_sensor_location'))
+ .then(characteristic => {
+ return event_after_promise(characteristic,
+ 'readValue',
+ '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!
+ }).then(results => {
+ let event_value = new Uint8Array(results[0]);
+ let read_value = new Uint8Array(results[1]);
+ // 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.
+ // should be the same ArrayBuffer than the one saved in the
+ // characteristic.
+ // http://crbug.com/543347
+ // assert_equals(event.target.value, value);
+ assert_array_equals(event_value, read_value);
+ });
+}, 'Reading a characteristic should dispatch an event as well.');
+
+promise_test(() => {
+ testRunner.setBluetoothMockDataSet('HeartRateAdapter');
+ let char;
+ return requestDeviceWithKeyDown({filters: [{services: ['heart_rate']}]})
+ .then(device => device.connectGATT())
+ .then(gattServer => gattServer.getPrimaryService('heart_rate'))
+ .then(service => service.getCharacteristic('heart_rate_measurement'))
+ .then(characteristic => {
+ char = characteristic;
+ return event_after_promise(characteristic,
+ 'startNotifications',
+ 'characteristicvaluechanged');
+ }).then(() => char.stopNotifications())
+ .then(() => assert_no_events(char, 'characteristicvaluechanged'));
+}, 'Starting a notification should dispatch an event.');
+</script>

Powered by Google App Engine
This is Rietveld 408576698