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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/canvas/pointInPath.js

Issue 2701053003: 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
OLDNEW
(Empty)
1 description("Series of tests for Canvas.isPointInPath");
2
3 ctx = document.getElementById("canvas").getContext("2d");
4 ctx.save();
5 debug("Rectangle at (0,0) 20x20");
6 ctx.rect(0, 0, 20, 20);
7 shouldBe("ctx.isPointInPath(5, 5)", "true");
8 shouldBe("ctx.isPointInPath(10, 10)", "true");
9 shouldBe("ctx.isPointInPath(19, 19)", "true");
10 shouldBe("ctx.isPointInPath(30, 30)", "false");
11 shouldBe("ctx.isPointInPath(-1, 10)", "false");
12 shouldBe("ctx.isPointInPath(10, -1)", "false");
13 debug("Translate context (10,10)");
14 ctx.translate(10,10);
15 shouldBe("ctx.isPointInPath(5, 5)", "true");
16 shouldBe("ctx.isPointInPath(10, 10)", "true");
17 shouldBe("ctx.isPointInPath(19, 19)", "true");
18 shouldBe("ctx.isPointInPath(30, 30)", "false");
19 shouldBe("ctx.isPointInPath(-1, 10)", "false");
20 shouldBe("ctx.isPointInPath(10, -1)", "false");
21 debug("Collapse ctm to non-invertible matrix");
22 ctx.scale(0,0);
23 shouldBe("ctx.isPointInPath(5, 5)", "false");
24 shouldBe("ctx.isPointInPath(10, 10)", "false");
25 shouldBe("ctx.isPointInPath(20, 20)", "false");
26 shouldBe("ctx.isPointInPath(30, 30)", "false");
27 shouldBe("ctx.isPointInPath(-1, 10)", "false");
28 shouldBe("ctx.isPointInPath(10, -1)", "false");
29 debug("Resetting context to a clean state");
30 ctx.restore();
31
32 ctx.save();
33 ctx.beginPath();
34 debug("Translate context (10,10)");
35 ctx.translate(10,10);
36 debug("Rectangle at (0,0) 20x20");
37 ctx.rect(0, 0, 20, 20);
38 shouldBe("ctx.isPointInPath(5, 5)", "false");
39 shouldBe("ctx.isPointInPath(10, 10)", "true");
40 shouldBe("ctx.isPointInPath(20, 20)", "true");
41 shouldBe("ctx.isPointInPath(29, 29)", "true");
42 shouldBe("ctx.isPointInPath(-1, 10)", "false");
43 shouldBe("ctx.isPointInPath(10, -1)", "false");
44 ctx.restore();
45
46 ctx.save();
47 ctx.beginPath();
48 debug("Translate context (10,20)");
49 ctx.translate(10,20);
50 debug("Transform context (1, 0, 0, -1, 0, 0)");
51 ctx.transform(1, 0, 0, -1, 0, 0);
52 debug("Rectangle at (0,0) 20x20");
53 ctx.rect(0, 0, 20, 20);
54 // After the flip, rect is actually 10, 0, 20, 20
55 shouldBe("ctx.isPointInPath(5, 5)", "false");
56 shouldBe("ctx.isPointInPath(10, 0)", "true");
57 shouldBe("ctx.isPointInPath(29, 0)", "true");
58 shouldBe("ctx.isPointInPath(10, 19)", "true");
59 shouldBe("ctx.isPointInPath(21, 10)", "true");
60 shouldBe("ctx.isPointInPath(29, 19)", "true");
61 ctx.strokeStyle = 'green';
62 ctx.stroke();
63 ctx.restore();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698