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

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

Issue 2693193003: 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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/fast/canvas/canvas-scale-strokePath-shadow-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/fast/canvas/canvas-scale-strokePath-shadow.html
diff --git a/third_party/WebKit/LayoutTests/fast/canvas/canvas-scale-strokePath-shadow.html b/third_party/WebKit/LayoutTests/fast/canvas/canvas-scale-strokePath-shadow.html
index 4e9f5dfed12aa5af757d88f3775372a7b477bc3d..ea50df6bef6c59101d3e70a79f6856b6938e3dcf 100644
--- a/third_party/WebKit/LayoutTests/fast/canvas/canvas-scale-strokePath-shadow.html
+++ b/third_party/WebKit/LayoutTests/fast/canvas/canvas-scale-strokePath-shadow.html
@@ -1,9 +1,87 @@
-<!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-scale-strokePath-shadow.js"></script>
+<script>
+// Ensure correct behavior of canvas with path stroke + shadow after scaling. A blue and red checkered pattern should be displayed.
+
+var canvas = document.createElement('canvas');
+document.body.appendChild(canvas);
+canvas.setAttribute('width', '600');
+canvas.setAttribute('height', '600');
+var ctx = canvas.getContext('2d');
+
+ctx.scale(2, 2);
+ctx.shadowOffsetX = 100;
+ctx.shadowOffsetY = 100;
+ctx.strokeStyle = 'rgba(0, 0, 255, 1)';
+ctx.lineWidth = 5;
+
+ctx.shadowColor = 'rgba(255, 0, 0, 1.0)';
+ctx.beginPath();
+ctx.moveTo(50, 50);
+ctx.lineTo(100, 50);
+ctx.lineTo(100, 100);
+ctx.lineTo(50, 100);
+ctx.lineTo(50, 50);
+ctx.stroke();
+
+ctx.shadowColor = 'rgba(255, 0, 0, 0.3)';
+ctx.beginPath();
+ctx.moveTo(50, 150);
+ctx.lineTo(100, 150);
+ctx.lineTo(100, 200);
+ctx.lineTo(50, 200);
+ctx.lineTo(50, 150);
+ctx.stroke();
+
+ctx.shadowColor = 'rgba(255, 0, 0, 1.0)';
+ctx.shadowBlur = 10;
+ctx.beginPath();
+ctx.moveTo(150, 50);
+ctx.lineTo(200, 50);
+ctx.lineTo(200, 100);
+ctx.lineTo(150, 100);
+ctx.lineTo(150, 50);
+ctx.stroke();
+
+ctx.shadowColor = 'rgba(255, 0, 0, 0.6)';
+ctx.beginPath();
+ctx.moveTo(150, 150);
+ctx.lineTo(200, 150);
+ctx.lineTo(200, 200);
+ctx.lineTo(150, 200);
+ctx.lineTo(150, 150);
+ctx.stroke();
+
+function testPixelShadowBlur(x, y, color)
+{
+ if (color.length == 4) {
+ assert_array_equals(ctx.getImageData(x, y, 1, 1).data, color);
+ } else { // we expect to have [r, g, b, a, alphaApprox]
+ var data = ctx.getImageData(x, y, 1, 1).data;
+ assert_array_equals(data.slice(0,3), color.slice(0,3));
+ assert_approx_equals(data[3], color[3], color[4]);
+ }
+}
+
+var testPixelShadowScenarios = [
+ ['Verify solid shadow 1', 250, 200, [255, 0, 0, 255]],
+ ['Verify solid shadow 2', 300, 290, [255, 0, 0, 255]],
+ ['Verify solid shadow 3', 200, 250, [255, 0, 0, 255]],
+
+ ['Verify solid alpha shadow 1', 201, 405, [255, 0, 0, 76, 20]],
+ ['Verify solid alpha shadow 2', 201, 500, [255, 0, 0, 76, 20]],
+ ['Verify solid alpha shadow 3', 300, 499, [255, 0, 0, 76, 20]],
+
+ ['Verify blurry shadow 1', 398, 210, [255, 0, 0, 200, 20]],
+ ['Verify blurry shadow 2', 508, 250, [255, 0, 0, 49, 20]],
+ ['Verify blurry shadow 3', 450, 198, [255, 0, 0, 199, 20]],
+
+ ['Verify blurry alpha shadow 1', 505, 450, [255, 0, 0, 70, 20]],
+ ['Verify blurry alpha shadow 2', 450, 405, [255, 0, 0, 70, 20]],
+];
+
+generate_tests(testPixelShadowBlur, testPixelShadowScenarios);
+
+</script>
</body>
-</html>
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/fast/canvas/canvas-scale-strokePath-shadow-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698