Bug 1200099. Relax test assumptions to accommodate streams not blocking. r=jwwang

--HG--
extra : commitid : CC0exrsItgv
extra : rebase_source : 3ea92854d4312e8b6c9bf4bf6cbbfd4549bb41cf
This commit is contained in:
Robert O'Callahan 2015-09-01 10:47:48 +12:00
Родитель 8bd21cdeac
Коммит 2299b65689
3 изменённых файлов: 39 добавлений и 21 удалений

Просмотреть файл

@ -9,6 +9,7 @@
<body>
<pre id="test">
<script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
// longer timeout for slow platforms
if (isSlowPlatform()) {
@ -16,8 +17,6 @@ if (isSlowPlatform()) {
SimpleTest.requestCompleteLog();
}
var manager = new MediaTestManager;
function checkDrawImage(vout) {
var canvas = document.createElement("canvas");
var ctx = canvas.getContext("2d");
@ -26,14 +25,14 @@ function checkDrawImage(vout) {
is(imgData.data[3], 255, "Check video frame pixel has been drawn");
}
function startTest(test, token) {
manager.started(token);
function isGreaterThanOrEqualEps(a, b, msg) {
ok(a >= b - 0.01,
"Got " + a + ", expected at least " + b + "; " + msg);
}
function startTest(test) {
var v = document.createElement('video');
var vout = document.createElement('video');
vout.token = token;
v.name = token + "(v)";
vout.name = token + "(vout)";
v.src = test.name;
var stream = v.mozCaptureStreamUntilEnded();
@ -44,8 +43,8 @@ function startTest(test, token) {
var checkEnded = function(test, vout, stream) { return function() {
is(stream.currentTime, vout.currentTime, test.name + " stream final currentTime");
if (test.duration) {
ok(Math.abs(vout.currentTime - test.duration) < 0.1,
test.name + " current time at end: " + vout.currentTime + " should be: " + test.duration);
isGreaterThanOrEqualEps(vout.currentTime, test.duration,
test.name + " current time at end");
}
is(vout.readyState, vout.HAVE_CURRENT_DATA, test.name + " checking readyState");
ok(vout.ended, test.name + " checking playback has ended");
@ -53,8 +52,8 @@ function startTest(test, token) {
checkDrawImage(vout);
}
vout.parentNode.removeChild(vout);
manager.finished(vout.token);
removeNodeAndSource(v);
SimpleTest.finish();
}}(test, vout, stream);
vout.addEventListener("ended", checkEnded, false);
@ -76,7 +75,16 @@ function startTest(test, token) {
}
manager.runTests(gSmallTests, startTest);
// We only test one playable video because for some of the audio files
// --- small-shot.mp3.mp4 and small-shot.m4a --- GStreamer doesn't decode
// as much data as indicated by the duration, causing this test to fail on
// Linux. See bug 1084185.
var testVideo = getPlayableVideo(gSmallTests);
if (testVideo) {
startTest(testVideo);
} else {
todo(false, "No playable video");
}
</script>
</pre>
</body>

Просмотреть файл

@ -21,6 +21,11 @@ function checkDrawImage(vout) {
is(imgData.data[3], 255, "Check video frame pixel has been drawn");
}
function isGreaterThanOrEqualEps(a, b, msg) {
ok(a >= b - 0.01,
"Got " + a + ", expected at least " + b + "; " + msg);
}
function startTest(test, token) {
manager.started(token);
@ -36,8 +41,8 @@ function startTest(test, token) {
var checkEnded = function(test, vout, stream) { return function() {
is(stream.currentTime, vout.currentTime, test.name + " stream final currentTime");
if (test.duration) {
ok(Math.abs(vout.currentTime - test.duration) < 0.1,
test.name + " current time at end: " + vout.currentTime + " should be: " + test.duration);
isGreaterThanOrEqualEps(vout.currentTime, test.duration,
test.name + " current time at end");
}
is(vout.readyState, vout.HAVE_CURRENT_DATA, test.name + " checking readyState");
ok(vout.ended, test.name + " checking playback has ended");

Просмотреть файл

@ -39,19 +39,24 @@ function isWithinEps(a, b, msg) {
"Got " + a + ", expected " + b + "; " + msg);
}
function isGreaterThanOrEqualEps(a, b, msg) {
ok(a >= b - 0.01,
"Got " + a + ", expected at least " + b + "; " + msg);
}
function startTest(test) {
var seekTime = test.duration/2;
function endedAfterReplay() {
isWithinEps(v.currentTime, test.duration, "checking v.currentTime at third 'ended' event");
isWithinEps(vout.currentTime, (test.duration - seekTime) + test.duration*2,
isGreaterThanOrEqualEps(v.currentTime, test.duration, "checking v.currentTime at third 'ended' event");
isGreaterThanOrEqualEps(vout.currentTime, (test.duration - seekTime) + test.duration*2,
"checking vout.currentTime after seeking, playing through and reloading");
SimpleTest.finish();
};
function endedAfterSeek() {
isWithinEps(v.currentTime, test.duration, "checking v.currentTime at second 'ended' event");
isWithinEps(vout.currentTime, (test.duration - seekTime) + test.duration,
isGreaterThanOrEqualEps(v.currentTime, test.duration, "checking v.currentTime at second 'ended' event");
isGreaterThanOrEqualEps(vout.currentTime, (test.duration - seekTime) + test.duration,
"checking vout.currentTime after seeking and playing through again");
v.removeEventListener("ended", endedAfterSeek, false);
v.addEventListener("ended", endedAfterReplay, false);
@ -60,8 +65,8 @@ function startTest(test) {
};
function seeked() {
isWithinEps(v.currentTime, seekTime, "Finished seeking");
isWithinEps(vout.currentTime, test.duration,
isGreaterThanOrEqualEps(v.currentTime, seekTime, "Finished seeking");
isGreaterThanOrEqualEps(vout.currentTime, test.duration,
"checking vout.currentTime has not changed after seeking");
v.removeEventListener("seeked", seeked, false);
function dontPlayAgain() {
@ -80,8 +85,8 @@ function startTest(test) {
return;
}
isWithinEps(vout.currentTime, test.duration, "checking vout.currentTime at first 'ended' event");
isWithinEps(v.currentTime, test.duration, "checking v.currentTime at first 'ended' event");
isGreaterThanOrEqualEps(vout.currentTime, test.duration, "checking vout.currentTime at first 'ended' event");
isGreaterThanOrEqualEps(v.currentTime, test.duration, "checking v.currentTime at first 'ended' event");
is(vout.ended, false, "checking vout has not ended");
is(vout_untilended.ended, true, "checking vout_untilended has actually ended");