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

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

Issue 11413071: Deprecating Element.elements for Element.children. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Review feedback. 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
« no previous file with comments | « tests/html/svgelement_test.dart ('k') | tests/html/xmlelement_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) 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 XMLDocumentTest; 5 library XMLDocumentTest;
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() {
11 useHtmlConfiguration(); 11 useHtmlConfiguration();
12 12
13 var isXMLDocument = predicate((x) => x is XMLDocument, 'is an XMLDocument'); 13 var isXMLDocument = predicate((x) => x is XMLDocument, 'is an XMLDocument');
14 var isXMLElement = predicate((x) => x is XMLElement, 'is an XMLElement'); 14 var isXMLElement = predicate((x) => x is XMLElement, 'is an XMLElement');
15 15
16 XMLDocument makeDocument() => new XMLDocument.xml("<xml><foo/><bar/></xml>"); 16 XMLDocument makeDocument() => new XMLDocument.xml("<xml><foo/><bar/></xml>");
17 17
18 group('constructor', () { 18 group('constructor', () {
19 test('with a well-formed document', () { 19 test('with a well-formed document', () {
20 final doc = makeDocument(); 20 final doc = makeDocument();
21 expect(doc, isXMLDocument); 21 expect(doc, isXMLDocument);
22 expect(doc.elements[0].tagName, 'foo'); 22 expect(doc.children[0].tagName, 'foo');
23 expect(doc.elements[1].tagName, 'bar'); 23 expect(doc.children[1].tagName, 'bar');
24 }); 24 });
25 25
26 // TODO(nweiz): re-enable this when Document#query matches the root-level 26 // TODO(nweiz): re-enable this when Document#query matches the root-level
27 // element. Otherwise it fails on Firefox. 27 // element. Otherwise it fails on Firefox.
28 // 28 //
29 // test('with a parse error', () { 29 // test('with a parse error', () {
30 // expect(() => new XMLDocument.xml("<xml></xml>foo"), 30 // expect(() => new XMLDocument.xml("<xml></xml>foo"),
31 // throwsArgumentError); 31 // throwsArgumentError);
32 // }); 32 // });
33 33
34 test('with a PARSERERROR tag', () { 34 test('with a PARSERERROR tag', () {
35 final doc = new XMLDocument.xml("<xml><parsererror /></xml>"); 35 final doc = new XMLDocument.xml("<xml><parsererror /></xml>");
36 expect(doc.elements[0].tagName, 'parsererror'); 36 expect(doc.children[0].tagName, 'parsererror');
37 }); 37 });
38 }); 38 });
39 39
40 // FilteredElementList is tested more thoroughly in DocumentFragmentTests. 40 // FilteredElementList is tested more thoroughly in DocumentFragmentTests.
41 group('elements', () { 41 group('children', () {
42 test('filters out non-element nodes', () { 42 test('filters out non-element nodes', () {
43 final doc = new XMLDocument.xml("<xml>1<a/><b/>2<c/>3<d/></xml>"); 43 final doc = new XMLDocument.xml("<xml>1<a/><b/>2<c/>3<d/></xml>");
44 expect(doc.elements.map((e) => e.tagName), ["a", "b", "c", "d"]); 44 expect(doc.children.map((e) => e.tagName), ["a", "b", "c", "d"]);
45 }); 45 });
46 46
47 test('overwrites nodes when set', () { 47 test('overwrites nodes when set', () {
48 final doc = new XMLDocument.xml("<xml>1<a/><b/>2<c/>3<d/></xml>"); 48 final doc = new XMLDocument.xml("<xml>1<a/><b/>2<c/>3<d/></xml>");
49 doc.elements = [new XMLElement.tag('x'), new XMLElement.tag('y')]; 49 doc.children = [new XMLElement.tag('x'), new XMLElement.tag('y')];
50 expect(doc.outerHTML, "<xml><x></x><y></y></xml>"); 50 expect(doc.outerHTML, "<xml><x></x><y></y></xml>");
51 }); 51 });
52 }); 52 });
53 53
54 group('classes', () { 54 group('classes', () {
55 XMLDocument makeDocumentWithClasses() => 55 XMLDocument makeDocumentWithClasses() =>
56 new XMLDocument.xml("<xml class='foo bar baz'></xml>"); 56 new XMLDocument.xml("<xml class='foo bar baz'></xml>");
57 57
58 Set<String> makeClassSet() => makeDocumentWithClasses().classes; 58 Set<String> makeClassSet() => makeDocumentWithClasses().classes;
59 59
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 test('manifest', () => expect(makeDocument().manifest), ''); 611 test('manifest', () => expect(makeDocument().manifest), '');
612 }); 612 });
613 613
614 test('unsupported operations', () { 614 test('unsupported operations', () {
615 expectUnsupported(() { makeDocument().body = new XMLElement.tag('xml'); }); 615 expectUnsupported(() { makeDocument().body = new XMLElement.tag('xml'); });
616 expectUnsupported(() => makeDocument().cookie); 616 expectUnsupported(() => makeDocument().cookie);
617 expectUnsupported(() { makeDocument().cookie = 'foo'; }); 617 expectUnsupported(() { makeDocument().cookie = 'foo'; });
618 expectUnsupported(() { makeDocument().manifest = 'foo'; }); 618 expectUnsupported(() { makeDocument().manifest = 'foo'; });
619 }); 619 });
620 } 620 }
OLDNEW
« no previous file with comments | « tests/html/svgelement_test.dart ('k') | tests/html/xmlelement_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698