WebRTC: Add media setup test using the legacy callback APIs
authoradam.bergkvist@ericsson.com <adam.bergkvist@ericsson.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 15 Jun 2016 21:27:07 +0000 (21:27 +0000)
committeradam.bergkvist@ericsson.com <adam.bergkvist@ericsson.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 15 Jun 2016 21:27:07 +0000 (21:27 +0000)
https://bugs.webkit.org/show_bug.cgi?id=158736

Reviewed by Eric Carlson.

Add a test that sets up media using the legacy callback-based createOffer/Answer() and
setLocal/RemoteDescription() methods [1].

[1] https://w3c.github.io/webrtc-pc/archives/20160513/webrtc.html#legacy-interface-extensions

* fast/mediastream/RTCPeerConnection-media-setup-callbacks-single-dialog-expected.txt: Added.
* fast/mediastream/RTCPeerConnection-media-setup-callbacks-single-dialog.html: Added.
* platform/mac/TestExpectations:
The mac port is not building with WEB_RTC yet.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202108 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/mediastream/RTCPeerConnection-media-setup-callbacks-single-dialog-expected.txt [new file with mode: 0644]
LayoutTests/fast/mediastream/RTCPeerConnection-media-setup-callbacks-single-dialog.html [new file with mode: 0644]
LayoutTests/platform/mac/TestExpectations

index c126408..0759bb4 100644 (file)
@@ -1,3 +1,20 @@
+2016-06-15  Adam Bergkvist  <adam.bergkvist@ericsson.com>
+
+        WebRTC: Add media setup test using the legacy callback APIs
+        https://bugs.webkit.org/show_bug.cgi?id=158736
+
+        Reviewed by Eric Carlson.
+
+        Add a test that sets up media using the legacy callback-based createOffer/Answer() and
+        setLocal/RemoteDescription() methods [1].
+
+        [1] https://w3c.github.io/webrtc-pc/archives/20160513/webrtc.html#legacy-interface-extensions
+
+        * fast/mediastream/RTCPeerConnection-media-setup-callbacks-single-dialog-expected.txt: Added.
+        * fast/mediastream/RTCPeerConnection-media-setup-callbacks-single-dialog.html: Added.
+        * platform/mac/TestExpectations:
+        The mac port is not building with WEB_RTC yet.
+
 2016-06-15  Antti Koivisto  <antti@apple.com>
 
         GoogleMaps transit schedule explorer comes up blank initially
diff --git a/LayoutTests/fast/mediastream/RTCPeerConnection-media-setup-callbacks-single-dialog-expected.txt b/LayoutTests/fast/mediastream/RTCPeerConnection-media-setup-callbacks-single-dialog-expected.txt
new file mode 100644 (file)
index 0000000..6dd401d
--- /dev/null
@@ -0,0 +1,39 @@
+Test setting up media between two RTCPeerConnection instances with a single SDP dialog using legacy callbacks API.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Create RTCPeerConnection A
+Create RTCPeerConnection B
+A: add media
+A: create offer
+A: got offer, set it as local description
+A: local offer set
+PASS pcA.signalingState is 'have-local-offer'
+A: send offer to B
+A --- offer --> B
+B: got offer from A, set it as remote description
+----------
+PASS B: got remote track event
+----------
+B: remote offer set
+PASS pcB.signalingState is 'have-remote-offer'
+B: add media (to include in answer)
+B: create answer
+B: got answer, set it as local description
+B: local answer set
+PASS pcB.signalingState is 'stable'
+B: send answer to A
+A <-- answer -- B
+A: got answer from B, set it as remote description
+----------
+PASS A: got remote track event
+----------
+A: remote answer set
+PASS pcA.signalingState is 'stable'
+PASS Offer/answer dialog completed
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/mediastream/RTCPeerConnection-media-setup-callbacks-single-dialog.html b/LayoutTests/fast/mediastream/RTCPeerConnection-media-setup-callbacks-single-dialog.html
new file mode 100644 (file)
index 0000000..1c479dc
--- /dev/null
@@ -0,0 +1,116 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <script src="../../resources/js-test-pre.js"></script>
+        <script src="resources/promise-utils.js"></script>
+    </head>
+    <body>
+        <script>
+            let stream;
+            let offer;
+
+            description("Test setting up media between two RTCPeerConnection instances with a single SDP dialog using legacy callbacks API.");
+
+            if (window.testRunner)
+                testRunner.setUserMediaPermission(true);
+            else {
+                debug("This test can not be run without the testRunner");
+                finishJSTest();
+            }
+
+            debug("Create RTCPeerConnection A");
+            const pcA = new webkitRTCPeerConnection({iceServers:[{urls:'stun:foo.com'}]});
+
+            debug("Create RTCPeerConnection B");
+            const pcB = new webkitRTCPeerConnection({iceServers:[{urls:'stun:foo.com'}]});
+
+            pcA.ontrack = function () {
+                debug("----------");
+                testPassed("A: got remote track event");
+                debug("----------");
+            };
+
+            pcB.ontrack = function () {
+                debug("----------");
+                testPassed("B: got remote track event");
+                debug("----------");
+            };
+
+            navigator.mediaDevices.getUserMedia({ "audio": true })
+            .then(function (s) {
+                stream = s;
+
+                startTestWithMedia();
+            })
+            .catch(function (error) {
+                testFailed(`Unable to get user media: ${error}`);
+                finishJSTest();
+            });
+
+            function startTestWithMedia() {
+                debug("A: add media");
+                pcA.addTrack(stream.getAudioTracks()[0], stream);
+
+                debug("A: create offer");
+                return pcA.createOffer(offer => {
+                    debug("A: got offer, set it as local description");
+                    pcA.setLocalDescription(offer, () => {
+                        debug("A: local offer set");
+                        shouldBe("pcA.signalingState", "'have-local-offer'");
+
+                        debug("A: send offer to B");
+                        debug("A --- offer --> B");
+                        offerToPcB(pcA.localDescription);
+                    }, gotError);
+
+                }, gotError);
+            }
+
+            function offerToPcB(offer) {
+                debug("B: got offer from A, set it as remote description");
+                pcB.setRemoteDescription(offer, () => {
+                    debug("B: remote offer set");
+                    shouldBe("pcB.signalingState", "'have-remote-offer'");
+
+                    debug("B: add media (to include in answer)");
+                    pcB.addTrack(stream.getAudioTracks()[0], stream);
+
+                    debug("B: create answer");
+                    return pcB.createAnswer(answer => {
+                        debug("B: got answer, set it as local description");
+                        pcB.setLocalDescription(answer, () => {
+                            debug("B: local answer set");
+                            shouldBe("pcB.signalingState", "'stable'");
+
+                            debug("B: send answer to A");
+                            debug("A <-- answer -- B");
+                            answerToA(pcB.localDescription);
+                        }, gotError);
+                    }, gotError);
+                }, gotError);
+            }
+
+            function answerToA(answer) {
+                debug("A: got answer from B, set it as remote description");
+                pcA.setRemoteDescription(answer, () => {
+                    debug("A: remote answer set");
+                    shouldBe("pcA.signalingState", "'stable'");
+
+                    testPassed("Offer/answer dialog completed")
+                    debug("");
+
+                    finishJSTest();
+                }, gotError);
+            }
+
+            function gotError() {
+                testFailed("Unexpected error callback fired");
+            }
+
+            window.jsTestIsAsync = true;
+            window.successfullyParsed = true;
+
+        </script>
+        <script src="../../resources/js-test-post.js"></script>
+    </body>
+</html>
index ebcb19d..564fe31 100644 (file)
@@ -198,6 +198,7 @@ fast/mediastream/RTCTrackEvent-constructor.html
 fast/mediastream/RTCPeerConnection-inspect-answer.html
 fast/mediastream/RTCPeerConnection-media-setup-single-dialog.html
 fast/mediastream/RTCPeerConnection-media-setup-two-dialogs.html
+fast/mediastream/RTCPeerConnection-media-setup-callbacks-single-dialog.html
 
 # Asserts in debug.
 [ Debug ] fast/images/large-size-image-crash.html [ Skip ]