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

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

Issue 11414069: Make mappedBy lazy. (Closed) Base URL: https://dart.googlecode.com/svn/experimental/lib_v2/dart
Patch Set: Reupload due to error. Created 8 years, 1 month 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
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('elements', () { 57 group('elements', () {
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.elements.mappedBy((e) => e.tagName), ["a", "b", "c", "d"]); 60 expect(el.elements.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.elements = [new XMLElement.tag('x'), new XMLElement.tag('y')]; 66 el.elements = [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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
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('map', () {
118 expect(makeClassSet().mappedBy((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('filter', () {
123 expect(makeClassSet().where((c) => c.contains('a')), 124 expect(makeClassSet().where((c) => c.contains('a')),
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);
(...skipping 281 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').mappedBy((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

Powered by Google App Engine
This is Rietveld 408576698