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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/canvas/canvas-blending-shadow.html

Issue 2673013003: 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> 1 <!DOCTYPE HTML>
2 <html> 2 <html>
3 <body> 3 <body>
4 <script src="../../resources/js-test.js"></script> 4 <script src="../../resources/testharness.js"></script>
5 <script type="text/javascript" src="canvas-blending-helpers.js"></script> 5 <script src="../../resources/testharnessreport.js"></script>
6 <script type="text/javascript"> 6 <script type="text/javascript" src="canvas-blending-helpers.js"></script>
7 <script>
8 test(function(t) {
9 function checkShadowColor(i, context, sigma) {
10 var expectedShadowColor = blendColors([192 / 255, 192 / 255, 192 / 255, 1], [1, 129 / 255, 129 / 255, 1], i);
11 var ac = context.getImageData(11, 11, 1, 1).data;
12 assert_approx_equals(ac[0], expectedShadowColor[0], sigma);
13 assert_approx_equals(ac[1], expectedShadowColor[1], sigma);
14 assert_approx_equals(ac[2], expectedShadowColor[2], sigma);
15 assert_approx_equals(ac[3], expectedShadowColor[3], sigma);
16 }
7 17
8 description("Series of tests to ensure correct results on applying diffe rent blend modes when drawing a rectangle with shadow."); 18 var canvas = document.createElement('canvas');
19 var sigma = 5;
20 canvas.width = 12;
21 canvas.height = 12;
22 context = canvas.getContext('2d');
9 23
10 var context; 24 for (var i = 0; i < blendModes.length; ++i) {
11 function actualColor(x, y) { 25 context.clearRect(0, 0, 12, 12);
12 return context.getImageData(x, y, 1, 1).data; 26 context.save();
13 } 27 drawBackdropColorWithShadowInContext(context);
14 28 context.globalCompositeOperation = blendModes[i];
15 function checkBlendModeResult(i, context, sigma) { 29 drawSourceColorRectOverShadow(context);
16 var expectedColor = blendColors([129 / 255, 1, 129 / 255, 1], [1, 12 9 / 255, 129 / 255, 1], i); 30 checkBlendModeResult(i, context, 5);
17 var ac = "actualColor(0, 0)"; 31 checkShadowColor(i, context, sigma);
18 shouldBeCloseTo(ac + "[0]", expectedColor[0], sigma); 32 context.restore();
19 shouldBeCloseTo(ac + "[1]", expectedColor[1], sigma); 33 }
20 shouldBeCloseTo(ac + "[2]", expectedColor[2], sigma); 34 }, 'Series of tests to ensure correct results on applying different blend modes when drawing a rectangle with shadow.');
21 shouldBeCloseTo(ac + "[3]", expectedColor[3], sigma); 35 </script>
22
23 var expectedShadowColor = blendColors([192 / 255, 192 / 255, 192 / 2 55, 1], [1, 129 / 255, 129 / 255, 1], i);
24 var ac = "actualColor(11, 11)";
25 shouldBeCloseTo(ac + "[0]", expectedShadowColor[0], sigma);
26 shouldBeCloseTo(ac + "[1]", expectedShadowColor[1], sigma);
27 shouldBeCloseTo(ac + "[2]", expectedShadowColor[2], sigma);
28 shouldBeCloseTo(ac + "[3]", expectedShadowColor[3], sigma);
29 }
30
31 function runTest() {
32 var canvas = document.createElement("canvas");
33 var sigma = 5;
34 canvas.width = 12;
35 canvas.height = 12;
36 context = canvas.getContext("2d");
37
38 for (var i = 0; i < blendModes.length; ++i) {
39 debug("Testing blend mode " + blendModes[i]);
40
41 context.clearRect(0, 0, 12, 12);
42 context.save();
43 drawBackdropColorWithShadowInContext(context);
44 context.globalCompositeOperation = blendModes[i];
45 drawSourceColorRectOverShadow(context);
46 checkBlendModeResult(i, context, sigma);
47 context.restore();
48 debug('');
49 }
50 }
51
52 runTest();
53 </script>
54 </body>
55 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698