Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(463)

Side by Side Diff: tests/html/svg_3_test.dart

Issue 12038036: SVG Library cleanups and adding supported tag. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 library SVG3Test;
2 import '../../pkg/unittest/lib/unittest.dart';
3 import '../../pkg/unittest/lib/html_config.dart';
4 import 'dart:html';
5 import 'dart:svg' as svg;
6
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'
9 // checks on the expected interfaces (that is in SVGTest2).
10
11 main() {
12
13 var isString = predicate((x) => x is String, 'is a 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');
16 var isSvgAnimatedBoolean =
17 predicate((x) => x is svg.AnimatedBoolean, 'is an svg.AnimatedBoolean');
18 var isSvgAnimatedString =
19 predicate((x) => x is svg.AnimatedString, 'is an svg.AnimatedString');
20 var isSvgRect = predicate((x) => x is svg.Rect, 'is a svg.Rect');
21 var isSvgAnimatedTransformList =
22 predicate((x) => x is svg.AnimatedTransformList,
23 'is an svg.AnimatedTransformList');
24 var isCssStyleDeclaration =
25 predicate((x) => x is CssStyleDeclaration, 'is a CssStyleDeclaration');
26 var isCssValue = predicate((x) => x is CssValue, 'is a CssValue');
27
28 insertTestDiv() {
29 var element = new Element.tag('div');
30 element.innerHtml = r'''
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>
33 </svg>
34 ''';
35 document.body.nodes.add(element);
36 return element;
37 }
38
39 useHtmlConfiguration();
40
41 /**
42 * Verifies that [e] supports the operations on the svg.Tests interface.
43 */
44 checkSvgTests(e) {
45 // Just check that the operations seem to exist.
46 var rx = e.requiredExtensions;
47 expect(rx, isStringList);
48 var rf = e.requiredFeatures;
49 expect(rf, isStringList);
50 var sl = e.systemLanguage;
51 expect(sl, isStringList);
52
53 bool hasDoDo = e.hasExtension("DoDo");
54 expect(hasDoDo, isFalse);
55 }
56
57 /**
58 * Verifies that [e] supports the operations on the svg.LangSpace interface.
59 */
60 checkSvgLangSpace(e) {
61 // Just check that the attribtes seem to exist.
62 var lang = e.xmllang;
63 e.xmllang = lang;
64
65 String space = e.xmlspace;
66 e.xmlspace = space;
67
68 expect(lang, isString);
69 expect(space, isString);
70 }
71
72 /**
73 * Verifies that [e] supports the operations on the
74 * svg.ExternalResourcesRequired interface.
75 */
76 checkSvgExternalResourcesRequired(e) {
77 var b = e.externalResourcesRequired;
78 expect(b, isSvgAnimatedBoolean);
79 expect(b.baseVal, isFalse);
80 expect(b.animVal, isFalse);
81 }
82
83 /**
84 * Verifies that [e] supports the operations on the svg.Stylable interface.
85 */
86 checkSvgStylable(e) {
87 var className = e.$dom_svgClassName;
88 expect(className, isSvgAnimatedString);
89
90 var s = e.style;
91 expect(s, isCssStyleDeclaration);
92
93 var attributeA = e.getPresentationAttribute('A');
94 expect(attributeA, anyOf(isNull, isCssValue));
95 }
96
97 /**
98 * Verifies that [e] supports the operations on the svg.Locatable interface.
99 */
100 checkSvgLocatable(e) {
101 var v1 = e.farthestViewportElement;
102 var v2 = e.nearestViewportElement;
103 expect(v1, same(v2));
104
105 var bbox = e.getBBox();
106 expect(bbox, isSvgRect);
107
108 var ctm = e.getCtm();
109 expect(ctm, isSvgMatrix);
110
111 var sctm = e.getScreenCtm();
112 expect(sctm, isSvgMatrix);
113
114 var xf2e = e.getTransformToElement(e);
115 expect(xf2e, isSvgMatrix);
116 }
117
118 /**
119 * Verifies that [e] supports the operations on the svg.Transformable
120 * interface.
121 */
122 checkSvgTransformable(e) {
123 var trans = e.transform;
124 expect(trans, isSvgAnimatedTransformList);
125 }
126
127 testRect(name, checker) {
128 test(name, () {
129 var div = insertTestDiv();
130 var r = document.query('#rect1');
131 checker(r);
132 div.remove();
133 });
134 }
135
136 testRect('rect_SvgTests', checkSvgTests);
137 testRect('rect_SvgLangSpace', checkSvgLangSpace);
138 testRect('rect_SvgExternalResourcesRequired',
139 checkSvgExternalResourcesRequired);
140 testRect('rect_SvgStylable', checkSvgStylable);
141 testRect('rect_SvgLocatable', checkSvgLocatable);
142 testRect('rect_SvgTransformable', checkSvgTransformable);
143
144 }
OLDNEW
« no previous file with comments | « tests/html/svg_2_test.dart ('k') | tests/html/svg_test.dart » ('j') | tests/html/svg_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698