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

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

Issue 1062393002: bluetooth: Use sequential_promise_test to stop test from running in parallel. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 8 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 | no next file » | 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/testharnessreport.js"></script> 3 <script src="../resources/testharnessreport.js"></script>
4 <script> 4 <script>
5 5
6 var promise_tests = Promise.resolve();
7 // Helper function to run promise tests one after the other.
Jeffrey Yasskin 2015/04/10 23:56:13 Add a TODO to remove this once https://github.com/
8 function sequential_promise_test(func, name) {
9 var test = async_test(name);
10 promise_tests = promise_tests.then(function() {
11 return Promise.resolve(test.step(func, test, test))
12 .then(
13 function() {
14 test.done();
15 })
16 .catch(test.step_func(
17 function(value) {
18 throw value;
19 }));
20 });
21 }
22
6 test(function(t) { assert_exists(window, "testRunner"); t.done(); }, 23 test(function(t) { assert_exists(window, "testRunner"); t.done(); },
7 "window.testRunner is required for the following tests."); 24 "window.testRunner is required for the following tests.");
8 25
9 async_test(function(t) { 26 sequential_promise_test(function(t) {
10 testRunner.setBluetoothMockDataSet('RejectRequestDevice_NotFoundError'); 27 testRunner.setBluetoothMockDataSet('RejectRequestDevice_NotFoundError');
11 navigator.bluetooth.requestDevice() 28 return navigator.bluetooth.requestDevice()
12 .then( 29 .then(
13 t.step_func(function() { assert_unreached('Mock was set to reject.'); }), 30 function() {
14 t.step_func(function(e) { 31 assert_unreached('Mock was set to reject.');
15 assert_equals(e.name, 'NotFoundError'); 32 },
16 t.done(); 33 function(e) {
17 })); 34 assert_equals(e.name, 'NotFoundErrora');
35 });
18 }, 'Reject with NotFoundError.'); 36 }, 'Reject with NotFoundError.');
19 37
20 async_test(function(t) { 38 sequential_promise_test(function(t) {
21 testRunner.setBluetoothMockDataSet('RejectRequestDevice_SecurityError'); 39 testRunner.setBluetoothMockDataSet('RejectRequestDevice_SecurityError');
22 navigator.bluetooth.requestDevice() 40 return navigator.bluetooth.requestDevice()
23 .then( 41 .then(
24 t.step_func(function() { assert_unreached('Mock was set to reject.'); }), 42 function() {
25 t.step_func(function(e) { 43 » assert_unreached('Mock was set to reject.');
44 },
45 function(e) {
26 assert_equals(e.name, 'SecurityError'); 46 assert_equals(e.name, 'SecurityError');
27 t.done(); 47 });
28 }));
29 }, 'Reject with SecurityError.'); 48 }, 'Reject with SecurityError.');
30 49
31 async_test(function(t) { 50 sequential_promise_test(function() {
32 testRunner.setBluetoothMockDataSet('Single Empty Device'); 51 testRunner.setBluetoothMockDataSet('Single Empty Device');
33 navigator.bluetooth.requestDevice() 52 return navigator.bluetooth.requestDevice()
34 .then( 53 .then(function(device) {
35 t.step_func(function(device) { 54 assert_equals(device.constructor.name, "BluetoothDevice");
36 assert_equals(device.constructor.name, "BluetoothDevice"); 55 });
37 t.done();
38 }),
39 t.step_func(function() { assert_unreached('Mock was set to resolve.'); })) ;
40 }, 'Mock will resolve.'); 56 }, 'Mock will resolve.');
41
42 </script> 57 </script>
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698