Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Side by Side Diff: samples/third_party/todomvc/test/todomvc_markdone_test.html

Issue 23539003: Turn on Polymer TodoMVC tests on Dart buildbots (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: rebase Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <!--
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
5 BSD-style license that can be found in the LICENSE file.
6 -->
7 <html lang="en">
8 <head>
9 <!--
10 This test runs the TodoMVC app, adds a few todos, marks some as done
11 programatically, and clicks on a checkbox to mark others via the UI.
12 -->
13 <meta charset="utf-8">
14 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
15 <link rel="import" href="../web/app.html">
16 <link rel="stylesheet" href="../web/base.css">
17 <script src="packages/polymer/testing/testing.js"></script>
18 <title>Dart • TodoMVC</title>
19 </head><body>
20 <todo-app></todo-app>
21 <script type="application/dart">
22 import 'dart:html';
23 import 'package:unittest/unittest.dart';
24 import 'package:polymer/polymer.dart';
25 import '../web/model.dart';
26
27 Node findWithText(Node node, String text) {
28 if (node.text == text) return node;
29 if (node is Element && (node as Element).localName == 'polymer-element') {
30 return null;
31 }
32 if (node is Element && (node as Element).shadowRoot != null) {
33 var r = findWithText((node as Element).shadowRoot, text);
34 if (r != null) return r;
35 }
36 for (var n in node.nodes) {
37 var r = findWithText(n, text);
38 if (r != null) return r;
39 }
40 return null;
41 }
42
43 Node findShadowHost(Node node, ShadowRoot root) {
44 if (node is Element) {
45 var shadowRoot = (node as Element).shadowRoot;
46 if (shadowRoot == root) return node;
47 if (shadowRoot != null) {
48 var r = findShadowHost(shadowRoot, root);
49 if (r != null) return r;
50 }
51 }
52 for (var n in node.nodes) {
53 var r = findShadowHost(n, root);
54 if (r != null) return r;
55 }
56 return null;
57 }
58
59 main() {
60 appModel.todos.add(new Todo('one (unchecked)'));
61 appModel.todos.add(new Todo('two (unchecked)'));
62 appModel.todos.add(new Todo('three (checked)')..done = true);
63 appModel.todos.add(new Todo('four (checked)'));
64
65 performMicrotaskCheckpoint();
66 var body = query('body');
67
68 var label = findWithText(body, 'four (checked)');
69 expect(label is LabelElement, isTrue, reason: 'text is in a label');
70
71 var host = findShadowHost(body, label.parentNode);
72 var node = host.parent.query('input');
73 expect(node is InputElement, isTrue, reason: 'node is a checkbox');
74 expect(node.type, 'checkbox', reason: 'node type is checkbox');
75 expect(node.checked, isFalse, reason: 'element is unchecked');
76
77 node.dispatchEvent(new MouseEvent('click', detail: 1));
78 expect(node.checked, isTrue, reason: 'element is checked');
79 performMicrotaskCheckpoint();
80
81 window.postMessage('done', '*');
82 }
83
84 </script>
85 </body>
86 </html>
OLDNEW
« no previous file with comments | « samples/third_party/todomvc/test/todomvc_mainpage_test.html ('k') | samples/third_party/todomvc/web/index.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698