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

Unified Diff: LayoutTests/fast/canvas/script-tests/canvas-path-addpath.js

Issue 170503002: Implement addPath() method for Path object (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 10 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: LayoutTests/fast/canvas/script-tests/canvas-path-addpath.js
diff --git a/LayoutTests/fast/canvas/script-tests/canvas-path-addpath.js b/LayoutTests/fast/canvas/script-tests/canvas-path-addpath.js
new file mode 100644
index 0000000000000000000000000000000000000000..54ce9d4f9a29154a2865a694cbbb11177664505b
--- /dev/null
+++ b/LayoutTests/fast/canvas/script-tests/canvas-path-addpath.js
@@ -0,0 +1,52 @@
+description("Test addPath() method.");
+var ctx = document.createElement('canvas').getContext('2d');
+
+debug("Test addPath() with transform as identity matrix.")
+ctx.beginPath();
+var p1 = new Path();
+p1.rect(0,0,100,100);
+var p2 = new Path();
+p2.rect(0,100,100,100);
+var svgElement = document.createElementNS("http://www.w3.org/2000/svg", "svg");
+var m = svgElement.createSVGMatrix();
Justin Novosad 2014/02/18 16:09:29 simpler way to create an SVGMatrix: var m = ctx.c
pals 2014/02/19 11:47:22 Done.
+p1.addPath(p2, m);
+ctx.fillStyle = 'yellow';
+ctx.currentPath = p1;
+ctx.fill();
+var imageData = ctx.getImageData(0, 100, 100, 100);
+var imgdata = imageData.data;
+shouldBe("imgdata[4]", "255");
+shouldBe("imgdata[5]", "255");
+shouldBe("imgdata[6]", "0");
+shouldBe("imgdata[7]", "255");
+debug("");
+
+debug("Test addPath() with transform as translate(100, -100).")
Justin Novosad 2014/02/18 16:09:29 Please add an additional test case where the trans
pals 2014/02/19 11:47:22 Done.
+ctx.beginPath();
+var p1 = new Path();
Justin Novosad 2014/02/18 16:09:29 re-declaration of existing variable.
pals 2014/02/19 11:47:22 Done.
+p1.rect(0,0,100,100);
+var p2 = new Path();
+p2.rect(0,100,100,100);
+var svgElement = document.createElementNS("http://www.w3.org/2000/svg", "svg");
Justin Novosad 2014/02/18 16:09:29 No need to re-create this
pals 2014/02/19 11:47:22 Done.
+var m = svgElement.createSVGMatrix();
+m.a = 1; m.b = 0;
+m.c = 0; m.d = 1;
+m.e = 100; m.f = -100;
+p1.addPath(p2, m);
+ctx.fillStyle = 'yellow';
+ctx.currentPath = p1;
+ctx.fill();
+var imageData = ctx.getImageData(100, 0, 100, 100);
+var imgdata = imageData.data;
+shouldBe("imgdata[4]", "255");
+shouldBe("imgdata[5]", "255");
+shouldBe("imgdata[6]", "0");
+shouldBe("imgdata[7]", "255");
+debug("");
+
+debug("Test addPath() with transform as null.")
+var p1 = new Path();
+p1.rect(0,0,100,100);
+var p2 = new Path();
+shouldThrow("p1.addPath(p2, null)");
Justin Novosad 2014/02/18 16:09:29 According to the spec, the transform is a nullable
pals 2014/02/19 11:47:22 The addPath idl changes generates following code
+debug("");

Powered by Google App Engine
This is Rietveld 408576698