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

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: Fix Web Exposed Layout Test 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 | LayoutTests/webexposed/global-interface-listing-expected.txt » ('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 }, 'Characteristic is not readable. Reject with NetworkError.');
52
53 // TODO(ortuno): Add a test for when a characterstics gets removed.
54 // http://crbug.com/499552
55
56 sequential_promise_test(function() {
57 testRunner.setBluetoothMockDataSet('ConnectableDeviceAdapter');
58 return navigator.bluetooth.requestDevice().then(function(device) {
59 return device.connectGATT();
60 }).then(function(gattServer) {
61 return gattServer.getPrimaryService(serviceUUID);
62 }).then(function(service) {
63 return service.getCharacteristic(includedCharacteristicUUID);
64 }).then(function(characteristic) {
65 return characteristic.readValue();
66 }).then(function(value) {
67 var decoder = new TextDecoder('utf-8');
68 var value_str = decoder.decode(value);
69 assert_equals(value_str, 'Empty Mock Device name');
70 });
71 }, 'Request for characteristic. Should return right characteristic');
72 </script>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/webexposed/global-interface-listing-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698