Commit 93501684 authored by elham@google.com's avatar elham@google.com

Adding two test cases to the existing webrtc content_browser tests:

1) Verify that setLocalDescription fails when trying to negotiate an unsupported video codec
 
- Verify that setLocalDescription fails when trying to negotiate with a client that does not support encryption
 

BUG=303035

Review URL: https://codereview.chromium.org/47923023

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@235798 0039d316-1c4b-4281-b951-d872f2087c98
parent 51f43811
......@@ -81,6 +81,8 @@ WebrtcBrowserTest.GetAudioAndVideoStreamAndClone
WebrtcBrowserTest.GetAudioAndVideoStreamAndStop
WebrtcBrowserTest.GetVideoStreamAndStop
WebRTCInternalsBrowserTest.WithRealPeerConnectionCall
WebRTCInternalsBrowserTest.NegotiateUnsupportedVideoCodec
WebRTCInternalsBrowserTest.NegotiateNonCryptoCall
# http://crbug.com/175683
WebrtcBrowserTest.CallWithDataAndLaterAddMedia
......
......@@ -233,6 +233,31 @@ IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest,
ExpectTitle("OK");
}
// This test will modify the SDP offer to an unsupported codec, which should
// cause SetLocalDescription to fail.
IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest,
NegotiateUnsupportedVideoCodec) {
ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
GURL url(embedded_test_server()->GetURL("/media/peerconnection-call.html"));
NavigateToURL(shell(), url);
EXPECT_TRUE(ExecuteJavascript("negotiateUnsupportedVideoCodec();"));
ExpectTitle("OK");
}
// This test will modify the SDP offer to use no encryption, which should
// cause SetLocalDescription to fail.
IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, NegotiateNonCryptoCall) {
ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
GURL url(embedded_test_server()->GetURL("/media/peerconnection-call.html"));
NavigateToURL(shell(), url);
EXPECT_TRUE(ExecuteJavascript("negotiateNonCryptoCall();"));
ExpectTitle("OK");
}
// This test will make a complete PeerConnection-based call using legacy SDP
// settings: GIce, external SDES, and no BUNDLE.
#if defined(OS_WIN) && defined(USE_AURA)
......
......@@ -9,7 +9,6 @@
var gFirstConnection = null;
var gSecondConnection = null;
var gTestWithoutMsid = false;
var gLocalStream = null;
var gSentTones = '';
......@@ -19,6 +18,7 @@
var transformSdp = function(sdp) { return sdp; };
var transformRemoteSdp = function(sdp) { return sdp; };
var transformCandidate = function(candidate) { return candidate; };
var onLocalDescriptionError = function(error) { };
// When using external SDES, the crypto key is chosen by javascript.
var EXTERNAL_SDES_LINES = {
......@@ -114,11 +114,43 @@
transformRemoteSdp = removeMsid;
gTestWithoutMsid = true;
navigator.webkitGetUserMedia({audio: true, video: true},
addStreamToBothConnectionsAndNegotiate, printGetUserMediaError);
addStreamToBothConnectionsAndNegotiate, printGetUserMediaError);
waitForVideo('remote-view-1');
waitForVideo('remote-view-2');
}
// Test that we can't setup a call with an unsupported video codec
function negotiateUnsupportedVideoCodec() {
createConnections(null);
transformSdp = removeVideoCodec;
navigator.webkitGetUserMedia({audio: true, video: true},
addStreamToBothConnectionsAndNegotiate, printGetUserMediaError);
onLocalDescriptionError = function(error) {
var expectedMsg = 'SetLocalDescription failed: Failed to' +
' update session state: ERROR_CONTENT';
expectEquals(expectedMsg, error);
// Got the right message, test succeeded.
document.title = 'OK';
};
}
// Test that we can't setup a call if one peer does not support encryption
function negotiateNonCryptoCall() {
createConnections(null);
transformSdp = removeCrypto;
navigator.webkitGetUserMedia({audio: true, video: true},
addStreamToBothConnectionsAndNegotiate, printGetUserMediaError);
onLocalDescriptionError = function(error) {
var expectedMsg = 'SetLocalDescription failed: Called with a SDP without'
+ ' crypto enabled.';
expectEquals(expectedMsg, error);
// Got the right message, test succeeded.
document.title = 'OK';
};
}
// Test that we can setup call with legacy settings.
function callWithLegacySdp() {
transformSdp = function(sdp) {
......@@ -418,10 +450,10 @@
gLocalStream = localStream;
}
// Called if getUserMedia fails.
function printGetUserMediaError(error) {
document.title = 'getUserMedia request failed with code ' + error.code;
document.title = 'getUserMedia request failed with code ' + error.code;
}
// Called if getUserMedia succeeds and we want to send from both connections.
......@@ -510,7 +542,8 @@
function onOfferCreated(offer, caller, callee) {
offer.sdp = transformSdp(offer.sdp);
caller.setLocalDescription(offer);
caller.setLocalDescription(offer, null, onLocalDescriptionError);
expectEquals('have-local-offer', caller.signalingState);
receiveOffer(offer.sdp, caller, callee);
}
......@@ -535,6 +568,18 @@
return offerSdp;
}
function removeVideoCodec(offerSdp) {
offerSdp = offerSdp.replace('a=rtpmap:100 VP8/90000\r\n',
'a=rtpmap:100 XVP8/90000\r\n');
return offerSdp;
}
function removeCrypto(offerSdp) {
offerSdp = offerSdp.replace(/a=crypto.*\r\n/g, 'a=Xcrypto\r\n');
offerSdp = offerSdp.replace(/a=fingerprint.*\r\n/g, '');
return offerSdp;
}
function removeBundle(sdp) {
return sdp.replace(/a=group:BUNDLE .*\r\n/g, '');
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment