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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/fast/peerconnection/RTCPeerConnection-ice.html
diff --git a/third_party/WebKit/LayoutTests/fast/peerconnection/RTCPeerConnection-ice.html b/third_party/WebKit/LayoutTests/fast/peerconnection/RTCPeerConnection-ice.html
index 934839020d6996be6d9f682de355e51311e85619..3c6b1f8669f86b9d16fb06b8a46428c9bf07e37a 100644
--- a/third_party/WebKit/LayoutTests/fast/peerconnection/RTCPeerConnection-ice.html
+++ b/third_party/WebKit/LayoutTests/fast/peerconnection/RTCPeerConnection-ice.html
@@ -6,100 +6,99 @@
</head>
<body>
<script>
-function onIceChange2()
-{
- if (window.pc.iceConnectionState === "closed") {
- calledCallbacks.push("iceConnectionState closed");
- assert_array_equals(calledCallbacks, [
- 'iceConnectionState complete',
- 'expectedTypeError',
- 'expectedTypeError',
- 'expectedTypeError',
- 'expectedTypeError',
- 'success1',
- 'success2',
- 'success3',
- 'success4',
- 'iceConnectionState closed'
- ]);
- window.testRTC.done();
- }
-}
-
-function addIceCandidateSuccess1()
-{
- calledCallbacks.push('success1');
- window.pc.addIceCandidate({candidate: "candidate", sdpMid: 0}, addIceCandidateSuccess2, unexpectedCallback);
-}
-
-function addIceCandidateSuccess2()
-{
- calledCallbacks.push('success2');
- window.pc.addIceCandidate({candidate: "candidate", sdpMLineIndex: 0}, addIceCandidateSuccess3, unexpectedCallback);
-}
-
-function addIceCandidateSuccess3()
-{
- calledCallbacks.push('success3');
- window.pc.addIceCandidate({candidate: "candidate", sdpMid: 0, sdpMLineIndex: 0}, addIceCandidateSuccess4, unexpectedCallback);
-}
-
-function addIceCandidateSuccess4()
-{
- calledCallbacks.push('success4');
- window.pc.oniceconnectionstatechange = onIceChange2;
- window.pc.close();
-}
-
-function unexpectedCallback()
-{
- assert_unreached('Unexpected callback');
-}
-
-function expectedTypeError(error)
-{
- assert_equals(error.name, 'TypeError');
- calledCallbacks.push('expectedTypeError');
-}
-
-function onIceChange1()
-{
- if (window.pc.iceConnectionState === "completed") {
- calledCallbacks.push('iceConnectionState complete');
- var iceCandidate = new RTCIceCandidate({candidate: "nano nano"});
- window.pc.addIceCandidate(null, unexpectedCallback, unexpectedCallback).catch(expectedTypeError);
- window.pc.addIceCandidate({candidate: "candidate"}, unexpectedCallback, unexpectedCallback).catch(expectedTypeError);
- window.pc.addIceCandidate(iceCandidate, null, unexpectedCallback).catch(expectedTypeError);
- window.pc.addIceCandidate(iceCandidate, unexpectedCallback, null).catch(expectedTypeError);
- window.pc.addIceCandidate(iceCandidate, addIceCandidateSuccess1, unexpectedCallback);
- }
-}
-
-function testExecutionOrderClosedConnection()
-{
- var localPeerConnection = new webkitRTCPeerConnection(null, null);
+
+async_test(function(t) {
+ const localPeerConnection = new webkitRTCPeerConnection(null, null);
localPeerConnection.close();
- var counter = 0;
+
+ let counter = 0;
window.events = [];
+
Promise.resolve().then(_ => events[counter++] = 1);
- var iceCandidate = new RTCIceCandidate({candidate:"nano nano"});
- localPeerConnection.addIceCandidate(iceCandidate, unexpectedCallback, error => {
+
+ const iceCandidate = new RTCIceCandidate({candidate: 'nano nano'});
+
+ const unexpectedCallback = t.step_func(function() {
+ assert_unreached('Unexpected callback');
+ });
+
+ localPeerConnection.addIceCandidate(iceCandidate, unexpectedCallback, t.step_func(error => {
assert_equals(error.name, 'InvalidStateError');
assert_equals(error.toString(), 'InvalidStateError: The RTCPeerConnection\'s signalingState is \'closed\'.');
events[counter++] = 2;
- });
- Promise.resolve().then(_ => {
+ }));
+
+ Promise.resolve().then(t.step_func_done(_ => {
events[counter++] = 3;
assert_array_equals(events, [1, 2, 3]);
+ }));
+}, 'Tests closed connection execution order.');
+
+async_test(function(t) {
+ const unexpectedCallback = t.step_func(function() {
+ assert_unreached('Unexpected callback');
+ });
+
+ const expectedTypeError = t.step_func(function(error) {
+ assert_equals(error.name, 'TypeError');
+ calledCallbacks.push('expectedTypeError');
});
-}
-window.calledCallbacks = [];
-window.testRTC = async_test("Tests the RTCPeerConnection Ice functionality.");
+ const addIceCandidateSuccess1 = t.step_func(function() {
+ calledCallbacks.push('success1');
+ pc.addIceCandidate({candidate: 'candidate', sdpMid: 0}, addIceCandidateSuccess2, unexpectedCallback);
+ });
+
+ const addIceCandidateSuccess2 = t.step_func(function() {
+ calledCallbacks.push('success2');
+ pc.addIceCandidate({candidate: 'candidate', sdpMLineIndex: 0}, addIceCandidateSuccess3, unexpectedCallback);
+ });
+
+ const addIceCandidateSuccess3 = t.step_func(function() {
+ calledCallbacks.push('success3');
+ pc.addIceCandidate({candidate: 'candidate', sdpMid: 0, sdpMLineIndex: 0}, addIceCandidateSuccess4, unexpectedCallback);
+ });
+
+ const addIceCandidateSuccess4 = t.step_func(function() {
+ calledCallbacks.push('success4');
+ pc.oniceconnectionstatechange = t.step_func_done(onIceChange2);
+ pc.close();
+ });
+
+ const onIceChange1 = t.step_func(function() {
+ if (pc.iceConnectionState === 'completed') {
+ calledCallbacks.push('iceConnectionState complete');
+ const iceCandidate = new RTCIceCandidate({candidate: 'nano nano'});
+ pc.addIceCandidate(null, unexpectedCallback, unexpectedCallback).catch(expectedTypeError);
+ pc.addIceCandidate({candidate: 'candidate'}, unexpectedCallback, unexpectedCallback).catch(expectedTypeError);
+ pc.addIceCandidate(iceCandidate, null, unexpectedCallback).catch(expectedTypeError);
+ pc.addIceCandidate(iceCandidate, unexpectedCallback, null).catch(expectedTypeError);
+ pc.addIceCandidate(iceCandidate, addIceCandidateSuccess1, unexpectedCallback);
+ }
+ });
+
+ const onIceChange2 = t.step_func_done(function() {
+ if (pc.iceConnectionState === 'closed') {
+ calledCallbacks.push('iceConnectionState closed');
+ assert_array_equals(calledCallbacks, [
+ 'iceConnectionState complete',
+ 'expectedTypeError',
+ 'expectedTypeError',
+ 'expectedTypeError',
+ 'expectedTypeError',
+ 'success1',
+ 'success2',
+ 'success3',
+ 'success4',
+ 'iceConnectionState closed'
+ ]);
+ }
+ });
-testExecutionOrderClosedConnection();
-window.pc = new webkitRTCPeerConnection(null, null);
-window.pc.oniceconnectionstatechange = onIceChange1;
+ const calledCallbacks = [];
+ const pc = new webkitRTCPeerConnection(null, null);
+ pc.oniceconnectionstatechange = t.step_func(onIceChange1);
+}, 'Tests the RTCPeerConnection Ice functionality.');
</script>
</body>
</html>
« 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