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

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

Issue 1295373003: Remove sequential_promise_test helper, just use promise_test (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: remove testharness-helpers.js inclusion from bluetooth tests Created 5 years, 4 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 | Annotate | Revision Log
« 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="resources/bluetooth-helpers.js"></script> 4 <script src="resources/bluetooth-helpers.js"></script>
6 <script> 5 <script>
7 'use strict'; 6 'use strict';
8 7
9 test(t => { assert_true(window.testRunner instanceof Object); t.done(); }, 8 test(t => { assert_true(window.testRunner instanceof Object); t.done(); },
10 'window.testRunner is required for the following tests.'); 9 'window.testRunner is required for the following tests.');
11 10
12 sequential_promise_test(() => { 11 promise_test(() => {
13 testRunner.setBluetoothMockDataSet('GenericAccessAdapter'); 12 testRunner.setBluetoothMockDataSet('GenericAccessAdapter');
14 return requestDeviceWithKeyDown({filters: [{services: ['generic_access']}]}) 13 return requestDeviceWithKeyDown({filters: [{services: ['generic_access']}]})
15 .then(device => device.connectGATT()) 14 .then(device => device.connectGATT())
16 .then(gattServer => gattServer.getPrimaryService('generic_access')) 15 .then(gattServer => gattServer.getPrimaryService('generic_access'))
17 .then(service => { 16 .then(service => {
18 testRunner.setBluetoothMockDataSet('EmptyAdapter'); 17 testRunner.setBluetoothMockDataSet('EmptyAdapter');
19 return assert_promise_rejects_with_message( 18 return assert_promise_rejects_with_message(
20 service.getCharacteristic('gap.device_name'), { 19 service.getCharacteristic('gap.device_name'), {
21 name: 'NetworkError', 20 name: 'NetworkError',
22 message: 'Bluetooth Device is no longer in range.' 21 message: 'Bluetooth Device is no longer in range.'
23 }, 'Device went out of range.'); 22 }, 'Device went out of range.');
24 }); 23 });
25 }, 'Device goes out of range. Reject with NetworkError.'); 24 }, 'Device goes out of range. Reject with NetworkError.');
26 25
27 sequential_promise_test(() => { 26 promise_test(() => {
28 testRunner.setBluetoothMockDataSet('GenericAccessAdapter'); 27 testRunner.setBluetoothMockDataSet('GenericAccessAdapter');
29 return requestDeviceWithKeyDown({filters: [{services: ['generic_access']}]}) 28 return requestDeviceWithKeyDown({filters: [{services: ['generic_access']}]})
30 .then(device => device.connectGATT()) 29 .then(device => device.connectGATT())
31 .then(gattService => gattService.getPrimaryService('generic_access')) 30 .then(gattService => gattService.getPrimaryService('generic_access'))
32 .then(service => { 31 .then(service => {
33 testRunner.setBluetoothMockDataSet('MissingServiceGenericAccessAdapter'); 32 testRunner.setBluetoothMockDataSet('MissingServiceGenericAccessAdapter');
34 return assert_promise_rejects_with_message( 33 return assert_promise_rejects_with_message(
35 service.getCharacteristic('gap.device_name'), { 34 service.getCharacteristic('gap.device_name'), {
36 name: 'InvalidStateError', 35 name: 'InvalidStateError',
37 message: 'GATT Service no longer exists.' 36 message: 'GATT Service no longer exists.'
38 }, 'Service got removed.'); 37 }, 'Service got removed.');
39 }); 38 });
40 }, 'Service is removed. Reject with InvalidStateError.'); 39 }, 'Service is removed. Reject with InvalidStateError.');
41 40
42 41
43 sequential_promise_test(() => { 42 promise_test(() => {
44 testRunner.setBluetoothMockDataSet('GenericAccessAdapter'); 43 testRunner.setBluetoothMockDataSet('GenericAccessAdapter');
45 return requestDeviceWithKeyDown({filters: [{services: ['generic_access']}]}) 44 return requestDeviceWithKeyDown({filters: [{services: ['generic_access']}]})
46 .then(device => device.connectGATT()) 45 .then(device => device.connectGATT())
47 .then(gattServer => gattServer.getPrimaryService('generic_access')) 46 .then(gattServer => gattServer.getPrimaryService('generic_access'))
48 .then(service => Promise.all( 47 .then(service => Promise.all(
49 [service.getCharacteristic(battery_level.alias), 48 [service.getCharacteristic(battery_level.alias),
50 service.getCharacteristic(battery_level.name), 49 service.getCharacteristic(battery_level.name),
51 service.getCharacteristic(battery_level.uuid)])) 50 service.getCharacteristic(battery_level.uuid)]))
52 .then(characteristics => { 51 .then(characteristics => {
53 characteristics.forEach(characteristic => { 52 characteristics.forEach(characteristic => {
54 assert_equals(characteristic, null, 53 assert_equals(characteristic, null,
55 'Non existent characteristic should return null.'); 54 'Non existent characteristic should return null.');
56 }); 55 });
57 }); 56 });
58 }, 'Request for wrong characteristic. Should return null.'); 57 }, 'Request for wrong characteristic. Should return null.');
59 58
60 sequential_promise_test(() => { 59 promise_test(() => {
61 testRunner.setBluetoothMockDataSet('GenericAccessAdapter'); 60 testRunner.setBluetoothMockDataSet('GenericAccessAdapter');
62 return requestDeviceWithKeyDown({filters: [{services: ['generic_access']}]}) 61 return requestDeviceWithKeyDown({filters: [{services: ['generic_access']}]})
63 .then(device => device.connectGATT()) 62 .then(device => device.connectGATT())
64 .then(gattServer => gattServer.getPrimaryService('generic_access')) 63 .then(gattServer => gattServer.getPrimaryService('generic_access'))
65 .then(service => Promise.all( 64 .then(service => Promise.all(
66 [service.getCharacteristic(device_name.alias), 65 [service.getCharacteristic(device_name.alias),
67 service.getCharacteristic(device_name.name), 66 service.getCharacteristic(device_name.name),
68 service.getCharacteristic(device_name.uuid)])) 67 service.getCharacteristic(device_name.uuid)]))
69 .then(characteristics => { 68 .then(characteristics => {
70 characteristics.forEach(characteristic => { 69 characteristics.forEach(characteristic => {
71 assert_equals( 70 assert_equals(
72 characteristic.uuid, device_name.uuid, 71 characteristic.uuid, device_name.uuid,
73 'Characteristic UUID should be the same as requested UUID.'); 72 'Characteristic UUID should be the same as requested UUID.');
74 }); 73 });
75 }); 74 });
76 }, 'Request for characteristic. Should return right characteristic'); 75 }, 'Request for characteristic. Should return right characteristic');
77 76
78 sequential_promise_test(() => { 77 promise_test(() => {
79 testRunner.setBluetoothMockDataSet('GenericAccessAdapter'); 78 testRunner.setBluetoothMockDataSet('GenericAccessAdapter');
80 return requestDeviceWithKeyDown({filters: [{services: ['generic_access']}]}) 79 return requestDeviceWithKeyDown({filters: [{services: ['generic_access']}]})
81 .then(device => device.connectGATT()) 80 .then(device => device.connectGATT())
82 .then(gattServer => gattServer.getPrimaryService('generic_access')) 81 .then(gattServer => gattServer.getPrimaryService('generic_access'))
83 .then(services => Promise.all( 82 .then(services => Promise.all(
84 [services.getCharacteristic(device_name.alias), 83 [services.getCharacteristic(device_name.alias),
85 services.getCharacteristic(device_name.alias), 84 services.getCharacteristic(device_name.alias),
86 services.getCharacteristic(device_name.name), 85 services.getCharacteristic(device_name.name),
87 services.getCharacteristic(device_name.name), 86 services.getCharacteristic(device_name.name),
88 services.getCharacteristic(device_name.uuid), 87 services.getCharacteristic(device_name.uuid),
89 services.getCharacteristic(device_name.uuid)])) 88 services.getCharacteristic(device_name.uuid)]))
90 .then(characteristics => { 89 .then(characteristics => {
91 // TODO(ortuno): getCharacteristic should return the same object 90 // TODO(ortuno): getCharacteristic should return the same object
92 // if it was created earlier. 91 // if it was created earlier.
93 // https://crbug.com/495270 92 // https://crbug.com/495270
94 for (var i = 1; i < characteristics.length; i++) { 93 for (var i = 1; i < characteristics.length; i++) {
95 assert_not_equals( 94 assert_not_equals(
96 characteristics[0], characteristics[i], 95 characteristics[0], characteristics[i],
97 'Should return the same characteristic as the first call.'); 96 'Should return the same characteristic as the first call.');
98 } 97 }
99 }); 98 });
100 }, 'Calls to get the same characteristic should return the same object.'); 99 }, 'Calls to get the same characteristic should return the same object.');
101 100
102 sequential_promise_test(() => { 101 promise_test(() => {
103 testRunner.setBluetoothMockDataSet('GenericAccessAdapter'); 102 testRunner.setBluetoothMockDataSet('GenericAccessAdapter');
104 return requestDeviceWithKeyDown({filters: [{services: ['generic_access']}]}) 103 return requestDeviceWithKeyDown({filters: [{services: ['generic_access']}]})
105 .then(device => device.connectGATT()) 104 .then(device => device.connectGATT())
106 .then(gattServer => gattServer.getPrimaryService('generic_access')) 105 .then(gattServer => gattServer.getPrimaryService('generic_access'))
107 .then(service => { 106 .then(service => {
108 return assert_promise_rejects_with_message( 107 return assert_promise_rejects_with_message(
109 service.getCharacteristic('wrong_name'), { 108 service.getCharacteristic('wrong_name'), {
110 name: 'SyntaxError', 109 name: 'SyntaxError',
111 message: 'Failed to execute \'getCharacteristic\' on ' + 110 message: 'Failed to execute \'getCharacteristic\' on ' +
112 '\'BluetoothGATTService\': \Invalid Characteristic name: ' + 111 '\'BluetoothGATTService\': \Invalid Characteristic name: ' +
113 '\'wrong_name\'.' 112 '\'wrong_name\'.'
114 }, 'Wrong Characteristic name passed.'); 113 }, 'Wrong Characteristic name passed.');
115 }); 114 });
116 }, 'Wrong Characteristic name. Reject with SyntaxError.'); 115 }, 'Wrong Characteristic name. Reject with SyntaxError.');
117 </script> 116 </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