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

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

Issue 1930043002: Add all dart:html tests from the sdk to test/codegen. (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: ptal Created 4 years, 7 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
« no previous file with comments | « test/codegen/lib/html/query_test.dart ('k') | test/codegen/lib/html/range_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file
4
5 library NodeListTest;
6 import 'package:unittest/unittest.dart';
7 import 'package:unittest/html_config.dart';
8 import 'dart:html';
9
10 main() {
11 useHtmlConfiguration();
12
13 var isElement = predicate((x) => x is Element, 'is an Element');
14 var isCanvasElement =
15 predicate((x) => x is CanvasElement, 'is a CanvasElement');
16 var isDivElement = predicate((x) => x is DivElement, 'is a isDivElement');
17
18 var div = new DivElement();
19 div.id = 'test';
20 document.body.append(div);
21
22 div.nodes.addAll([
23 new DivElement(),
24 new CanvasElement(),
25 new DivElement(),
26 new Text('Hello'),
27 new DivElement(),
28 new Text('World'),
29 new CanvasElement()]);
30
31 test('queryAll', () {
32 List<Node> all = queryAll('*');
33 for (var e in all) {
34 expect(e, isElement);
35 }
36 });
37
38 test('document.queryAll', () {
39 List<Element> all1 = queryAll('*');
40 List<Element> all2 = document.queryAll('*');
41 expect(all1.length, equals(all2.length));
42 for (var i = 0; i < all1.length; ++i) {
43 expect(all1[i], equals(all2[i]));
44 }
45 });
46
47 test('queryAll-canvas', () {
48 List<CanvasElement> all = queryAll('canvas');
49 for (var e in all) {
50 expect(e, isCanvasElement);
51 }
52 expect(all.length, equals(2));
53 });
54
55 test('queryAll-contains', () {
56 List<Element> all = queryAll('*');
57 for (var e in all) {
58 expect(all.contains(e), isTrue);
59 }
60 });
61
62 test('queryAll-where', () {
63 List<Element> all = queryAll('*');
64 Iterable<CanvasElement> canvases = all.where((e) => e is CanvasElement);
65 for (var e in canvases) {
66 expect(e is CanvasElement, isTrue);
67 }
68 expect(canvases.length, equals(2));
69 });
70
71 test('node.queryAll', () {
72 List<Element> list = div.queryAll('*');
73 expect(list.length, equals(5));
74 expect(list[0], isDivElement);
75 expect(list[1], isCanvasElement);
76 expect(list[2], isDivElement);
77 expect(list[3], isDivElement);
78 expect(list[4], isCanvasElement);
79 });
80
81 test('immutable', () {
82 List<Element> list = div.queryAll('*');
83 int len = list.length;
84 expect(() { list.add(new DivElement()); }, throwsUnsupportedError);
85 expect(list.length, equals(len));
86 });
87 }
OLDNEW
« no previous file with comments | « test/codegen/lib/html/query_test.dart ('k') | test/codegen/lib/html/range_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698