Commit 6e4ce866 authored by Dale Curtis's avatar Dale Curtis Committed by Commit Bot

Improve MediaElement capture test.

This reduces the run time of the test from 25 events to 5 events since
it looks like it is timing out on the TSAN bot now and there doesn't
seem to be any good reason to wait for more than a handful.

It also adds ended handling since if stop() isn't called soon after
ended() the MediaRecorder will generate an error event due to the tracks
being removed from the MediaStream upon ended.

It also sets MediaElement.preload=auto to speed up test startup by
avoiding preload=metadata suspend for non-autoplay elements.

R=guidou

Bug: 1138712
Change-Id: I87dbb1430db8629ca614836aa19b5ef1deeaae63
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2481907
Commit-Queue: Guido Urdaneta <guidou@chromium.org>
Reviewed-by: default avatarGuido Urdaneta <guidou@chromium.org>
Auto-Submit: Dale Curtis <dalecurtis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#818234}
parent 9af5e360
...@@ -19,10 +19,9 @@ ...@@ -19,10 +19,9 @@
#include "base/system/sys_info.h" #include "base/system/sys_info.h"
#endif #endif
#if BUILDFLAG(ENABLE_MOJO_RENDERER) || defined(THREAD_SANITIZER) #if BUILDFLAG(ENABLE_MOJO_RENDERER)
// Remote mojo renderer does not send audio/video frames back to the renderer // Remote mojo renderer does not send audio/video frames back to the renderer
// process and hence does not support capture: https://crbug.com/641559. // process and hence does not support capture: https://crbug.com/641559.
// Failing on TSan: crbug.com/1138712
#define MAYBE_CaptureFromMediaElement DISABLED_CaptureFromMediaElement #define MAYBE_CaptureFromMediaElement DISABLED_CaptureFromMediaElement
#else #else
#define MAYBE_CaptureFromMediaElement CaptureFromMediaElement #define MAYBE_CaptureFromMediaElement CaptureFromMediaElement
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
'use strict'; 'use strict';
const NUMBER_OF_EVENTS_TO_RECORD = 25; const NUMBER_OF_EVENTS_TO_RECORD = 5;
function testCaptureFromMediaElement(filename, function testCaptureFromMediaElement(filename,
has_video, has_video,
...@@ -25,8 +25,9 @@ function testCaptureFromMediaElement(filename, ...@@ -25,8 +25,9 @@ function testCaptureFromMediaElement(filename,
element.onerror = function(e) { element.onerror = function(e) {
failTest("error playing back [" + filename + "] " + e); failTest("error playing back [" + filename + "] " + e);
} };
element.preload = "auto"; // Ensures element doesn't suspend on load.
element.src = filename; element.src = filename;
var recorded_events = 0; var recorded_events = 0;
...@@ -41,13 +42,19 @@ function testCaptureFromMediaElement(filename, ...@@ -41,13 +42,19 @@ function testCaptureFromMediaElement(filename,
recorder.onerror = function(e) { recorder.onerror = function(e) {
failTest("error recording [" + filename + "] " + e); failTest("error recording [" + filename + "] " + e);
} };
recorder.ondataavailable = function(event) { recorder.ondataavailable = function(event) {
if (++recorded_events > NUMBER_OF_EVENTS_TO_RECORD) if (++recorded_events > NUMBER_OF_EVENTS_TO_RECORD || element.ended)
reportTestSuccess(); reportTestSuccess();
}; };
element.onended = function() {
console.log('Playback ended before event count saturated.');
// This will trigger a final ondataavailable().
recorder.stop();
};
recorder.start(0); recorder.start(0);
element.play(); element.play();
}; };
......
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