From 9a0052199c0a0f31a321754017055bb859580a5c Mon Sep 17 00:00:00 2001 From: Henrik Skupin Date: Sun, 23 Dec 2012 23:04:37 +0100 Subject: [PATCH] Bug 796890 - Create Mochitest for Video/Audio connection (send/receive/disconnect). r=jesup --- dom/media/tests/mochitest/Makefile.in | 2 + dom/media/tests/mochitest/pc.js | 27 +++ .../test_peerConnection_basicAudio.html | 19 +-- .../test_peerConnection_basicAudioVideo.html | 156 ++++++++++++++++++ ...eerConnection_basicAudioVideoCombined.html | 144 ++++++++++++++++ .../test_peerConnection_basicVideo.html | 24 ++- 6 files changed, 349 insertions(+), 23 deletions(-) create mode 100644 dom/media/tests/mochitest/test_peerConnection_basicAudioVideo.html create mode 100644 dom/media/tests/mochitest/test_peerConnection_basicAudioVideoCombined.html diff --git a/dom/media/tests/mochitest/Makefile.in b/dom/media/tests/mochitest/Makefile.in index 7e27a378a16..e0aeb2038c8 100644 --- a/dom/media/tests/mochitest/Makefile.in +++ b/dom/media/tests/mochitest/Makefile.in @@ -26,6 +26,8 @@ MOCHITEST_FILES += \ test_getUserMedia_basicAudio.html \ test_getUserMedia_basicVideoAudio.html \ test_peerConnection_basicAudio.html \ + test_peerConnection_basicAudioVideo.html \ + test_peerConnection_basicAudioVideoCombined.html \ test_peerConnection_basicVideo.html \ $(NULL) endif diff --git a/dom/media/tests/mochitest/pc.js b/dom/media/tests/mochitest/pc.js index ac253d17abd..772d7d57d0a 100644 --- a/dom/media/tests/mochitest/pc.js +++ b/dom/media/tests/mochitest/pc.js @@ -7,6 +7,13 @@ var PeerConnection = { pc1_offer : null, pc2_answer : null, + /** + * Establishes the peer connection between two clients + * + * @param {object) aPCLocal Local client + * @param {object} aPCRemote Remote client + * @param {function} aSuccessCallback Method to call when the connection has been established + */ handShake: function PC_handShake(aPCLocal, aPCRemote, aSuccessCallback) { function onCreateOfferSuccess(aOffer) { @@ -40,5 +47,25 @@ var PeerConnection = { } aPCLocal.createOffer(onCreateOfferSuccess, unexpectedCallbackAndFinish); + }, + + /** + * Finds the given media stream in the list of available streams. + * + * This function is necessary because localStreams and remoteStreams don't have + * an indexOf method. + * + * @param {object} aMediaStreamList List of available media streams + * @param {object} aMediaStream Media stream to check for + * @return {number} Index in the media stream list + */ + findStream: function PC_findStream(aMediaStreamList, aMediaStream) { + for (var index = 0; index < aMediaStreamList.length; index++) { + if (aMediaStreamList[index] === aMediaStream) { + return index; + } + } + + return -1 } }; diff --git a/dom/media/tests/mochitest/test_peerConnection_basicAudio.html b/dom/media/tests/mochitest/test_peerConnection_basicAudio.html index 50f8a7de0be..1d242c01d07 100644 --- a/dom/media/tests/mochitest/test_peerConnection_basicAudio.html +++ b/dom/media/tests/mochitest/test_peerConnection_basicAudio.html @@ -14,7 +14,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=796892 Basic audio-only peer connection

-
+