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

Side by Side Diff: LayoutTests/fast/canvas/script-tests/canvas-path-constructors.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 different constructors of Path."); 1 description("Test different constructors of Path.");
2 var ctx = document.createElement('canvas').getContext('2d'); 2 var ctx = document.createElement('canvas').getContext('2d');
3 3
4 debug("Test constructor Path().") 4 debug("Test constructor Path().")
5 ctx.beginPath(); 5 ctx.beginPath();
6 var p1 = new Path(); 6 var p1 = new Path2D();
7 p1.rect(0,0,100,100); 7 p1.rect(0,0,100,100);
8 ctx.fillStyle = 'yellow'; 8 ctx.fillStyle = 'yellow';
9 ctx.currentPath = p1; 9 ctx.currentPath = p1;
10 ctx.fill(); 10 ctx.fill();
11 var imageData = ctx.getImageData(0, 0, 100, 100); 11 var imageData = ctx.getImageData(0, 0, 100, 100);
12 var imgdata = imageData.data; 12 var imgdata = imageData.data;
13 shouldBe("imgdata[4]", "255"); 13 shouldBe("imgdata[4]", "255");
14 shouldBe("imgdata[5]", "255"); 14 shouldBe("imgdata[5]", "255");
15 shouldBe("imgdata[6]", "0"); 15 shouldBe("imgdata[6]", "0");
16 shouldBe("imgdata[7]", "255"); 16 shouldBe("imgdata[7]", "255");
17 debug(""); 17 debug("");
18 18
19 debug("Test constructor Path(DOMString) which takes a SVG data string.") 19 debug("Test constructor Path(DOMString) which takes a SVG data string.")
20 ctx.beginPath(); 20 ctx.beginPath();
21 var p2 = new Path("M100,0L200,0L200,100L100,100z"); 21 var p2 = new Path2D("M100,0L200,0L200,100L100,100z");
22 ctx.currentPath = p2; 22 ctx.currentPath = p2;
23 ctx.fillStyle = 'blue'; 23 ctx.fillStyle = 'blue';
24 ctx.fill(); 24 ctx.fill();
25 imageData = ctx.getImageData(100, 0, 100, 100); 25 imageData = ctx.getImageData(100, 0, 100, 100);
26 imgdata = imageData.data; 26 imgdata = imageData.data;
27 shouldBe("imgdata[4]", "0"); 27 shouldBe("imgdata[4]", "0");
28 shouldBe("imgdata[5]", "0"); 28 shouldBe("imgdata[5]", "0");
29 shouldBe("imgdata[6]", "255"); 29 shouldBe("imgdata[6]", "255");
30 shouldBe("imgdata[7]", "255"); 30 shouldBe("imgdata[7]", "255");
31 debug(""); 31 debug("");
32 32
33 debug("Test constructor Path(Path) which takes another Path object.") 33 debug("Test constructor Path(Path) which takes another Path object.")
34 ctx.beginPath(); 34 ctx.beginPath();
35 var p3 = new Path(p1); 35 var p3 = new Path2D(p1);
36 ctx.translate(200,0); 36 ctx.translate(200,0);
37 ctx.currentPath = p3; 37 ctx.currentPath = p3;
38 ctx.fillStyle = 'green'; 38 ctx.fillStyle = 'green';
39 ctx.translate(-200,0); 39 ctx.translate(-200,0);
40 ctx.fill(); 40 ctx.fill();
41 imageData = ctx.getImageData(200, 0, 100, 100); 41 imageData = ctx.getImageData(200, 0, 100, 100);
42 imgdata = imageData.data; 42 imgdata = imageData.data;
43 shouldBe("imgdata[4]", "0"); 43 shouldBe("imgdata[4]", "0");
44 shouldBe("imgdata[5]", "128"); 44 shouldBe("imgdata[5]", "128");
45 shouldBe("imgdata[6]", "0"); 45 shouldBe("imgdata[6]", "0");
46 shouldBe("imgdata[7]", "255"); 46 shouldBe("imgdata[7]", "255");
47 debug(""); 47 debug("");
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698