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