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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/peerconnection/RTCPeerConnection-ice.html

Issue 2316573004: Refactor async_test in RTCPeerConnection-ice layout test (Closed)
Patch Set: Add step_func_done to end of 2nd test Created 4 years, 3 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 PUBLIC "-//IETF//DTD HTML//EN"> 1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2 <html> 2 <html>
3 <head> 3 <head>
4 <script src="../../resources/testharness.js"></script> 4 <script src="../../resources/testharness.js"></script>
5 <script src="../../resources/testharnessreport.js"></script> 5 <script src="../../resources/testharnessreport.js"></script>
6 </head> 6 </head>
7 <body> 7 <body>
8 <script> 8 <script>
9 function onIceChange2()
10 {
11 if (window.pc.iceConnectionState === "closed") {
12 calledCallbacks.push("iceConnectionState closed");
13 assert_array_equals(calledCallbacks, [
14 'iceConnectionState complete',
15 'expectedTypeError',
16 'expectedTypeError',
17 'expectedTypeError',
18 'expectedTypeError',
19 'success1',
20 'success2',
21 'success3',
22 'success4',
23 'iceConnectionState closed'
24 ]);
25 window.testRTC.done();
26 }
27 }
28 9
29 function addIceCandidateSuccess1() 10 async_test(function(t) {
30 { 11 const localPeerConnection = new webkitRTCPeerConnection(null, null);
31 calledCallbacks.push('success1'); 12 localPeerConnection.close();
32 window.pc.addIceCandidate({candidate: "candidate", sdpMid: 0}, addIceCandida teSuccess2, unexpectedCallback);
33 }
34 13
35 function addIceCandidateSuccess2() 14 let counter = 0;
36 { 15 window.events = [];
37 calledCallbacks.push('success2');
38 window.pc.addIceCandidate({candidate: "candidate", sdpMLineIndex: 0}, addIce CandidateSuccess3, unexpectedCallback);
39 }
40 16
41 function addIceCandidateSuccess3() 17 Promise.resolve().then(_ => events[counter++] = 1);
42 {
43 calledCallbacks.push('success3');
44 window.pc.addIceCandidate({candidate: "candidate", sdpMid: 0, sdpMLineIndex: 0}, addIceCandidateSuccess4, unexpectedCallback);
45 }
46 18
47 function addIceCandidateSuccess4() 19 const iceCandidate = new RTCIceCandidate({candidate: 'nano nano'});
48 {
49 calledCallbacks.push('success4');
50 window.pc.oniceconnectionstatechange = onIceChange2;
51 window.pc.close();
52 }
53 20
54 function unexpectedCallback() 21 const unexpectedCallback = t.step_func(function() {
55 { 22 assert_unreached('Unexpected callback');
56 assert_unreached('Unexpected callback'); 23 });
57 }
58 24
59 function expectedTypeError(error) 25 localPeerConnection.addIceCandidate(iceCandidate, unexpectedCallback, t.step _func(error => {
60 {
61 assert_equals(error.name, 'TypeError');
62 calledCallbacks.push('expectedTypeError');
63 }
64
65 function onIceChange1()
66 {
67 if (window.pc.iceConnectionState === "completed") {
68 calledCallbacks.push('iceConnectionState complete');
69 var iceCandidate = new RTCIceCandidate({candidate: "nano nano"});
70 window.pc.addIceCandidate(null, unexpectedCallback, unexpectedCallback). catch(expectedTypeError);
71 window.pc.addIceCandidate({candidate: "candidate"}, unexpectedCallback, unexpectedCallback).catch(expectedTypeError);
72 window.pc.addIceCandidate(iceCandidate, null, unexpectedCallback).catch( expectedTypeError);
73 window.pc.addIceCandidate(iceCandidate, unexpectedCallback, null).catch( expectedTypeError);
74 window.pc.addIceCandidate(iceCandidate, addIceCandidateSuccess1, unexpec tedCallback);
75 }
76 }
77
78 function testExecutionOrderClosedConnection()
79 {
80 var localPeerConnection = new webkitRTCPeerConnection(null, null);
81 localPeerConnection.close();
82 var counter = 0;
83 window.events = [];
84 Promise.resolve().then(_ => events[counter++] = 1);
85 var iceCandidate = new RTCIceCandidate({candidate:"nano nano"});
86 localPeerConnection.addIceCandidate(iceCandidate, unexpectedCallback, error => {
87 assert_equals(error.name, 'InvalidStateError'); 26 assert_equals(error.name, 'InvalidStateError');
88 assert_equals(error.toString(), 'InvalidStateError: The RTCPeerConnectio n\'s signalingState is \'closed\'.'); 27 assert_equals(error.toString(), 'InvalidStateError: The RTCPeerConnectio n\'s signalingState is \'closed\'.');
89 events[counter++] = 2; 28 events[counter++] = 2;
90 }); 29 }));
91 Promise.resolve().then(_ => { 30
31 Promise.resolve().then(t.step_func_done(_ => {
92 events[counter++] = 3; 32 events[counter++] = 3;
93 assert_array_equals(events, [1, 2, 3]); 33 assert_array_equals(events, [1, 2, 3]);
34 }));
35 }, 'Tests closed connection execution order.');
36
37 async_test(function(t) {
38 const unexpectedCallback = t.step_func(function() {
39 assert_unreached('Unexpected callback');
94 }); 40 });
95 }
96 41
97 window.calledCallbacks = []; 42 const expectedTypeError = t.step_func(function(error) {
98 window.testRTC = async_test("Tests the RTCPeerConnection Ice functionality."); 43 assert_equals(error.name, 'TypeError');
44 calledCallbacks.push('expectedTypeError');
45 });
99 46
100 testExecutionOrderClosedConnection(); 47 const addIceCandidateSuccess1 = t.step_func(function() {
101 window.pc = new webkitRTCPeerConnection(null, null); 48 calledCallbacks.push('success1');
102 window.pc.oniceconnectionstatechange = onIceChange1; 49 pc.addIceCandidate({candidate: 'candidate', sdpMid: 0}, addIceCandidateS uccess2, unexpectedCallback);
50 });
51
52 const addIceCandidateSuccess2 = t.step_func(function() {
53 calledCallbacks.push('success2');
54 pc.addIceCandidate({candidate: 'candidate', sdpMLineIndex: 0}, addIceCan didateSuccess3, unexpectedCallback);
55 });
56
57 const addIceCandidateSuccess3 = t.step_func(function() {
58 calledCallbacks.push('success3');
59 pc.addIceCandidate({candidate: 'candidate', sdpMid: 0, sdpMLineIndex: 0} , addIceCandidateSuccess4, unexpectedCallback);
60 });
61
62 const addIceCandidateSuccess4 = t.step_func(function() {
63 calledCallbacks.push('success4');
64 pc.oniceconnectionstatechange = t.step_func_done(onIceChange2);
65 pc.close();
66 });
67
68 const onIceChange1 = t.step_func(function() {
69 if (pc.iceConnectionState === 'completed') {
70 calledCallbacks.push('iceConnectionState complete');
71 const iceCandidate = new RTCIceCandidate({candidate: 'nano nano'});
72 pc.addIceCandidate(null, unexpectedCallback, unexpectedCallback).cat ch(expectedTypeError);
73 pc.addIceCandidate({candidate: 'candidate'}, unexpectedCallback, une xpectedCallback).catch(expectedTypeError);
74 pc.addIceCandidate(iceCandidate, null, unexpectedCallback).catch(exp ectedTypeError);
75 pc.addIceCandidate(iceCandidate, unexpectedCallback, null).catch(exp ectedTypeError);
76 pc.addIceCandidate(iceCandidate, addIceCandidateSuccess1, unexpected Callback);
77 }
78 });
79
80 const onIceChange2 = t.step_func_done(function() {
81 if (pc.iceConnectionState === 'closed') {
82 calledCallbacks.push('iceConnectionState closed');
83 assert_array_equals(calledCallbacks, [
84 'iceConnectionState complete',
85 'expectedTypeError',
86 'expectedTypeError',
87 'expectedTypeError',
88 'expectedTypeError',
89 'success1',
90 'success2',
91 'success3',
92 'success4',
93 'iceConnectionState closed'
94 ]);
95 }
96 });
97
98 const calledCallbacks = [];
99 const pc = new webkitRTCPeerConnection(null, null);
100 pc.oniceconnectionstatechange = t.step_func(onIceChange1);
101 }, 'Tests the RTCPeerConnection Ice functionality.');
103 </script> 102 </script>
104 </body> 103 </body>
105 </html> 104 </html>
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