OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <!-- | 2 <!-- |
3 Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 3 Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
4 for details. All rights reserved. Use of this source code is governed by a | 4 for details. All rights reserved. Use of this source code is governed by a |
5 BSD-style license that can be found in the LICENSE file. | 5 BSD-style license that can be found in the LICENSE file. |
6 --> | 6 --> |
7 <html lang="en"> | 7 <html lang="en"> |
8 <head> | 8 <head> |
9 <!-- | 9 <!-- |
10 This test runs the TodoMVC app, adds a few elements, marks some as done, and | 10 This test runs the TodoMVC app, adds a few elements, marks some as done, and |
11 switches from back and forth between "Active" and "All". This will make some | 11 switches from back and forth between "Active" and "All". This will make some |
12 nodes to be hidden and readded to the page. | 12 nodes to be hidden and readded to the page. |
13 | 13 |
14 This is a regression test for a bug in dwc that made the nodes appear in the | 14 This is a regression test for a bug in dwc that made the nodes appear in the |
15 wrong order when using lists and ifs together. | 15 wrong order when using lists and ifs together. |
16 --> | 16 --> |
17 <meta charset="utf-8"> | 17 <meta charset="utf-8"> |
18 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> | 18 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> |
19 <link rel="import" href="../web/app.html"> | 19 <link rel="import" href="../web/app.html"> |
20 <link rel="stylesheet" href="../web/base.css"> | 20 <link rel="stylesheet" href="../web/base.css"> |
21 <script src="packages/polymer/testing/testing.js"></script> | 21 <script src="packages/polymer/testing/testing.js"></script> |
22 <title>Dart • TodoMVC</title> | 22 <title>Dart • TodoMVC</title> |
23 </head> | 23 </head> |
24 <body> | 24 <body> |
25 <todo-app></todo-app> | 25 <todo-app></todo-app> |
26 <script type="application/dart"> | 26 <script type="application/dart"> |
27 import 'dart:async'; | |
28 import 'dart:html'; | 27 import 'dart:html'; |
29 import 'package:mdv/mdv.dart' as mdv; | 28 import 'package:polymer/polymer.dart'; |
30 import 'package:observe/observe.dart'; | |
31 import 'package:unittest/unittest.dart'; | 29 import 'package:unittest/unittest.dart'; |
32 import 'package:polymer/polymer.dart'; | |
33 import '../web/model.dart'; | 30 import '../web/model.dart'; |
34 | 31 |
35 main() { | 32 main() { |
36 mdv.initialize(); | 33 appModel.todos.add(new Todo('one (unchecked)')); |
| 34 appModel.todos.add(new Todo('two (checked)')..done = true); |
| 35 appModel.todos.add(new Todo('three (unchecked)')); |
37 | 36 |
38 Timer.run(() { | 37 var root = query('span[is=todo-app]').xtag.shadowRoot; |
39 appModel.todos.add(new Todo('one (unchecked)')); | |
40 appModel.todos.add(new Todo('two (checked)')..done = true); | |
41 appModel.todos.add(new Todo('three (unchecked)')); | |
42 | 38 |
43 var root = query('span[is=todo-app]').xtag.shadowRoot; | 39 windowLocation.hash = '#/'; |
| 40 performMicrotaskCheckpoint(); |
44 | 41 |
45 windowLocation.hash = '#/'; | 42 expect(root.queryAll('#todo-list li[is=todo-row]').length, 3); |
46 Timer.run(() { | 43 windowLocation.hash = '#/active'; |
47 expect(root.queryAll('#todo-list li[is=todo-row]').length, 3); | 44 performMicrotaskCheckpoint(); |
48 | 45 |
49 windowLocation.hash = '#/active'; | 46 expect(root.queryAll('#todo-list li[is=todo-row]').length, 2); |
50 Timer.run(() { | 47 windowLocation.hash = '#/completed'; |
51 expect(root.queryAll('#todo-list li[is=todo-row]').length, 2); | 48 performMicrotaskCheckpoint(); |
52 | 49 |
53 windowLocation.hash = '#/completed'; | 50 expect(root.queryAll('#todo-list li[is=todo-row]').length, 1); |
54 Timer.run(() { | 51 windowLocation.hash = '#/'; |
55 expect(root.queryAll('#todo-list li[is=todo-row]').length, 1); | 52 performMicrotaskCheckpoint(); |
56 | 53 |
57 windowLocation.hash = '#/'; | 54 window.postMessage('done', '*'); |
58 // TODO(sigmund): investigate why is not enough to do Timer.run | |
59 new Timer(new Duration(milliseconds: 200), () { | |
60 window.postMessage('done', '*'); | |
61 }); | |
62 }); | |
63 }); | |
64 }); | |
65 }); | |
66 } | 55 } |
67 </script> | 56 </script> |
68 </body> | 57 </body> |
69 </html> | 58 </html> |
OLD | NEW |