Upgrade to ExtJS 4.0.1 - Released 05/18/2011
[extjs.git] / jsbuilder / src / generators / app / files / lib / sencha-jasmine / sencha-jasmine.js
1 jasmine.TrivialReporter.prototype.reportRunnerStarting = function(runner) {
2   var showPassed, showSkipped;
3
4   this.outerDiv = this.createDom('div', { className: 'jasmine_reporter' },
5       this.createDom('div', { className: 'banner' },
6         this.createDom('div', { className: 'logo' }),
7         this.createDom('div', { className: 'options' },
8             this.createDom('div', { className: 'show' },
9                 this.createDom('label', { "for": "__jasmine_TrivialReporter_showPassed__" }, " passed "),
10                 showPassed = this.createDom('input', { id: "__jasmine_TrivialReporter_showPassed__", type: 'checkbox' })
11             ),
12             this.createDom('div', { className: 'show' },
13                 this.createDom('label', { "for": "__jasmine_TrivialReporter_showSkipped__" }, " skipped"),
14                 showSkipped = this.createDom('input', { id: "__jasmine_TrivialReporter_showSkipped__", type: 'checkbox' })
15             ),
16             this.createDom('div', { className: 'show' },
17                 this.createDom('label', { "for": "__jasmine_TrivialReporter_automaticReload__" }," automatic reload"),
18                 automaticReload = this.createDom('input',
19                     (window.location.hash == "#reload") ? {id: "__jasmine_TrivialReporter_automaticReload__", type: 'checkbox', checked: true } : {id: "__jasmine_TrivialReporter_automaticReload__", type: 'checkbox'}
20                 )
21             )
22             )
23           ),
24
25       this.runnerDiv = this.createDom('div', { className: 'runner running' },
26           this.createDom('a', { className: 'run_spec', href: '?' }, "run all"),
27           this.runnerMessageSpan = this.createDom('span', {}, "Running..."),
28           this.finishedAtSpan = this.createDom('span', { className: 'finished-at' }, ""))
29       );
30
31   this.document.body.appendChild(this.outerDiv);
32
33   var suites = runner.suites();
34   for (var i = 0; i < suites.length; i++) {
35     var suite = suites[i];
36     var suiteDiv = this.createDom('div', { className: 'suite' },
37         this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, "run"),
38         this.createDom('a', { className: 'description', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, suite.description));
39     this.suiteDivs[suite.id] = suiteDiv;
40     var parentDiv = this.outerDiv;
41     if (suite.parentSuite) {
42       parentDiv = this.suiteDivs[suite.parentSuite.id];
43     }
44     parentDiv.appendChild(suiteDiv);
45   }
46
47   this.startedAt = new Date();
48
49   var self = this;
50   showPassed.onchange = function(evt) {
51     if (evt.target.checked) {
52       self.outerDiv.className += ' show-passed';
53     } else {
54       self.outerDiv.className = self.outerDiv.className.replace(/ show-passed/, '');
55     }
56   };
57
58   showSkipped.onchange = function(evt) {
59     if (evt.target.checked) {
60       self.outerDiv.className += ' show-skipped';
61     } else {
62       self.outerDiv.className = self.outerDiv.className.replace(/ show-skipped/, '');
63     }
64   };
65
66   automaticReload.onchange = function(evt) {
67       if (evt.target.checked) {
68         window.location.hash = "#reload";
69         window.location.reload();
70       } else {
71         window.location.hash = "";
72         window.location.reload();
73       }
74     };
75 };
76
77 if (window.location.hash == "#reload") {
78     var interval = setInterval(function() {
79         var isRunning = jasmine.getEnv().currentRunner_.queue.isRunning();
80         if (!isRunning) {
81             clearInterval(interval);
82         
83             setTimeout(function() {
84                 window.location.reload();
85             }, 5000);
86         };
87     }, 1500);
88 };