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

Unified Diff: third_party/WebKit/LayoutTests/svg/dom/script-tests/path-parser.js

Issue 1413953002: Add unit test for SVG path parsing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Drop line-wrap. Created 5 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/script-tests/path-parser.js
diff --git a/third_party/WebKit/LayoutTests/svg/dom/script-tests/path-parser.js b/third_party/WebKit/LayoutTests/svg/dom/script-tests/path-parser.js
deleted file mode 100644
index 3274242bbc6fcec54b7cdc468c851547c0bc1ea9..0000000000000000000000000000000000000000
--- a/third_party/WebKit/LayoutTests/svg/dom/script-tests/path-parser.js
+++ /dev/null
@@ -1,132 +0,0 @@
-description("This tests the SVG path parser by parsing and then re-serializing various paths.");
-
-var pathElement = document.createElementNS("http://www.w3.org/2000/svg", "path");
-
-var pathProperties = {
- "M": [ "x", "y" ],
- "m": [ "x", "y" ],
- "L": [ "x", "y" ],
- "l": [ "x", "y" ],
- "H": [ "x" ],
- "h": [ "x" ],
- "V": [ "y" ],
- "v": [ "y" ],
- "Z": [ ],
- "z": [ ],
- "C": [ "x1", "y1", "x2", "y2", "x", "y" ],
- "c": [ "x1", "y1", "x2", "y2", "x", "y" ],
- "S": [ "x2", "y2", "x", "y" ],
- "s": [ "x2", "y2", "x", "y" ],
- "Q": [ "x1", "y1", "x", "y" ],
- "q": [ "x1", "y1", "x", "y" ],
- "T": [ "x", "y" ],
- "t": [ "x", "y" ],
- "A": [ "r1", "r2", "angle", "largeArcFlag", "sweepFlag", "x", "y" ],
- "a": [ "r1", "r2", "angle", "largeArcFlag", "sweepFlag", "x", "y" ]
-};
-
-function printSegment(segment)
-{
- var letter = segment.pathSegTypeAsLetter;
- var names = pathProperties[letter];
- if (!names)
- return letter + "?";
- var string = letter;
- for (var i = 0; i < names.length; ++i) {
- if (i)
- string += ",";
- var value = segment[names[i]];
- if (value == undefined) {
- string += "?";
- continue;
- }
- if (typeof(value) === "boolean") {
- string += value ? 1 : 0;
- continue;
- }
- string += value.toFixed(1).replace(/\.0$/, "");
- }
- return string;
-}
-
-function parsePath(string)
-{
- pathElement.setAttributeNS(null, "d", string);
-
- var pathSegList = pathElement.pathSegList;
- var numberOfItems = pathSegList.numberOfItems;
-
- var pathCommands = "";
- for (var i = 0; i < numberOfItems; i++) {
- if (i)
- pathCommands += " ";
- pathCommands += printSegment(pathSegList.getItem(i));
- }
-
- return pathCommands;
-}
-
-shouldBe("parsePath('M1,2')", "'M1,2'");
-shouldBe("parsePath('m1,2')", "'m1,2'");
-shouldBe("parsePath('M100,200 m3,4')", "'M100,200 m3,4'");
-shouldBe("parsePath('M100,200 L3,4')", "'M100,200 L3,4'");
-shouldBe("parsePath('M100,200 l3,4')", "'M100,200 l3,4'");
-shouldBe("parsePath('M100,200 H3')", "'M100,200 H3'");
-shouldBe("parsePath('M100,200 h3')", "'M100,200 h3'");
-shouldBe("parsePath('M100,200 V3')", "'M100,200 V3'");
-shouldBe("parsePath('M100,200 v3')", "'M100,200 v3'");
-shouldBe("parsePath('M100,200 Z')", "'M100,200 Z'");
-shouldBe("parsePath('M100,200 z')", "'M100,200 Z'");
-shouldBe("parsePath('M100,200 C3,4,5,6,7,8')", "'M100,200 C3,4,5,6,7,8'");
-shouldBe("parsePath('M100,200 c3,4,5,6,7,8')", "'M100,200 c3,4,5,6,7,8'");
-shouldBe("parsePath('M100,200 S3,4,5,6')", "'M100,200 S3,4,5,6'");
-shouldBe("parsePath('M100,200 s3,4,5,6')", "'M100,200 s3,4,5,6'");
-shouldBe("parsePath('M100,200 Q3,4,5,6')", "'M100,200 Q3,4,5,6'");
-shouldBe("parsePath('M100,200 q3,4,5,6')", "'M100,200 q3,4,5,6'");
-shouldBe("parsePath('M100,200 T3,4')", "'M100,200 T3,4'");
-shouldBe("parsePath('M100,200 t3,4')", "'M100,200 t3,4'");
-shouldBe("parsePath('M100,200 A3,4,5,0,0,6,7')", "'M100,200 A3,4,5,0,0,6,7'");
-shouldBe("parsePath('M100,200 A3,4,5,1,0,6,7')", "'M100,200 A3,4,5,1,0,6,7'");
-shouldBe("parsePath('M100,200 A3,4,5,0,1,6,7')", "'M100,200 A3,4,5,0,1,6,7'");
-shouldBe("parsePath('M100,200 A3,4,5,1,1,6,7')", "'M100,200 A3,4,5,1,1,6,7'");
-shouldBe("parsePath('M100,200 a3,4,5,0,0,6,7')", "'M100,200 a3,4,5,0,0,6,7'");
-shouldBe("parsePath('M100,200 a3,4,5,0,1,6,7')", "'M100,200 a3,4,5,0,1,6,7'");
-shouldBe("parsePath('M100,200 a3,4,5,1,0,6,7')", "'M100,200 a3,4,5,1,0,6,7'");
-shouldBe("parsePath('M100,200 a3,4,5,1,1,6,7')", "'M100,200 a3,4,5,1,1,6,7'");
-shouldBe("parsePath('M100,200 a3,4,5,006,7')", "'M100,200 a3,4,5,0,0,6,7'");
-shouldBe("parsePath('M100,200 a3,4,5,016,7')", "'M100,200 a3,4,5,0,1,6,7'");
-shouldBe("parsePath('M100,200 a3,4,5,106,7')", "'M100,200 a3,4,5,1,0,6,7'");
-shouldBe("parsePath('M100,200 a3,4,5,116,7')", "'M100,200 a3,4,5,1,1,6,7'");
-shouldBe("parsePath('M100,200 a3,4,5,2,1,6,7')", "'M100,200'");
-shouldBe("parsePath('M100,200 a3,4,5,1,2,6,7')", "'M100,200'");
-
-shouldBe("parsePath('M100,200 a0,4,5,0,0,10,0 a4,0,5,0,0,0,10 a0,0,5,0,0,-10,0 z')", "'M100,200 a0,4,5,0,0,10,0 a4,0,5,0,0,0,10 a0,0,5,0,0,-10,0 Z'");
-
-shouldBe("parsePath('M1,2,3,4')", "'M1,2 L3,4'");
-shouldBe("parsePath('m100,200,3,4')", "'m100,200 l3,4'");
-
-shouldBe("parsePath('M 100-200')", "'M100,-200'");
-shouldBe("parsePath('M 0.6.5')", "'M0.6,0.5'");
-
-shouldBe("parsePath(' M1,2')", "'M1,2'");
-shouldBe("parsePath(' M1,2')", "'M1,2'");
-shouldBe("parsePath('\\tM1,2')", "'M1,2'");
-shouldBe("parsePath('\\nM1,2')", "'M1,2'");
-shouldBe("parsePath('\\rM1,2')", "'M1,2'");
-shouldBe("parsePath('\\vM1,2')", "''");
-shouldBe("parsePath('xM1,2')", "''");
-shouldBe("parsePath('M1,2 ')", "'M1,2'");
-shouldBe("parsePath('M1,2\\t')", "'M1,2'");
-shouldBe("parsePath('M1,2\\n')", "'M1,2'");
-shouldBe("parsePath('M1,2\\r')", "'M1,2'");
-shouldBe("parsePath('M1,2\\v')", "'M1,2'");
-shouldBe("parsePath('M1,2x')", "'M1,2'");
-shouldBe("parsePath('M1,2 L40,0#90')", "'M1,2 L40,0'");
-
-shouldBe("parsePath('')", "''");
-shouldBe("parsePath(' ')", "''");
-shouldBe("parsePath('x')", "''");
-shouldBe("parsePath('L1,2')", "''");
-shouldBe("parsePath('M.1 .2 L.3 .4 .5 .6')", "'M0.1,0.2 L0.3,0.4 L0.5,0.6'");
-
-successfullyParsed = true;
« no previous file with comments | « third_party/WebKit/LayoutTests/svg/dom/path-parser-expected.txt ('k') | third_party/WebKit/Source/core/core.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698