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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/canvas/canvas-scale-shadowBlur.html

Issue 2696023002: Use testharness.js instead of js-test.js in LayoutTests/fast/canvas tests. (Closed)
Patch Set: Rebaseline 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 unified diff | Download patch
OLDNEW
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> 1 <script src="../../resources/testharness.js"></script>
2 <html> 2 <script src="../../resources/testharnessreport.js"></script>
3 <head>
4 <script src="../../resources/js-test.js"></script>
5 </head>
6 <body> 3 <body>
7 <script src="script-tests/canvas-scale-shadowBlur.js"></script> 4 <script>
5 // Ensure that canvas shadowBlur is not affected by transformations.
6
7 var canvas = document.createElement('canvas');
8 document.body.appendChild(canvas);
9 canvas.setAttribute('width', '600');
10 canvas.setAttribute('height', '600');
11 var ctx = canvas.getContext('2d');
12
13 ctx.shadowBlur = 25;
14 ctx.shadowOffsetX = 100;
15 ctx.shadowOffsetY = 100;
16 ctx.fillStyle = 'rgba(0, 0, 255, 1)';
17
18 // top left
19 ctx.shadowColor = 'rgba(255, 0, 0, 1.0)';
20 ctx.scale(4, 4);
21 ctx.rotate(Math.PI/2);
22 ctx.translate(25, -50);
23 ctx.fillRect(0, 0, 25, 25);
24
25 // bottom left
26 ctx.shadowColor = 'rgba(255, 0, 0, 0.5)';
27 ctx.setTransform(1, 0, 0, 1, 0, 0);
28 ctx.scale(0.5, 0.5);
29 ctx.fillRect(200, 600, 200, 200);
30
31 // top right
32 ctx.shadowColor = 'rgba(255, 0, 0, 1.0)';
33 ctx.scale(2, 2);
34 ctx.fillRect(300, 100, 100, 100);
35
36 // bottom right
37 ctx.shadowColor = 'rgba(255, 0, 0, 0.5)';
38 ctx.fillRect(300, 300, 100, 100);
39
40 function testPixelShadowBlur(x, y, color)
41 {
42 if (color.length == 4) {
43 assert_array_equals(ctx.getImageData(x, y, 1, 1).data, color);
44 } else { // we expect to have [r, g, b, a, alphaApprox]
45 var data = ctx.getImageData(x, y, 1, 1).data;
46 assert_array_equals(data.slice(0,3), color.slice(0,3));
47 assert_approx_equals(data[3], color[3], color[4]);
48 }
49 }
50
51 var testPixelShadowBlurScenarios = [
52 ['Verify top left 1', 250, 250, [255, 0, 0, 255]],
53 ['Verify top left 2', 250, 175, [0, 0, 0, 0]],
54 ['Verify top left 3', 250, 325, [0, 0, 0, 0]],
55 ['Verify top left 4', 175, 250, [0, 0, 0, 0]],
56 ['Verify top left 5', 325, 250, [0, 0, 0, 0]],
57
58 ['Verify bottom left 1', 250, 450, [255, 0, 0, 126, 20]],
59 ['Verify bottom left 2', 250, 375, [0, 0, 0, 0]],
60 ['Verify bottom left 3', 250, 525, [0, 0, 0, 0]],
61 ['Verify bottom left 4', 175, 450, [0, 0, 0, 0]],
62 ['Verify bottom left 5', 325, 450, [0, 0, 0, 0]],
63 ['Verify bottom left 6', 250, 250, [255, 0, 0, 255, 20]],
64
65 ['Verify top right 1', 450, 250, [255, 0, 0, 255, 20]],
66 ['Verify top right 2', 450, 175, [0, 0, 0, 0]],
67 ['Verify top right 3', 450, 325, [0, 0, 0, 0]],
68 ['Verify top right 4', 375, 250, [0, 0, 0, 0]],
69 ['Verify top right 5', 525, 250, [0, 0, 0, 0]],
70
71 ['Verify bottom right 1', 450, 450, [255, 0, 0, 126, 20]],
72 ['Verify bottom right 2', 450, 375, [0, 0, 0, 0]],
73 ['Verify bottom right 3', 450, 525, [0, 0, 0, 0]],
74 ['Verify bottom right 2', 375, 450, [0, 0, 0, 0]],
75 ['Verify bottom right 2', 525, 450, [0, 0, 0, 0]],
76
77 ];
78
79 generate_tests(testPixelShadowBlur, testPixelShadowBlurScenarios);
80
81 </script>
8 </body> 82 </body>
9 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698