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

Side by Side Diff: third_party/WebKit/LayoutTests/svg/dom/SVGGeometryElement-totalLength.html

Issue 2413753004: Move getTotalLength and getPointAtLength methods from SVGPathElement to SVGGeometryElement. (Closed)
Patch Set: nits Created 4 years, 2 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
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <title>SVGGeometryElement.totalLength method</title>
fs 2016/10/24 10:48:53 getTotalLength (here, below, and in the filename f
Shanmuga Pandi 2016/10/26 09:52:12 Done.
3 <script src="../../resources/testharness.js"></script>
4 <script src="../../resources/testharnessreport.js"></script>
5 <p></p>
6 <script>
7 test(function() {
8 var pathElement = document.createElementNS("http://www.w3.org/2000/svg", "path ");
fs 2016/10/24 10:48:52 So here we're testing an element not in the docume
Shanmuga Pandi 2016/10/26 09:52:12 Done.
9
10 function getTotalLength(string) {
11 pathElement.setAttributeNS(null, "d", string);
fs 2016/10/24 10:48:52 Could just use setAttribute.
Shanmuga Pandi 2016/10/26 09:52:12 Done.
12
13 var length = pathElement.getTotalLength();
14 return length;
fs 2016/10/24 10:48:53 return pathElement.getTotalLength(); ?
Shanmuga Pandi 2016/10/26 09:52:12 Done.
15 }
16
17 assert_equals(getTotalLength('M0,20 L400,20 L640,20'), 640);
18 assert_equals(getTotalLength('M0,20 L400,20 L640,20 z'), 1280);
19 assert_equals(getTotalLength('M0,20 L400,20 z M 320,20 L640,20'), 1120);
20 }, "SVGGeometryElement.totalLength with SVGPathElement");
21
22 test(function() {
23 var svgElement = document.createElementNS("http://www.w3.org/2000/svg", "svg") ;
fs 2016/10/24 10:48:52 Make this is something that could either be handle
Shanmuga Pandi 2016/10/26 09:52:12 Done.
24 var rectElement = document.createElementNS("http://www.w3.org/2000/svg", "rect ");
25 svgElement.appendChild(rectElement);
26 document.querySelector("p").appendChild(svgElement);
27
28 function getTotalLength(rx, ry, width, height) {
29 rectElement.setAttribute("rx", rx);
30 rectElement.setAttribute("ry", ry);
31 rectElement.setAttribute("width", width);
32 rectElement.setAttribute("height", height);
33
34 var length = rectElement.getTotalLength();
35 return length;
fs 2016/10/24 10:48:52 return rectElement.getTotalLength(); ?
Shanmuga Pandi 2016/10/26 09:52:12 Done.
36 }
37
38 assert_equals(getTotalLength('0', '0', '200', '300'), 1000);
fs 2016/10/24 10:48:52 Shouldn't need to explicitly "stringify" here, the
Shanmuga Pandi 2016/10/26 09:52:12 Done.
39 assert_approx_equals(getTotalLength('50', '50', '200', '300'), 913.65, 0.1);
40 }, "SVGGeometryElement.totalLength with SVGRectElement");
41
42 test(function() {
43 var svgElement = document.createElementNS("http://www.w3.org/2000/svg", "svg") ;
44 var circleElement = document.createElementNS("http://www.w3.org/2000/svg", "ci rcle");
45 svgElement.appendChild(circleElement);
46 document.querySelector("p").appendChild(svgElement);
47
48 circleElement.setAttribute("r", 10);
49 assert_approx_equals(circleElement.getTotalLength(), 62.42, 0.1);
50 circleElement.setAttribute("r", 20);
51 assert_approx_equals(circleElement.getTotalLength(), 124.85, 0.1);
52 }, "SVGGeometryElement.totalLength with SVGCircleElement");
53 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698