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

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

Issue 11275054: Modified unittest to use new argument syntax. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: 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) 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('SVGElementTest'); 5 #library('SVGElementTest');
6 #import('../../pkg/unittest/unittest.dart'); 6 #import('../../pkg/unittest/unittest.dart');
7 #import('../../pkg/unittest/html_config.dart'); 7 #import('../../pkg/unittest/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 isSVGSVGElement =
14 predicate((x) => x is SVGSVGElement, 'is a SVGSVGElement');
15
13 Collection<String> _nodeStrings(Collection<Node> input) { 16 Collection<String> _nodeStrings(Collection<Node> input) {
14 final out = new List<String>(); 17 final out = new List<String>();
15 for (Node n in input) { 18 for (Node n in input) {
16 if (n is Element) { 19 if (n is Element) {
17 Element e = n; 20 Element e = n;
18 out.add(e.tagName); 21 out.add(e.tagName);
19 } else { 22 } else {
20 out.add(n.text); 23 out.add(n.text);
21 } 24 }
22 } 25 }
23 return out; 26 return out;
24 }; 27 };
25 28
26 testConstructor(String tagName, Function isExpectedClass) { 29 testConstructor(String tagName, Function isExpectedClass) {
27 test(tagName, () { 30 test(tagName, () {
28 Expect.isTrue(isExpectedClass(new SVGElement.tag(tagName))); 31 expect(isExpectedClass(new SVGElement.tag(tagName)), isTrue);
29 Expect.isTrue(isExpectedClass( 32 expect(isExpectedClass(
30 new SVGElement.svg('<$tagName></$tagName>'))); 33 new SVGElement.svg('<$tagName></$tagName>')), isTrue);
31 }); 34 });
32 } 35 }
33 36
34 group('constructors', () { 37 group('constructors', () {
35 group('svg', () { 38 group('svg', () {
36 test('valid', () { 39 test('valid', () {
37 final svg = """ 40 final svg = """
38 <svg version="1.1"> 41 <svg version="1.1">
39 <circle></circle> 42 <circle></circle>
40 <path></path> 43 <path></path>
41 </svg>"""; 44 </svg>""";
42 final el = new SVGElement.svg(svg); 45 final el = new SVGElement.svg(svg);
43 Expect.isTrue(el is SVGSVGElement); 46 expect(el, isSVGSVGElement);
44 Expect.equals("<circle></circle><path></path>", el.innerHTML); 47 expect(el.innerHTML, "<circle></circle><path></path>");
45 Expect.equals(svg, el.outerHTML); 48 expect(el.outerHTML, svg);
46 }); 49 });
47 50
48 test('has no parent', () => 51 test('has no parent', () =>
49 Expect.isNull(new SVGElement.svg('<circle/>').parent)); 52 expect(new SVGElement.svg('<circle/>').parent, isNull)
53 );
50 54
51 test('empty', () { 55 test('empty', () {
52 Expect.throws(() => new SVGElement.svg(""), 56 expect(() => new SVGElement.svg(""), throwsArgumentError);
53 (e) => e is ArgumentError);
54 }); 57 });
55 58
56 test('too many elements', () { 59 test('too many elements', () {
57 Expect.throws( 60 expect(() => new SVGElement.svg("<circle></circle><path></path>"),
58 () => new SVGElement.svg("<circle></circle><path></path>"), 61 throwsArgumentError);
59 (e) => e is ArgumentError);
60 }); 62 });
61 }); 63 });
62 64
63 testConstructor('a', (e) => e is SVGAElement); 65 testConstructor('a', (e) => e is SVGAElement);
64 testConstructor('altGlyphDef', (e) => e is SVGAltGlyphDefElement); 66 testConstructor('altGlyphDef', (e) => e is SVGAltGlyphDefElement);
65 testConstructor('altGlyph', (e) => e is SVGAltGlyphElement); 67 testConstructor('altGlyph', (e) => e is SVGAltGlyphElement);
66 testConstructor('animateColor', (e) => e is SVGAnimateColorElement); 68 testConstructor('animateColor', (e) => e is SVGAnimateColorElement);
67 testConstructor('animate', (e) => e is SVGAnimateElement); 69 testConstructor('animate', (e) => e is SVGAnimateElement);
68 // WebKit doesn't recognize animateMotion 70 // WebKit doesn't recognize animateMotion
69 // testConstructor('animateMotion', (e) => e is SVGAnimateMotionElement); 71 // testConstructor('animateMotion', (e) => e is SVGAnimateMotionElement);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 testConstructor('title', (e) => e is SVGTitleElement); 144 testConstructor('title', (e) => e is SVGTitleElement);
143 testConstructor('use', (e) => e is SVGUseElement); 145 testConstructor('use', (e) => e is SVGUseElement);
144 testConstructor('vkern', (e) => e is SVGVKernElement); 146 testConstructor('vkern', (e) => e is SVGVKernElement);
145 testConstructor('view', (e) => e is SVGViewElement); 147 testConstructor('view', (e) => e is SVGViewElement);
146 }); 148 });
147 149
148 test('outerHTML', () { 150 test('outerHTML', () {
149 final el = new SVGSVGElement(); 151 final el = new SVGSVGElement();
150 el.elements.add(new SVGElement.tag("circle")); 152 el.elements.add(new SVGElement.tag("circle"));
151 el.elements.add(new SVGElement.tag("path")); 153 el.elements.add(new SVGElement.tag("path"));
152 Expect.equals('<svg version="1.1"><circle></circle><path></path></svg>', 154 expect(el.outerHTML,
153 el.outerHTML); 155 '<svg version="1.1"><circle></circle><path></path></svg>');
154 }); 156 });
155 157
156 group('innerHTML', () { 158 group('innerHTML', () {
157 test('get', () { 159 test('get', () {
158 final el = new SVGSVGElement(); 160 final el = new SVGSVGElement();
159 el.elements.add(new SVGElement.tag("circle")); 161 el.elements.add(new SVGElement.tag("circle"));
160 el.elements.add(new SVGElement.tag("path")); 162 el.elements.add(new SVGElement.tag("path"));
161 Expect.equals('<circle></circle><path></path>', el.innerHTML); 163 expect(el.innerHTML, '<circle></circle><path></path>');
162 }); 164 });
163 165
164 test('set', () { 166 test('set', () {
165 final el = new SVGSVGElement(); 167 final el = new SVGSVGElement();
166 el.elements.add(new SVGElement.tag("circle")); 168 el.elements.add(new SVGElement.tag("circle"));
167 el.elements.add(new SVGElement.tag("path")); 169 el.elements.add(new SVGElement.tag("path"));
168 el.innerHTML = '<rect></rect><a></a>'; 170 el.innerHTML = '<rect></rect><a></a>';
169 Expect.listEquals(["rect", "a"], _nodeStrings(el.elements)); 171 expect(_nodeStrings(el.elements), ["rect", "a"]);
170 }); 172 });
171 }); 173 });
172 174
173 group('elements', () { 175 group('elements', () {
174 test('get', () { 176 test('get', () {
175 final el = new SVGElement.svg(""" 177 final el = new SVGElement.svg("""
176 <svg version="1.1"> 178 <svg version="1.1">
177 <circle></circle> 179 <circle></circle>
178 <path></path> 180 <path></path>
179 text 181 text
180 </svg>"""); 182 </svg>""");
181 Expect.listEquals(["circle", "path"], _nodeStrings(el.elements)); 183 expect(_nodeStrings(el.elements), ["circle", "path"]);
182 }); 184 });
183 185
184 test('set', () { 186 test('set', () {
185 final el = new SVGSVGElement(); 187 final el = new SVGSVGElement();
186 el.elements = [new SVGElement.tag("circle"), new SVGElement.tag("path")]; 188 el.elements = [new SVGElement.tag("circle"), new SVGElement.tag("path")];
187 Expect.equals('<circle></circle><path></path>', el.innerHTML); 189 expect(el.innerHTML, '<circle></circle><path></path>');
188 }); 190 });
189 }); 191 });
190 } 192 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698