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

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

Issue 11783009: Big merge from experimental to bleeding edge. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « tests/corelib/strings_test.dart ('k') | tests/html/element_classes_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
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 DocumentFragmentTest; 5 library DocumentFragmentTest;
6 import '../../pkg/unittest/lib/unittest.dart'; 6 import '../../pkg/unittest/lib/unittest.dart';
7 import '../../pkg/unittest/lib/html_config.dart'; 7 import '../../pkg/unittest/lib/html_config.dart';
8 import 'util.dart'; 8 import 'util.dart';
9 import 'dart:html'; 9 import 'dart:html';
10 10
11 main() { 11 main() {
12 useHtmlConfiguration(); 12 useHtmlConfiguration();
13 13
14 var isAnchorElement = 14 var isAnchorElement =
15 predicate((x) => x is AnchorElement, 'is an AnchorElement'); 15 predicate((x) => x is AnchorElement, 'is an AnchorElement');
16 16
17 Collection<String> _nodeStrings(Collection<Node> input) { 17 List<String> _nodeStrings(Iterable<Node> input) {
18 var out = new List<String>(); 18 var out = new List<String>();
19 for (Node n in input) { 19 for (Node n in input) {
20 if (n is Element) { 20 if (n is Element) {
21 Element e = n; 21 Element e = n;
22 out.add(e.tagName); 22 out.add(e.tagName);
23 } else { 23 } else {
24 out.add(n.text); 24 out.add(n.text);
25 } 25 }
26 } 26 }
27 return out; 27 return out;
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 159
160 expect(children.removeLast().tagName, "I"); 160 expect(children.removeLast().tagName, "I");
161 expect(_nodeStrings(fragment.nodes), 161 expect(_nodeStrings(fragment.nodes),
162 equals(["1", "A", "B", "2", "3"])); 162 equals(["1", "A", "B", "2", "3"]));
163 expect(_nodeStrings(children), equals(["A", "B"])); 163 expect(_nodeStrings(children), equals(["A", "B"]));
164 }); 164 });
165 165
166 test('accessors are wrapped', () { 166 test('accessors are wrapped', () {
167 init(); 167 init();
168 expect(children[0].tagName, "A"); 168 expect(children[0].tagName, "A");
169 expect(_nodeStrings(children.filter((e) => e.tagName == "I")), ["I"]); 169 expect(_nodeStrings(children.where((e) => e.tagName == "I")), ["I"]);
170 expect(children.every((e) => e is Element), isTrue); 170 expect(children.every((e) => e is Element), isTrue);
171 expect(children.some((e) => e.tagName == "U"), isTrue); 171 expect(children.any((e) => e.tagName == "U"), isTrue);
172 expect(children.isEmpty, isFalse); 172 expect(children.isEmpty, isFalse);
173 expect(children.length, 4); 173 expect(children.length, 4);
174 expect(children[2].tagName, "I"); 174 expect(children[2].tagName, "I");
175 expect(children.last.tagName, "U"); 175 expect(children.last.tagName, "U");
176 }); 176 });
177 177
178 test('setting children overwrites nodes as well', () { 178 test('setting children overwrites nodes as well', () {
179 init(); 179 init();
180 fragment.children = [new Element.tag("DIV"), new Element.tag("HEAD")]; 180 fragment.children = [new Element.tag("DIV"), new Element.tag("HEAD")];
181 expect(_nodeStrings(fragment.nodes), equals(["DIV", "HEAD"])); 181 expect(_nodeStrings(fragment.nodes), equals(["DIV", "HEAD"]));
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 // // assertConstError(() => fragment.classes.add('foo')); 344 // // assertConstError(() => fragment.classes.add('foo'));
345 // }); 345 // });
346 346
347 test('query searches the fragment', () { 347 test('query searches the fragment', () {
348 var fragment = new DocumentFragment.html( 348 var fragment = new DocumentFragment.html(
349 "<div class='foo'><a>foo</a><b>bar</b></div>"); 349 "<div class='foo'><a>foo</a><b>bar</b></div>");
350 expect(fragment.query(".foo a").tagName, "A"); 350 expect(fragment.query(".foo a").tagName, "A");
351 expect(_nodeStrings(fragment.queryAll(".foo *")), equals(["A", "B"])); 351 expect(_nodeStrings(fragment.queryAll(".foo *")), equals(["A", "B"]));
352 }); 352 });
353 } 353 }
OLDNEW
« no previous file with comments | « tests/corelib/strings_test.dart ('k') | tests/html/element_classes_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698