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

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

Issue 1216203003: Replace all sequential_promise_tests (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@update-testharnessjs
Patch Set: Created 5 years, 5 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 | « LayoutTests/bluetooth/connectGATT.html ('k') | LayoutTests/bluetooth/getPrimaryService.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <script src="../resources/testharness.js"></script> 2 <script src="../resources/testharness.js"></script>
3 <script src="../resources/testharness-helpers.js"></script>
4 <script src="../resources/testharnessreport.js"></script> 3 <script src="../resources/testharnessreport.js"></script>
5 <script src="bluetooth-helpers.js"></script> 4 <script src="bluetooth-helpers.js"></script>
6 <script> 5 <script>
7 test(function(t) { assert_true(window.testRunner instanceof Object); t.done(); } , 6 test(function(t) { assert_true(window.testRunner instanceof Object); t.done(); } ,
8 "window.testRunner is required for the following tests."); 7 "window.testRunner is required for the following tests.");
9 8
10 // Generic Access Service. 9 // Generic Access Service.
11 var serviceUUID = "00001800-0000-1000-8000-00805f9b34fb"; 10 var serviceUUID = "00001800-0000-1000-8000-00805f9b34fb";
12 // Device Name Characteristic. Belongs to Generic Access. 11 // Device Name Characteristic. Belongs to Generic Access.
13 var includedCharacteristicUUID = "00002a00-0000-1000-8000-00805f9b34fb"; 12 var includedCharacteristicUUID = "00002a00-0000-1000-8000-00805f9b34fb";
14 // Battery Level. Belongs to Battery Service. 13 // Battery Level. Belongs to Battery Service.
15 var nonIncludedCharacteristicUUID = "00002a19-0000-1000-8000-00805f9b34fb"; 14 var nonIncludedCharacteristicUUID = "00002a19-0000-1000-8000-00805f9b34fb";
16 15
17 sequential_promise_test(function() { 16 promise_test(function() {
18 testRunner.setBluetoothMockDataSet('ConnectableDeviceAdapter'); 17 testRunner.setBluetoothMockDataSet('ConnectableDeviceAdapter');
19 return navigator.bluetooth.requestDevice({ 18 return navigator.bluetooth.requestDevice({
20 filters: [{services: [serviceUUID]}] 19 filters: [{services: [serviceUUID]}]
21 }).then(function(device) { 20 }).then(function(device) {
22 return device.connectGATT(); 21 return device.connectGATT();
23 }).then(function(gattServer) { 22 }).then(function(gattServer) {
24 return gattServer.getPrimaryService(serviceUUID); 23 return gattServer.getPrimaryService(serviceUUID);
25 }).then(function(service) { 24 }).then(function(service) {
26 testRunner.setBluetoothMockDataSet('EmptyAdapter'); 25 testRunner.setBluetoothMockDataSet('EmptyAdapter');
27 return service.getCharacteristic(includedCharacteristicUUID).then(function() { 26 return service.getCharacteristic(includedCharacteristicUUID).then(function() {
28 assert_unreached("Device went out of range, should fail."); 27 assert_unreached("Device went out of range, should fail.");
29 }, function(e) { 28 }, function(e) {
30 assert_equals(e.name, "NetworkError"); 29 assert_equals(e.name, "NetworkError");
31 assert_equals(e.message, 'Bluetooth Device is no longer in range.'); 30 assert_equals(e.message, 'Bluetooth Device is no longer in range.');
32 }); 31 });
33 }); 32 });
34 }, 'Device goes out of range. Reject with NetworkError.'); 33 }, 'Device goes out of range. Reject with NetworkError.');
35 34
36 sequential_promise_test(function() { 35 promise_test(function() {
37 testRunner.setBluetoothMockDataSet('ConnectableDeviceAdapter'); 36 testRunner.setBluetoothMockDataSet('ConnectableDeviceAdapter');
38 return navigator.bluetooth.requestDevice({ 37 return navigator.bluetooth.requestDevice({
39 filters: [{services: [serviceUUID]}] 38 filters: [{services: [serviceUUID]}]
40 }).then(function(device) { 39 }).then(function(device) {
41 return device.connectGATT(); 40 return device.connectGATT();
42 }).then(function(gattServer) { 41 }).then(function(gattServer) {
43 return gattServer.getPrimaryService(serviceUUID); 42 return gattServer.getPrimaryService(serviceUUID);
44 }).then(function(service) { 43 }).then(function(service) {
45 return service.getCharacteristic(nonIncludedCharacteristicUUID); 44 return service.getCharacteristic(nonIncludedCharacteristicUUID);
46 }).then(function(characteristic) { 45 }).then(function(characteristic) {
47 assert_equals(characteristic, null, 46 assert_equals(characteristic, null,
48 "Non existent characteristic should return null."); 47 "Non existent characteristic should return null.");
49 }); 48 });
50 }, 'Request for wrong characteristic. Should return null.'); 49 }, 'Request for wrong characteristic. Should return null.');
51 50
52 sequential_promise_test(function() { 51 promise_test(function() {
53 testRunner.setBluetoothMockDataSet('ConnectableDeviceAdapter'); 52 testRunner.setBluetoothMockDataSet('ConnectableDeviceAdapter');
54 return navigator.bluetooth.requestDevice({ 53 return navigator.bluetooth.requestDevice({
55 filters: [{services: [serviceUUID]}] 54 filters: [{services: [serviceUUID]}]
56 }).then(function(device) { 55 }).then(function(device) {
57 return device.connectGATT(); 56 return device.connectGATT();
58 }).then(function(gattServer) { 57 }).then(function(gattServer) {
59 return gattServer.getPrimaryService(serviceUUID); 58 return gattServer.getPrimaryService(serviceUUID);
60 }).then(function(service) { 59 }).then(function(service) {
61 return service.getCharacteristic(includedCharacteristicUUID); 60 return service.getCharacteristic(includedCharacteristicUUID);
62 }).then(function(characteristic) { 61 }).then(function(characteristic) {
63 assert_equals(characteristic.uuid, includedCharacteristicUUID, 62 assert_equals(characteristic.uuid, includedCharacteristicUUID,
64 "Characteristic UUID should be the same as requested UUID."); 63 "Characteristic UUID should be the same as requested UUID.");
65 }); 64 });
66 }, 'Request for characteristic. Should return right characteristic'); 65 }, 'Request for characteristic. Should return right characteristic');
67 66
68 sequential_promise_test(function() { 67 promise_test(function() {
69 testRunner.setBluetoothMockDataSet('ConnectableDeviceAdapter'); 68 testRunner.setBluetoothMockDataSet('ConnectableDeviceAdapter');
70 return navigator.bluetooth.requestDevice({ 69 return navigator.bluetooth.requestDevice({
71 filters: [{services: [serviceUUID]}] 70 filters: [{services: [serviceUUID]}]
72 }).then(function(device) { 71 }).then(function(device) {
73 return device.connectGATT(); 72 return device.connectGATT();
74 }).then(function(gattServer) { 73 }).then(function(gattServer) {
75 return gattServer.getPrimaryService(serviceUUID); 74 return gattServer.getPrimaryService(serviceUUID);
76 }).then(function(services) { 75 }).then(function(services) {
77 return Promise.all([services.getCharacteristic(includedCharacteristicUUID), 76 return Promise.all([services.getCharacteristic(includedCharacteristicUUID),
78 services.getCharacteristic(includedCharacteristicUUID)]) ; 77 services.getCharacteristic(includedCharacteristicUUID)]) ;
79 }).then(function(characteristics) { 78 }).then(function(characteristics) {
80 // TODO(ortuno): getCharacteristic should return the same object 79 // TODO(ortuno): getCharacteristic should return the same object
81 // if it was created earlier. 80 // if it was created earlier.
82 // https://crbug.com/495270 81 // https://crbug.com/495270
83 assert_not_equals(characteristics[0], characteristics[1], 82 assert_not_equals(characteristics[0], characteristics[1],
84 "Should return the same service as the first call."); 83 "Should return the same service as the first call.");
85 }); 84 });
86 }, 'Calls to get the same characteristic should return the same object.'); 85 }, 'Calls to get the same characteristic should return the same object.');
87 86
88 </script> 87 </script>
OLDNEW
« no previous file with comments | « LayoutTests/bluetooth/connectGATT.html ('k') | LayoutTests/bluetooth/getPrimaryService.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698