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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/canvas/canvas-path-context-clip.html

Issue 2689243002: 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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/fast/canvas/canvas-path-context-clip-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <canvas id="canvas" width="200" height="200"></canvas> 4 <canvas id="canvas" width="200" height="200"></canvas>
8 <script src="script-tests/canvas-path-context-clip.js"></script> 5 <script>
6
7 var ctx = document.getElementById('canvas').getContext('2d');
8
9 function checkResult(expectedColors, sigma) {
10 data = ctx.getImageData(50, 50, 1, 1).data;
11 for (var i = 0; i < 4; i++)
12 assert_approx_equals(data[i], expectedColors[i], sigma);
13 }
14
15 function drawRectanglesOn(contextOrPath) {
16 contextOrPath.rect(0, 0, 100, 100);
17 contextOrPath.rect(25, 25, 50, 50);
18 }
19
20 function testClipWith(fillRule, path) {
21 ctx.fillStyle = 'rgb(255,0,0)';
22 ctx.beginPath();
23 ctx.fillRect(0, 0, 100, 100);
24 ctx.fillStyle = 'rgb(0,255,0)';
25 if (path) {
26 if (fillRule) {
27 ctx.clip(path, fillRule);
28 } else {
29 ctx.clip(path);
30 }
31 } else {
32 ctx.beginPath();
33 drawRectanglesOn(ctx);
34 if (fillRule) {
35 ctx.clip(fillRule);
36 } else {
37 ctx.clip();
38 }
39 }
40 ctx.beginPath();
41 ctx.fillRect(0, 0, 100, 100);
42 if (fillRule == 'evenodd') {
43 checkResult([255, 0, 0, 255], 5);
44 } else {
45 checkResult([0, 255, 0, 255], 5);
46 }
47 }
48
49 test(function(t) {
50 fillRules = [undefined, 'nonzero', 'evenodd'];
51 path = new Path2D();
52 drawRectanglesOn(path);
53
54 for (var i = 0; i < fillRules.length; i++) {
55 testClipWith(fillRules[i]);
56 testClipWith(fillRules[i], path);
57 }
58
59 // Test exception cases.
60 assert_throws(null, function() {ctx.clip(null);});
61 assert_throws(null, function() {ctx.clip(null, null);});
62 assert_throws(null, function() {ctx.clip(null, 'nonzero');});
63 assert_throws(null, function() {ctx.clip(path, null);});
64 assert_throws(null, function() {ctx.clip([], 'nonzero');});
65 assert_throws(null, function() {ctx.clip({}, 'nonzero');});
66 assert_throws(null, function() {ctx.clip(null, 'evenodd');});
67 assert_throws(null, function() {ctx.clip([], 'evenodd');});
68 assert_throws(null, function() {ctx.clip({}, 'evenodd');});
69 assert_throws(null, function() {ctx.clip('gazonk');});
70 assert_throws(null, function() {ctx.clip(path, 'gazonk');});
71 assert_throws(null, function() {ctx.clip(undefined, undefined);});
72 assert_throws(null, function() {ctx.clip(undefined, 'nonzero');});
73 }, 'Series of tests to ensure clip() works with path and winding rule parameters .');
74 </script>
9 </body> 75 </body>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/fast/canvas/canvas-path-context-clip-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698