From bd64fc421e499bfdcf524e7f0050c6efa79e879a Mon Sep 17 00:00:00 2001 From: Jeff Schiller Date: Thu, 28 Jan 2010 23:17:17 +0000 Subject: [PATCH] Add beginning unit test for path conversion code git-svn-id: http://svg-edit.googlecode.com/svn/trunk@1292 eee81c28-f429-11dd-99c0-75d572ba1ddd --- test/test1.html | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/test/test1.html b/test/test1.html index d79c2aac..341f4a58 100644 --- a/test/test1.html +++ b/test/test1.html @@ -34,6 +34,41 @@ equals(typeof {}, typeof svgCanvas); }); + module("Path Module"); + + test("Test path conversion from absolute to relative", function() { + expect(6); + var convert = svgCanvas.pathActions.convertPath; + + // TODO: + svgCanvas.setSvgString("" + + "" + + "" + + ""); + + var p1 = document.getElementById("p1"), + p2 = document.getElementById("p2"), + d_abs = p1.getAttribute("d"), + seglist = p1.pathSegList, + curseg = null; + + equals(p1.nodeName, "path", "Expected 'path', got"); + + equals(seglist.numberOfItems, 3, "Number of segments before conversion"); + + // verify segments before conversion + curseg = seglist.getItem(0); + equals(curseg.pathSegTypeAsLetter, "M", "Before conversion, segment #1 type"); + curseg = seglist.getItem(1); + equals(curseg.pathSegTypeAsLetter, "L", "Before conversion, segment #2 type"); + curseg = seglist.getItem(2); + equals(curseg.pathSegType, 1, "Before conversion, segment #3 type"); + + // convert and verify segments + var d = convert(p1, true); + equals(d, "m100,100l100,0z", "Converted path to relative string"); + }); + module("Transform Module"); test("Test matrixMultiply", function() { @@ -116,6 +151,6 @@

- + \ No newline at end of file