Changeset 7887

Show
Ignore:
Timestamp:
04/01/07 01:22:59 (16 months ago)
Author:
alex
Message:

adding sounds so that success and failure sound like...well...success or failure. Refs #2550

Location:
dojo/trunk/tests
Files:
5 added
3 modified

Legend:

Unmodified
Added
Removed
  • dojo/trunk/tests/runner.html

    r7847 r7887  
    1313                        }catch(e){ 
    1414                                document.write("<scr"+"ipt type='text/javascript' src='runner.js'></scr"+"ipt>"); 
     15                                document.write("<scr"+"ipt type='text/javascript'>tests.selfTest = true;</scr"+"ipt>"); 
    1516                                document.write("<scr"+"ipt type='text/javascript' src='_browserRunner.js'></scr"+"ipt>"); 
    1617                        } 
     
    237238                        </tr> 
    238239                </table> 
     240                <span id="hiddenAudio"></span> 
    239241        </body> 
    240242</html> 
  • dojo/trunk/tests/runner.js

    r7847 r7887  
    610610                        // gonna wait for an async result. It's up to the test code to trap 
    611611                        // errors and give us an errback or callback. 
    612                         if(ret instanceof this.Deferred){ 
     612                        if(ret instanceof tests.Deferred){ 
    613613 
    614614                                tg.inFlight++; 
     
    627627                                        } 
    628628                                        tests._testFinished(groupName, fixture, ret.results[0]); 
     629                                        if(tests._paused){ 
     630                                                // console.debug("finished deferred test group:", groupName, tests); 
     631                                                tests.run(); 
     632                                        } 
    629633                                } 
    630634 
     
    638642                                        retEnd(); 
    639643                                }); 
     644                                tests.pause(); 
    640645                                return ret; 
    641646                        } 
     
    654659        //              runs the specified test group 
    655660 
    656         // FIXME: we need group status and individual tests to be async-able. Would 
    657         // preferr, perhaps, avoiding use of the full Deferred system, but we'll 
    658         // see what we can get away w/. 
    659661        var tg = this._groups[groupName]; 
    660662        if(tg.skip === true){ return; } 
    661663        if(this._isArray(tg)){ 
     664                if(idx<=tg.length){ 
     665                        if(!tg.inFlight){ 
     666                                tests._groupFinished(groupName, (!tg.failures)); 
     667                        } 
     668                        return; 
     669                } 
    662670                tg.inFlight = 0; 
    663671                tg.iterated = false; 
     
    672680                        } 
    673681                        tests._runFixture(groupName, tg[y]); 
     682                        if(this._paused){ 
     683                                this._currentTest = y+1; 
     684                                if(this._currentTest == tg.length){ 
     685                                        tg.iterated = true; 
     686                                } 
     687                                this.debug("PAUSED at", this._currentGroup, this._currentTest); 
     688                                return; 
     689                        } 
    674690                } 
    675691                tg.iterated = true; 
     
    724740                        if(!found){ 
    725741                                found = true; 
     742                                // console.debug("starting from:", x, ct); 
    726743                                this.runGroup(x, ct); 
    727744                        }else{ 
    728745                                this.runGroup(x); 
    729746                        } 
     747                        if(this._paused){ return; } 
    730748                } 
    731749        } 
    732750        this._currentGroup = null; 
    733751        this._currentTest = null; 
    734         this._paused = true; 
     752        this._paused = false; 
    735753        this._onEnd(); 
    736754        this._report(); 
  • dojo/trunk/tests/_browserRunner.js

    r7880 r7887  
    213213                } 
    214214 
     215                var _playSound = function(name){ 
     216                        byId("hiddenAudio").innerHTML = '<embed src="_sounds/'+name+'.wav" autostart="true" loop="false" hidden="true" width="1" height="1"></embed>'; 
     217                } 
     218 
    215219                tests._testFinished = function(group, fixture, success){ 
    216220                        var fn = getFixtureNode(group, fixture); 
     
    218222                                fn.getElementsByTagName("td")[2].innerHTML = ((new Date())-fixture.startTime)+"ms"; 
    219223                                fn.className = (success) ? "success" : "failure"; 
     224 
     225                                if(!success){ 
     226                                        _playSound("doh"); 
     227                                } 
    220228                        } 
    221229                        this.debug(((success) ? "PASSED" : "FAILED"), "test:", fixture.name); 
     
    344352                                        } 
    345353                                } 
    346                                 tests._onEnd = toggleRunning; 
     354                                tests._onEnd = function(){ 
     355                                        toggleRunning(); 
     356                                        if(tests._failureCount == 0){ 
     357                                                alert("WOOHOO!!"); 
     358                                                tests.debug("WOOHOO!!"); 
     359                                                _playSound("woohoo"); 
     360                                        } 
     361                                } 
    347362                                tests.run = (function(oldRun){ 
    348363                                        return function(){ 
     
    369384                        } 
    370385                        tests._onEnd = function(){ 
     386                                _tests._errorCount += tests._errorCount; 
     387                                _tests._failureCount += tests._failureCount; 
     388                                _tests._testCount += tests._testCount; 
     389                                // should we be really adding raw group counts? 
     390                                _tests._groupCount += tests._groupCount; 
    371391                                _tests.currentTestDeferred.callback(true); 
    372392                        } 
     
    385405                                _tests._testFinished(_thisGroup, f, s); 
    386406                        } 
     407                        tests._report = function(){}; 
    387408                } 
    388409        }