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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/canvas/canvas-fillPath-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-fillPath-gradient-shadow.js"></script> 4 <script>
5 var canvas = document.createElement('canvas');
6 document.body.appendChild(canvas);
7 canvas.setAttribute('width', '600');
8 canvas.setAttribute('height', '1100');
9 var ctx = canvas.getContext('2d');
10
11 var gradient = ctx.createLinearGradient(0, 0, 300, 0);
12 gradient.addColorStop(0, 'rgba(0, 0, 255, 0.5)');
13 gradient.addColorStop(1, 'rgba(0, 0, 255, 0.5)');
14
15 ctx.save();
16 ctx.fillStyle = gradient;
17 ctx.shadowColor = 'rgba(255, 0, 0, 0.5)';
18 ctx.shadowOffsetX = 250;
19
20 function fillShape(x, y) {
21 ctx.beginPath();
22 ctx.arc(x, y, 100, 0, Math.PI*2, true);
23 ctx.arc(x, y, 50, 0, Math.PI*2, false);
24 ctx.fill();
25 }
26
27 // Alpha shadow.
28 ctx.shadowBlur = 0;
29 fillShape(150, 150);
30
31 // Blurry shadow.
32 ctx.shadowBlur = 10;
33 fillShape(150, 400);
34
35 ctx.rotate(Math.PI/2);
36
37 // Rotated alpha shadow.
38 ctx.shadowBlur = 0;
39 fillShape(650, -150);
40
41 // Rotated blurry shadow.
42 ctx.shadowBlur = 10;
43 fillShape(900, -150);
44
45 ctx.restore();
46 ctx.fillStyle = 'black';
47
48 function testPixelShadow(pixel, reference, alphaApprox) {
49 var testPassed = true;
50 for(i = 0; i < 3; i++)
51 if(pixel[i] != reference[i]) {
52 testPassed = false;
53 break;
54 }
55 assert_true(testPassed);
56 assert_approx_equals(pixel[3], reference[3], alphaApprox);
57 }
58
59 testScenarios =
60 [
61 ['TestAlphaShadow 1', ctx.getImageData(400, 150, 1, 1).data, [ 0, 0, 0, 0, 0], 0],
62 ['TestAlphaShadow 2', ctx.getImageData(400, 75, 1, 1).data, [ 255, 0, 0, 64], 15],
63 ['TestAlphaShadow 3', ctx.getImageData(400, 225, 1, 1).data, [ 255, 0, 0, 64], 15],
64 ['TestAlphaShadow 4', ctx.getImageData(325, 150, 1, 1).data, [ 255, 0, 0, 64], 15],
65 ['TestAlphaShadow 5', ctx.getImageData(475, 150, 1, 1).data, [ 255, 0, 0, 64], 15],
66
67 ['TestBlurryShadow 1', ctx.getImageData(400, 400, 1, 1).data, [ 0, 0 , 0, 0, 0], 0],
68 ['TestBlurryShadow 2', ctx.getImageData(400, 300, 1, 1).data, [ 255, 0, 0, 31], 15],
69 ['TestBlurryShadow 3', ctx.getImageData(400, 500, 1, 1).data, [ 255, 0, 0, 31], 15],
70 ['TestBlurryShadow 4', ctx.getImageData(300, 400, 1, 1).data, [ 255, 0, 0, 31], 15],
71 ['TestBlurryShadow 5', ctx.getImageData(500, 400, 1, 1).data, [ 255, 0, 0, 31], 15],
72
73 ['TestRotatedAlphaShadow 1', ctx.getImageData(400, 650, 1, 1).data, [ 0, 0, 0, 0, 0], 0],
74 ['TestRotatedAlphaShadow 2', ctx.getImageData(400, 575, 1, 1).data, [ 255, 0, 0, 64], 15],
75 ['TestRotatedAlphaShadow 3', ctx.getImageData(400, 725, 1, 1).data, [ 255, 0, 0, 64], 15],
76 ['TestRotatedAlphaShadow 4', ctx.getImageData(325, 650, 1, 1).data, [ 255, 0, 0, 64], 15],
77 ['TestRotatedAlphaShadow 5', ctx.getImageData(475, 650, 1, 1).data, [ 255, 0, 0, 64], 15],
78
79 ['TestRotatedBlurryShadow 1', ctx.getImageData(400, 900, 1, 1).data, [ 0, 0, 0, 0, 0], 0],
80 ['TestRotatedBlurryShadow 2', ctx.getImageData(400, 800, 1, 1).data, [ 255, 0, 0, 31], 15],
81 ['TestRotatedBlurryShadow 3', ctx.getImageData(400, 1000, 1, 1).data , [ 255, 0, 0, 31], 15],
82 ['TestRotatedBlurryShadow 4', ctx.getImageData(300, 900, 1, 1).data, [ 255, 0, 0, 31], 15],
83 ['TestRotatedBlurryShadow 5', ctx.getImageData(500, 900, 1, 1).data, [ 255, 0, 0, 31], 15],
84 ];
85
86 generate_tests(testPixelShadow, testScenarios);
87
88 </script>
8 </body> 89 </body>
9 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698