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

Unified Diff: third_party/WebKit/LayoutTests/fast/canvas/canvas-fillPath-shadow.html

Issue 2678493002: Use testharness.js instead of js-test.js in LayoutTests/fast/canvas tests. (Closed)
Patch Set: Addressing comments 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-fillPath-shadow.html
diff --git a/third_party/WebKit/LayoutTests/fast/canvas/canvas-fillPath-shadow.html b/third_party/WebKit/LayoutTests/fast/canvas/canvas-fillPath-shadow.html
index 6c082a754b19d3a8765ae5c7200da23c5dd9a1d9..4f5ece08554782b594a6abc644f5d8ec29771296 100644
--- a/third_party/WebKit/LayoutTests/fast/canvas/canvas-fillPath-shadow.html
+++ b/third_party/WebKit/LayoutTests/fast/canvas/canvas-fillPath-shadow.html
@@ -1,9 +1,63 @@
-<!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-fillPath-shadow.js"></script>
+<script>
+var greenApprox = 0;
+function testPixelShadow(pixel, reference, shouldBeTransparent) {
+ assert_equals(pixel[0], reference[0]);
+ assert_approx_equals(pixel[1], reference[1], greenApprox);
+ assert_equals(pixel[2], reference[2]);
+ if(shouldBeTransparent)
+ assert_not_equals(pixel[3], 255);
+}
+
+var canvas = document.createElement('canvas');
+document.body.appendChild(canvas);
+canvas.setAttribute('width', '700');
+canvas.setAttribute('height', '700');
+var ctx = canvas.getContext('2d');
+
+ctx.beginPath();
+ctx.moveTo(300, 300);
+ctx.lineTo(300, 50);
+ctx.bezierCurveTo(200, 40, 75, 150, 30, 30);
+ctx.quadraticCurveTo(250, 75, 50, 300);
+ctx.shadowOffsetX = 350;
+ctx.shadowColor = 'rgba(255, 20, 0, 0.5)';
+ctx.shadowBlur = 0;
+ctx.fillStyle = 'rgba(0, 0, 255, 1)';
+ctx.lineWidth = 30;
+ctx.fill();
+
+ctx.beginPath();
+ctx.moveTo(300,650);
+ctx.lineTo(300,400);
+ctx.bezierCurveTo(200, 390, 75, 500, 30, 380);
+ctx.quadraticCurveTo(250, 425, 50, 650);
+ctx.shadowOffsetX = 350;
+ctx.shadowColor = 'rgba(255, 0, 0, 0.5)';
+ctx.shadowBlur = 30;
+ctx.fillStyle = 'rgba(0, 0, 255, 1)';
+ctx.lineWidth = 30;
+ctx.fill();
+
+testScenarios =
+ [
+ ['TestSolidShadow 1', ctx.getImageData(640, 290, 1, 1).data, [ 255, 20, 0, 0], false],
+ ['TestSolidShadow 2', ctx.getImageData(570, 85, 1, 1).data, [ 255, 20, 0, 0], false],
+ ['TestSolidShadow 4', ctx.getImageData(400, 40, 1, 1).data, [ 255, 20, 0, 0], false],
+
+ ['TestBlurryShadow 1', ctx.getImageData(640, 640, 1, 1).data, [ 255, 0, 0, 0], true],
+ ['TestBlurryShadow 2', ctx.getImageData(650, 400, 1, 1).data, [ 255, 0, 0, 0], true],
+ ['TestBlurryShadow 3', ctx.getImageData(380, 380, 1, 1).data, [ 255, 0, 0, 0], true],
+ ['TestBlurryShadow 4', ctx.getImageData(375, 390, 1, 1).data, [ 255, 0, 0, 0], true]
+ ];
+
+testScenarios2 =
+ [['TestSolidShadow 3', ctx.getImageData(380, 30, 1, 1).data, [ 255, 20, 0, 0], false]];
+
+generate_tests(testPixelShadow, testScenarios);
+greenApprox = 3;
+generate_tests(testPixelShadow, testScenarios2);
+</script>
</body>
-</html>

Powered by Google App Engine
This is Rietveld 408576698