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; | |
6 import 'dart:html'; | 5 import 'dart:html'; |
7 import 'dart:svg' as svg; | 6 import 'dart:svg' as svg; |
8 import 'package:expect/expect.dart'; | 7 |
9 import 'package:unittest/html_individual_config.dart'; | 8 import 'package:expect/minitest.dart'; |
10 import 'package:unittest/unittest.dart'; | |
11 | 9 |
12 main() { | 10 main() { |
13 useHtmlIndividualConfiguration(); | |
14 | |
15 var isSvgSvgElement = | 11 var isSvgSvgElement = |
16 predicate((x) => x is svg.SvgSvgElement, 'is a SvgSvgElement'); | 12 predicate((x) => x is svg.SvgSvgElement, 'is a SvgSvgElement'); |
17 | 13 |
18 List<String> _nodeStrings(Iterable<Node> input) { | 14 List<String> _nodeStrings(Iterable<Node> input) { |
19 final out = new List<String>(); | 15 final out = new List<String>(); |
20 for (Node n in input) { | 16 for (Node n in input) { |
21 if (n is Element) { | 17 if (n is Element) { |
22 Element e = n; | 18 Element e = n; |
23 out.add(e.tagName); | 19 out.add(e.tagName); |
24 } else { | 20 } else { |
(...skipping 15 matching lines...) Expand all Loading... |
40 } | 36 } |
41 group('additionalConstructors', () { | 37 group('additionalConstructors', () { |
42 test('valid', () { | 38 test('valid', () { |
43 final svgContent = | 39 final svgContent = |
44 "<svg version=\"1.1\">\n" | 40 "<svg version=\"1.1\">\n" |
45 " <circle></circle>\n" | 41 " <circle></circle>\n" |
46 " <path></path>\n" | 42 " <path></path>\n" |
47 "</svg>"; | 43 "</svg>"; |
48 final el = new svg.SvgElement.svg(svgContent); | 44 final el = new svg.SvgElement.svg(svgContent); |
49 expect(el, isSvgSvgElement); | 45 expect(el, isSvgSvgElement); |
50 expect(el.innerHtml, anyOf("<circle></circle><path></path>", '<circle ' | 46 expect(el.innerHtml, anyOf(["<circle></circle><path></path>", '<circle ' |
51 'xmlns="http://www.w3.org/2000/svg" /><path ' | 47 'xmlns="http://www.w3.org/2000/svg" /><path ' |
52 'xmlns="http://www.w3.org/2000/svg" />')); | 48 'xmlns="http://www.w3.org/2000/svg" />'])); |
53 expect(el.outerHtml, anyOf(svgContent, | 49 expect(el.outerHtml, anyOf([svgContent, |
54 '<svg xmlns="http://www.w3.org/2000/svg" version="1.1">\n ' | 50 '<svg xmlns="http://www.w3.org/2000/svg" version="1.1">\n ' |
55 '<circle />\n <path />\n</svg>')); | 51 '<circle />\n <path />\n</svg>'])); |
56 }); | 52 }); |
57 | 53 |
58 test('has no parent', () => | 54 test('has no parent', () => |
59 expect(new svg.SvgElement.svg('<circle/>').parent, isNull) | 55 expect(new svg.SvgElement.svg('<circle/>').parent, isNull) |
60 ); | 56 ); |
61 | 57 |
62 test('empty', () { | 58 test('empty', () { |
63 expect(() => new svg.SvgElement.svg(""), throwsStateError); | 59 expect(() => new svg.SvgElement.svg(""), throwsStateError); |
64 }); | 60 }); |
65 | 61 |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 group('PathElement', () { | 461 group('PathElement', () { |
466 test('pathSegList', () { | 462 test('pathSegList', () { |
467 svg.PathElement path = | 463 svg.PathElement path = |
468 new svg.SvgElement.svg('<path d="M 100 100 L 300 100 L 200 300 z"/>'); | 464 new svg.SvgElement.svg('<path d="M 100 100 L 300 100 L 200 300 z"/>'); |
469 for (var seg in path.pathSegList) { | 465 for (var seg in path.pathSegList) { |
470 expect(seg is svg.PathSeg, isTrue); | 466 expect(seg is svg.PathSeg, isTrue); |
471 } | 467 } |
472 }); | 468 }); |
473 }); | 469 }); |
474 } | 470 } |
OLD | NEW |