OLD | NEW |
1 #library('SVG1Test'); | 1 #library('SVG1Test'); |
2 #import('../../pkg/unittest/unittest.dart'); | 2 #import('../../pkg/unittest/unittest.dart'); |
3 #import('../../pkg/unittest/html_config.dart'); | 3 #import('../../pkg/unittest/html_config.dart'); |
4 #import('dart:html'); | 4 #import('dart:html'); |
5 | 5 |
6 // Test that SVG is present in dart:html API | 6 // Test that SVG is present in dart:html API |
7 | 7 |
8 main() { | 8 main() { |
9 useHtmlConfiguration(); | 9 useHtmlConfiguration(); |
10 | 10 |
| 11 var isSVGElement = predicate((x) => x is SVGElement, 'is a SVGElement'); |
| 12 |
11 test('simpleRect', () { | 13 test('simpleRect', () { |
12 var div = new Element.tag('div'); | 14 var div = new Element.tag('div'); |
13 document.body.nodes.add(div); | 15 document.body.nodes.add(div); |
14 div.innerHTML = r''' | 16 div.innerHTML = r''' |
15 <svg id='svg1' width='200' height='100'> | 17 <svg id='svg1' width='200' height='100'> |
16 <rect id='rect1' x='10' y='20' width='130' height='40' rx='5'fill='blue'></rect> | 18 <rect id='rect1' x='10' y='20' width='130' height='40' rx='5'fill='blue'></rect> |
17 </svg> | 19 </svg> |
18 | 20 |
19 '''; | 21 '''; |
20 | 22 |
21 var e = document.query('#svg1'); | 23 var e = document.query('#svg1'); |
22 Expect.isTrue(e != null); | 24 expect(e, isNotNull); |
23 | 25 |
24 SVGRectElement r = document.query('#rect1'); | 26 SVGRectElement r = document.query('#rect1'); |
25 Expect.equals(10, r.x.baseVal.value); | 27 expect(r.x.baseVal.value, 10); |
26 Expect.equals(20, r.y.baseVal.value); | 28 expect(r.y.baseVal.value, 20); |
27 Expect.equals(40, r.height.baseVal.value); | 29 expect(r.height.baseVal.value, 40); |
28 Expect.equals(130, r.width.baseVal.value); | 30 expect(r.width.baseVal.value, 130); |
29 Expect.equals(5, r.rx.baseVal.value); | 31 expect(r.rx.baseVal.value, 5); |
30 }); | 32 }); |
31 | 33 |
32 test('trailing newline', () { | 34 test('trailing newline', () { |
33 // Ensures that we handle SVG with trailing newlines. | 35 // Ensures that we handle SVG with trailing newlines. |
34 var logo = new SVGElement.svg(""" | 36 var logo = new SVGElement.svg(""" |
35 <svg xmlns="http://www.w3.org/2000/svg" version="1.1"> | 37 <svg xmlns="http://www.w3.org/2000/svg" version="1.1"> |
36 <path/> | 38 <path/> |
37 </svg> | 39 </svg> |
38 """); | 40 """); |
39 | 41 |
40 expect(logo is SVGElement, true); | 42 expect(logo, isSVGElement); |
41 | 43 |
42 }); | 44 }); |
43 } | 45 } |
OLD | NEW |