OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 QueryTest; | |
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 final div = new DivElement(); | 10 final div = new DivElement(); |
14 final canvas = new CanvasElement(width: 200, height: 200); | 11 final canvas = new CanvasElement(width: 200, height: 200); |
15 canvas.id = 'testcanvas'; | 12 canvas.id = 'testcanvas'; |
16 final element = | 13 final element = |
17 new Element.html("<div><br/><img/><input/><img/></div>"); | 14 new Element.html("<div><br/><img/><input/><img/></div>"); |
18 document.body.nodes.addAll([div, canvas, element]); | 15 document.body.nodes.addAll([div, canvas, element]); |
19 | 16 |
20 var isCanvasElement = | 17 var isCanvasElement = |
21 predicate((x) => x is CanvasElement, 'is a CanvasElement'); | 18 predicate((x) => x is CanvasElement, 'is a CanvasElement'); |
22 var isImageElement = | 19 var isImageElement = |
23 predicate((x) => x is ImageElement, 'is an ImageElement'); | 20 predicate((x) => x is ImageElement, 'is an ImageElement'); |
24 | 21 |
25 test('query', () { | 22 test('query', () { |
26 Element e = query('#testcanvas'); | 23 Element e = query('#testcanvas'); |
27 expect(e, isNotNull); | 24 expect(e, isNotNull); |
28 expect(e.id, 'testcanvas'); | 25 expect(e.id, 'testcanvas'); |
29 expect(e, isCanvasElement); | 26 expect(e, isCanvasElement); |
(...skipping 10 matching lines...) Expand all Loading... |
40 expect(l.length, 1); | 37 expect(l.length, 1); |
41 expect(l[0], canvas); | 38 expect(l[0], canvas); |
42 }); | 39 }); |
43 | 40 |
44 | 41 |
45 test('queryAll (Multiple)', () { | 42 test('queryAll (Multiple)', () { |
46 List l = queryAll('img'); | 43 List l = queryAll('img'); |
47 expect(l.length, 2); | 44 expect(l.length, 2); |
48 expect(l[0], isImageElement); | 45 expect(l[0], isImageElement); |
49 expect(l[1], isImageElement); | 46 expect(l[1], isImageElement); |
50 expect(l[0], isNot(equals(l[1]))); | 47 expect(l[0] == l[1], isFalse); |
51 }); | 48 }); |
52 | 49 |
53 test('queryAll (None)', () { | 50 test('queryAll (None)', () { |
54 List l = queryAll('video'); | 51 List l = queryAll('video'); |
55 expect(l.isEmpty, isTrue); | 52 expect(l.isEmpty, isTrue); |
56 }); | 53 }); |
57 } | 54 } |
OLD | NEW |