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

Side by Side Diff: tests/html/queryall_test.dart

Issue 2771453003: Format all tests. (Closed)
Patch Set: Format files Created 3 years, 8 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
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 NodeListTest; 5 library NodeListTest;
6
6 import 'package:unittest/unittest.dart'; 7 import 'package:unittest/unittest.dart';
7 import 'package:unittest/html_config.dart'; 8 import 'package:unittest/html_config.dart';
8 import 'dart:html'; 9 import 'dart:html';
9 10
10 main() { 11 main() {
11 useHtmlConfiguration(); 12 useHtmlConfiguration();
12 13
13 var isElement = predicate((x) => x is Element, 'is an Element'); 14 var isElement = predicate((x) => x is Element, 'is an Element');
14 var isCanvasElement = 15 var isCanvasElement =
15 predicate((x) => x is CanvasElement, 'is a CanvasElement'); 16 predicate((x) => x is CanvasElement, 'is a CanvasElement');
16 var isDivElement = predicate((x) => x is DivElement, 'is a isDivElement'); 17 var isDivElement = predicate((x) => x is DivElement, 'is a isDivElement');
17 18
18 var div = new DivElement(); 19 var div = new DivElement();
19 div.id = 'test'; 20 div.id = 'test';
20 document.body.append(div); 21 document.body.append(div);
21 22
22 div.nodes.addAll([ 23 div.nodes.addAll([
23 new DivElement(), 24 new DivElement(),
24 new CanvasElement(), 25 new CanvasElement(),
25 new DivElement(), 26 new DivElement(),
26 new Text('Hello'), 27 new Text('Hello'),
27 new DivElement(), 28 new DivElement(),
28 new Text('World'), 29 new Text('World'),
29 new CanvasElement()]); 30 new CanvasElement()
31 ]);
30 32
31 test('queryAll', () { 33 test('queryAll', () {
32 List<Node> all = queryAll('*'); 34 List<Node> all = queryAll('*');
33 for (var e in all) { 35 for (var e in all) {
34 expect(e, isElement); 36 expect(e, isElement);
35 } 37 }
36 }); 38 });
37 39
38 test('document.queryAll', () { 40 test('document.queryAll', () {
39 List<Element> all1 = queryAll('*'); 41 List<Element> all1 = queryAll('*');
40 List<Element> all2 = document.queryAll('*'); 42 List<Element> all2 = document.queryAll('*');
41 expect(all1.length, equals(all2.length)); 43 expect(all1.length, equals(all2.length));
42 for (var i = 0; i < all1.length; ++i) { 44 for (var i = 0; i < all1.length; ++i) {
43 expect(all1[i], equals(all2[i])); 45 expect(all1[i], equals(all2[i]));
44 } 46 }
45 }); 47 });
46 48
47 test('queryAll-canvas', () { 49 test('queryAll-canvas', () {
48 List<CanvasElement> all = queryAll('canvas'); 50 List<CanvasElement> all = queryAll('canvas');
49 for (var e in all) { 51 for (var e in all) {
50 expect(e, isCanvasElement); 52 expect(e, isCanvasElement);
51 } 53 }
52 expect(all.length, equals(2)); 54 expect(all.length, equals(2));
53 }); 55 });
54 56
55 test('queryAll-contains', () { 57 test('queryAll-contains', () {
56 List<Element> all = queryAll('*'); 58 List<Element> all = queryAll('*');
57 for (var e in all) { 59 for (var e in all) {
58 expect(all.contains(e), isTrue); 60 expect(all.contains(e), isTrue);
59 } 61 }
60 }); 62 });
61 63
62 test('queryAll-where', () { 64 test('queryAll-where', () {
63 List<Element> all = queryAll('*'); 65 List<Element> all = queryAll('*');
64 Iterable<CanvasElement> canvases = all.where((e) => e is CanvasElement); 66 Iterable<CanvasElement> canvases = all.where((e) => e is CanvasElement);
65 for (var e in canvases) { 67 for (var e in canvases) {
66 expect(e is CanvasElement, isTrue); 68 expect(e is CanvasElement, isTrue);
67 } 69 }
68 expect(canvases.length, equals(2)); 70 expect(canvases.length, equals(2));
69 }); 71 });
70 72
71 test('node.queryAll', () { 73 test('node.queryAll', () {
72 List<Element> list = div.queryAll('*'); 74 List<Element> list = div.queryAll('*');
73 expect(list.length, equals(5)); 75 expect(list.length, equals(5));
74 expect(list[0], isDivElement); 76 expect(list[0], isDivElement);
75 expect(list[1], isCanvasElement); 77 expect(list[1], isCanvasElement);
76 expect(list[2], isDivElement); 78 expect(list[2], isDivElement);
77 expect(list[3], isDivElement); 79 expect(list[3], isDivElement);
78 expect(list[4], isCanvasElement); 80 expect(list[4], isCanvasElement);
79 }); 81 });
80 82
81 test('immutable', () { 83 test('immutable', () {
82 List<Element> list = div.queryAll('*'); 84 List<Element> list = div.queryAll('*');
83 int len = list.length; 85 int len = list.length;
84 expect(() { list.add(new DivElement()); }, throwsUnsupportedError); 86 expect(() {
85 expect(list.length, equals(len)); 87 list.add(new DivElement());
86 }); 88 }, throwsUnsupportedError);
89 expect(list.length, equals(len));
90 });
87 } 91 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698