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

Side by Side Diff: LayoutTests/bluetooth/writeValue.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
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(function(t) { assert_exists(window, 'testRunner'); t.done(); }, 8 test(function(t) { assert_exists(window, 'testRunner'); 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 => service.getCharacteristic('gap.device_name')) 16 .then(service => service.getCharacteristic('gap.device_name'))
18 .then(characteristic => { 17 .then(characteristic => {
19 testRunner.setBluetoothMockDataSet('EmptyAdapter'); 18 testRunner.setBluetoothMockDataSet('EmptyAdapter');
20 return assert_promise_rejects_with_message( 19 return assert_promise_rejects_with_message(
21 characteristic.writeValue(new ArrayBuffer(1 /* length */)), { 20 characteristic.writeValue(new ArrayBuffer(1 /* length */)), {
22 name: 'NetworkError', 21 name: 'NetworkError',
23 message: 'Bluetooth Device is no longer in range.' 22 message: 'Bluetooth Device is no longer in range.'
24 }, 'Device went out of range.'); 23 }, 'Device went out of range.');
25 }); 24 });
26 }, 'Device goes out of range. Reject with NetworkError.'); 25 }, 'Device goes out of range. Reject with NetworkError.');
27 26
28 sequential_promise_test(() => { 27 promise_test(() => {
29 testRunner.setBluetoothMockDataSet('GenericAccessAdapter'); 28 testRunner.setBluetoothMockDataSet('GenericAccessAdapter');
30 return requestDeviceWithKeyDown({filters: [{services: ['generic_access']}]}) 29 return requestDeviceWithKeyDown({filters: [{services: ['generic_access']}]})
31 .then(device => device.connectGATT()) 30 .then(device => device.connectGATT())
32 .then(gattServer => gattServer.getPrimaryService('generic_access')) 31 .then(gattServer => gattServer.getPrimaryService('generic_access'))
33 .then(service => service.getCharacteristic('gap.device_name')) 32 .then(service => service.getCharacteristic('gap.device_name'))
34 .then(characteristic => { 33 .then(characteristic => {
35 testRunner.setBluetoothMockDataSet('MissingServiceGenericAccessAdapter'); 34 testRunner.setBluetoothMockDataSet('MissingServiceGenericAccessAdapter');
36 return assert_promise_rejects_with_message( 35 return assert_promise_rejects_with_message(
37 characteristic.writeValue(new ArrayBuffer(1 /* length */)), { 36 characteristic.writeValue(new ArrayBuffer(1 /* length */)), {
38 name: 'InvalidStateError', 37 name: 'InvalidStateError',
39 message: 'GATT Service no longer exists.' 38 message: 'GATT Service no longer exists.'
40 }, 'Service got removed.'); 39 }, 'Service got removed.');
41 }); 40 });
42 }, 'Service gets removed. Reject with InvalidStateError.'); 41 }, 'Service gets removed. Reject with InvalidStateError.');
43 42
44 sequential_promise_test(() => { 43 promise_test(() => {
45 testRunner.setBluetoothMockDataSet('GenericAccessAdapter'); 44 testRunner.setBluetoothMockDataSet('GenericAccessAdapter');
46 return requestDeviceWithKeyDown({filters: [{services: ['generic_access']}]}) 45 return requestDeviceWithKeyDown({filters: [{services: ['generic_access']}]})
47 .then(device => device.connectGATT()) 46 .then(device => device.connectGATT())
48 .then(gattServer => gattServer.getPrimaryService('generic_access')) 47 .then(gattServer => gattServer.getPrimaryService('generic_access'))
49 .then(service => service.getCharacteristic('gap.device_name')) 48 .then(service => service.getCharacteristic('gap.device_name'))
50 .then(characteristic => { 49 .then(characteristic => {
51 testRunner.setBluetoothMockDataSet('MissingCharacteristicGenericAccessAdap ter'); 50 testRunner.setBluetoothMockDataSet('MissingCharacteristicGenericAccessAdap ter');
52 return assert_promise_rejects_with_message( 51 return assert_promise_rejects_with_message(
53 characteristic.writeValue(new ArrayBuffer(1 /* length */)), { 52 characteristic.writeValue(new ArrayBuffer(1 /* length */)), {
54 name: 'InvalidStateError', 53 name: 'InvalidStateError',
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 message: 'GATT Error: Not paired.' 117 message: 'GATT Error: Not paired.'
119 } 118 }
120 }, { 119 }, {
121 testName: 'GATT Error: Not Supported.', 120 testName: 'GATT Error: Not Supported.',
122 uuid: errorUUID(0xA8), 121 uuid: errorUUID(0xA8),
123 error: { 122 error: {
124 name: 'NotSupportedError', 123 name: 'NotSupportedError',
125 message: 'GATT Error: Not supported.' 124 message: 'GATT Error: Not supported.'
126 } 125 }
127 }].forEach(testSpec => { 126 }].forEach(testSpec => {
128 sequential_promise_test(() => { 127 promise_test(() => {
129 testRunner.setBluetoothMockDataSet('FailingGATTOperationsAdapter'); 128 testRunner.setBluetoothMockDataSet('FailingGATTOperationsAdapter');
130 return requestDeviceWithKeyDown({filters: [{services: [errorUUID(0xA0)]}]}) 129 return requestDeviceWithKeyDown({filters: [{services: [errorUUID(0xA0)]}]})
131 .then(device => device.connectGATT()) 130 .then(device => device.connectGATT())
132 .then(gattServer => gattServer.getPrimaryService(errorUUID(0xA0))) 131 .then(gattServer => gattServer.getPrimaryService(errorUUID(0xA0)))
133 .then(service => service.getCharacteristic(testSpec.uuid)) 132 .then(service => service.getCharacteristic(testSpec.uuid))
134 .then(characteristic => { 133 .then(characteristic => {
135 return assert_promise_rejects_with_message( 134 return assert_promise_rejects_with_message(
136 characteristic.writeValue(new Uint8Array([1])), 135 characteristic.writeValue(new Uint8Array([1])),
137 testSpec.error, 136 testSpec.error,
138 'Trying to write to a characteristic failed.'); 137 'Trying to write to a characteristic failed.');
139 }); 138 });
140 }, testSpec.testName); 139 }, testSpec.testName);
141 }); 140 });
142 141
143 sequential_promise_test(() => { 142 promise_test(() => {
144 testRunner.setBluetoothMockDataSet('GenericAccessAdapter'); 143 testRunner.setBluetoothMockDataSet('GenericAccessAdapter');
145 return requestDeviceWithKeyDown({filters: [{services: ['generic_access']}]}) 144 return requestDeviceWithKeyDown({filters: [{services: ['generic_access']}]})
146 .then(device => device.connectGATT()) 145 .then(device => device.connectGATT())
147 .then(gattServer => gattServer.getPrimaryService('generic_access')) 146 .then(gattServer => gattServer.getPrimaryService('generic_access'))
148 .then(service => service.getCharacteristic('gap.device_name')) 147 .then(service => service.getCharacteristic('gap.device_name'))
149 .then(characteristic => { 148 .then(characteristic => {
150 return assert_promise_rejects_with_message( 149 return assert_promise_rejects_with_message(
151 characteristic.writeValue(new Uint8Array(513 /* length */)), { 150 characteristic.writeValue(new Uint8Array(513 /* length */)), {
152 name: 'InvalidModificationError', 151 name: 'InvalidModificationError',
153 message: 'Value can\'t exceed 512 bytes.' 152 message: 'Value can\'t exceed 512 bytes.'
154 }, 'Value passed was too long.'); 153 }, 'Value passed was too long.');
155 }); 154 });
156 }, 'Trying to write more than 512 bytes should return an error.'); 155 }, 'Trying to write more than 512 bytes should return an error.');
157 156
158 sequential_promise_test(() => { 157 promise_test(() => {
159 testRunner.setBluetoothMockDataSet('GenericAccessAdapter'); 158 testRunner.setBluetoothMockDataSet('GenericAccessAdapter');
160 return requestDeviceWithKeyDown({filters: [{services: ['generic_access']}]}) 159 return requestDeviceWithKeyDown({filters: [{services: ['generic_access']}]})
161 .then(device => device.connectGATT()) 160 .then(device => device.connectGATT())
162 .then(gattServer => gattServer.getPrimaryService('generic_access')) 161 .then(gattServer => gattServer.getPrimaryService('generic_access'))
163 .then(service => service.getCharacteristic('gap.device_name')) 162 .then(service => service.getCharacteristic('gap.device_name'))
164 .then(characteristic => Promise.all( 163 .then(characteristic => Promise.all(
165 [characteristic.writeValue(new Uint8Array(1 /* length */)), 164 [characteristic.writeValue(new Uint8Array(1 /* length */)),
166 characteristic.writeValue(new ArrayBuffer(1 /* length */)), 165 characteristic.writeValue(new ArrayBuffer(1 /* length */)),
167 characteristic.writeValue(new DataView(new ArrayBuffer(1 /* length */)))] )); 166 characteristic.writeValue(new DataView(new ArrayBuffer(1 /* length */)))] ));
168 }, 'A regular write request to a writable characteristic should succeed.'); 167 }, 'A regular write request to a writable characteristic should succeed.');
169 </script> 168 </script>
OLDNEW
« no previous file with comments | « LayoutTests/bluetooth/requestDevice.html ('k') | LayoutTests/http/tests/fetch/chromium/error-messages.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698