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

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: Rename BluetoothArrayBuffer to ConverWebVectorToArrayBuffer 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
« no previous file with comments | « no previous file | Source/modules/bluetooth/BluetoothGATTCharacteristic.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // Reconnection Address. Belongs to Generic Access.
14 var unreadableCharacteristicUUID = '00002a03-0000-1000-8000-00805f9b34fb';
15
16 sequential_promise_test(function() {
17 testRunner.setBluetoothMockDataSet('ConnectableDeviceAdapter');
18 return navigator.bluetooth.requestDevice().then(function(device) {
19 return device.connectGATT();
20 }).then(function(gattServer) {
21 return gattServer.getPrimaryService(serviceUUID);
22 }).then(function(service) {
23 return service.getCharacteristic(includedCharacteristicUUID);
24 }).then(function(characteristic) {
25 testRunner.setBluetoothMockDataSet('EmptyAdapter');
26 return characteristic.readValue().then(function() {
27 assert_unreached('Device went out of range, should fail.');
28 }, function(e) {
29 assert_equals(e.name, 'NetworkError');
30 });
31 });
32 }, 'Device goes out of range. Reject with NetworkError.');
33
34 sequential_promise_test(function() {
35 testRunner.setBluetoothMockDataSet('ConnectableDeviceAdapter');
36 return navigator.bluetooth.requestDevice().then(function(device) {
37 return device.connectGATT();
38 }).then(function(gattServer) {
39 return gattServer.getPrimaryService(serviceUUID);
40 }).then(function(service) {
41 return service.getCharacteristic(unreadableCharacteristicUUID);
42 }).then(function(characteristic) {
43 return characteristic.readValue().then(function() {
44 assert_unreached('Characteristic is unreadable. Should fail.');
45 }, function(e) {
46 // TODO(ortuno): Should be NotSupportedError when implemented.
47 // https://crbug.com/436283
48 assert_equals(e.name, 'NetworkError');
49 });
50 });
51 }, 'Device goes out of range. Reject with NetworkError.');
scheib 2015/06/11 20:19:13 Update test description.
ortuno 2015/06/11 21:32:17 Done.
52
53 // TODO(ortuno): Add a test for when a characterstics gets removed.
scheib 2015/06/11 20:19:13 Create a crbug.com issue so we can track known TOD
ortuno 2015/06/11 21:32:18 Done.
54
55 sequential_promise_test(function() {
56 testRunner.setBluetoothMockDataSet('ConnectableDeviceAdapter');
57 return navigator.bluetooth.requestDevice().then(function(device) {
58 return device.connectGATT();
59 }).then(function(gattServer) {
60 return gattServer.getPrimaryService(serviceUUID);
61 }).then(function(service) {
62 return service.getCharacteristic(includedCharacteristicUUID);
63 }).then(function(characteristic) {
64 return characteristic.readValue();
65 }).then(function(value) {
66 var decoder = new TextDecoder('utf-8');
67 var value_str = decoder.decode(value);
68 assert_equals(value_str, 'Empty Mock Device name');
69 });
70 }, 'Request for characteristic. Should return right characteristic');
71 </script>
OLDNEW
« no previous file with comments | « no previous file | Source/modules/bluetooth/BluetoothGATTCharacteristic.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698