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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/canvas/canvas-fill-rule.html

Issue 2676493005: Use testharness.js instead of js-test.js in LayoutTests/fast/canvas tests. (Closed)
Patch Set: 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 <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-fill-rule.js"></script> 4 <script>
5
6 var tmpimg = document.createElement('canvas');
7 tmpimg.width = 200;
8 tmpimg.height = 200;
9 ctx = tmpimg.getContext('2d');
10
11 // Create the image for blending test with images.
12 var img = document.createElement('canvas');
13 img.width = 100;
14 img.height = 100;
15 var imgCtx = img.getContext('2d');
16
17 function pixelDataAtPoint()
18 {
19 return ctx.getImageData(50, 50, 1, 1).data;
20 }
21
22 function checkResult(expectedColors, sigma) {
23 for (var i = 0; i < 4; i++)
24 assert_approx_equals(pixelDataAtPoint()[i], expectedColors[i], sigma);
25 }
26
27 // Execute test.
28 function prepareTestScenario() {
29 // Testing default fill
30 ctx.fillStyle = 'rgb(255,0,0)';
31 ctx.beginPath();
32 ctx.fillRect(0, 0, 100, 100);
33 ctx.fillStyle = 'rgb(0,255,0)';
34 ctx.beginPath();
35 ctx.rect(0, 0, 100, 100);
36 ctx.rect(25, 25, 50, 50);
37 ctx.fill();
38 checkResult([0, 255, 0, 255], 5);
39
40 // Testing nonzero fill
41 ctx.fillStyle = 'rgb(255,0,0)';
42 ctx.beginPath();
43 ctx.fillRect(0, 0, 100, 100);
44 ctx.fillStyle = 'rgb(0,255,0)';
45 ctx.beginPath();
46 ctx.rect(0, 0, 100, 100);
47 ctx.rect(25, 25, 50, 50);
48 ctx.fill('nonzero');
49 checkResult([0, 255, 0, 255], 5);
50
51 // Testing evenodd fill
52 ctx.fillStyle = 'rgb(255,0,0)';
53 ctx.beginPath();
54 ctx.fillRect(0, 0, 100, 100);
55 ctx.fillStyle = 'rgb(0,255,0)';
56 ctx.beginPath();
57 ctx.rect(0, 0, 100, 100);
58 ctx.rect(25, 25, 50, 50);
59 ctx.fill('evenodd');
60 checkResult([255, 0, 0, 255], 5);
61 }
62
63 test(function(t) {
64 // Run test and allow variation of results.
65 prepareTestScenario();
66 }, "Series of tests to ensure correct results of the winding rule.");
67 </script>
8 </body> 68 </body>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698