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

Unified Diff: third_party/WebKit/LayoutTests/svg/dom/SVGGeometryElement-pointAtLength.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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/svg/dom/SVGGeometryElement-pointAtLength.html
diff --git a/third_party/WebKit/LayoutTests/svg/dom/SVGGeometryElement-pointAtLength.html b/third_party/WebKit/LayoutTests/svg/dom/SVGGeometryElement-pointAtLength.html
new file mode 100644
index 0000000000000000000000000000000000000000..5e72125557cc9aaf3353e4212e5097d3297a3e70
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/svg/dom/SVGGeometryElement-pointAtLength.html
@@ -0,0 +1,59 @@
+<!DOCTYPE html>
+<title>SVGGeometryElement.getPointAtLength method</title>
fs 2016/10/24 10:48:52 Maybe name the file ...-getPointAtLength too for c
Shanmuga Pandi 2016/10/26 09:52:12 Done.
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<p></p>
+<script>
+test(function() {
+ var pathElement = document.createElementNS("http://www.w3.org/2000/svg", "path");
fs 2016/10/24 10:48:52 Please apply the (relevant) feedback on the getTot
+
+ function pointAtLength(string) {
+ pathElement.setAttributeNS(null, "d", string);
+
+ var point = pathElement.getPointAtLength(700);
+ return "(" + Math.round(point.x) + ", " + Math.round(point.y) + ")";
fs 2016/10/24 10:48:52 Maybe return an array instead and use assert_array
+ }
+
+ assert_equals(pointAtLength('M0,20 L400,20 L640,20'), "(640, 20)");
+ assert_equals(pointAtLength('M0,20 L400,20 L640,20 z'), "(580, 20)");
+ assert_equals(pointAtLength('M0,20 L400,20 z M 320,20 L640,20'), "(100, 20)");
+ assert_equals(pointAtLength('M0,20 L20,40'), "(20, 40)");
+}, "SVGGeometryElement.getPointAtLength with SVGPathElement");
+
+test(function() {
+ var svgElement = document.createElementNS("http://www.w3.org/2000/svg", "svg");
+ var rectElement = document.createElementNS("http://www.w3.org/2000/svg", "rect");
+ svgElement.appendChild(rectElement);
+ document.querySelector("p").appendChild(svgElement);
+
+ function pointAtLength(rx, ry, width, height) {
+ rectElement.setAttribute("rx", rx);
+ rectElement.setAttribute("ry", ry);
+ rectElement.setAttribute("width", width);
+ rectElement.setAttribute("height", height);
+
+ var point = rectElement.getPointAtLength(300);
+ return "(" + Math.round(point.x) + ", " + Math.round(point.y) + ")";
+ }
+
+ assert_equals(pointAtLength('0', '0', '200', '300'), "(200, 100)");
+ assert_equals(pointAtLength('50', '50', '200', '300'), "(200, 172)");
+}, "SVGGeometryElement.getPointAtLength with SVGRectElement");
+
+test(function() {
+ var svgElement = document.createElementNS("http://www.w3.org/2000/svg", "svg");
+ var circleElement = document.createElementNS("http://www.w3.org/2000/svg", "circle");
+ svgElement.appendChild(circleElement);
+ document.querySelector("p").appendChild(svgElement);
+
+ function pointAtLength(string) {
+ circleElement.setAttribute("r", string);
+
+ var point = circleElement.getPointAtLength(100);
+ return "(" + Math.round(point.x) + ", " + Math.round(point.y) + ")";
+ }
+
+ assert_equals(pointAtLength('10'), "(10, 0)");
+ assert_equals(pointAtLength('100'), "(54, 84)");
+}, "SVGGeometryElement.getPointAtLength with SVGCircleElement");
+</script>

Powered by Google App Engine
This is Rietveld 408576698