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

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

Issue 14298022: Add support for new canvas ellipse method. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 8 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-ellipse.js
diff --git a/LayoutTests/fast/canvas/script-tests/canvas-ellipse.js b/LayoutTests/fast/canvas/script-tests/canvas-ellipse.js
new file mode 100644
index 0000000000000000000000000000000000000000..765bf75f07dae95dbaadf5eb39b97fd80cca318d
--- /dev/null
+++ b/LayoutTests/fast/canvas/script-tests/canvas-ellipse.js
@@ -0,0 +1,89 @@
+description("This test checks ellipse API in canvas v5");
+
+var canvas = document.createElement('canvas');
+document.body.appendChild(canvas);
+canvas.setAttribute('width', '400');
+canvas.setAttribute('height', '400');
+var ctx = canvas.getContext('2d');
+
+function deg2rad(x) {
+ return x * Math.PI / 180;
+}
+
+ctx.fillStyle="rgba(255, 255, 255, 1.0)";
+ctx.fillRect(0, 0, 400, 400);
+
+ctx.strokeStyle="rgba(0, 0, 0, 1.0)";
+ctx.lineWidth = 10;
+ctx.beginPath();
+ctx.moveTo(0, 100);
+ctx.ellipse(200, 200, 100, 150, deg2rad(20), deg2rad(-180), deg2rad(100), false);
+ctx.lineTo(0, 300);
+ctx.stroke();
+
+var imageData, data;
+
+// Verify the method must add a straight line from the last point in the subpath
+// to the start point of the ellipse.
+imageData = ctx.getImageData(5, 103, 1, 1);
+data = imageData.data;
+shouldBe('data[0]', '0');
+
+imageData = ctx.getImageData(49, 130, 1, 1);
+data = imageData.data;
+shouldBe('data[0]', '0');
+
+imageData = ctx.getImageData(103, 163, 1, 1);
+data = imageData.data;
+shouldBe('data[0]', '0');
+
+imageData = ctx.getImageData(36, 108, 1, 1);
+data = imageData.data;
+shouldBe('data[0]', '255');
+
+// Verify ellipse API draws well.
+imageData = ctx.getImageData(101, 179, 1, 1);
+data = imageData.data;
+shouldBe('data[0]', '255');
+
+imageData = ctx.getImageData(119, 132, 1, 1);
+data = imageData.data;
+shouldBe('data[0]', '0');
+
+imageData = ctx.getImageData(260, 62, 1, 1);
+data = imageData.data;
+shouldBe('data[0]', '0');
+
+imageData = ctx.getImageData(301, 122, 1, 1);
+data = imageData.data;
+shouldBe('data[0]', '0');
+
+imageData = ctx.getImageData(273, 272, 1, 1);
+data = imageData.data;
+shouldBe('data[0]', '0');
+
+imageData = ctx.getImageData(169, 344, 1, 1);
+data = imageData.data;
+shouldBe('data[0]', '0');
+
+imageData = ctx.getImageData(196, 362, 1, 1);
+data = imageData.data;
+shouldBe('data[0]', '255');
+
+// Verify the last point of ellipse is the start point of the next subpath.
+imageData = ctx.getImageData(128, 331, 1, 1);
+data = imageData.data;
+shouldBe('data[0]', '0');
+
+imageData = ctx.getImageData(65, 315, 1, 1);
+data = imageData.data;
+shouldBe('data[0]', '0');
+
+imageData = ctx.getImageData(9, 302, 1, 1);
+data = imageData.data;
+shouldBe('data[0]', '0');
+
+imageData = ctx.getImageData(58, 300, 1, 1);
+data = imageData.data;
+shouldBe('data[0]', '255');
+

Powered by Google App Engine
This is Rietveld 408576698