B2G/gecko/content/media/test/manifest.js
//      or end the mochitest if all the tests are done.
or end the mochitest if all the tests are done.
or end the mochitest if all the tests are done .
function MediaTestManager() {
  this.runTests = function(tests, startTest) {
    this.startTime = new Date();
    SimpleTest.info("Started " + this.startTime + " (" + this.startTime.getTime()/1000 + "s)");
    this.testNum = 0;
    this.tests = tests;
    this.startTest = startTest;
    this.tokens = [];
    this.isShutdown = false;
    this.numTestsRunning = 0;
    SimpleTest.waitForExplicitFinish();
    this.nextTest();
  }
  this.started = function(token) {
    this.tokens.push(token);
    this.numTestsRunning++;
    is(this.numTestsRunning, this.tokens.length, "[started " + token + "] Length of array should match number of running tests");
  }
  this.finished = function(token) {
    var i = this.tokens.indexOf(token);
    if (i != -1) {
      this.tokens.splice(i, 1);
    }
    this.numTestsRunning--;
    is(this.numTestsRunning, this.tokens.length, "[finished " + token + "] Length of array should match number of running tests");
    if (this.tokens.length < PARALLEL_TESTS) {
      this.nextTest();
    }
  }
  this.nextTest = function() {
    SpecialPowers.forceGC();
    while (this.testNum < this.tests.length && this.tokens.length < PARALLEL_TESTS) {
      var test = this.tests[this.testNum];
      var token = (test.name ? (test.name + "-"): "") + this.testNum;
      this.testNum++;
      if (DEBUG_TEST_LOOP_FOREVER && this.testNum == this.tests.length) {
        this.testNum = 0;
      }
      if (test.type && !document.createElement('video').canPlayType(test.type))
        continue;
      this.startTest(test, token);
    }
    if (this.testNum == this.tests.length &&
        !DEBUG_TEST_LOOP_FOREVER &&
        this.tokens.length == 0 &&
        !this.isShutdown)
    {
      this.isShutdown = true;
      if (this.onFinished) {
        this.onFinished();
      }
      mediaTestCleanup();
      var end = new Date();
      SimpleTest.info("Finished at " + end + " (" + (end.getTime() / 1000) + "s)");
      SimpleTest.info("Running time: " + (end.getTime() - this.startTime.getTime())/1000 + "s");
      SimpleTest.finish();
      return;
    }
  }
}
function MediaTestManager ( ) { this . runTests = function ( tests , startTest ) { this . startTime = new Date ( ) ; SimpleTest . info ( "Started " + this . startTime + " (" + this . startTime . getTime ( ) / 1000 + "s)" ) ; this . testNum = 0 ; this . tests = tests ; this . startTest = startTest ; this . tokens = [ ] ; this . isShutdown = false ; this . numTestsRunning = 0 ; SimpleTest . waitForExplicitFinish ( ) ; this . nextTest ( ) ; } this . started = function ( token ) { this . tokens . push ( token ) ; this . numTestsRunning ++ ; is ( this . numTestsRunning , this . tokens . length , "[started " + token + "] Length of array should match number of running tests" ) ; } this . finished = function ( token ) { var i = this . tokens . indexOf ( token ) ; if ( i != - 1 ) { this . tokens . splice ( i , 1 ) ; } this . numTestsRunning -- ; is ( this . numTestsRunning , this . tokens . length , "[finished " + token + "] Length of array should match number of running tests" ) ; if ( this . tokens . length < PARALLEL_TESTS ) { this . nextTest ( ) ; } } this . nextTest = function ( ) { SpecialPowers . forceGC ( ) ; while ( this . testNum < this . tests . length && this . tokens . length < PARALLEL_TESTS ) { var test = this . tests [ this . testNum ] ; var token = ( test . name ? ( test . name + "-" ) : "" ) + this . testNum ; this . testNum ++ ; if ( DEBUG_TEST_LOOP_FOREVER && this . testNum == this . tests . length ) { this . testNum = 0 ; } if ( test . type && ! document . createElement ( 'video' ) . canPlayType ( test . type ) ) continue ; this . startTest ( test , token ) ; } if ( this . testNum == this . tests . length && ! DEBUG_TEST_LOOP_FOREVER && this . tokens . length == 0 && ! this . isShutdown ) { this . isShutdown = true ; if ( this . onFinished ) { this . onFinished ( ) ; } mediaTestCleanup ( ) ; var end = new Date ( ) ; SimpleTest . info ( "Finished at " + end + " (" + ( end . getTime ( ) / 1000 ) + "s)" ) ; SimpleTest . info ( "Running time: " + ( end . getTime ( ) - this . startTime . getTime ( ) ) / 1000 + "s" ) ; SimpleTest . finish ( ) ; return ; } } }
or end the mochitest if all the tests are done.
or end the mochitest if all the tests are done .
// Sets up a MediaTestManager to runs through the 'tests' array, which needs // to be one of, or have the same fields as, the g*Test arrays of tests. Uses // the user supplied 'startTest' function to initialize the test. This  // function must accept two arguments, the test entry from the 'tests' array, // and a token. Call MediaTestManager.started(token) if you start the test, // and MediaTestManager.finished(token) when the test finishes. You don't have // to start every test, but if you call started() you *must* call finish() // else you'll timeout.  // Always wait for explicit finish. // Registers that the test corresponding to 'token' has been started. // Don't call more than once per token. // Registers that the test corresponding to 'token' has finished. Call when // you've finished your test. If all tests are complete this will finish the // run, otherwise it may start up the next run. It's ok to call multiple times // per token. // Remove the element from the list of running tests. // 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. // Force a GC after every completed testcase. This ensures that any decoders // with live threads waiting for the GC are killed promptly, to free up the // thread stacks' address space. // Ensure we can play the resource type. // Do the init. This should start the test.