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

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

Issue 13704017: Make html lists print a nice toString method. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 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/element_test.dart ('k') | tools/dom/src/WrappedList.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 NodeTest; 5 library NodeTest;
6 import '../../pkg/unittest/lib/unittest.dart'; 6 import '../../pkg/unittest/lib/unittest.dart';
7 import '../../pkg/unittest/lib/html_individual_config.dart'; 7 import '../../pkg/unittest/lib/html_individual_config.dart';
8 import 'dart:html'; 8 import 'dart:html';
9 import 'dart:svg' as svg; 9 import 'dart:svg' as svg;
10 10
11 Node makeNode() => new Element.tag('div'); 11 Node makeNode() => new Element.tag('div');
12 Node makeNodeWithChildren() => 12 Node makeNodeWithChildren() =>
13 new Element.html("<div>Foo<br/><!--baz--></div>"); 13 new Element.html("<div>Foo<br/><!--baz--></div>");
14 14
15 main() { 15 main() {
16 useHtmlIndividualConfiguration(); 16 useHtmlIndividualConfiguration();
17 17
18 var isText = predicate((x) => x is Text, 'is a Text'); 18 var isText = predicate((x) => x is Text, 'is a Text');
19 var isComment = predicate((x) => x is Comment, 'is a Comment'); 19 var isComment = predicate((x) => x is Comment, 'is a Comment');
20 var isBRElement = predicate((x) => x is BRElement, 'is a BRElement'); 20 var isBRElement = predicate((x) => x is BRElement, 'is a BRElement');
21 var isHRElement = predicate((x) => x is HRElement, 'is a HRElement'); 21 var isHRElement = predicate((x) => x is HRElement, 'is a HRElement');
22 var isNodeList = predicate((x) => x is List<Node>, 'is a List<Node>'); 22 var isNodeList = predicate((x) => x is List<Node>, 'is a List<Node>');
23 var isImageElement = 23 var isImageElement =
24 predicate((x) => x is ImageElement, 'is an ImageElement'); 24 predicate((x) => x is ImageElement, 'is an ImageElement');
25 var isInputElement = 25 var isInputElement =
26 predicate((x) => x is InputElement, 'is an InputElement'); 26 predicate((x) => x is InputElement, 'is an InputElement');
27 27
28 group('functional', () { 28 group('functional', () {
29 test('toString', () {
30 final nodes = makeNodeWithChildren();
31 // TODO(efortuna): Update this test when you have actual toString methods
32 // for the items in the node List as well.
33 expect(nodes.nodes.toString(), "[Instance of 'Text', BR, "
34 "Instance of 'Comment']");
35 final node = makeNode();
36 expect(node.nodes.toString(), '[]');
37 });
38
29 test('replaceWith', () { 39 test('replaceWith', () {
30 final node = makeNodeWithChildren(); 40 final node = makeNodeWithChildren();
31 final subnode = node.nodes[1]; 41 final subnode = node.nodes[1];
32 final out = subnode.replaceWith(new Text('Bar')); 42 final out = subnode.replaceWith(new Text('Bar'));
33 expect(out, equals(subnode), reason: '#replaceWith should be chainable'); 43 expect(out, equals(subnode), reason: '#replaceWith should be chainable');
34 expect(node.nodes.length, 3); 44 expect(node.nodes.length, 3);
35 expect(node.nodes[0], isText); 45 expect(node.nodes[0], isText);
36 expect(node.nodes[0].text, 'Foo'); 46 expect(node.nodes[0].text, 'Foo');
37 expect(node.nodes[1], isText); 47 expect(node.nodes[1], isText);
38 expect(node.nodes[1].text, 'Bar'); 48 expect(node.nodes[1].text, 'Bar');
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 }); 280 });
271 281
272 test('sublist', () { 282 test('sublist', () {
273 var range = makeNodeList().sublist(1, 3); 283 var range = makeNodeList().sublist(1, 3);
274 expect(range, isNodeList); 284 expect(range, isNodeList);
275 expect(range[0], isBRElement); 285 expect(range[0], isBRElement);
276 expect(range[1], isComment); 286 expect(range[1], isComment);
277 }); 287 });
278 }); 288 });
279 } 289 }
OLDNEW
« no previous file with comments | « tests/html/element_test.dart ('k') | tools/dom/src/WrappedList.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698