OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library dromaeo; | 5 library dromaeo; |
6 import '../../pkg/unittest/lib/unittest.dart'; | 6 import '../../pkg/unittest/lib/unittest.dart'; |
7 import '../../pkg/unittest/lib/html_config.dart'; | 7 import '../../pkg/unittest/lib/html_config.dart'; |
8 import '../../samples/third_party/dromaeo/Dromaeo.dart' as originalTest; | 8 import '../../samples/third_party/dromaeo/Dromaeo.dart' as originalTest; |
9 import 'dart:html'; | 9 import 'dart:html'; |
10 import 'dart:async'; | 10 import 'dart:async'; |
11 | 11 |
12 /** A variant of the Dromaeo test shoehorned into a unit test. */ | 12 /** A variant of the Dromaeo test shoehorned into a unit test. */ |
13 void main() { | 13 void main() { |
14 var combo = '?dartANDhtmlANDnothing'; | 14 var combo = '?dartANDhtmlANDnothing'; |
15 if (!window.location.search.toString().contains(combo)) { | 15 if (!window.location.search.toString().contains(combo)) { |
16 if (window.location.href.toString().indexOf("?") == -1) { | 16 if (window.location.href.toString().indexOf("?") == -1) { |
17 window.location.href = '${window.location.href}${combo}'; | 17 window.location.href = '${window.location.href}${combo}'; |
18 } else { | 18 } else { |
19 window.location.href = '${window.location.href.toString().substring(0, | 19 window.location.href = '${window.location.href.toString().substring(0, |
20 window.location.href.toString().indexOf("?"))}${combo}'; | 20 window.location.href.toString().indexOf("?"))}${combo}'; |
21 } | 21 } |
22 } | 22 } |
23 | 23 |
24 useHtmlConfiguration(); | 24 useHtmlConfiguration(); |
25 | 25 |
26 var scriptSrc = new ScriptElement(); | 26 var scriptSrc = new ScriptElement(); |
27 scriptSrc.src = '../../../../pkg/browser/lib/dart.js'; | 27 scriptSrc.src = '/root_dart/pkg/browser/lib/dart.js'; |
28 document.head.children.add(scriptSrc); | 28 document.head.children.add(scriptSrc); |
29 document.body.innerHtml = '''${document.body.innerHtml} | 29 document.body.innerHtml = '''${document.body.innerHtml} |
30 <div id="main"> | 30 <div id="main"> |
31 <h1 id="overview" class="test"><span>Performance Tests</span> | 31 <h1 id="overview" class="test"><span>Performance Tests</span> |
32 <input type="button" id="pause" class="pause" value="Loading..."/> | 32 <input type="button" id="pause" class="pause" value="Loading..."/> |
33 <div class="bar"> | 33 <div class="bar"> |
34 <div id="timebar" style="width:25%;"> | 34 <div id="timebar" style="width:25%;"> |
35 <span class="left">Est. Time: <strong id="left">0:00</strong> | 35 <span class="left">Est. Time: <strong id="left">0:00</strong> |
36 </span> | 36 </span> |
37 </div> | 37 </div> |
38 </div> | 38 </div> |
39 <ul id="tests"> | 39 <ul id="tests"> |
40 <li><a href="?dom">Smoke Tests</a></li> | 40 <li><a href="?dom">Smoke Tests</a></li> |
41 </ul> | 41 </ul> |
42 </div>'''; | 42 </div>'''; |
43 | 43 |
44 bool isDone = false; | 44 bool isDone = false; |
45 originalTest.main(); | 45 originalTest.main(); |
46 | 46 |
47 test('dromaeo runs', () { | 47 test('dromaeo runs', () { |
48 new Timer.repeating(new Duration(milliseconds: 500), | 48 new Timer.repeating(new Duration(milliseconds: 500), |
49 expectAsyncUntil1((timer) { | 49 expectAsyncUntil1((timer) { |
50 if (document.query('.alldone') != null) { | 50 if (document.query('.alldone') != null) { |
51 timer.cancel(); | 51 timer.cancel(); |
52 isDone = true; | 52 isDone = true; |
53 } | 53 } |
54 }, () => isDone)); | 54 }, () => isDone)); |
55 }); | 55 }); |
56 } | 56 } |
OLD | NEW |