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

Side by Side Diff: pkg/dev_compiler/test/codegen/lib/html/queryall_test.dart

Issue 2419863002: Remove uses of unittest in the HTML tests where possible. (Closed)
Patch Set: Remove TODO. Created 4 years, 2 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;
6 import 'package:unittest/unittest.dart';
7 import 'package:unittest/html_config.dart';
8 import 'dart:html'; 5 import 'dart:html';
9 6
7 import 'package:expect/minitest.dart';
8
10 main() { 9 main() {
11 useHtmlConfiguration();
12
13 var isElement = predicate((x) => x is Element, 'is an Element'); 10 var isElement = predicate((x) => x is Element, 'is an Element');
14 var isCanvasElement = 11 var isCanvasElement =
15 predicate((x) => x is CanvasElement, 'is a CanvasElement'); 12 predicate((x) => x is CanvasElement, 'is a CanvasElement');
16 var isDivElement = predicate((x) => x is DivElement, 'is a isDivElement'); 13 var isDivElement = predicate((x) => x is DivElement, 'is a isDivElement');
17 14
18 var div = new DivElement(); 15 var div = new DivElement();
19 div.id = 'test'; 16 div.id = 'test';
20 document.body.append(div); 17 document.body.append(div);
21 18
22 div.nodes.addAll([ 19 div.nodes.addAll([
(...skipping 15 matching lines...) Expand all
38 test('document.queryAll', () { 35 test('document.queryAll', () {
39 List<Element> all1 = queryAll('*'); 36 List<Element> all1 = queryAll('*');
40 List<Element> all2 = document.queryAll('*'); 37 List<Element> all2 = document.queryAll('*');
41 expect(all1.length, equals(all2.length)); 38 expect(all1.length, equals(all2.length));
42 for (var i = 0; i < all1.length; ++i) { 39 for (var i = 0; i < all1.length; ++i) {
43 expect(all1[i], equals(all2[i])); 40 expect(all1[i], equals(all2[i]));
44 } 41 }
45 }); 42 });
46 43
47 test('queryAll-canvas', () { 44 test('queryAll-canvas', () {
48 List<CanvasElement> all = queryAll('canvas'); 45 var all = queryAll('canvas');
49 for (var e in all) { 46 for (var e in all) {
50 expect(e, isCanvasElement); 47 expect(e, isCanvasElement);
51 } 48 }
52 expect(all.length, equals(2)); 49 expect(all.length, equals(2));
53 }); 50 });
54 51
55 test('queryAll-contains', () { 52 test('queryAll-contains', () {
56 List<Element> all = queryAll('*'); 53 List<Element> all = queryAll('*');
57 for (var e in all) { 54 for (var e in all) {
58 expect(all.contains(e), isTrue); 55 expect(all.contains(e), isTrue);
59 } 56 }
60 }); 57 });
61 58
62 test('queryAll-where', () { 59 test('queryAll-where', () {
63 List<Element> all = queryAll('*'); 60 List<Element> all = queryAll('*');
64 Iterable<CanvasElement> canvases = all.where((e) => e is CanvasElement); 61 var canvases = all.where((e) => e is CanvasElement);
65 for (var e in canvases) { 62 for (var e in canvases) {
66 expect(e is CanvasElement, isTrue); 63 expect(e is CanvasElement, isTrue);
67 } 64 }
68 expect(canvases.length, equals(2)); 65 expect(canvases.length, equals(2));
69 }); 66 });
70 67
71 test('node.queryAll', () { 68 test('node.queryAll', () {
72 List<Element> list = div.queryAll('*'); 69 List<Element> list = div.queryAll('*');
73 expect(list.length, equals(5)); 70 expect(list.length, equals(5));
74 expect(list[0], isDivElement); 71 expect(list[0], isDivElement);
75 expect(list[1], isCanvasElement); 72 expect(list[1], isCanvasElement);
76 expect(list[2], isDivElement); 73 expect(list[2], isDivElement);
77 expect(list[3], isDivElement); 74 expect(list[3], isDivElement);
78 expect(list[4], isCanvasElement); 75 expect(list[4], isCanvasElement);
79 }); 76 });
80 77
81 test('immutable', () { 78 test('immutable', () {
82 List<Element> list = div.queryAll('*'); 79 List<Element> list = div.queryAll('*');
83 int len = list.length; 80 int len = list.length;
84 expect(() { list.add(new DivElement()); }, throwsUnsupportedError); 81 expect(() { list.add(new DivElement()); }, throwsUnsupportedError);
85 expect(list.length, equals(len)); 82 expect(list.length, equals(len));
86 }); 83 });
87 } 84 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698