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

Side by Side Diff: LayoutTests/bluetooth/readValue.html

Issue 1147243004: bluetooth: readValue Blink implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@bluetooth-read-value-interface
Patch Set: readValue blink Implementation. Created 5 years, 6 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 unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <script src="../resources/testharness.js"></script>
3 <script src="../resources/testharnessreport.js"></script>
4 <script src="bluetooth-helpers.js"></script>
5 <script>
6 test(function(t) { assert_exists(window, "testRunner"); t.done(); },
7 "window.testRunner is required for the following tests.");
8
9 // Generic Access Service.
10 var serviceUUID = "00001800-0000-1000-8000-00805f9b34fb";
11 // Device Name Characteristic. Belongs to Generic Access.
12 var includedCharacteristicUUID = "00002a00-0000-1000-8000-00805f9b34fb";
13
14 sequential_promise_test(function() {
15 testRunner.setBluetoothMockDataSet('ConnectableDeviceAdapter');
16 return navigator.bluetooth.requestDevice().then(function(device) {
17 return device.connectGATT();
18 }).then(function(gattServer) {
19 return gattServer.getPrimaryService(serviceUUID);
20 }).then(function(service) {
21 return service.getCharacteristic(includedCharacteristicUUID);
22 }).then(function(characteristic) {
23 testRunner.setBluetoothMockDataSet('EmptyAdapter');
24 return characteristic.readValue().then(function() {
25 assert_unreached("Device went out of range, should fail.");
Jeffrey Yasskin 2015/06/10 21:12:25 We have ~4 error cases here: Device disappears, de
ortuno 2015/06/11 00:10:52 Added a test for the 4th case. The third is gonna
26 }, function(e) {
27 assert_equals(e.name, "NetworkError");
28 });
29 });
30 }, 'Device goes out of range. Reject with NetworkError.');
31
32 sequential_promise_test(function() {
33 testRunner.setBluetoothMockDataSet('ConnectableDeviceAdapter');
34 return navigator.bluetooth.requestDevice().then(function(device) {
35 return device.connectGATT();
36 }).then(function(gattServer) {
37 return gattServer.getPrimaryService(serviceUUID);
38 }).then(function(service) {
39 return service.getCharacteristic(includedCharacteristicUUID);
40 }).then(function(characteristic) {
41 return characteristic.readValue();
42 }).then(function(value) {
43 var decoder = new TextDecoder();
Jeffrey Yasskin 2015/06/10 21:12:25 You should probably specify "utf-8" even though it
ortuno 2015/06/11 00:10:52 Done.
44 var value_str = decoder.decode(value);
45 assert_equals(value_str, "Empty Mock Device name");
46 });
47 }, 'Request for characteristic. Should return right characteristic');
48 </script>
OLDNEW
« no previous file with comments | « no previous file | Source/modules/bluetooth/BluetoothArrayBuffer.h » ('j') | Source/modules/bluetooth/BluetoothArrayBuffer.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698