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

Unified Diff: third_party/WebKit/LayoutTests/fast/canvas/canvas-modify-emptyPath.html

Issue 2694703004: Use testharness.js instead of js-test.js in LayoutTests/fast/canvas tests. (Closed)
Patch Set: Created 3 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: third_party/WebKit/LayoutTests/fast/canvas/canvas-modify-emptyPath.html
diff --git a/third_party/WebKit/LayoutTests/fast/canvas/canvas-modify-emptyPath.html b/third_party/WebKit/LayoutTests/fast/canvas/canvas-modify-emptyPath.html
index 165893644c5802d00c27e6f321a7ad749f134eab..545c86093d455e43c9d19c1d9a3c5c165b5a9b61 100644
--- a/third_party/WebKit/LayoutTests/fast/canvas/canvas-modify-emptyPath.html
+++ b/third_party/WebKit/LayoutTests/fast/canvas/canvas-modify-emptyPath.html
@@ -1,9 +1,96 @@
-<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
-<html>
-<head>
-<script src="../../resources/js-test.js"></script>
-</head>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
<body>
-<script src="script-tests/canvas-modify-emptyPath.js"></script>
+<script>
+
+function getColor(x,y) {
+ return ctx.getImageData(x, y, 1, 1).data;
+}
+
+var canvas = document.createElement('canvas');
+canvas.width = 300;
+canvas.height = 300;
+var ctx = canvas.getContext('2d');
+
+// Test no drawing cases
+ctx.fillStyle = 'green';
+ctx.strokeStyle = 'red';
+ctx.lineWidth = 50;
+
+
+test(function(t) {
+ ctx.beginPath();
+ ctx.fillRect(0, 0, 100, 100);
+ ctx.lineTo(50, 50);
+ ctx.stroke();
+ assert_array_equals(getColor(40,40), [0,128,0,255]);
+ ctx.clearRect(0, 0, 300, 300);
+
+ // Test when create rectangle path using a rectangle with width = height = 0.
+
+ ctx.strokeStyle = 'red';
+ ctx.lineWidth = 10;
+ ctx.beginPath();
+ ctx.rect(0, 0, 0, 0);
+ ctx.stroke();
+ assert_array_equals(getColor(1,1), [0,0,0,0]);
+ ctx.clearRect(0, 0, 300, 300);
+
+ // Test path modifications that result in drawing
+ ctx.fillStyle = 'red';
+ ctx.strokeStyle = 'green';
+
+
+ ctx.beginPath();
+ ctx.fillRect(0, 0, 100, 100);
+ ctx.lineTo(0, 50);
+ ctx.lineTo(100, 50);
+ ctx.stroke();
+ assert_array_equals(getColor(0,0), [255,0,0,255]);
+ assert_array_equals(getColor(50,50), [0,128,0,255]);
+ ctx.clearRect(0, 0, 300, 300);
+
+
+ ctx.beginPath();
+ ctx.fillRect(0, 0, 100, 100);
+ ctx.quadraticCurveTo(0, 50, 100, 50);
+ ctx.stroke();
+ assert_array_equals(getColor(10,10), [255,0,0,255]);
+ assert_array_equals(getColor(50,50), [0,128,0,255]);
+ ctx.clearRect(0, 0, 300, 300);
+
+
+ ctx.beginPath();
+ ctx.fillRect(0, 0, 100, 100);
+ ctx.quadraticCurveTo(0, 50, 100, 50);
+ ctx.lineTo(50, 100);
+ ctx.stroke();
+ assert_array_equals(getColor(10,10), [255,0,0,255]);
+ assert_array_equals(getColor(99,51), [0,128,0,255]);
+ assert_array_equals(getColor(50,50), [0,128,0,255]);
+ ctx.clearRect(0, 0, 300, 300);
+
+
+ ctx.beginPath();
+ ctx.fillRect(0, 0, 100, 100);
+ ctx.bezierCurveTo(0, 50, 50, 50, 100, 50);
+ ctx.stroke();
+ assert_array_equals(getColor(10,10), [255,0,0,255]);
+ assert_array_equals(getColor(50,50), [0,128,0,255]);
+ ctx.clearRect(0, 0, 300, 300);
+
+
+ ctx.beginPath();
+ ctx.fillRect(0, 0, 100, 100);
+ ctx.bezierCurveTo(0, 50, 50, 50, 100, 50);
+ ctx.stroke();
+ ctx.lineTo(50, 100);
+ ctx.stroke();
+ assert_array_equals(getColor(10,10), [255,0,0,255]);
+ assert_array_equals(getColor(99,51), [0,128,0,255]);
+ assert_array_equals(getColor(50,50), [0,128,0,255]);
+ ctx.clearRect(0, 0, 300, 300);
+
+}, "This tests behaviour of path modification APIs on an empty path.");
+</script>
</body>
-</html>

Powered by Google App Engine
This is Rietveld 408576698