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

Side by Side Diff: tests/html/xmlelement_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/html/xmldocument_test.dart ('k') | tests/isolate/isolate.status » ('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) 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 XMLElementTest; 5 library XMLElementTest;
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 'dart:html'; 8 import 'dart:html';
9 9
10 main() { 10 main() {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 final el = new XMLElement.tag('foo'); 50 final el = new XMLElement.tag('foo');
51 expect(el, isXMLElement); 51 expect(el, isXMLElement);
52 expect(el.tagName, 'foo'); 52 expect(el.tagName, 'foo');
53 }); 53 });
54 }); 54 });
55 55
56 // FilteredElementList is tested more thoroughly in DocumentFragmentTests. 56 // FilteredElementList is tested more thoroughly in DocumentFragmentTests.
57 group('children', () { 57 group('children', () {
58 test('filters out non-element nodes', () { 58 test('filters out non-element nodes', () {
59 final el = new XMLElement.xml("<xml>1<a/><b/>2<c/>3<d/></xml>"); 59 final el = new XMLElement.xml("<xml>1<a/><b/>2<c/>3<d/></xml>");
60 expect(el.children.map((e) => e.tagName), ["a", "b", "c", "d"]); 60 expect(el.children.mappedBy((e) => e.tagName).toList(),
61 ["a", "b", "c", "d"]);
61 }); 62 });
62 63
63 test('overwrites nodes when set', () { 64 test('overwrites nodes when set', () {
64 final el = new XMLElement.xml("<xml>1<a/><b/>2<c/>3<d/></xml>"); 65 final el = new XMLElement.xml("<xml>1<a/><b/>2<c/>3<d/></xml>");
65 el.children = [new XMLElement.tag('x'), new XMLElement.tag('y')]; 66 el.children = [new XMLElement.tag('x'), new XMLElement.tag('y')];
66 expect(el.outerHtml, "<xml><x></x><y></y></xml>"); 67 expect(el.outerHtml, "<xml><x></x><y></y></xml>");
67 }); 68 });
68 }); 69 });
69 70
70 group('classes', () { 71 group('classes', () {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 }); 108 });
108 109
109 test('iterator', () { 110 test('iterator', () {
110 final classes = <String>[]; 111 final classes = <String>[];
111 for (var el in makeClassSet()) { 112 for (var el in makeClassSet()) {
112 classes.add(el); 113 classes.add(el);
113 } 114 }
114 expect(classes, unorderedEquals(['foo', 'bar', 'baz'])); 115 expect(classes, unorderedEquals(['foo', 'bar', 'baz']));
115 }); 116 });
116 117
117 test('map', () { 118 test('mappedBy', () {
118 expect(makeClassSet().map((c) => c.toUpperCase()), 119 expect(makeClassSet().mappedBy((c) => c.toUpperCase()).toList(),
119 unorderedEquals(['FOO', 'BAR', 'BAZ'])); 120 unorderedEquals(['FOO', 'BAR', 'BAZ']));
120 }); 121 });
121 122
122 test('filter', () { 123 test('where', () {
123 expect(makeClassSet().filter((c) => c.contains('a')), 124 expect(makeClassSet().where((c) => c.contains('a')).toSet(),
124 unorderedEquals(['bar', 'baz'])); 125 unorderedEquals(['bar', 'baz']));
125 }); 126 });
126 127
127 test('every', () { 128 test('every', () {
128 expect(makeClassSet().every((c) => c is String), isTrue); 129 expect(makeClassSet().every((c) => c is String), isTrue);
129 expect(makeClassSet().every((c) => c.contains('a')), isFalse); 130 expect(makeClassSet().every((c) => c.contains('a')), isFalse);
130 }); 131 });
131 132
132 test('some', () { 133 test('any', () {
133 expect(makeClassSet().some((c) => c.contains('a')), isTrue); 134 expect(makeClassSet().any((c) => c.contains('a')), isTrue);
134 expect(makeClassSet().some((c) => c is num), isFalse); 135 expect(makeClassSet().any((c) => c is num), isFalse);
135 }); 136 });
136 137
137 test('isEmpty', () { 138 test('isEmpty', () {
138 expect(makeClassSet().isEmpty, isFalse); 139 expect(makeClassSet().isEmpty, isFalse);
139 expect(makeElement().classes.isEmpty, isTrue); 140 expect(makeElement().classes.isEmpty, isTrue);
140 }); 141 });
141 142
142 test('length', () { 143 test('length', () {
143 expect(makeClassSet().length, 3); 144 expect(makeClassSet().length, 3);
144 expect(makeElement().classes.length, 0); 145 expect(makeElement().classes.length, 0);
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 411
411 test('query', () { 412 test('query', () {
412 final el = makeElement(); 413 final el = makeElement();
413 expect(el.query('foo').tagName, 'foo'); 414 expect(el.query('foo').tagName, 'foo');
414 expect(el.query('baz'), isNull); 415 expect(el.query('baz'), isNull);
415 }); 416 });
416 417
417 test('queryAll', () { 418 test('queryAll', () {
418 final el = new XMLElement.xml( 419 final el = new XMLElement.xml(
419 "<xml><foo id='f1' /><bar><foo id='f2' /></bar></xml>"); 420 "<xml><foo id='f1' /><bar><foo id='f2' /></bar></xml>");
420 expect(el.queryAll('foo').map((e) => e.id), ['f1', 'f2']); 421 expect(el.queryAll('foo').mappedBy((e) => e.id).toList(), ['f1', 'f2']);
421 expect(el.queryAll('baz'), []); 422 expect(el.queryAll('baz'), []);
422 }); 423 });
423 424
424 // TODO(nweiz): re-enable this when matchesSelector works cross-browser. 425 // TODO(nweiz): re-enable this when matchesSelector works cross-browser.
425 // 426 //
426 // test('matchesSelector', () { 427 // test('matchesSelector', () {
427 // final el = makeElement(); 428 // final el = makeElement();
428 // expect(el.matchesSelector('*'), isTrue); 429 // expect(el.matchesSelector('*'), isTrue);
429 // expect(el.matchesSelector('xml'), isTrue); 430 // expect(el.matchesSelector('xml'), isTrue);
430 // expect(el.matchesSelector('html'), isFalse); 431 // expect(el.matchesSelector('html'), isFalse);
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 makeElement().rect.then( 573 makeElement().rect.then(
573 expectAsync1(ElementRect rect) { 574 expectAsync1(ElementRect rect) {
574 expectEmptyRect(rect.client); 575 expectEmptyRect(rect.client);
575 expectEmptyRect(rect.offset); 576 expectEmptyRect(rect.offset);
576 expectEmptyRect(rect.scroll); 577 expectEmptyRect(rect.scroll);
577 expectEmptyRect(rect.bounding); 578 expectEmptyRect(rect.bounding);
578 expect(rect.clientRects.isEmpty, isTrue); 579 expect(rect.clientRects.isEmpty, isTrue);
579 })); 580 }));
580 }); 581 });
581 } 582 }
OLDNEW
« no previous file with comments | « tests/html/xmldocument_test.dart ('k') | tests/isolate/isolate.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698