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

Unified Diff: third_party/WebKit/LayoutTests/fast/canvas/canvas-fillPath-alpha-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-alpha-shadow.html
diff --git a/third_party/WebKit/LayoutTests/fast/canvas/canvas-fillPath-alpha-shadow.html b/third_party/WebKit/LayoutTests/fast/canvas/canvas-fillPath-alpha-shadow.html
index 324e67b8d2b19a7c4ec1cd3522e573a37676bc04..e3daded8670e8133fecdd13fdacf73a13acd7ade 100644
--- a/third_party/WebKit/LayoutTests/fast/canvas/canvas-fillPath-alpha-shadow.html
+++ b/third_party/WebKit/LayoutTests/fast/canvas/canvas-fillPath-alpha-shadow.html
@@ -1,9 +1,85 @@
-<!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-alpha-shadow.js"></script>
+<script>
+var canvas = document.createElement('canvas');
+document.body.appendChild(canvas);
+canvas.setAttribute('width', '600');
+canvas.setAttribute('height', '1100');
+var ctx = canvas.getContext('2d');
+
+ctx.save();
+ctx.fillStyle = 'rgba(0, 0, 255, 0.5)';
+ctx.shadowColor = 'rgba(255, 0, 0, 0.5)';
+ctx.shadowOffsetX = 250;
+
+function fillShape(x, y) {
+ ctx.beginPath();
+ ctx.arc(x, y, 100, 0, Math.PI*2, true);
+ ctx.arc(x, y, 50, 0, Math.PI*2, false);
+ ctx.fill();
+}
+
+// Alpha shadow.
+ctx.shadowBlur = 0;
+fillShape(150, 150);
+
+// Blurry shadow.
+ctx.shadowBlur = 10;
+fillShape(150, 400);
+
+ctx.rotate(Math.PI/2);
+
+// Rotated alpha shadow.
+ctx.shadowBlur = 0;
+fillShape(650, -150);
+
+// Rotated blurry shadow.
+ctx.shadowBlur = 10;
+fillShape(900, -150);
+
+ctx.restore();
+ctx.fillStyle = 'black';
+
+function testPixelShadow(pixel, reference, alphaApprox) {
+ var testPassed = true;
+ for(i = 0; i < 3; i++)
+ if(pixel[i] != reference[i]) {
+ testPassed = false;
+ break;
+ }
+ assert_true(testPassed);
+ assert_approx_equals(pixel[3], reference[3], alphaApprox);
+}
+
+testScenarios =
+ [
+ ['TestAlphaShadow 1', ctx.getImageData(400, 150, 1, 1).data, [ 0, 0, 0, 0, 0], 0],
+ ['TestAlphaShadow 2', ctx.getImageData(400, 75, 1, 1).data, [ 255, 0, 0, 64], 15],
+ ['TestAlphaShadow 3', ctx.getImageData(400, 225, 1, 1).data, [ 255, 0, 0, 64], 15],
+ ['TestAlphaShadow 4', ctx.getImageData(325, 150, 1, 1).data, [ 255, 0, 0, 64], 15],
+ ['TestAlphaShadow 5', ctx.getImageData(475, 150, 1, 1).data, [ 255, 0, 0, 64], 15],
+
+ ['TestBlurryShadow 1', ctx.getImageData(400, 400, 1, 1).data, [ 0, 0, 0, 0, 0], 0],
+ ['TestBlurryShadow 2', ctx.getImageData(400, 300, 1, 1).data, [ 255, 0, 0, 31], 15],
+ ['TestBlurryShadow 3', ctx.getImageData(400, 500, 1, 1).data, [ 255, 0, 0, 31], 15],
+ ['TestBlurryShadow 4', ctx.getImageData(300, 400, 1, 1).data, [ 255, 0, 0, 31], 15],
+ ['TestBlurryShadow 5', ctx.getImageData(500, 400, 1, 1).data, [ 255, 0, 0, 31], 15],
+
+ ['TestRotatedAlphaShadow 1', ctx.getImageData(400, 650, 1, 1).data, [ 0, 0, 0, 0, 0], 0],
+ ['TestRotatedAlphaShadow 2', ctx.getImageData(400, 575, 1, 1).data, [ 255, 0, 0, 64], 15],
+ ['TestRotatedAlphaShadow 3', ctx.getImageData(400, 725, 1, 1).data, [ 255, 0, 0, 64], 15],
+ ['TestRotatedAlphaShadow 4', ctx.getImageData(325, 650, 1, 1).data, [ 255, 0, 0, 64], 15],
+ ['TestRotatedAlphaShadow 5', ctx.getImageData(475, 650, 1, 1).data, [ 255, 0, 0, 64], 15],
+
+ ['TestRotatedBlurryShadow 1', ctx.getImageData(400, 900, 1, 1).data, [ 0, 0, 0, 0, 0], 0],
+ ['TestRotatedBlurryShadow 2', ctx.getImageData(400, 800, 1, 1).data, [ 255, 0, 0, 31], 15],
+ ['TestRotatedBlurryShadow 3', ctx.getImageData(400, 1000, 1, 1).data, [ 255, 0, 0, 31], 15],
+ ['TestRotatedBlurryShadow 4', ctx.getImageData(300, 900, 1, 1).data, [ 255, 0, 0, 31], 15],
+ ['TestRotatedBlurryShadow 5', ctx.getImageData(500, 900, 1, 1).data, [ 255, 0, 0, 31], 15],
+ ];
+
+generate_tests(testPixelShadow, testScenarios);
+
+ </script>
</body>
-</html>

Powered by Google App Engine
This is Rietveld 408576698