OLD | NEW |
| (Empty) |
1 #import('../../../../../dart/client/testing/unittest/unittest.dart'); | |
2 #import('dart:dom'); | |
3 | |
4 // Test that SVG elements have the operations advertised through all the IDL | |
5 // interfaces. This is a 'duck typing' test, and does not explicitly use 'is' | |
6 // checks on the expected interfaces (that is in SVGTest2). | |
7 | |
8 main() { | |
9 | |
10 insertTestDiv() { | |
11 var element = document.createElement('div'); | |
12 element.innerHTML = @''' | |
13 <svg id='svg1' width='200' height='100'> | |
14 <rect id='rect1' x='10' y='20' width='130' height='40' rx='5'fill='blue'></rect> | |
15 </svg> | |
16 '''; | |
17 document.body.appendChild(element); | |
18 return element; | |
19 } | |
20 | |
21 forLayoutTests(); | |
22 | |
23 /** | |
24 * Verifies that [e] supports the operations on the SVGTests interface. | |
25 */ | |
26 checkSVGTests(e) { | |
27 // Just check that the operations seem to exist. | |
28 var rx = e.requiredExtensions; | |
29 Expect.isTrue(rx is SVGStringList); | |
30 var rf = e.requiredFeatures; | |
31 Expect.isTrue(rf is SVGStringList); | |
32 var sl = e.systemLanguage; | |
33 Expect.isTrue(sl is SVGStringList); | |
34 | |
35 bool hasDoDo = e.hasExtension("DoDo"); | |
36 Expect.isFalse(hasDoDo); | |
37 } | |
38 | |
39 /** | |
40 * Verifies that [e] supports the operations on the SVGLangSpace interface. | |
41 */ | |
42 checkSVGLangSpace(e) { | |
43 // Just check that the attribtes seem to exist. | |
44 var lang = e.xmllang; | |
45 e.xmllang = lang; | |
46 | |
47 String space = e.xmlspace; | |
48 e.xmlspace = space; | |
49 | |
50 Expect.isTrue(lang is String); | |
51 Expect.isTrue(space is String); | |
52 } | |
53 | |
54 /** | |
55 * Verifies that [e] supports the operations on the | |
56 * SVGExternalResourcesRequired interface. | |
57 */ | |
58 checkSVGExternalResourcesRequired(e) { | |
59 var b = e.externalResourcesRequired; | |
60 Expect.isTrue(b is SVGAnimatedBoolean); | |
61 Expect.isFalse(b.baseVal); | |
62 Expect.isFalse(b.animVal); | |
63 } | |
64 | |
65 /** | |
66 * Verifies that [e] supports the operations on the SVGStylable interface. | |
67 */ | |
68 checkSVGStylable(e) { | |
69 var className = e.className; | |
70 Expect.isTrue(className is SVGAnimatedString); | |
71 | |
72 var s = e.style; | |
73 Expect.isTrue(s is CSSStyleDeclaration); | |
74 | |
75 var attributeA = e.getPresentationAttribute('A'); | |
76 Expect.isTrue(attributeA === null || attributeA is CSSValue); | |
77 } | |
78 | |
79 /** | |
80 * Verifies that [e] supports the operations on the SVGLocatable interface. | |
81 */ | |
82 checkSVGLocatable(e) { | |
83 var v1 = e.farthestViewportElement; | |
84 var v2 = e.nearestViewportElement; | |
85 Expect.isTrue(v1 === v2); | |
86 | |
87 var bbox = e.getBBox(); | |
88 Expect.isTrue(bbox is SVGRect); | |
89 | |
90 var ctm = e.getCTM(); | |
91 Expect.isTrue(ctm is SVGMatrix); | |
92 | |
93 var sctm = e.getScreenCTM(); | |
94 Expect.isTrue(sctm is SVGMatrix); | |
95 | |
96 var xf2e = e.getTransformToElement(e); | |
97 Expect.isTrue(xf2e is SVGMatrix); | |
98 } | |
99 | |
100 /** | |
101 * Verifies that [e] supports the operations on the SVGTransformable | |
102 * interface. | |
103 */ | |
104 checkSVGTransformable(e) { | |
105 var trans = e.transform; | |
106 Expect.isTrue(trans is SVGAnimatedTransformList); | |
107 } | |
108 | |
109 testRect(name, checker) { | |
110 test(name, () { | |
111 var div = insertTestDiv(); | |
112 var r = document.getElementById('rect1'); | |
113 checker(r); | |
114 document.body.removeChild(div); | |
115 }); | |
116 } | |
117 | |
118 testRect('rect_SVGTests', checkSVGTests); | |
119 testRect('rect_SVGLangSpace', checkSVGLangSpace); | |
120 testRect('rect_SVGExternalResourcesRequired', | |
121 checkSVGExternalResourcesRequired); | |
122 testRect('rect_SVGStylable', checkSVGStylable); | |
123 testRect('rect_SVGLocatable', checkSVGLocatable); | |
124 testRect('rect_SVGTransformable', checkSVGTransformable); | |
125 | |
126 } | |
OLD | NEW |