Bug 687972 - Add some verification to MediaTestManager. r=roc

This commit is contained in:
Chris Pearce 2011-11-29 12:17:09 +13:00
parent 108072317c
commit cc0f868b9b
2 changed files with 12 additions and 7 deletions

View File

@ -341,6 +341,7 @@ function MediaTestManager() {
this.startTest = startTest;
this.tokens = [];
this.isShutdown = false;
this.numTestsRunning = 0;
// Always wait for explicit finish.
SimpleTest.waitForExplicitFinish();
this.nextTest();
@ -350,6 +351,8 @@ function MediaTestManager() {
// Don't call more than once per token.
this.started = function(token) {
this.tokens.push(token);
this.numTestsRunning++;
is(this.numTestsRunning, this.tokens.length, "[started] Length of array should match number of running tests");
}
// Registers that the test corresponding to 'token' has finished. Call when
@ -362,11 +365,13 @@ function MediaTestManager() {
// Remove the element from the list of running tests.
this.tokens.splice(i, 1);
}
this.numTestsRunning--;
is(this.numTestsRunning, this.tokens.length, "[finished] Length of array should match number of running tests");
if (this.tokens.length < PARALLEL_TESTS) {
this.nextTest();
}
}
// Starts the next batch of tests, or finishes if they're all done.
// Don't call this directly, call finished(token) when you're done.
this.nextTest = function() {

View File

@ -35,9 +35,9 @@ function startTest(test, token) {
is(v.readyState, v.HAVE_CURRENT_DATA, test.name + " checking readyState");
ok(v.readyState != v.NETWORK_LOADED, test.name + " shouldn't report NETWORK_LOADED");
ok(v.ended, test.name + " checking playback has ended");
if (v.ended && v.seenSuspend) {
if (v.parentNode)
v.parentNode.removeChild(v);
if (v.ended && v.seenSuspend && !v.finished) {
v.finished = true;
v.parentNode.removeChild(v);
manager.finished(v.token);
}
}}(test, v);
@ -48,9 +48,9 @@ function startTest(test, token) {
v.seenSuspend = true;
ok(true, test.name + " got suspend");
if (v.ended && v.seenSuspend) {
if (v.parentNode)
v.parentNode.removeChild(v);
if (v.ended && !v.finished) {
v.finished = true;
v.parentNode.removeChild(v);
manager.finished(v.token);
}
}}(test, v);