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