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

Side by Side Diff: LayoutTests/fast/canvas/script-tests/canvas-isPointInStroke-with-path.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
(Empty)
1 description("Test the behavior of isPointInStroke in Canvas with path object");
2 var ctx = document.createElement('canvas').getContext('2d');
3
4 document.body.appendChild(ctx.canvas);
5
6 ctx.strokeStyle = '#0ff';
7
8 // Create new path.
9 var path = new Path();
10 path.rect(20,20,100,100);
11
12 debug("Initial behavior: lineWidth = 1.0")
13 shouldBeTrue("ctx.isPointInStroke(path,20,20)");
14 shouldBeTrue("ctx.isPointInStroke(path,120,20)");
15 shouldBeTrue("ctx.isPointInStroke(path,20,120)");
16 shouldBeTrue("ctx.isPointInStroke(path,120,120)");
17 shouldBeTrue("ctx.isPointInStroke(path,70,20)");
18 shouldBeTrue("ctx.isPointInStroke(path,20,70)");
19 shouldBeTrue("ctx.isPointInStroke(path,120,70)");
20 shouldBeTrue("ctx.isPointInStroke(path,70,120)");
21 shouldBeFalse("ctx.isPointInStroke(path,22,22)");
22 shouldBeFalse("ctx.isPointInStroke(path,118,22)");
23 shouldBeFalse("ctx.isPointInStroke(path,22,118)");
24 shouldBeFalse("ctx.isPointInStroke(path,118,118)");
25 shouldBeFalse("ctx.isPointInStroke(path,70,18)");
26 shouldBeFalse("ctx.isPointInStroke(path,122,70)");
27 shouldBeFalse("ctx.isPointInStroke(path,70,122)");
28 shouldBeFalse("ctx.isPointInStroke(path,18,70)");
29 shouldBeFalse("ctx.isPointInStroke(path,NaN,122)");
30 shouldBeFalse("ctx.isPointInStroke(path,18,NaN)");
31 debug("");
32
33 debug("Check null and invalid type");
34 shouldThrow("ctx.isPointInStroke(null,70,20)");
35 shouldThrow("ctx.isPointInStroke([],20,70)");
36 shouldThrow("ctx.isPointInStroke({},120,70)");
37 debug("");
38
39 debug("Set lineWidth = 10.0");
40 ctx.lineWidth = 10;
41 shouldBeTrue("ctx.isPointInStroke(path,22,22)");
42 shouldBeTrue("ctx.isPointInStroke(path,118,22)");
43 shouldBeTrue("ctx.isPointInStroke(path,22,118)");
44 shouldBeTrue("ctx.isPointInStroke(path,118,118)");
45 shouldBeTrue("ctx.isPointInStroke(path,70,18)");
46 shouldBeTrue("ctx.isPointInStroke(path,122,70)");
47 shouldBeTrue("ctx.isPointInStroke(path,70,122)");
48 shouldBeTrue("ctx.isPointInStroke(path,18,70)");
49 shouldBeFalse("ctx.isPointInStroke(path,26,70)");
50 shouldBeFalse("ctx.isPointInStroke(path,70,26)");
51 shouldBeFalse("ctx.isPointInStroke(path,70,114)");
52 shouldBeFalse("ctx.isPointInStroke(path,114,70)");
53 debug("");
54
55 debug("Check lineJoin = 'bevel'");
56 path = new Path();
57 path.moveTo(10,10);
58 path.lineTo(110,20);
59 path.lineTo(10,30);
60 ctx.lineJoin = "bevel";
61 shouldBeFalse("ctx.isPointInStroke(path,113,20)");
62 debug("");
63
64 debug("Check lineJoin = 'miter'");
65 ctx.miterLimit = 40.0;
66 ctx.lineJoin = "miter";
67 shouldBeTrue("ctx.isPointInStroke(path,113,20)");
68 debug("");
69
70 debug("Check miterLimit = 2.0");
71 ctx.miterLimit = 2.0;
72 shouldBeFalse("ctx.isPointInStroke(path,113,20)");
73 debug("");
74
75 debug("Check lineCap = 'butt'");
76 path = new Path();
77 path.moveTo(10,10);
78 path.lineTo(110,10);
79 ctx.lineCap = "butt";
80 shouldBeFalse("ctx.isPointInStroke(path,112,10)");
81 debug("");
82
83 debug("Check lineCap = 'round'");
84 ctx.lineCap = "round";
85 shouldBeTrue("ctx.isPointInStroke(path,112,10)");
86 shouldBeFalse("ctx.isPointInStroke(path,117,10)");
87 debug("");
88
89 debug("Check lineCap = 'square'");
90 ctx.lineCap = "square";
91 shouldBeTrue("ctx.isPointInStroke(path,112,10)");
92 shouldBeFalse("ctx.isPointInStroke(path,117,10)");
93 debug("");
94
95 debug("Check setLineDash([10,10])");
96 ctx.lineCap = "butt";
97 ctx.setLineDash([10,10]);
98 shouldBeTrue("ctx.isPointInStroke(path,15,10)");
99 shouldBeFalse("ctx.isPointInStroke(path,25,10)");
100 shouldBeTrue("ctx.isPointInStroke(path,35,10)");
101 debug("");
102
103 debug("Check dashOffset = 10");
104 ctx.lineDashOffset = 10;
105 shouldBeFalse("ctx.isPointInStroke(path,15,10)");
106 shouldBeTrue("ctx.isPointInStroke(path,25,10)");
107 shouldBeFalse("ctx.isPointInStroke(path,35,10)");
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698