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

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

Issue 2703803002: Use testharness.js instead of js-test.js in LayoutTests/fast/canvas tests. (Closed)
Patch Set: Addressing comments Created 3 years, 9 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>
7 <canvas width="600" height="300" style="border: solid 1px gray"></canvas> 3 <canvas width="600" height="300" style="border: solid 1px gray"></canvas>
4
8 <script> 5 <script>
9 description('Tests that (vertical) shadow offsets are applied correctly when usi ng fillText() regardless of blur amount.'); 6
7 // Tests that (vertical) shadow offsets are applied correctly when using fillTex t() regardless of blur amount.
8
10 var ctx = document.getElementsByTagName('canvas')[0].getContext('2d'); 9 var ctx = document.getElementsByTagName('canvas')[0].getContext('2d');
11 ctx.font = 'bold 128px sans-serif'; 10 ctx.font = 'bold 128px sans-serif';
12 ctx.shadowColor = 'red' 11 ctx.shadowColor = 'red'
13 ctx.shadowOffsetY = 100; 12 ctx.shadowOffsetY = 100;
14 13
15 function testWithBlur(blur, belowOffset) { 14 function testWithBlur(blur, belowOffset) {
16 ctx.clearRect(0, 0, 600, 300); 15 ctx.clearRect(0, 0, 600, 300);
17 ctx.shadowBlur = blur; 16 ctx.shadowBlur = blur;
18 17
19 // Center the I around the Y axis. 18 // Center the I around the Y axis.
20 ctx.fillText('I', -ctx.measureText('I').width/2, 128); 19 ctx.fillText('I', -ctx.measureText('I').width/2, 128);
21
22 debug('Testing with blur of ' + blur + ' pixels');
23 20
24 // Make sure that the shadow doesn't end up above the text... 21 // Make sure that the shadow doesn't end up above the text...
25 var imageData = ctx.getImageData(0, 0, 1, 1); 22 var imageData = ctx.getImageData(0, 0, 1, 1).data;
26 imgdata = imageData.data; 23 assert_array_equals(imageData, [0, 0, 0, 0]);
27 24
28 shouldBe('imgdata[0]', '0'); 25 // ...but below.
29 shouldBe('imgdata[1]', '0'); 26 var imageData = ctx.getImageData(0, belowOffset, 1, 1).data;
30 shouldBe('imgdata[2]', '0'); 27 assert_array_equals(imageData, [255, 0, 0, 255]);
31 shouldBe('imgdata[3]', '0');
32
33 // ...but below.
34 var imageData = ctx.getImageData(0, belowOffset, 1, 1);
35 imgdata = imageData.data;
36 shouldBe('imgdata[0]', '255');
37 shouldBe('imgdata[1]', '0');
38 shouldBe('imgdata[2]', '0');
39 shouldBe('imgdata[3]', '255');
40 } 28 }
41 29
42 debug('Testing with no transform'); 30 var testScenariosNoTransform = [
43 testWithBlur(0, 150); 31 ['TestShadowOffsetWithNoTransform 1', 0, 150],
44 testWithBlur(1, 150); 32 ['TestShadowOffsetWithNoTransform 2', 1, 150],
45 testWithBlur(5, 150); 33 ['TestShadowOffsetWithNoTransform 3', 5, 150],
34 ];
46 35
47 debug('Testing with scale transform'); 36 var testScenariosScaleTransform = [
37 ['TestShadowOffsetWithScaleTransform 1', 0, 299],
38 ['TestShadowOffsetWithScaleTransform 2', 1, 299],
39 ['TestShadowOffsetWithScaleTransform 3', 5, 299],
40 ];
41
42 generate_tests(testWithBlur, testScenariosNoTransform);
43
48 ctx.scale(1, 2); 44 ctx.scale(1, 2);
49 testWithBlur(0, 299); 45 generate_tests(testWithBlur, testScenariosScaleTransform);
50 testWithBlur(1, 299);
51 testWithBlur(5, 299);
52 46
53 </script> 47 </script>
54 </body>
55 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698