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

Side by Side Diff: samples/third_party/todomvc/test/markdone_test.dart

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 // 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
3 // BSD-style license that can be found in the LICENSE file.
4
5 library todomvc.test.markdone_test;
6
7 import 'dart:html';
8 import 'package:polymer/polymer.dart';
9 import 'package:unittest/unittest.dart';
10 import 'package:unittest/html_config.dart';
11 import '../web/model.dart';
12
13 Node findWithText(Node node, String text) {
14 if (node.text == text) return node;
15 if (node is Element && (node as Element).localName == 'polymer-element') {
16 return null;
17 }
18 if (node is Element && (node as Element).shadowRoot != null) {
19 var r = findWithText((node as Element).shadowRoot, text);
20 if (r != null) return r;
21 }
22 for (var n in node.nodes) {
23 var r = findWithText(n, text);
24 if (r != null) return r;
25 }
26 return null;
27 }
28
29 Node findShadowHost(Node node, ShadowRoot root) {
30 if (node is Element) {
31 var shadowRoot = (node as Element).shadowRoot;
32 if (shadowRoot == root) return node;
33 if (shadowRoot != null) {
34 var r = findShadowHost(shadowRoot, root);
35 if (r != null) return r;
36 }
37 }
38 for (var n in node.nodes) {
39 var r = findShadowHost(n, root);
40 if (r != null) return r;
41 }
42 return null;
43 }
44
45 /**
46 * This test runs the TodoMVC app, adds a few todos, marks some as done
47 * programatically, and clicks on a checkbox to mark others via the UI.
48 */
49 main() {
50 useHtmlConfiguration();
51
52 test('mark done', () {
53 appModel.todos.add(new Todo('one (unchecked)'));
54 appModel.todos.add(new Todo('two (unchecked)'));
55 appModel.todos.add(new Todo('three (checked)')..done = true);
56 appModel.todos.add(new Todo('four (checked)'));
57
58 performMicrotaskCheckpoint();
59 var body = query('body');
60
61 var label = findWithText(body, 'four (checked)');
62 expect(label is LabelElement, isTrue, reason: 'text is in a label');
63
64 var host = findShadowHost(body, label.parentNode);
65 var node = host.parent.query('input');
66 expect(node is InputElement, isTrue, reason: 'node is a checkbox');
67 expect(node.type, 'checkbox', reason: 'node type is checkbox');
68 expect(node.checked, isFalse, reason: 'element is unchecked');
69
70 node.dispatchEvent(new MouseEvent('click', detail: 1));
71 expect(node.checked, isTrue, reason: 'element is checked');
72 });
73 }
OLDNEW
« no previous file with comments | « samples/third_party/todomvc/test/markdone_shadow_test.html ('k') | samples/third_party/todomvc/test/markdone_test.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698