| OLD | NEW |
| 1 import 'dart:html'; | 1 import 'dart:html'; |
| 2 import 'dart:json'; | 2 import 'dart:json'; |
| 3 import 'dart:math' as Math; | 3 import 'dart:math' as Math; |
| 4 import 'Suites.dart'; | 4 import 'Suites.dart'; |
| 5 | 5 |
| 6 main() { | 6 main() { |
| 7 new Dromaeo().run(); | 7 new Dromaeo().run(); |
| 8 } | 8 } |
| 9 | 9 |
| 10 class SuiteController { | 10 class SuiteController { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 _suiteIframe.contentWindow.postMessage('start', '*'); | 26 _suiteIframe.contentWindow.postMessage('start', '*'); |
| 27 } | 27 } |
| 28 | 28 |
| 29 update(String testName, num mean, num error, double percent) { | 29 update(String testName, num mean, num error, double percent) { |
| 30 _meanProduct *= mean; | 30 _meanProduct *= mean; |
| 31 _nTests++; | 31 _nTests++; |
| 32 | 32 |
| 33 final meanAsString = mean.toStringAsFixed(2); | 33 final meanAsString = mean.toStringAsFixed(2); |
| 34 final errorAsString = error.toStringAsFixed(2); | 34 final errorAsString = error.toStringAsFixed(2); |
| 35 final Element progressDisplay = _element.nextNode.nextNode; | 35 final Element progressDisplay = _element.nextNode.nextNode; |
| 36 progressDisplay.innerHTML = | 36 progressDisplay.innerHtml = |
| 37 '${progressDisplay.innerHTML}<li><b>${testName}:</b>' | 37 '${progressDisplay.innerHtml}<li><b>${testName}:</b>' |
| 38 '${meanAsString}<small> runs/s ±${errorAsString}%<small></li>'; | 38 '${meanAsString}<small> runs/s ±${errorAsString}%<small></li>'; |
| 39 _updateTestPos(percent); | 39 _updateTestPos(percent); |
| 40 } | 40 } |
| 41 | 41 |
| 42 _make() { | 42 _make() { |
| 43 _element = _createDiv('test'); | 43 _element = _createDiv('test'); |
| 44 // TODO(antonm): add an onclick functionality. | 44 // TODO(antonm): add an onclick functionality. |
| 45 _updateTestPos(); | 45 _updateTestPos(); |
| 46 } | 46 } |
| 47 | 47 |
| 48 _updateTestPos([double percent = 1.0]) { | 48 _updateTestPos([double percent = 1.0]) { |
| 49 String suiteName = _suiteDescription.name; | 49 String suiteName = _suiteDescription.name; |
| 50 final done = percent >= 100.0; | 50 final done = percent >= 100.0; |
| 51 String info = ''; | 51 String info = ''; |
| 52 if (done) { | 52 if (done) { |
| 53 final parent = _element.parent; | 53 final parent = _element.parent; |
| 54 parent.attributes['class'] = '${parent.attributes["class"]} done'; | 54 parent.attributes['class'] = '${parent.attributes["class"]} done'; |
| 55 final mean = Math.pow(_meanProduct, 1.0 / _nTests).toStringAsFixed(2); | 55 final mean = Math.pow(_meanProduct, 1.0 / _nTests).toStringAsFixed(2); |
| 56 info = '<span>${mean} runs/s</span>'; | 56 info = '<span>${mean} runs/s</span>'; |
| 57 } | 57 } |
| 58 _element.innerHTML = | 58 _element.innerHtml = |
| 59 '<b>${suiteName}:</b>' | 59 '<b>${suiteName}:</b>' |
| 60 '<div class="bar"><div style="width:${percent}%;">${info}</div></div>'; | 60 '<div class="bar"><div style="width:${percent}%;">${info}</div></div>'; |
| 61 } | 61 } |
| 62 | 62 |
| 63 _init() { | 63 _init() { |
| 64 final div = _createDiv('result-item'); | 64 final div = _createDiv('result-item'); |
| 65 div.nodes.add(_element); | 65 div.nodes.add(_element); |
| 66 final description = _suiteDescription.description; | 66 final description = _suiteDescription.description; |
| 67 final originUrl = _suiteDescription.origin.url; | 67 final originUrl = _suiteDescription.origin.url; |
| 68 final testUrl = 'tests/${_suiteDescription.file}'; | 68 final testUrl = 'tests/${_suiteDescription.file}'; |
| 69 div.innerHTML = | 69 div.innerHtml = |
| 70 '${div.innerHTML}<p>${description}<br/><a href="${originUrl}">Origin</a' | 70 '${div.innerHtml}<p>${description}<br/><a href="${originUrl}">Origin</a' |
| 71 '>, <a href="${testUrl}">Source</a>' | 71 '>, <a href="${testUrl}">Source</a>' |
| 72 '<ol class="results"></ol>'; | 72 '<ol class="results"></ol>'; |
| 73 // Reread the element, as the previous wrapper get disconnected thanks | 73 // Reread the element, as the previous wrapper get disconnected thanks |
| 74 // to .innerHTML update above. | 74 // to .innerHtml update above. |
| 75 _element = div.nodes[0]; | 75 _element = div.nodes[0]; |
| 76 | 76 |
| 77 document.query('#main').nodes.add(div); | 77 document.query('#main').nodes.add(div); |
| 78 } | 78 } |
| 79 | 79 |
| 80 DivElement _createDiv(String clazz) { | 80 DivElement _createDiv(String clazz) { |
| 81 final div = new DivElement(); | 81 final div = new DivElement(); |
| 82 div.attributes['class'] = clazz; | 82 div.attributes['class'] = clazz; |
| 83 return div; | 83 return div; |
| 84 } | 84 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 // TODO(vsm): Update when we change Dart VM detection. | 116 // TODO(vsm): Update when we change Dart VM detection. |
| 117 tags = 'js|dart&html'; | 117 tags = 'js|dart&html'; |
| 118 } else { | 118 } else { |
| 119 tags = 'js|dart2js&html'; | 119 tags = 'js|dart2js&html'; |
| 120 } | 120 } |
| 121 | 121 |
| 122 // TODO(antonm): create Re-run tests href. | 122 // TODO(antonm): create Re-run tests href. |
| 123 final Element suiteNameElement = _byId('overview').nodes[0]; | 123 final Element suiteNameElement = _byId('overview').nodes[0]; |
| 124 final category = Suites.getCategory(tags); | 124 final category = Suites.getCategory(tags); |
| 125 if (category != null) { | 125 if (category != null) { |
| 126 suiteNameElement.innerHTML = category; | 126 suiteNameElement.innerHtml = category; |
| 127 } | 127 } |
| 128 _css(_byId('tests'), 'display', 'none'); | 128 _css(_byId('tests'), 'display', 'none'); |
| 129 for (SuiteDescription suite in Suites.getSuites(tags)) { | 129 for (SuiteDescription suite in Suites.getSuites(tags)) { |
| 130 final iframe = new IFrameElement(); | 130 final iframe = new IFrameElement(); |
| 131 _css(iframe, 'height', '1px'); | 131 _css(iframe, 'height', '1px'); |
| 132 _css(iframe, 'width', '1px'); | 132 _css(iframe, 'width', '1px'); |
| 133 iframe.src = 'tests/${suite.file}'; | 133 iframe.src = 'tests/${suite.file}'; |
| 134 document.body.nodes.add(iframe); | 134 document.body.nodes.add(iframe); |
| 135 | 135 |
| 136 _suiteControllers.add(new SuiteController(suite, iframe)); | 136 _suiteControllers.add(new SuiteController(suite, iframe)); |
| 137 } | 137 } |
| 138 } | 138 } |
| 139 | 139 |
| 140 static const double _SECS_PER_TEST = 5.0; | 140 static const double _SECS_PER_TEST = 5.0; |
| 141 | 141 |
| 142 Function _createHandler() { | 142 Function _createHandler() { |
| 143 int suitesLoaded = 0; | 143 int suitesLoaded = 0; |
| 144 int totalTests = 0; | 144 int totalTests = 0; |
| 145 int currentSuite; | 145 int currentSuite; |
| 146 double totalTimeSecs, estimatedTimeSecs; | 146 double totalTimeSecs, estimatedTimeSecs; |
| 147 | 147 |
| 148 // TODO(jat): Remove void type below. Bug 5269037. | 148 // TODO(jat): Remove void type below. Bug 5269037. |
| 149 void _updateTime() { | 149 void _updateTime() { |
| 150 final mins = (estimatedTimeSecs / 60).floor().toInt(); | 150 final mins = (estimatedTimeSecs / 60).floor().toInt(); |
| 151 final secs = (estimatedTimeSecs - mins * 60).round().toInt(); | 151 final secs = (estimatedTimeSecs - mins * 60).round().toInt(); |
| 152 final secsAsString = '${(secs < 10 ? "0" : "")}$secs'; | 152 final secsAsString = '${(secs < 10 ? "0" : "")}$secs'; |
| 153 _byId('left').innerHTML = '${mins}:${secsAsString}'; | 153 _byId('left').innerHtml = '${mins}:${secsAsString}'; |
| 154 | 154 |
| 155 final elapsed = totalTimeSecs - estimatedTimeSecs; | 155 final elapsed = totalTimeSecs - estimatedTimeSecs; |
| 156 final percent = (100 * elapsed / totalTimeSecs).toStringAsFixed(2); | 156 final percent = (100 * elapsed / totalTimeSecs).toStringAsFixed(2); |
| 157 _css(_byId('timebar'), 'width', '${percent}%'); | 157 _css(_byId('timebar'), 'width', '${percent}%'); |
| 158 } | 158 } |
| 159 | 159 |
| 160 Function loading, running, done; | 160 Function loading, running, done; |
| 161 | 161 |
| 162 loading = (String command, var data) { | 162 loading = (String command, var data) { |
| 163 assert(command == 'inited'); | 163 assert(command == 'inited'); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 } | 213 } |
| 214 | 214 |
| 215 Element _byId(String id) { | 215 Element _byId(String id) { |
| 216 return document.query('#$id'); | 216 return document.query('#$id'); |
| 217 } | 217 } |
| 218 | 218 |
| 219 int get _suitesTotal { | 219 int get _suitesTotal { |
| 220 return _suiteControllers.length; | 220 return _suiteControllers.length; |
| 221 } | 221 } |
| 222 } | 222 } |
| OLD | NEW |