| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library SvgElementTest; | 5 library SvgElementTest; |
| 6 import 'dart:html'; | 6 import 'dart:html'; |
| 7 import 'dart:svg' as svg; | 7 import 'dart:svg' as svg; |
| 8 import 'package:expect/expect.dart'; | 8 import 'package:expect/expect.dart'; |
| 9 import 'package:unittest/html_individual_config.dart'; | 9 import 'package:unittest/html_individual_config.dart'; |
| 10 import 'package:unittest/unittest.dart'; | 10 import 'package:unittest/unittest.dart'; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 Element e = n; | 22 Element e = n; |
| 23 out.add(e.tagName); | 23 out.add(e.tagName); |
| 24 } else { | 24 } else { |
| 25 out.add(n.text); | 25 out.add(n.text); |
| 26 } | 26 } |
| 27 } | 27 } |
| 28 return out; | 28 return out; |
| 29 }; | 29 }; |
| 30 | 30 |
| 31 testConstructor(String tagName, Function isExpectedClass, | 31 testConstructor(String tagName, Function isExpectedClass, |
| 32 [bool expectation = true]) { | 32 [bool expectation = true, allowsInnerHtml = true]) { |
| 33 test(tagName, () { | 33 test(tagName, () { |
| 34 expect(isExpectedClass(new svg.SvgElement.tag(tagName)), expectation); | 34 expect(isExpectedClass(new svg.SvgElement.tag(tagName)), expectation); |
| 35 expect(isExpectedClass( | 35 if (allowsInnerHtml) { |
| 36 new svg.SvgElement.svg('<$tagName></$tagName>')), expectation); | 36 expect(isExpectedClass(new svg.SvgElement.svg('<$tagName></$tagName>')), |
| 37 allowsInnerHtml); |
| 38 } |
| 37 }); | 39 }); |
| 38 } | 40 } |
| 39 group('additionalConstructors', () { | 41 group('additionalConstructors', () { |
| 40 test('valid', () { | 42 test('valid', () { |
| 41 final svgContent = """ | 43 final svgContent = """ |
| 42 <svg version="1.1"> | 44 <svg version="1.1"> |
| 43 <circle></circle> | 45 <circle></circle> |
| 44 <path></path> | 46 <path></path> |
| 45 </svg>"""; | 47 </svg>"""; |
| 46 final el = new svg.SvgElement.svg(svgContent); | 48 final el = new svg.SvgElement.svg(svgContent); |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 }); | 238 }); |
| 237 }); | 239 }); |
| 238 | 240 |
| 239 group('supported_set', () { | 241 group('supported_set', () { |
| 240 test('supported', () { | 242 test('supported', () { |
| 241 expect(svg.SetElement.supported, true); | 243 expect(svg.SetElement.supported, true); |
| 242 }); | 244 }); |
| 243 }); | 245 }); |
| 244 | 246 |
| 245 group('constructors', () { | 247 group('constructors', () { |
| 246 group('supported', () { | |
| 247 testConstructor('a', (e) => e is svg.AElement); | 248 testConstructor('a', (e) => e is svg.AElement); |
| 248 testConstructor('circle', (e) => e is svg.CircleElement); | 249 testConstructor('circle', (e) => e is svg.CircleElement); |
| 249 testConstructor('clipPath', (e) => e is svg.ClipPathElement); | 250 testConstructor('clipPath', (e) => e is svg.ClipPathElement); |
| 250 testConstructor('defs', (e) => e is svg.DefsElement); | 251 testConstructor('defs', (e) => e is svg.DefsElement); |
| 251 testConstructor('desc', (e) => e is svg.DescElement); | 252 testConstructor('desc', (e) => e is svg.DescElement); |
| 252 testConstructor('ellipse', (e) => e is svg.EllipseElement); | 253 testConstructor('ellipse', (e) => e is svg.EllipseElement); |
| 253 testConstructor('g', (e) => e is svg.GElement); | 254 testConstructor('g', (e) => e is svg.GElement); |
| 254 testConstructor('image', (e) => e is svg.ImageElement); | 255 testConstructor('image', (e) => e is svg.ImageElement); |
| 255 testConstructor('line', (e) => e is svg.LineElement); | 256 testConstructor('line', (e) => e is svg.LineElement); |
| 256 testConstructor('linearGradient', (e) => e is svg.LinearGradientElement); | 257 testConstructor('linearGradient', (e) => e is svg.LinearGradientElement); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 268 testConstructor('stop', (e) => e is svg.StopElement); | 269 testConstructor('stop', (e) => e is svg.StopElement); |
| 269 testConstructor('style', (e) => e is svg.StyleElement); | 270 testConstructor('style', (e) => e is svg.StyleElement); |
| 270 testConstructor('switch', (e) => e is svg.SwitchElement); | 271 testConstructor('switch', (e) => e is svg.SwitchElement); |
| 271 testConstructor('symbol', (e) => e is svg.SymbolElement); | 272 testConstructor('symbol', (e) => e is svg.SymbolElement); |
| 272 testConstructor('tspan', (e) => e is svg.TSpanElement); | 273 testConstructor('tspan', (e) => e is svg.TSpanElement); |
| 273 testConstructor('text', (e) => e is svg.TextElement); | 274 testConstructor('text', (e) => e is svg.TextElement); |
| 274 testConstructor('textPath', (e) => e is svg.TextPathElement); | 275 testConstructor('textPath', (e) => e is svg.TextPathElement); |
| 275 testConstructor('title', (e) => e is svg.TitleElement); | 276 testConstructor('title', (e) => e is svg.TitleElement); |
| 276 testConstructor('use', (e) => e is svg.UseElement); | 277 testConstructor('use', (e) => e is svg.UseElement); |
| 277 testConstructor('view', (e) => e is svg.ViewElement); | 278 testConstructor('view', (e) => e is svg.ViewElement); |
| 279 // TODO(alanknight): Issue 23144 |
| 278 testConstructor('altGlyph', (e) => e is svg.AltGlyphElement, | 280 testConstructor('altGlyph', (e) => e is svg.AltGlyphElement, |
| 279 svg.AltGlyphElement.supported); | 281 svg.AltGlyphElement.supported, false); |
| 280 testConstructor('animate', (e) => e is svg.AnimateElement, | 282 testConstructor('animate', (e) => e is svg.AnimateElement, |
| 281 svg.AnimateElement.supported); | 283 svg.AnimateElement.supported); |
| 282 testConstructor('animateMotion', (e) => e is svg.AnimateMotionElement, | 284 testConstructor('animateMotion', (e) => e is svg.AnimateMotionElement, |
| 283 svg.AnimateMotionElement.supported); | 285 svg.AnimateMotionElement.supported); |
| 284 testConstructor('animateTransform', (e) => e is svg.AnimateTransformElemen
t, | 286 testConstructor('animateTransform', (e) => e is svg.AnimateTransformElemen
t, |
| 285 svg.AnimateTransformElement.supported); | 287 svg.AnimateTransformElement.supported); |
| 286 testConstructor('feBlend', (e) => e is svg.FEBlendElement, | 288 testConstructor('feBlend', (e) => e is svg.FEBlendElement, |
| 287 svg.FEBlendElement.supported); | 289 svg.FEBlendElement.supported); |
| 288 testConstructor('feColorMatrix', (e) => e is svg.FEColorMatrixElement, | 290 testConstructor('feColorMatrix', (e) => e is svg.FEColorMatrixElement, |
| 289 svg.FEColorMatrixElement.supported); | 291 svg.FEColorMatrixElement.supported); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 svg.FESpecularLightingElement.supported); | 330 svg.FESpecularLightingElement.supported); |
| 329 testConstructor('feSpotLight', (e) => e is svg.FESpotLightElement, | 331 testConstructor('feSpotLight', (e) => e is svg.FESpotLightElement, |
| 330 svg.FESpotLightElement.supported); | 332 svg.FESpotLightElement.supported); |
| 331 testConstructor('feTile', (e) => e is svg.FETileElement, | 333 testConstructor('feTile', (e) => e is svg.FETileElement, |
| 332 svg.FETileElement.supported); | 334 svg.FETileElement.supported); |
| 333 testConstructor('feTurbulence', (e) => e is svg.FETurbulenceElement, | 335 testConstructor('feTurbulence', (e) => e is svg.FETurbulenceElement, |
| 334 svg.FETurbulenceElement.supported); | 336 svg.FETurbulenceElement.supported); |
| 335 testConstructor('filter', (e) => e is svg.FilterElement, | 337 testConstructor('filter', (e) => e is svg.FilterElement, |
| 336 svg.FilterElement.supported); | 338 svg.FilterElement.supported); |
| 337 testConstructor('foreignObject', (e) => e is svg.ForeignObjectElement, | 339 testConstructor('foreignObject', (e) => e is svg.ForeignObjectElement, |
| 338 svg.ForeignObjectElement.supported); | 340 svg.ForeignObjectElement.supported, false); |
| 339 testConstructor('metadata', (e) => e is svg.MetadataElement); | 341 testConstructor('metadata', (e) => e is svg.MetadataElement); |
| 340 testConstructor('set', (e) => e is svg.SetElement, | 342 testConstructor('set', (e) => e is svg.SetElement, |
| 341 svg.SetElement.supported); | 343 svg.SetElement.supported); |
| 342 }); | |
| 343 }); | 344 }); |
| 344 | 345 |
| 345 group('outerHtml', () { | 346 group('outerHtml', () { |
| 346 test('outerHtml', () { | 347 test('outerHtml', () { |
| 347 final el = new svg.SvgSvgElement(); | 348 final el = new svg.SvgSvgElement(); |
| 348 el.children.add(new svg.CircleElement()); | 349 el.children.add(new svg.CircleElement()); |
| 349 el.children.add(new svg.PathElement()); | 350 el.children.add(new svg.PathElement()); |
| 350 expect([ | 351 expect([ |
| 351 '<svg version="1.1"><circle></circle><path></path></svg>', | 352 '<svg version="1.1"><circle></circle><path></path></svg>', |
| 352 '<svg xmlns="http://www.w3.org/2000/svg" version="1.1">' | 353 '<svg xmlns="http://www.w3.org/2000/svg" version="1.1">' |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 group('PathElement', () { | 446 group('PathElement', () { |
| 446 test('pathSegList', () { | 447 test('pathSegList', () { |
| 447 svg.PathElement path = | 448 svg.PathElement path = |
| 448 new svg.SvgElement.svg('<path d="M 100 100 L 300 100 L 200 300 z"/>'); | 449 new svg.SvgElement.svg('<path d="M 100 100 L 300 100 L 200 300 z"/>'); |
| 449 for (var seg in path.pathSegList) { | 450 for (var seg in path.pathSegList) { |
| 450 expect(seg is svg.PathSeg, isTrue); | 451 expect(seg is svg.PathSeg, isTrue); |
| 451 } | 452 } |
| 452 }); | 453 }); |
| 453 }); | 454 }); |
| 454 } | 455 } |
| OLD | NEW |