summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormallinath@chromium.org <mallinath@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-16 23:23:12 +0000
committermallinath@chromium.org <mallinath@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-16 23:23:12 +0000
commitc28dd9ede5869f1d92af8334727f1d7c0f3a380f (patch)
tree1781a0cd023c3768d6ca526fbe60e8cd4a62b1de
parent31b19b4f3beedf1a641c6961f3cac78e08d456e7 (diff)
downloadchromium_src-c28dd9ede5869f1d92af8334727f1d7c0f3a380f.zip
chromium_src-c28dd9ede5869f1d92af8334727f1d7c0f3a380f.tar.gz
chromium_src-c28dd9ede5869f1d92af8334727f1d7c0f3a380f.tar.bz2
Adding SCTP based data channels to the existing webrtc content_browser tests.
R=phoglund@chromium.org, wjia@chromium.org Review URL: https://codereview.chromium.org/23875039 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@229001 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--content/browser/media/webrtc_browsertest.cc31
-rw-r--r--content/test/data/media/peerconnection-call.html89
2 files changed, 108 insertions, 12 deletions
diff --git a/content/browser/media/webrtc_browsertest.cc b/content/browser/media/webrtc_browsertest.cc
index 98e4374..3c73870 100644
--- a/content/browser/media/webrtc_browsertest.cc
+++ b/content/browser/media/webrtc_browsertest.cc
@@ -235,6 +235,7 @@ IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest,
// This test will make a PeerConnection-based call and test an unreliable text
// dataChannel.
+// TODO(mallinath) - Remove this test after rtp based data channel is disabled.
IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, CallWithDataOnly) {
ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
@@ -245,6 +246,16 @@ IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, CallWithDataOnly) {
ExpectTitle("OK");
}
+IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, CallWithSctpDataOnly) {
+ ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
+
+ GURL url(embedded_test_server()->GetURL("/media/peerconnection-call.html"));
+ NavigateToURL(shell(), url);
+
+ EXPECT_TRUE(ExecuteJavascript("callWithSctpDataOnly();"));
+ ExpectTitle("OK");
+}
+
#if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY)
// Timing out on ARM linux bot: http://crbug.com/238490
#define MAYBE_CallWithDataAndMedia DISABLED_CallWithDataAndMedia
@@ -254,6 +265,7 @@ IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, CallWithDataOnly) {
// This test will make a PeerConnection-based call and test an unreliable text
// dataChannel and audio and video tracks.
+// TODO(mallinath) - Remove this test after rtp based data channel is disabled.
IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, MAYBE_CallWithDataAndMedia) {
ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
@@ -264,6 +276,25 @@ IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, MAYBE_CallWithDataAndMedia) {
ExpectTitle("OK");
}
+
+#if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY)
+// Timing out on ARM linux bot: http://crbug.com/238490
+#define MAYBE_CallWithSctpDataAndMedia DISABLED_CallWithSctpDataAndMedia
+#else
+#define MAYBE_CallWithSctpDataAndMedia CallWithSctpDataAndMedia
+#endif
+
+IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest,
+ MAYBE_CallWithSctpDataAndMedia) {
+ ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
+
+ GURL url(embedded_test_server()->GetURL("/media/peerconnection-call.html"));
+ NavigateToURL(shell(), url);
+
+ EXPECT_TRUE(ExecuteJavascript("callWithSctpDataAndMedia();"));
+ ExpectTitle("OK");
+}
+
#if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY)
// Timing out on ARM linux bot: http://crbug.com/238490
#define MAYBE_CallWithDataAndLaterAddMedia DISABLED_CallWithDataAndLaterAddMedia
diff --git a/content/test/data/media/peerconnection-call.html b/content/test/data/media/peerconnection-call.html
index 3cc53b2..c2acbdc 100644
--- a/content/test/data/media/peerconnection-call.html
+++ b/content/test/data/media/peerconnection-call.html
@@ -92,7 +92,7 @@
function callWithoutMsidAndBundle() {
createConnections(null);
gTestWithoutMsidAndBundle = true;
- navigator.webkitGetUserMedia({audio:true, video:true},
+ navigator.webkitGetUserMedia({audio: true, video: true},
addStreamToBothConnectionsAndNegotiate, printGetUserMediaError);
waitForVideo('remote-view-1');
waitForVideo('remote-view-2');
@@ -101,25 +101,42 @@
// Test only a data channel.
function callWithDataOnly() {
createConnections({optional:[{RtpDataChannels: true}]});
- setupDataChannel();
+ setupDataChannel({reliable: false});
+ negotiate();
+ }
+
+ function callWithSctpDataOnly() {
+ createConnections({optional: [{DtlsSrtpKeyAgreement: true}]});
+ setupSctpDataChannel({reliable: true});
negotiate();
}
// Test call with audio, video and a data channel.
function callWithDataAndMedia() {
createConnections({optional:[{RtpDataChannels: true}]});
- setupDataChannel();
- navigator.webkitGetUserMedia({audio:true, video:true},
+ setupDataChannel({reliable: false});
+ navigator.webkitGetUserMedia({audio: true, video: true},
addStreamToBothConnectionsAndNegotiate,
printGetUserMediaError);
waitForVideo('remote-view-1');
waitForVideo('remote-view-2');
}
+ function callWithSctpDataAndMedia() {
+ createConnections({optional: [{DtlsSrtpKeyAgreement: true}]});
+ setupSctpDataChannel({reliable: true});
+ navigator.webkitGetUserMedia({audio: true, video: true},
+ addStreamToBothConnectionsAndNegotiate,
+ printGetUserMediaError);
+ waitForVideo('remote-view-1');
+ waitForVideo('remote-view-2');
+ }
+
+
// Test call with a data channel and later add audio and video.
function callWithDataAndLaterAddMedia() {
createConnections({optional:[{RtpDataChannels: true}]});
- setupDataChannel();
+ setupDataChannel({reliable: false});
negotiate();
// Set an event handler for when the data channel has been closed.
@@ -128,7 +145,7 @@
setAllEventsOccuredHandler(function() {
document.title = 'OK';
});
- navigator.webkitGetUserMedia({audio:true, video:true},
+ navigator.webkitGetUserMedia({audio: true, video: true},
addStreamToBothConnectionsAndNegotiate, printGetUserMediaError);
waitForVideo('remote-view-1');
waitForVideo('remote-view-2');
@@ -138,7 +155,7 @@
// Test that we can setup call and send DTMF.
function callAndSendDtmf(tones) {
createConnections(null);
- navigator.webkitGetUserMedia({audio:true, video:true},
+ navigator.webkitGetUserMedia({audio: true, video: true},
addStreamToBothConnectionsAndNegotiate, printGetUserMediaError);
var onCallEstablished = function() {
// Send DTMF tones.
@@ -165,7 +182,7 @@
// stream generated by getUserMedia.
function callWithNewVideoMediaStream() {
createConnections(null);
- navigator.webkitGetUserMedia({audio:true, video:true},
+ navigator.webkitGetUserMedia({audio: true, video: true},
createNewVideoStreamAndAddToBothConnections, printGetUserMediaError);
waitForVideo('remote-view-1');
waitForVideo('remote-view-2');
@@ -178,7 +195,7 @@
// mediastream works.
function callWithNewVideoMediaStreamLaterSwitchToAudio() {
createConnections(null);
- navigator.webkitGetUserMedia({audio:true, video:true},
+ navigator.webkitGetUserMedia({audio: true, video: true},
createNewVideoStreamAndAddToBothConnections, printGetUserMediaError);
waitForVideo('remote-view-1');
@@ -241,10 +258,10 @@
// is sent to |gFirstConnection|.
// 3. When data is received on |gFirstConnection|, the data
// channel is closed. The test passes when the state transition completes.
- function setupDataChannel() {
+ function setupDataChannel(params) {
var sendDataString = "send some text on a data channel."
firstDataChannel = gFirstConnection.createDataChannel(
- "sendDataChannel", {reliable : false});
+ "sendDataChannel", params);
expectEquals('connecting', firstDataChannel.readyState);
// When |firstDataChannel| transition to open state, send a text string.
@@ -281,11 +298,59 @@
}
}
+ // SCTP data channel setup is slightly different then RTP based
+ // channels. Due to a bug in libjingle, we can't send data immediately
+ // after channel becomes open. So for that reason in SCTP,
+ // we are sending data from second channel, when ondatachannel event is
+ // received. So data flow happens 2 -> 1 -> 2.
+ function setupSctpDataChannel(params) {
+ var sendDataString = "send some text on a data channel."
+ firstDataChannel = gFirstConnection.createDataChannel(
+ "sendDataChannel", params);
+ expectEquals('connecting', firstDataChannel.readyState);
+
+ // When |firstDataChannel| transition to open state, send a text string.
+ firstDataChannel.onopen = function() {
+ expectEquals('open', firstDataChannel.readyState);
+ }
+
+ // When |firstDataChannel| receive a message, send message back.
+ // initiate a new offer/answer exchange to complete the closure.
+ firstDataChannel.onmessage = function(event) {
+ expectEquals('open', firstDataChannel.readyState);
+ expectEquals(event.data, sendDataString);
+ firstDataChannel.send(sendDataString);
+ }
+
+
+ // Event handler for when |gSecondConnection| receive a new dataChannel.
+ gSecondConnection.ondatachannel = function (event) {
+ var secondDataChannel = event.channel;
+ secondDataChannel.send(sendDataString);
+
+ // When |secondDataChannel| receive a message, close the channel and
+ // initiate a new offer/answer exchange to complete the closure.
+ secondDataChannel.onmessage = function(event) {
+ expectEquals(event.data, sendDataString);
+ expectEquals('open', secondDataChannel.readyState);
+ secondDataChannel.close();
+ negotiate();
+ }
+
+ // When |secondDataChannel| transition to closed state, the test pass.
+ addExpectedEvent();
+ secondDataChannel.onclose = function() {
+ expectEquals('closed', secondDataChannel.readyState);
+ eventOccured();
+ }
+ }
+ }
+
// Test call with a stream that has been created by getUserMedia, clone
// the stream to a cloned stream, send them via the same peer connection.
function addTwoMediaStreamsToOneConnection() {
createConnections(null);
- navigator.webkitGetUserMedia({audio:true, video:true},
+ navigator.webkitGetUserMedia({audio: true, video: true},
CloneStreamAndAddTwoStreamstoOneConnection, printGetUserMediaError);
}