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

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

Issue 77373002: "Reverting 30388" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 1 month 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
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 todomvc.test.mainpage_test; 5 library todomvc.test.mainpage_test;
6 6
7 import 'dart:async';
7 import 'dart:html'; 8 import 'dart:html';
9 import 'dart:js' as js;
8 import 'package:polymer/polymer.dart'; 10 import 'package:polymer/polymer.dart';
9 import 'package:unittest/html_config.dart'; 11 import 'package:unittest/html_config.dart';
10 import 'package:unittest/unittest.dart'; 12 import 'package:unittest/unittest.dart';
11 import '../web/app.dart'; 13 import '../web/elements/td_model.dart';
12 import '../web/model.dart'; 14 import '../web/elements/td_todos.dart';
15 import 'utils.dart';
13 16
14 /** 17 /**
15 * This test runs the TodoMVC app and checks the state of the initial page. 18 * This test runs the TodoMVC app and checks the state of the initial page.
16 */ 19 */
17 // TODO(jmesserly): verify some styles (colors, fonts, relative size) as well.
18 main() { 20 main() {
19 initPolymer(); 21 initPolymer();
20 useHtmlConfiguration(); 22 useHtmlConfiguration();
21 23
22 setUp(() => Polymer.onReady); 24 setUp(() => Polymer.onReady);
23 25
24 test('initial state', () { 26 test('initial state', () {
25 final todoApp = querySelector('todo-app'); 27 final model = querySelector('td-model');
26 expect(appModel.todos.length, 0); 28 expect(model is TodoModel, true, reason: 'TodoModel should be created');
27 expect(todoApp.xtag is TodoApp, true, reason: 'TodoApp should be created');
28 29
29 final root = todoApp.shadowRoot; 30 final app = querySelector('td-todos');
31 expect(app is TodoList, true, reason: 'TodoList should be created');
32
33 final root = app.shadowRoot;
30 final newTodo = root.querySelector('#new-todo'); 34 final newTodo = root.querySelector('#new-todo');
31 expect(newTodo.placeholder, "What needs to be done?"); 35 expect(newTodo.placeholder, "What needs to be done?");
32 36
33 // TODO(jmesserly): re-enable this. It fails on Firefox with ShadowDOM. 37 expect(app.modelId, 'model', reason: 'modelId is set via attribute');
34 // The issue appears to be that 38
35 // Wait for setTimeout 0 for focus to activate. 39 // Validate the stylesheet was loaded
36 /*Timer.run(expectAsync0(() { 40 if (js.context.hasProperty('ShadowDOMPolyfill')) {
37 expect(document.activeElement, todoApp, reason: 'app should have focus'); 41 final style = document.head.querySelector('style[ShadowCSSShim]');
38 expect(root.activeElement, newTodo, reason: 'New todo should have focus'); 42 expect(style.text, contains('\ntd-todos #todoapp {'));
39 expect(root.querySelectorAll('[is=todo-row]').length, 0, reason: 'no items yet'); 43 } else {
40 }));*/ 44 final style = root.querySelector('style');
45 expect(style, isNotNull, reason: '<link> was replaced with <style>');
46 expect(style.text, contains('\n#todoapp {'));
47 }
48
49 // Validate a style got applied
50 var color = root.querySelector('#footer').getComputedStyle().color;
51 expect(color, 'rgb(119, 119, 119)');
52
53 return onPropertyInit(model, 'items').then((_) {
54 expect(model.items, [], reason: 'no items yet');
55 expect(app.model, model, reason: 'model should be data-bound');
56 });
41 }); 57 });
42 } 58 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698