OLD | NEW |
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 #import('../../pkg/unittest/unittest.dart'); | 6 #import('../../pkg/unittest/unittest.dart'); |
7 #import('../../pkg/unittest/html_config.dart'); | 7 #import('../../pkg/unittest/html_config.dart'); |
8 #import('dart:html'); | 8 #import('dart:html'); |
9 | 9 |
10 main() { | 10 main() { |
(...skipping 29 matching lines...) Expand all Loading... |
40 }); | 40 }); |
41 | 41 |
42 test('queryAll-canvas', () { | 42 test('queryAll-canvas', () { |
43 List<CanvasElement> all = queryAll('canvas'); | 43 List<CanvasElement> all = queryAll('canvas'); |
44 for (var e in all) { | 44 for (var e in all) { |
45 expect(e is CanvasElement, isTrue); | 45 expect(e is CanvasElement, isTrue); |
46 } | 46 } |
47 expect(all.length, equals(2)); | 47 expect(all.length, equals(2)); |
48 }); | 48 }); |
49 | 49 |
| 50 test('queryAll-contains', () { |
| 51 List<Element> all = queryAll('*'); |
| 52 for (var e in all) { |
| 53 expect(all.contains(e), isTrue); |
| 54 } |
| 55 }); |
| 56 |
50 test('queryAll-filter', () { | 57 test('queryAll-filter', () { |
51 List<Element> all = queryAll('*'); | 58 List<Element> all = queryAll('*'); |
52 List<CanvasElement> canvases = all.filter((e) => e is CanvasElement); | 59 List<CanvasElement> canvases = all.filter((e) => e is CanvasElement); |
53 for (var e in canvases) { | 60 for (var e in canvases) { |
54 expect(e is CanvasElement, isTrue); | 61 expect(e is CanvasElement, isTrue); |
55 } | 62 } |
56 expect(canvases.length, equals(2)); | 63 expect(canvases.length, equals(2)); |
57 }); | 64 }); |
58 | 65 |
59 test('node.queryAll', () { | 66 test('node.queryAll', () { |
60 List<Element> list = div.queryAll('*'); | 67 List<Element> list = div.queryAll('*'); |
61 expect(list.length, equals(5)); | 68 expect(list.length, equals(5)); |
62 expect(list[0] is DivElement, isTrue); | 69 expect(list[0] is DivElement, isTrue); |
63 expect(list[1] is CanvasElement, isTrue); | 70 expect(list[1] is CanvasElement, isTrue); |
64 expect(list[2] is DivElement, isTrue); | 71 expect(list[2] is DivElement, isTrue); |
65 expect(list[3] is DivElement, isTrue); | 72 expect(list[3] is DivElement, isTrue); |
66 expect(list[4] is CanvasElement, isTrue); | 73 expect(list[4] is CanvasElement, isTrue); |
67 }); | 74 }); |
68 | 75 |
69 test('immutable', () { | 76 test('immutable', () { |
70 List<Element> list = div.queryAll('*'); | 77 List<Element> list = div.queryAll('*'); |
71 int len = list.length; | 78 int len = list.length; |
72 expect(() { list.add(new DivElement()); }, throwsException); | 79 expect(() { list.add(new DivElement()); }, throwsException); |
73 expect(list.length, equals(len)); | 80 expect(list.length, equals(len)); |
74 }); | 81 }); |
75 } | 82 } |
OLD | NEW |