Commit 89d7ce0b authored by phoglund@chromium.org's avatar phoglund@chromium.org

Ported media stream track enable-disable test to content module.

Also improves the tests to check that audio muting doesn't mute video
and vice versa.

BUG=328196,331045

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@243591 0039d316-1c4b-4281-b951-d872f2087c98
parent 44bf3f8f
......@@ -92,11 +92,6 @@ class WebrtcBrowserTest : public WebRtcTestBase {
tab_contents));
}
void WaitForVideoToStopPlaying(content::WebContents* tab_contents) {
EXPECT_TRUE(PollingWaitUntil("isVideoPlaying()", "video-not-playing",
tab_contents));
}
void HangUp(content::WebContents* from_tab) {
EXPECT_EQ("ok-call-hung-up", ExecuteJavascript("hangUp()", from_tab));
}
......@@ -106,20 +101,6 @@ class WebrtcBrowserTest : public WebRtcTestBase {
"no-peer-connection", tab_contents));
}
std::string ToggleLocalVideoTrack(content::WebContents* tab_contents) {
// Toggle the only video track in the page (e.g. video track 0).
return ExecuteJavascript("toggleLocalStream("
"function(local) { return local.getVideoTracks()[0]; }, "
"'video');", tab_contents);
}
std::string ToggleRemoteVideoTrack(content::WebContents* tab_contents) {
// Toggle the only video track in the page (e.g. video track 0).
return ExecuteJavascript("toggleRemoteStream("
"function(local) { return local.getVideoTracks()[0]; }, "
"'video');", tab_contents);
}
void PrintProcessMetrics(base::ProcessMetrics* process_metrics,
const std::string& suffix) {
perf_test::PrintResult("cpu", "", "cpu" + suffix,
......@@ -249,44 +230,6 @@ IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, MANUAL_CpuUsage15Seconds) {
ASSERT_TRUE(peerconnection_server_.Stop());
}
#if defined(OS_WIN)
// Timing out on Windows: http://crbug.com/331045
#define MAYBE_TestMediaStreamTrackEnableDisable DISABLED_TestMediaStreamTrackEnableDisable
#else
#define MAYBE_TestMediaStreamTrackEnableDisable MANUAL_TestMediaStreamTrackEnableDisable
#endif
IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest,
MAYBE_TestMediaStreamTrackEnableDisable) {
ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
ASSERT_TRUE(peerconnection_server_.Start());
content::WebContents* left_tab = OpenTestPageAndGetUserMediaInNewTab();
content::WebContents* right_tab = OpenTestPageAndGetUserMediaInNewTab();
EstablishCall(left_tab, right_tab);
StartDetectingVideo(left_tab, "remote-view");
StartDetectingVideo(right_tab, "remote-view");
WaitForVideoToPlay(left_tab);
WaitForVideoToPlay(right_tab);
EXPECT_EQ("ok-video-toggled-to-false", ToggleLocalVideoTrack(left_tab));
WaitForVideoToStopPlaying(right_tab);
EXPECT_EQ("ok-video-toggled-to-true", ToggleLocalVideoTrack(left_tab));
WaitForVideoToPlay(right_tab);
HangUp(left_tab);
WaitUntilHangupVerified(left_tab);
WaitUntilHangupVerified(right_tab);
ASSERT_TRUE(peerconnection_server_.Stop());
}
IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest,
MANUAL_RunsAudioVideoCall60SecsAndLogsInternalMetrics) {
ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
......
......@@ -457,6 +457,9 @@ IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, MANUAL_CanSetupCallAndSendDtmf) {
ExpectTitle("OK");
}
// TODO(phoglund): this test fails because the peer connection state will be
// stable in the second negotiation round rather than have-local-offer.
// http://crbug.com/293125.
IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest,
DISABLED_CanMakeEmptyCallThenAddStreamsAndRenegotiate) {
const char* kJavascript =
......@@ -709,6 +712,16 @@ IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest,
MakeTypicalPeerConnectionCall("callAndEnsureAudioMutingWorks();");
}
IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, CallAndVerifyVideoMutingWorks) {
ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
GURL url(embedded_test_server()->GetURL("/media/peerconnection-call.html"));
NavigateToURL(shell(), url);
EXPECT_TRUE(ExecuteJavascript("callAndEnsureVideoMutingWorks();"));
ExpectTitle("OK");
}
#if defined(OS_WIN) || (defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY))
// Timing out on ARM linux bot: http://crbug.com/238490
// Failing on Windows: http://crbug.com/331035
......
......@@ -72,11 +72,12 @@
function callEmptyThenAddOneStreamAndRenegotiate(constraints) {
createConnections(null);
negotiate();
waitForConnectionToStabilize(gFirstConnection);
navigator.webkitGetUserMedia(constraints,
addStreamToTheFirstConnectionAndNegotiate, printGetUserMediaError);
// Only the first connection is sending here.
waitForVideo('remote-view-2');
waitForConnectionToStabilize(gFirstConnection, function() {
navigator.webkitGetUserMedia(constraints,
addStreamToTheFirstConnectionAndNegotiate, printGetUserMediaError);
// Only the first connection is sending here.
waitForVideo('remote-view-2');
});
}
// First makes a call between pc1 and pc2, and then makes a call between pc3
......@@ -265,6 +266,18 @@
detectVideoPlaying('remote-view-2', onCallEstablished);
}
function enableRemoteVideo(peerConnection, enabled) {
remoteStream = peerConnection.getRemoteStreams()[0];
remoteVideoTrack = remoteStream.getVideoTracks()[0];
remoteVideoTrack.enabled = enabled;
}
function enableRemoteAudio(peerConnection, enabled) {
remoteStream = peerConnection.getRemoteStreams()[0];
remoteAudioTrack = remoteStream.getAudioTracks()[0];
remoteAudioTrack.enabled = enabled;
}
function callAndEnsureAudioIsPlaying() {
createConnections(null);
navigator.webkitGetUserMedia({audio: true, video: true},
......@@ -278,20 +291,20 @@
verifyAudioIsPlaying(samples);
eventOccured();
});
// (Also, ensure video muting doesn't affect audio).
enableRemoteVideo(gSecondConnection, false);
};
detectVideoPlaying('remote-view-2', onCallEstablished);
}
function callAndEnsureAudioMutingWorks(force_isac_16k) {
callAndEnsureAudioIsPlaying(force_isac_16k);
function callAndEnsureAudioMutingWorks() {
callAndEnsureAudioIsPlaying();
setAllEventsOccuredHandler(function() {
var audioTrack =
gSecondConnection.getRemoteStreams()[0].getAudioTracks()[0];
// Call is up, now mute the track and check everything goes silent (give
// it a small delay though, we don't expect it to happen instantly).
audioTrack.enabled = false;
enableRemoteAudio(gSecondConnection, false);
setTimeout(function() {
gatherAudioLevelSamples(gSecondConnection, 200, 100, function(samples) {
......@@ -302,6 +315,26 @@
});
}
function callAndEnsureVideoMutingWorks() {
createConnections(null);
navigator.webkitGetUserMedia({audio: true, video: true},
addStreamToBothConnectionsAndNegotiate, printGetUserMediaError);
addExpectedEvent();
detectVideoPlaying('remote-view-2', function() {
// Disable the receiver's remote media stream. Video should stop.
// (Also, ensure muting audio doesn't affect video).
enableRemoteVideo(gSecondConnection, false);
enableRemoteAudio(gSecondConnection, false);
detectVideoStopped('remote-view-2', function() {
// Video has stopped: unmute and succeed if it starts playing again.
enableRemoteVideo(gSecondConnection, true);
detectVideoPlaying('remote-view-2', eventOccured);
})
});
}
// Test call with a new Video MediaStream that has been created based on a
// stream generated by getUserMedia.
function callWithNewVideoMediaStream() {
......
......@@ -70,12 +70,11 @@ function waitForVideoToStop(videoElement) {
detectVideoStopped(videoElement, function () { eventOccured(); });
}
function waitForConnectionToStabilize(peerConnection) {
addExpectedEvent();
function waitForConnectionToStabilize(peerConnection, callback) {
var waitForStabilization = setInterval(function() {
if (peerConnection.signalingState == 'stable') {
clearInterval(waitForStabilization);
eventOccured();
callback();
}
}, 100);
}
......
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