Commit 3b1e1daa authored by Jakob Ivarsson's avatar Jakob Ivarsson Committed by Commit Bot

Use polling until expected resolution is received.

Tests using callAndExpectResolution falsely assume that the captured
resolution is always sent. The sent resolution is dependent on
bandwidth estimation so any changes to that can make these tests fail.

This is blocking landing of:
https://webrtc-review.googlesource.com/c/src/+/190143

Bug: webrtc:6762
Change-Id: I69c226ca146db7cd03dd90c073aa84cc0d064d14
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2506433Reviewed-by: default avatarGuido Urdaneta <guidou@chromium.org>
Commit-Queue: Jakob Ivarsson <jakobi@google.com>
Cr-Commit-Position: refs/heads/master@{#822152}
parent c452cff9
...@@ -90,18 +90,9 @@ ...@@ -90,18 +90,9 @@
.then(addStreamToBothConnectionsAndNegotiate) .then(addStreamToBothConnectionsAndNegotiate)
.catch(failTest); .catch(failTest);
function hasExpectedResolution(elementName) {
// Returns a promise that video is playing and has the expected
// resolution.
return detectVideoPlaying('remote-view-1').then(resolution => {
assertEquals(expected_width, resolution.width);
assertEquals(expected_height, resolution.height);
});
}
Promise.all([ Promise.all([
hasExpectedResolution('remote-view-1'), detectVideoPlayingWithExpectedResolution('remote-view-1', expected_width, expected_height),
hasExpectedResolution('remote-view-2') detectVideoPlayingWithExpectedResolution('remote-view-2', expected_width, expected_height)
]).then(reportTestSuccess); ]).then(reportTestSuccess);
} }
......
...@@ -46,6 +46,15 @@ function cancelTestTimeout() { ...@@ -46,6 +46,15 @@ function cancelTestTimeout() {
gPendingTimeout = null; gPendingTimeout = null;
} }
function detectVideoPlayingWithExpectedResolution(
videoElementName, video_width, video_height) {
return detectVideo(
videoElementName, function(pixels, previous_pixels, videoElement) {
return hasExpectedResolution(videoElement, video_width, video_height) &&
isVideoPlaying(pixels, previous_pixels);
});
}
function detectVideoPlaying(videoElementName) { function detectVideoPlaying(videoElementName) {
return detectVideo(videoElementName, isVideoPlaying); return detectVideo(videoElementName, isVideoPlaying);
} }
...@@ -110,7 +119,8 @@ function detectVideoWithDimension( ...@@ -110,7 +119,8 @@ function detectVideoWithDimension(
// that case. // that case.
// There's a failure(?) mode here where the video generated claims to // There's a failure(?) mode here where the video generated claims to
// have size 2x2. Don't consider that a valid video. // have size 2x2. Don't consider that a valid video.
if (oldPixels.length == pixels.length && predicate(pixels, oldPixels)) { if (oldPixels.length == pixels.length &&
predicate(pixels, oldPixels, videoElement)) {
console.log('Done looking at video in element ' + videoElementName); console.log('Done looking at video in element ' + videoElementName);
console.log('DEBUG: video.width = ' + videoElement.videoWidth); console.log('DEBUG: video.width = ' + videoElement.videoWidth);
console.log('DEBUG: video.height = ' + videoElement.videoHeight); console.log('DEBUG: video.height = ' + videoElement.videoHeight);
...@@ -155,6 +165,11 @@ function waitForConnectionToStabilizeIfNeeded(peerConnection) { ...@@ -155,6 +165,11 @@ function waitForConnectionToStabilizeIfNeeded(peerConnection) {
}); });
} }
function hasExpectedResolution(videoElement, expected_width, expected_height) {
return videoElement.videoWidth == expected_width &&
videoElement.videoHeight == expected_height;
}
// This very basic video verification algorithm will be satisfied if any // This very basic video verification algorithm will be satisfied if any
// pixels are changed. // pixels are changed.
function isVideoPlaying(pixels, previousPixels) { function isVideoPlaying(pixels, previousPixels) {
......
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