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

Side by Side Diff: LayoutTests/fast/canvas/script-tests/canvas-isPointInPath-winding.js

Issue 179383002: Add versions of isPointIn*() that take a Path parameter. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase again Created 6 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 description("Series of tests to ensure correct results of the winding rule in is PointInPath."); 1 description("Series of tests to ensure correct results of the winding rule in is PointInPath.");
2 2
3
4 var tmpimg = document.createElement('canvas'); 3 var tmpimg = document.createElement('canvas');
5 tmpimg.width = 200; 4 tmpimg.width = 200;
6 tmpimg.height = 200; 5 tmpimg.height = 200;
7 ctx = tmpimg.getContext('2d'); 6 ctx = tmpimg.getContext('2d');
8 7
9 // Create the image for blending test with images.
10 var img = document.createElement('canvas');
11 img.width = 100;
12 img.height = 100;
13 var imgCtx = img.getContext('2d');
14
15 // Execute test. 8 // Execute test.
16 function prepareTestScenario() { 9 function prepareTestScenario() {
17 debug('Testing default isPointInPath'); 10 debug('Testing default isPointInPath');
18 ctx.beginPath(); 11 ctx.beginPath();
19 ctx.rect(0, 0, 100, 100); 12 ctx.rect(0, 0, 100, 100);
20 ctx.rect(25, 25, 50, 50); 13 ctx.rect(25, 25, 50, 50);
21 shouldBeTrue("ctx.isPointInPath(50, 50)"); 14 shouldBeTrue("ctx.isPointInPath(50, 50)");
15 shouldBeFalse("ctx.isPointInPath(NaN, 50)");
16 shouldBeFalse("ctx.isPointInPath(50, NaN)");
22 debug(''); 17 debug('');
23 18
24 debug('Testing nonzero isPointInPath'); 19 debug('Testing nonzero isPointInPath');
25 ctx.beginPath(); 20 ctx.beginPath();
26 ctx.rect(0, 0, 100, 100); 21 ctx.rect(0, 0, 100, 100);
27 ctx.rect(25, 25, 50, 50); 22 ctx.rect(25, 25, 50, 50);
28 shouldBeTrue("ctx.isPointInPath(50, 50, 'nonzero')"); 23 shouldBeTrue("ctx.isPointInPath(50, 50, 'nonzero')");
29 debug(''); 24 debug('');
30 25
31 debug('Testing evenodd isPointInPath'); 26 debug('Testing evenodd isPointInPath');
32 ctx.beginPath(); 27 ctx.beginPath();
33 ctx.rect(0, 0, 100, 100); 28 ctx.rect(0, 0, 100, 100);
34 ctx.rect(25, 25, 50, 50); 29 ctx.rect(25, 25, 50, 50);
35 shouldBeFalse("ctx.isPointInPath(50, 50, 'evenodd')"); 30 shouldBeFalse("ctx.isPointInPath(50, 50, 'evenodd')");
31 debug('');
32
33 // reset path in context
34 ctx.beginPath();
35
36 debug('Testing default isPointInPath with Path object');
37 path = new Path();
38 path.rect(0, 0, 100, 100);
39 path.rect(25, 25, 50, 50);
40 shouldBeTrue("ctx.isPointInPath(path, 50, 50)");
41 shouldBeFalse("ctx.isPointInPath(path, NaN, 50)");
42 shouldBeFalse("ctx.isPointInPath(path, 50, NaN)");
43 debug('');
44
45 debug('Testing nonzero isPointInPath with Path object');
46 path = new Path();
47 path.rect(0, 0, 100, 100);
48 path.rect(25, 25, 50, 50);
49 shouldBeTrue("ctx.isPointInPath(path, 50, 50, 'nonzero')");
50 debug('');
51
52 debug('Testing evenodd isPointInPath with Path object');
53 path = new Path();
54 path.rect(0, 0, 100, 100);
55 path.rect(25, 25, 50, 50);
56 shouldBeFalse("ctx.isPointInPath(path, 50, 50, 'evenodd')");
57 debug('');
58
59 debug('Testing null isPointInPath with Path object');
60 path = null;
61 shouldThrow("ctx.isPointInPath(null, 50, 50)");
62 shouldThrow("ctx.isPointInPath(null, 50, 50, 'nonzero')");
63 shouldThrow("ctx.isPointInPath(null, 50, 50, 'evenodd')");
64 shouldThrow("ctx.isPointInPath(path, 50, 50)");
65 shouldThrow("ctx.isPointInPath(path, 50, 50, 'nonzero')");
66 shouldThrow("ctx.isPointInPath(path, 50, 50, 'evenodd')");
67 debug('');
68
69 debug('Testing invalid type isPointInPath with Path object');
70 shouldThrow("ctx.isPointInPath([], 50, 50)");
71 shouldThrow("ctx.isPointInPath([], 50, 50, 'nonzero')");
72 shouldThrow("ctx.isPointInPath([], 50, 50, 'evenodd')");
73 shouldThrow("ctx.isPointInPath({}, 50, 50)");
74 shouldThrow("ctx.isPointInPath({}, 50, 50, 'nonzero')");
75 shouldThrow("ctx.isPointInPath({}, 50, 50, 'evenodd')");
36 debug(''); 76 debug('');
37 } 77 }
38 78
39 // Run test and allow variation of results. 79 // Run test and allow variation of results.
40 prepareTestScenario(); 80 prepareTestScenario();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698