Commit 88e17497 authored by perkj's avatar perkj Committed by Commit bot

Reland WebRtcBrowserTest.CanSetupVideoCallAndDisableLocalVideo originally...

Reland WebRtcBrowserTest.CanSetupVideoCallAndDisableLocalVideo originally landed in https://codereview.chromium.org/442313002/

The only difference is that the test has been disabled on
DrMemory since it times out. Notice that many WebRtcBrowsertests are disabled due to the same reason.

BUG= 403070, 398844

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

Cr-Commit-Position: refs/heads/master@{#292142}
parent ae5bc7f7
......@@ -166,6 +166,21 @@ IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest,
MakeTypicalPeerConnectionCall(javascript);
}
// Flaky on TSAN v2. http://crbug.com/408006
#if defined(THREAD_SANITIZER)
#define MAYBE_CanSetupVideoCallAndDisableLocalVideo \
DISABLED_CanSetupVideoCallAndDisableLocalVideo
#else
#define MAYBE_CanSetupVideoCallAndDisableLocalVideo \
CanSetupVideoCallAndDisableLocalVideo
#endif
IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest,
MAYBE_CanSetupVideoCallAndDisableLocalVideo) {
const std::string javascript =
"callAndDisableLocalVideo({video: true});";
MakeTypicalPeerConnectionCall(javascript);
}
#if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY)
// Timing out on ARM linux, see http://crbug.com/240376
#define MAYBE_CanSetupAudioAndVideoCall DISABLED_CanSetupAudioAndVideoCall
......
......@@ -58,6 +58,20 @@
waitForVideo('remote-view-2');
}
// Test that we can setup a call with a video track and that the remote peer
// receives black frames if the local video track is disabled.
function callAndDisableLocalVideo(constraints) {
createConnections(null);
navigator.webkitGetUserMedia(constraints,
addStreamToBothConnectionsAndNegotiate, printGetUserMediaError);
detectVideoPlaying('remote-view-1',
function () {
assertEquals(gLocalStream.getVideoTracks().length, 1);
gLocalStream.getVideoTracks()[0].enabled = false;
waitForBlackVideo('remote-view-1');
});
}
// Test that we can setup call with an audio and video track and check that
// the video resolution is as expected.
function callAndExpectResolution(constraints,
......
......@@ -52,6 +52,14 @@ function detectVideoStopped(videoElementName, callback) {
callback);
}
function detectBlackVideo(videoElementName, callback) {
detectVideo(videoElementName,
function (pixels, previous_pixels) {
return isVideoBlack(pixels);
},
callback);
}
function detectVideo(videoElementName, predicate, callback) {
console.log('Looking at video in element ' + videoElementName);
......@@ -97,6 +105,11 @@ function waitForVideoToStop(videoElement) {
detectVideoStopped(videoElement, function () { eventOccured(); });
}
function waitForBlackVideo(videoElement) {
addExpectedEvent();
detectBlackVideo(videoElement, function () { eventOccured(); });
}
// Calculates the current frame rate and compares to |expected_frame_rate|
// |callback| is triggered with value |true| if the calculated frame rate
// is +-1 the expected or |false| if five calculations fail to match
......@@ -171,6 +184,16 @@ function isVideoPlaying(pixels, previousPixels) {
return false;
}
function isVideoBlack(pixels) {
for (var i = 0; i < pixels.length; i++) {
// |pixels| is in RGBA. Ignore the alpha channel.
if (pixels[i] != 0 && (i + 1) % 4 != 0) {
return false;
}
}
return true;
}
// This function matches |left| and |right| and fails the test if the
// values don't match using normal javascript equality (i.e. the hard
// types of the operands aren't checked).
......
......@@ -36,6 +36,7 @@ WebRtcBrowserTest.CallWithSctpDataOnly
WebRtcBrowserTest.CanSetupAudioAndVideoCall
WebRtcBrowserTest.CanSetupAudioAndVideoCallWithoutMsidAndBundle
WebRtcBrowserTest.CanSetupDefaultVideoCall
WebRtcBrowserTest.CanSetupVideoCallAndDisableLocalVideo
WebRtcBrowserTest.CanSetupLegacyCall
WebRtcBrowserTest.CanSetupVideoCallWith16To9AspectRatio
WebRtcBrowserTest.CanSetupVideoCallWith1To1AspectRatio
......
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