OLD | NEW |
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 "package:expect/expect.dart"; | |
7 import '../../pkg/unittest/lib/unittest.dart'; | |
8 import '../../pkg/unittest/lib/html_individual_config.dart'; | |
9 import 'dart:html'; | 6 import 'dart:html'; |
10 import 'dart:svg' as svg; | 7 import 'dart:svg' as svg; |
| 8 import 'package:expect/expect.dart'; |
| 9 import 'package:unittest/html_individual_config.dart'; |
| 10 import 'package:unittest/unittest.dart'; |
11 | 11 |
12 main() { | 12 main() { |
13 useHtmlIndividualConfiguration(); | 13 useHtmlIndividualConfiguration(); |
14 | 14 |
15 var isSvgSvgElement = | 15 var isSvgSvgElement = |
16 predicate((x) => x is svg.SvgSvgElement, 'is a SvgSvgElement'); | 16 predicate((x) => x is svg.SvgSvgElement, 'is a SvgSvgElement'); |
17 | 17 |
18 List<String> _nodeStrings(Iterable<Node> input) { | 18 List<String> _nodeStrings(Iterable<Node> input) { |
19 final out = new List<String>(); | 19 final out = new List<String>(); |
20 for (Node n in input) { | 20 for (Node n in input) { |
(...skipping 30 matching lines...) Expand all Loading... |
51 expect(el.outerHtml, anyOf(svgContent, | 51 expect(el.outerHtml, anyOf(svgContent, |
52 '<svg xmlns="http://www.w3.org/2000/svg" version="1.1">\n ' | 52 '<svg xmlns="http://www.w3.org/2000/svg" version="1.1">\n ' |
53 '<circle />\n <path />\n</svg>')); | 53 '<circle />\n <path />\n</svg>')); |
54 }); | 54 }); |
55 | 55 |
56 test('has no parent', () => | 56 test('has no parent', () => |
57 expect(new svg.SvgElement.svg('<circle/>').parent, isNull) | 57 expect(new svg.SvgElement.svg('<circle/>').parent, isNull) |
58 ); | 58 ); |
59 | 59 |
60 test('empty', () { | 60 test('empty', () { |
61 expect(() => new svg.SvgElement.svg(""), throwsArgumentError); | 61 expect(() => new svg.SvgElement.svg(""), throwsStateError); |
62 }); | 62 }); |
63 | 63 |
64 test('too many elements', () { | 64 test('too many elements', () { |
65 expect(() => new svg.SvgElement.svg("<circle></circle><path></path>"), | 65 expect(() => new svg.SvgElement.svg("<circle></circle><path></path>"), |
66 throwsArgumentError); | 66 throwsStateError); |
67 }); | 67 }); |
68 }); | 68 }); |
69 | 69 |
70 // Unfortunately, because the filtering mechanism in unitttest is a regex done | 70 // Unfortunately, because the filtering mechanism in unitttest is a regex done |
71 group('supported_altGlyph', () { | 71 group('supported_altGlyph', () { |
72 test('supported', () { | 72 test('supported', () { |
73 expect(svg.AltGlyphElement.supported, true); | 73 expect(svg.AltGlyphElement.supported, true); |
74 }); | 74 }); |
75 }); | 75 }); |
76 | 76 |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 testConstructor('line', (e) => e is svg.LineElement); | 255 testConstructor('line', (e) => e is svg.LineElement); |
256 testConstructor('linearGradient', (e) => e is svg.LinearGradientElement); | 256 testConstructor('linearGradient', (e) => e is svg.LinearGradientElement); |
257 testConstructor('marker', (e) => e is svg.MarkerElement); | 257 testConstructor('marker', (e) => e is svg.MarkerElement); |
258 testConstructor('mask', (e) => e is svg.MaskElement); | 258 testConstructor('mask', (e) => e is svg.MaskElement); |
259 testConstructor('path', (e) => e is svg.PathElement); | 259 testConstructor('path', (e) => e is svg.PathElement); |
260 testConstructor('pattern', (e) => e is svg.PatternElement); | 260 testConstructor('pattern', (e) => e is svg.PatternElement); |
261 testConstructor('polygon', (e) => e is svg.PolygonElement); | 261 testConstructor('polygon', (e) => e is svg.PolygonElement); |
262 testConstructor('polyline', (e) => e is svg.PolylineElement); | 262 testConstructor('polyline', (e) => e is svg.PolylineElement); |
263 testConstructor('radialGradient', (e) => e is svg.RadialGradientElement); | 263 testConstructor('radialGradient', (e) => e is svg.RadialGradientElement); |
264 testConstructor('rect', (e) => e is svg.RectElement); | 264 testConstructor('rect', (e) => e is svg.RectElement); |
265 testConstructor('script', (e) => e is svg.ScriptElement); | 265 test('script', () { |
| 266 expect(new svg.SvgElement.tag('script') is svg.ScriptElement, isTrue); |
| 267 }); |
266 testConstructor('stop', (e) => e is svg.StopElement); | 268 testConstructor('stop', (e) => e is svg.StopElement); |
267 testConstructor('style', (e) => e is svg.StyleElement); | 269 testConstructor('style', (e) => e is svg.StyleElement); |
268 testConstructor('switch', (e) => e is svg.SwitchElement); | 270 testConstructor('switch', (e) => e is svg.SwitchElement); |
269 testConstructor('symbol', (e) => e is svg.SymbolElement); | 271 testConstructor('symbol', (e) => e is svg.SymbolElement); |
270 testConstructor('tspan', (e) => e is svg.TSpanElement); | 272 testConstructor('tspan', (e) => e is svg.TSpanElement); |
271 testConstructor('text', (e) => e is svg.TextElement); | 273 testConstructor('text', (e) => e is svg.TextElement); |
272 testConstructor('textPath', (e) => e is svg.TextPathElement); | 274 testConstructor('textPath', (e) => e is svg.TextPathElement); |
273 testConstructor('title', (e) => e is svg.TitleElement); | 275 testConstructor('title', (e) => e is svg.TitleElement); |
274 testConstructor('use', (e) => e is svg.UseElement); | 276 testConstructor('use', (e) => e is svg.UseElement); |
275 testConstructor('view', (e) => e is svg.ViewElement); | 277 testConstructor('view', (e) => e is svg.ViewElement); |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
443 group('PathElement', () { | 445 group('PathElement', () { |
444 test('pathSegList', () { | 446 test('pathSegList', () { |
445 svg.PathElement path = | 447 svg.PathElement path = |
446 new svg.SvgElement.svg('<path d="M 100 100 L 300 100 L 200 300 z"/>'); | 448 new svg.SvgElement.svg('<path d="M 100 100 L 300 100 L 200 300 z"/>'); |
447 for (var seg in path.pathSegList) { | 449 for (var seg in path.pathSegList) { |
448 expect(seg is svg.PathSeg, isTrue); | 450 expect(seg is svg.PathSeg, isTrue); |
449 } | 451 } |
450 }); | 452 }); |
451 }); | 453 }); |
452 } | 454 } |
OLD | NEW |