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

Side by Side 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 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-fillRect-gradient-shadow.js"></script> 4 <script>
5
6 var alphaApprox = 0, alphaMax = 0;
7 function testPixelShadow(pixel, reference) {
8 var testPassed = true;
9 for(i = 0; i < 3; i++)
10 if(pixel[i] != reference[i]) {
11 testPassed = false;
12 break;
13 }
14 assert_true(testPassed);
15 if(alphaMax != 0)
16 assert_true(pixel[3] < alphaMax);
17 else
18 assert_approx_equals(pixel[3], reference[3], alphaApprox);
19 }
20
21 var canvas = document.createElement('canvas');
22 document.body.appendChild(canvas);
23 canvas.setAttribute('width', '400');
24 canvas.setAttribute('height', '650');
25 var ctx = canvas.getContext('2d');
26
27 var gradient = ctx.createLinearGradient(0, 0, 100, 100);
28 gradient.addColorStop(0, 'rgba(0, 0, 255, 1.0)');
29 gradient.addColorStop(1, 'rgba(0, 0, 255, 1.0)');
30
31 ctx.shadowOffsetX = 200;
32 ctx.fillStyle = gradient;
33
34 ctx.shadowColor = 'rgba(255, 0, 0, 1.0)';
35 ctx.fillRect(50, 50, 100, 100);
36
37 ctx.shadowColor = 'rgba(255, 0, 0, 0.3)';
38 ctx.fillRect(50, 200, 100, 100);
39
40 ctx.shadowColor = 'rgba(255, 0, 0, 1.0)';
41 ctx.shadowBlur = 5;
42 ctx.fillRect(50, 350, 100, 100);
43
44 ctx.shadowColor = 'rgba(255, 0, 0, 0.3)';
45 ctx.fillRect(50, 500, 100, 100);
46
47 testSolidShadow =
48 [
49 ['testSolidShadow 1', ctx.getImageData(250, 50, 1, 1).data, [255, 0, 0, 255]],
50 ['testSolidShadow 2', ctx.getImageData(250, 149, 1, 1).data, [255, 0, 0, 255]],
51 ['testSolidShadow 3', ctx.getImageData(349, 50, 1, 1).data, [255, 0, 0, 255]],
52 ['testSolidShadow 4', ctx.getImageData(349, 149, 1, 1).data, [255, 0, 0, 255]],
53 ];
54
55 // alphaApprox = 5
56 testSolidAlphaShadow =
57 [
58 ['testSolidAlphaShadow 1', ctx.getImageData(250, 200, 1, 1).data, [255, 0, 0, 76]],
59 ['testSolidAlphaShadow 2', ctx.getImageData(250, 299, 1, 1).data, [255, 0, 0, 76]],
60 ['testSolidAlphaShadow 3', ctx.getImageData(349, 200, 1, 1).data, [255, 0, 0, 76]],
61 ['testSolidAlphaShadow 4', ctx.getImageData(349, 299, 1, 1).data, [255, 0, 0, 76]],
62 ];
63
64 // alpha < 25
65 testBlurryShadow =
66 [
67 ['testBlurryShadow 1', ctx.getImageData(248, 348, 1, 1).data, [255, 0, 0 , 0]],
68 ['testBlurryShadow 2', ctx.getImageData(248, 451, 1, 1).data, [255, 0, 0 , 0]],
69 ['testBlurryShadow 3', ctx.getImageData(351, 348, 1, 1).data, [255, 0, 0 , 0]],
70 ['testBlurryShadow 4', ctx.getImageData(351, 451, 1, 1).data, [255, 0, 0 , 0]],
71 ];
72
73 // alpha < 10
74 testBlurryAlphaShadow =
75 [
76 ['testBlurryShadow 1', ctx.getImageData(248, 498, 1, 1).data, [255, 0, 0 , 0]],
77 ['testBlurryShadow 2', ctx.getImageData(248, 601, 1, 1).data, [255, 0, 0 , 0]],
78 ['testBlurryShadow 3', ctx.getImageData(351, 498, 1, 1).data, [255, 0, 0 , 0]],
79 ['testBlurryShadow 4', ctx.getImageData(351, 601, 1, 1).data, [255, 0, 0 , 0]],
80 ];
81
82 generate_tests(testPixelShadow, testSolidShadow);
83 alphaApprox = 5;
84 generate_tests(testPixelShadow, testSolidAlphaShadow);
85 alphaMax = 25;
86 generate_tests(testPixelShadow, testBlurryShadow);
87 alphaMax = 10;
88 generate_tests(testPixelShadow, testBlurryAlphaShadow);
89
90 </script>
8 </body> 91 </body>
9 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698