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

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

Issue 178673002: Rename Path to Path2D (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@path
Patch Set: Merge to head which includes isPoint and addPath changes. 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("Test the behavior of currentPath in Canvas"); 1 description("Test the behavior of currentPath in Canvas");
2 var ctx = document.createElement('canvas').getContext('2d'); 2 var c = document.createElement('canvas');
3 document.body.appendChild(c);
4 var ctx = c.getContext('2d');
3 5
4 var testStrings = [ 6 var testStrings = [
5 "ctx.isPointInPath(49,49)", 7 "ctx.isPointInPath(49,49)",
6 "ctx.isPointInPath(99,99)", 8 "ctx.isPointInPath(99,99)",
7 "ctx.isPointInPath(149,149)", 9 "ctx.isPointInPath(149,149)",
8 "ctx.isPointInPath(199,199)", 10 "ctx.isPointInPath(199,199)",
9 "ctx.isPointInPath(249,249)" 11 "ctx.isPointInPath(249,249)"
10 ]; 12 ];
11 13
12 // Test collection of points. Each point has an offset of 50,50 to previous poin t. 14 // Test collection of points. Each point has an offset of 50,50 to previous poin t.
13 function testPointCollection(hitResults) { 15 function testPointCollection(hitResults) {
14 for (var i = 0; i < hitResults.length; i++) { 16 for (var i = 0; i < hitResults.length; i++) {
15 if (hitResults[i]) 17 if (hitResults[i])
16 shouldBeTrue(testStrings[i]); 18 shouldBeTrue(testStrings[i]);
17 else 19 else
18 shouldBeFalse(testStrings[i]); 20 shouldBeFalse(testStrings[i]);
19 } 21 }
20 } 22 }
21 23
22 document.body.appendChild(ctx.canvas); 24 document.body.appendChild(ctx.canvas);
23 25
24 ctx.fillStyle = '#0f0'; 26 ctx.fillStyle = '#0f0';
25 ctx.beginPath(); 27 ctx.beginPath();
26 28
27 debug("Create path object, replace current context path with the path of this ob ject."); 29 debug("Create path object, replace current context path with the path of this ob ject.");
28 var p = new Path(); 30 var p = new Path2D();
29 p.rect(0,0,200,200); 31 p.rect(0,0,200,200);
30 testPointCollection([false, false, false, false, false]); 32 testPointCollection([false, false, false, false, false]);
31 33
32 ctx.currentPath = p; 34 ctx.currentPath = p;
33 35
34 testPointCollection([true, true, true, true, false]); 36 testPointCollection([true, true, true, true, false]);
35 debug(""); 37 debug("");
36 38
37 debug("Add new segment to context path and check that this is not added to the p ath object (not live).") 39 debug("Add new segment to context path and check that this is not added to the p ath object (not live).")
38 40
(...skipping 14 matching lines...) Expand all
53 testPointCollection([false, false, true, true, true]); 55 testPointCollection([false, false, true, true, true]);
54 56
55 debug(""); 57 debug("");
56 58
57 debug("Test that currentPath returns a path object."); 59 debug("Test that currentPath returns a path object.");
58 p = null; 60 p = null;
59 shouldBeNull("p"); 61 shouldBeNull("p");
60 ctx.beginPath(); 62 ctx.beginPath();
61 ctx.rect(0,0,200,200); 63 ctx.rect(0,0,200,200);
62 p = ctx.currentPath; 64 p = ctx.currentPath;
63 shouldBeType("p", "Path"); 65 shouldBeType("p", "Path2D");
64 debug(""); 66 debug("");
65 67
66 debug("Create context path and test that it exists."); 68 debug("Create context path and test that it exists.");
67 testPointCollection([true, true, true, true, false]); 69 testPointCollection([true, true, true, true, false]);
68 debug(""); 70 debug("");
69 71
70 debug("Clear context path."); 72 debug("Clear context path.");
71 ctx.beginPath(); 73 ctx.beginPath();
72 testPointCollection([false, false, false, false, false]); 74 testPointCollection([false, false, false, false, false]);
73 debug(""); 75 debug("");
(...skipping 13 matching lines...) Expand all
87 p = ctx.currentPath; 89 p = ctx.currentPath;
88 90
89 debug("Clear current path on object and check that it is cleaned up."); 91 debug("Clear current path on object and check that it is cleaned up.");
90 ctx.beginPath(); 92 ctx.beginPath();
91 testPointCollection([false, false, false, false, false]); 93 testPointCollection([false, false, false, false, false]);
92 debug(""); 94 debug("");
93 95
94 debug("Apply path back to context path.") 96 debug("Apply path back to context path.")
95 ctx.currentPath = p; 97 ctx.currentPath = p;
96 testPointCollection([true, true, false, true, true]); 98 testPointCollection([true, true, false, true, true]);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698