OLD | NEW |
| 1 library dromaeo_test; |
| 2 |
1 import 'dart:html'; | 3 import 'dart:html'; |
2 import 'dart:json' as json; | 4 import 'dart:json' as json; |
3 import 'dart:math' as Math; | 5 import 'dart:math' as Math; |
4 import 'Suites.dart'; | 6 import 'Suites.dart'; |
5 | 7 |
6 main() { | 8 main() { |
7 new Dromaeo().run(); | 9 new Dromaeo().run(); |
8 } | 10 } |
9 | 11 |
10 class SuiteController { | 12 class SuiteController { |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 Dromaeo() | 93 Dromaeo() |
92 : _suiteControllers = new List<SuiteController>() | 94 : _suiteControllers = new List<SuiteController>() |
93 { | 95 { |
94 _handler = _createHandler(); | 96 _handler = _createHandler(); |
95 window.onMessage.listen( | 97 window.onMessage.listen( |
96 (MessageEvent event) { | 98 (MessageEvent event) { |
97 try { | 99 try { |
98 final response = json.parse(event.data); | 100 final response = json.parse(event.data); |
99 _handler = _handler(response['command'], response['data']); | 101 _handler = _handler(response['command'], response['data']); |
100 } catch (e, stacktrace) { | 102 } catch (e, stacktrace) { |
101 window.alert('Exception: ${e}: ${stacktrace}'); | 103 if (!(e is FormatException && |
| 104 (event.data.toString().startsWith('unittest') || |
| 105 event.data.toString().startsWith('dart')))) { |
| 106 // Hack because unittest also uses post messages to communicate. |
| 107 // So the fact that the event.data is not proper json is not |
| 108 // always an error. |
| 109 print('Exception: ${e}: ${stacktrace}'); |
| 110 print(event.data); |
| 111 } |
102 } | 112 } |
103 }); | 113 }); |
104 } | 114 } |
105 | 115 |
106 run() { | 116 run() { |
107 // TODO(vsm): Initial page should not run. For now, run all | 117 // TODO(vsm): Initial page should not run. For now, run all |
108 // tests by default. | 118 // tests by default. |
109 final splitUrl = window.location.href.split('?'); | 119 var tags = window.location.search; |
110 var tags; | 120 if (tags.length > 1) { |
111 if (splitUrl.length > 1) { | 121 tags = tags.substring(1); |
112 tags = splitUrl[1]; | |
113 } else if (window.navigator.userAgent.contains('(Dart)')) { | 122 } else if (window.navigator.userAgent.contains('(Dart)')) { |
114 // TODO(vsm): Update when we change Dart VM detection. | 123 // TODO(vsm): Update when we change Dart VM detection. |
115 tags = 'js|dart&html'; | 124 tags = 'js|dart&html'; |
116 } else { | 125 } else { |
117 tags = 'js|dart2js&html'; | 126 tags = 'js|dart2js&html'; |
118 } | 127 } |
119 | 128 |
120 // TODO(antonm): create Re-run tests href. | 129 // TODO(antonm): create Re-run tests href. |
121 final Element suiteNameElement = _byId('overview').nodes[0]; | 130 final Element suiteNameElement = _byId('overview').nodes[0]; |
122 final category = Suites.getCategory(tags); | 131 final category = Suites.getCategory(tags); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 } | 220 } |
212 | 221 |
213 Element _byId(String id) { | 222 Element _byId(String id) { |
214 return document.query('#$id'); | 223 return document.query('#$id'); |
215 } | 224 } |
216 | 225 |
217 int get _suitesTotal { | 226 int get _suitesTotal { |
218 return _suiteControllers.length; | 227 return _suiteControllers.length; |
219 } | 228 } |
220 } | 229 } |
OLD | NEW |