| OLD | NEW |
| 1 library SVG3Test; | 1 library SVG3Test; |
| 2 import '../../pkg/unittest/lib/unittest.dart'; | 2 import '../../pkg/unittest/lib/unittest.dart'; |
| 3 import '../../pkg/unittest/lib/html_config.dart'; | 3 import '../../pkg/unittest/lib/html_config.dart'; |
| 4 import 'dart:html'; | 4 import 'dart:html'; |
| 5 import 'dart:svg' as svg; | 5 import 'dart:svg' as svg; |
| 6 | 6 |
| 7 // Test that SVG elements have the operations advertised through all the IDL | 7 // Test that SVG elements have the operations advertised through all the IDL |
| 8 // interfaces. This is a 'duck typing' test, and does not explicitly use 'is' | 8 // interfaces. This is a 'duck typing' test, and does not explicitly use 'is' |
| 9 // checks on the expected interfaces (that is in SVGTest2). | 9 // checks on the expected interfaces (that is in SVGTest2). |
| 10 | 10 |
| 11 main() { | 11 main() { |
| 12 | 12 |
| 13 var isString = predicate((x) => x is String, 'is a String'); | 13 var isString = predicate((x) => x is String, 'is a String'); |
| 14 var isStringList = predicate((x) => x is List<String>, 'is a List<String>'); | 14 var isStringList = predicate((x) => x is List<String>, 'is a List<String>'); |
| 15 var isSvgMatrix = predicate((x) => x is svg.Matrix, 'is a svg.Matrix'); | 15 var isSvgMatrix = predicate((x) => x is svg.Matrix, 'is a svg.Matrix'); |
| 16 var isSvgAnimatedBoolean = | 16 var isSvgAnimatedBoolean = |
| 17 predicate((x) => x is svg.AnimatedBoolean, 'is an svg.AnimatedBoolean'); | 17 predicate((x) => x is svg.AnimatedBoolean, 'is an svg.AnimatedBoolean'); |
| 18 var isSvgAnimatedString = | 18 var isSvgAnimatedString = |
| 19 predicate((x) => x is svg.AnimatedString, 'is an svg.AnimatedString'); | 19 predicate((x) => x is svg.AnimatedString, 'is an svg.AnimatedString'); |
| 20 var isSvgRect = predicate((x) => x is svg.Rect, 'is a svg.Rect'); | 20 var isSvgRect = predicate((x) => x is svg.Rect, 'is a svg.Rect'); |
| 21 var isSvgAnimatedTransformList = | 21 var isSvgAnimatedTransformList = |
| 22 predicate((x) => x is svg.AnimatedTransformList, | 22 predicate((x) => x is svg.AnimatedTransformList, |
| 23 'is an svg.AnimatedTransformList'); | 23 'is an svg.AnimatedTransformList'); |
| 24 var isCSSStyleDeclaration = | 24 var isCssStyleDeclaration = |
| 25 predicate((x) => x is CSSStyleDeclaration, 'is a CSSStyleDeclaration'); | 25 predicate((x) => x is CssStyleDeclaration, 'is a CssStyleDeclaration'); |
| 26 var isCSSValue = predicate((x) => x is CSSValue, 'is a CSSValue'); | 26 var isCssValue = predicate((x) => x is CssValue, 'is a CssValue'); |
| 27 | 27 |
| 28 insertTestDiv() { | 28 insertTestDiv() { |
| 29 var element = new Element.tag('div'); | 29 var element = new Element.tag('div'); |
| 30 element.innerHtml = r''' | 30 element.innerHtml = r''' |
| 31 <svg id='svg1' width='200' height='100'> | 31 <svg id='svg1' width='200' height='100'> |
| 32 <rect id='rect1' x='10' y='20' width='130' height='40' rx='5'fill='blue'></rect> | 32 <rect id='rect1' x='10' y='20' width='130' height='40' rx='5'fill='blue'></rect> |
| 33 </svg> | 33 </svg> |
| 34 '''; | 34 '''; |
| 35 document.body.nodes.add(element); | 35 document.body.nodes.add(element); |
| 36 return element; | 36 return element; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 } | 81 } |
| 82 | 82 |
| 83 /** | 83 /** |
| 84 * Verifies that [e] supports the operations on the svg.Stylable interface. | 84 * Verifies that [e] supports the operations on the svg.Stylable interface. |
| 85 */ | 85 */ |
| 86 checkSvgStylable(e) { | 86 checkSvgStylable(e) { |
| 87 var className = e.$dom_svgClassName; | 87 var className = e.$dom_svgClassName; |
| 88 expect(className, isSvgAnimatedString); | 88 expect(className, isSvgAnimatedString); |
| 89 | 89 |
| 90 var s = e.style; | 90 var s = e.style; |
| 91 expect(s, isCSSStyleDeclaration); | 91 expect(s, isCssStyleDeclaration); |
| 92 | 92 |
| 93 var attributeA = e.getPresentationAttribute('A'); | 93 var attributeA = e.getPresentationAttribute('A'); |
| 94 expect(attributeA, anyOf(isNull, isCSSValue)); | 94 expect(attributeA, anyOf(isNull, isCssValue)); |
| 95 } | 95 } |
| 96 | 96 |
| 97 /** | 97 /** |
| 98 * Verifies that [e] supports the operations on the svg.Locatable interface. | 98 * Verifies that [e] supports the operations on the svg.Locatable interface. |
| 99 */ | 99 */ |
| 100 checkSvgLocatable(e) { | 100 checkSvgLocatable(e) { |
| 101 var v1 = e.farthestViewportElement; | 101 var v1 = e.farthestViewportElement; |
| 102 var v2 = e.nearestViewportElement; | 102 var v2 = e.nearestViewportElement; |
| 103 expect(v1, same(v2)); | 103 expect(v1, same(v2)); |
| 104 | 104 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 135 | 135 |
| 136 testRect('rect_SvgTests', checkSvgTests); | 136 testRect('rect_SvgTests', checkSvgTests); |
| 137 testRect('rect_SvgLangSpace', checkSvgLangSpace); | 137 testRect('rect_SvgLangSpace', checkSvgLangSpace); |
| 138 testRect('rect_SvgExternalResourcesRequired', | 138 testRect('rect_SvgExternalResourcesRequired', |
| 139 checkSvgExternalResourcesRequired); | 139 checkSvgExternalResourcesRequired); |
| 140 testRect('rect_SvgStylable', checkSvgStylable); | 140 testRect('rect_SvgStylable', checkSvgStylable); |
| 141 testRect('rect_SvgLocatable', checkSvgLocatable); | 141 testRect('rect_SvgLocatable', checkSvgLocatable); |
| 142 testRect('rect_SvgTransformable', checkSvgTransformable); | 142 testRect('rect_SvgTransformable', checkSvgTransformable); |
| 143 | 143 |
| 144 } | 144 } |
| OLD | NEW |