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

Unified Diff: third_party/WebKit/LayoutTests/fast/canvas/canvas-fillRect-gradient-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-fillRect-gradient-shadow.html
diff --git a/third_party/WebKit/LayoutTests/fast/canvas/canvas-fillRect-gradient-shadow.html b/third_party/WebKit/LayoutTests/fast/canvas/canvas-fillRect-gradient-shadow.html
index d0a717801a8cb6a8d4d2f3bc40cb6ba6e69ca779..c29d13d914f8e91ddc404493cd8fb1b7860c6a2c 100644
--- a/third_party/WebKit/LayoutTests/fast/canvas/canvas-fillRect-gradient-shadow.html
+++ b/third_party/WebKit/LayoutTests/fast/canvas/canvas-fillRect-gradient-shadow.html
@@ -1,9 +1,91 @@
-<!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-fillRect-gradient-shadow.js"></script>
+<script>
+
+var alphaApprox = 0, alphaMax = 0;
+function testPixelShadow(pixel, reference) {
+ var testPassed = true;
+ for(i = 0; i < 3; i++)
+ if(pixel[i] != reference[i]) {
+ testPassed = false;
+ break;
+ }
+ assert_true(testPassed);
+ if(alphaMax != 0)
+ assert_true(pixel[3] < alphaMax);
+ else
+ assert_approx_equals(pixel[3], reference[3], alphaApprox);
+}
+
+var canvas = document.createElement('canvas');
+document.body.appendChild(canvas);
+canvas.setAttribute('width', '400');
+canvas.setAttribute('height', '650');
+var ctx = canvas.getContext('2d');
+
+var gradient = ctx.createLinearGradient(0, 0, 100, 100);
+gradient.addColorStop(0, 'rgba(0, 0, 255, 1.0)');
+gradient.addColorStop(1, 'rgba(0, 0, 255, 1.0)');
+
+ctx.shadowOffsetX = 200;
+ctx.fillStyle = gradient;
+
+ctx.shadowColor = 'rgba(255, 0, 0, 1.0)';
+ctx.fillRect(50, 50, 100, 100);
+
+ctx.shadowColor = 'rgba(255, 0, 0, 0.3)';
+ctx.fillRect(50, 200, 100, 100);
+
+ctx.shadowColor = 'rgba(255, 0, 0, 1.0)';
+ctx.shadowBlur = 5;
+ctx.fillRect(50, 350, 100, 100);
+
+ctx.shadowColor = 'rgba(255, 0, 0, 0.3)';
+ctx.fillRect(50, 500, 100, 100);
+
+testSolidShadow =
+ [
+ ['testSolidShadow 1', ctx.getImageData(250, 50, 1, 1).data, [255, 0, 0, 255]],
+ ['testSolidShadow 2', ctx.getImageData(250, 149, 1, 1).data, [255, 0, 0, 255]],
+ ['testSolidShadow 3', ctx.getImageData(349, 50, 1, 1).data, [255, 0, 0, 255]],
+ ['testSolidShadow 4', ctx.getImageData(349, 149, 1, 1).data, [255, 0, 0, 255]],
+ ];
+
+// alphaApprox = 5
+testSolidAlphaShadow =
+ [
+ ['testSolidAlphaShadow 1', ctx.getImageData(250, 200, 1, 1).data, [255, 0, 0, 76]],
+ ['testSolidAlphaShadow 2', ctx.getImageData(250, 299, 1, 1).data, [255, 0, 0, 76]],
+ ['testSolidAlphaShadow 3', ctx.getImageData(349, 200, 1, 1).data, [255, 0, 0, 76]],
+ ['testSolidAlphaShadow 4', ctx.getImageData(349, 299, 1, 1).data, [255, 0, 0, 76]],
+ ];
+
+// alpha < 25
+testBlurryShadow =
+ [
+ ['testBlurryShadow 1', ctx.getImageData(248, 348, 1, 1).data, [255, 0, 0, 0]],
+ ['testBlurryShadow 2', ctx.getImageData(248, 451, 1, 1).data, [255, 0, 0, 0]],
+ ['testBlurryShadow 3', ctx.getImageData(351, 348, 1, 1).data, [255, 0, 0, 0]],
+ ['testBlurryShadow 4', ctx.getImageData(351, 451, 1, 1).data, [255, 0, 0, 0]],
+ ];
+
+// alpha < 10
+testBlurryAlphaShadow =
+ [
+ ['testBlurryShadow 1', ctx.getImageData(248, 498, 1, 1).data, [255, 0, 0, 0]],
+ ['testBlurryShadow 2', ctx.getImageData(248, 601, 1, 1).data, [255, 0, 0, 0]],
+ ['testBlurryShadow 3', ctx.getImageData(351, 498, 1, 1).data, [255, 0, 0, 0]],
+ ['testBlurryShadow 4', ctx.getImageData(351, 601, 1, 1).data, [255, 0, 0, 0]],
+ ];
+
+generate_tests(testPixelShadow, testSolidShadow);
+alphaApprox = 5;
+generate_tests(testPixelShadow, testSolidAlphaShadow);
+alphaMax = 25;
+generate_tests(testPixelShadow, testBlurryShadow);
+alphaMax = 10;
+generate_tests(testPixelShadow, testBlurryAlphaShadow);
+
+</script>
</body>
-</html>

Powered by Google App Engine
This is Rietveld 408576698