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

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

Powered by Google App Engine
This is Rietveld 408576698