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

Side by Side Diff: third_party/WebKit/LayoutTests/svg/dom/SVGAnimatedEnumeration-SVGMarkerElement.html

Issue 2447633002: Convert LayoutTests/svg/dom/SVGAnimatedEnumeration*.html js-tests.js to testharness.js based tests. (Closed)
Patch Set: Created 4 years, 1 month 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
OLDNEW
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> 1 <!DOCTYPE HTML>
2 <html> 2 <title>Use of SVGAnimatedEnumeration within SVGMarkerElement</title>
3 <head> 3 <script src="../../resources/testharness.js"></script>
4 <script src="../../resources/js-test.js"></script> 4 <script src="../../resources/testharnessreport.js"></script>
5 </head> 5 <script>
6 <body> 6 test(function() {
7 <p id="description"></p> 7 // This test checks the use of SVGAnimatedEnumeration within SVGMarkerElement.
8 <div id="console"></div> 8
9 <script src="script-tests/SVGAnimatedEnumeration-SVGMarkerElement.js"></script> 9 var markerElement = document.createElementNS("http://www.w3.org/2000/svg", "ma rker");
10 </body> 10 markerElement.setAttribute("markerUnits", "userSpaceOnUse");
11 </html> 11 markerElement.setAttribute("orient", "auto");
12
13 var svgElement = document.createElementNS("http://www.w3.org/2000/svg", "svg") ;
14
15 // markerUnits
16 // Check initial 'markerUnits' value.
17 assert_true(markerElement.markerUnits instanceof SVGAnimatedEnumeration);
18 assert_equals(typeof(markerElement.markerUnits.baseVal), "number");
19 assert_equals(markerElement.markerUnits.baseVal, SVGMarkerElement.SVG_MARKERUN ITS_USERSPACEONUSE);
20
21 // Switch to 'strokeWidth'.
22 markerElement.markerUnits.baseVal = SVGMarkerElement.SVG_MARKERUNITS_STROKEWID TH;
23 assert_equals(markerElement.markerUnits.baseVal, SVGMarkerElement.SVG_MARKERUN ITS_STROKEWIDTH);
24 assert_equals(markerElement.getAttribute('markerUnits'), "strokeWidth");
25
26 // Try setting invalid values.
27 assert_throws(new TypeError(), function() { markerElement.markerUnits.baseVal = 3; });
28 assert_equals(markerElement.markerUnits.baseVal, SVGMarkerElement.SVG_MARKERUN ITS_STROKEWIDTH);
29 assert_equals(markerElement.getAttribute('markerUnits'), "strokeWidth");
30
31 assert_throws(new TypeError(), function() { markerElement.markerUnits.baseVal = -1; });
32 assert_equals(markerElement.markerUnits.baseVal, SVGMarkerElement.SVG_MARKERUN ITS_STROKEWIDTH);
33 assert_equals(markerElement.getAttribute('markerUnits'), "strokeWidth");
34
35 assert_throws(new TypeError(), function() { markerElement.markerUnits.baseVal = 0; });
36 assert_equals(markerElement.markerUnits.baseVal, SVGMarkerElement.SVG_MARKERUN ITS_STROKEWIDTH);
37 assert_equals(markerElement.getAttribute('markerUnits'), "strokeWidth");
38
39 // Switch to 'userSpaceOnUse'
40 markerElement.markerUnits.baseVal = SVGMarkerElement.SVG_MARKERUNITS_USERSPACE ONUSE;
41 assert_equals(markerElement.markerUnits.baseVal, SVGMarkerElement.SVG_MARKERUN ITS_USERSPACEONUSE);
42 assert_equals(markerElement.getAttribute('markerUnits'), "userSpaceOnUse");
43
44 // orientType
45 // Check initial 'orient' value.
46 assert_true(markerElement.orientType instanceof SVGAnimatedEnumeration);
47 assert_equals(typeof(markerElement.orientType.baseVal), "number");
48 assert_equals(markerElement.orientAngle.baseVal.value, 0);
49 assert_equals(markerElement.orientAngle.baseVal.unitType, SVGAngle.SVG_ANGLETY PE_UNSPECIFIED);
50 assert_equals(markerElement.orientType.baseVal, SVGMarkerElement.SVG_MARKER_OR IENT_AUTO);
51
52 // Switch to 'Pi/2 rad' value - via setOrientToAngle().
53 anglePiHalfRad = svgElement.createSVGAngle();
54 anglePiHalfRad.newValueSpecifiedUnits(SVGAngle.SVG_ANGLETYPE_RAD, (Math.PI / 2 ).toFixed(2));
55 markerElement.setOrientToAngle(anglePiHalfRad);
56 assert_equals(markerElement.orientAngle.baseVal.value.toFixed(1), "90.0");
57 assert_equals(markerElement.orientAngle.baseVal.unitType, SVGAngle.SVG_ANGLETY PE_RAD);
58 assert_equals(markerElement.orientType.baseVal, SVGMarkerElement.SVG_MARKER_OR IENT_ANGLE);
59 assert_equals(markerElement.getAttribute('orient'), (Math.PI / 2).toFixed(2) + "rad");
60
61 // Switch to 'auto' value - via setOrientToAuto().
62 markerElement.setOrientToAuto();
63 assert_equals(markerElement.orientAngle.baseVal.value, 0);
64 assert_equals(markerElement.orientAngle.baseVal.unitType, SVGAngle.SVG_ANGLETY PE_UNSPECIFIED);
65 assert_equals(markerElement.orientType.baseVal, SVGMarkerElement.SVG_MARKER_OR IENT_AUTO);
66 assert_equals(markerElement.getAttribute('orient'), "auto");
67
68 // Switch to '20deg' value - via setOrientToAngle().
69 angle20deg = svgElement.createSVGAngle();
70 angle20deg.newValueSpecifiedUnits(SVGAngle.SVG_ANGLETYPE_DEG, 20);
71 markerElement.setOrientToAngle(angle20deg);
72 assert_equals(markerElement.orientAngle.baseVal.value, 20);
73 assert_equals(markerElement.orientAngle.baseVal.unitType, SVGAngle.SVG_ANGLETY PE_DEG);
74 assert_equals(markerElement.orientType.baseVal, SVGMarkerElement.SVG_MARKER_OR IENT_ANGLE);
75 assert_equals(markerElement.getAttribute('orient'), "20deg");
76
77 // Switch to '10deg' value.
78 markerElement.orientAngle.baseVal.value = 10;
79 assert_equals(markerElement.orientAngle.baseVal.value, 10);
80 assert_equals(markerElement.orientAngle.baseVal.unitType, SVGAngle.SVG_ANGLETY PE_DEG);
81 assert_equals(markerElement.orientType.baseVal, SVGMarkerElement.SVG_MARKER_OR IENT_ANGLE);
82 assert_equals(markerElement.getAttribute('orient'), "10deg");
83
84 // Switch to 'auto' value - by modifying orientType.
85 markerElement.orientType.baseVal = SVGMarkerElement.SVG_MARKER_ORIENT_AUTO;
86 assert_equals(markerElement.orientAngle.baseVal.value, 0);
87 assert_equals(markerElement.orientAngle.baseVal.unitType, SVGAngle.SVG_ANGLETY PE_UNSPECIFIED);
88 assert_equals(markerElement.orientType.baseVal, SVGMarkerElement.SVG_MARKER_OR IENT_AUTO);
89 assert_equals(markerElement.getAttribute('orient'), "auto");
90
91 markerElement.setAttribute('orient', '10deg');
92
93 // Try setting invalid values.
94 assert_throws(new TypeError(), function() { markerElement.orientType.baseVal = 3; });
95 assert_equals(markerElement.orientType.baseVal, SVGMarkerElement.SVG_MARKER_OR IENT_ANGLE);
96 assert_equals(markerElement.getAttribute('orient'), "10deg");
97
98 assert_throws(new TypeError(), function() { markerElement.orientType.baseVal = -1; });
99 assert_equals(markerElement.orientType.baseVal, SVGMarkerElement.SVG_MARKER_OR IENT_ANGLE);
100 assert_equals(markerElement.getAttribute('orient'), "10deg");
101
102 assert_throws(new TypeError(), function() { markerElement.orientType.baseVal = 0; });
103 assert_equals(markerElement.orientType.baseVal, SVGMarkerElement.SVG_MARKER_OR IENT_ANGLE);
104 assert_equals(markerElement.getAttribute('orient'), "10deg");
105
106 // Switch back to 'auto' value.
107 markerElement.orientType.baseVal = SVGMarkerElement.SVG_MARKER_ORIENT_AUTO;
108 assert_equals(markerElement.orientAngle.baseVal.value, 0);
109 assert_equals(markerElement.orientAngle.baseVal.unitType, SVGAngle.SVG_ANGLETY PE_UNSPECIFIED);
110 assert_equals(markerElement.orientType.baseVal, SVGMarkerElement.SVG_MARKER_OR IENT_AUTO);
111 assert_equals(markerElement.getAttribute('orient'), "auto");
112 });
113 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698