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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/canvas/canvas-hit-regions-clear-test.html

Issue 2679193002: 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
1 <!DOCTYPE html> 1 <script src='../../resources/testharness.js'></script>
2 <html> 2 <script src='../../resources/testharnessreport.js'></script>
3 <head>
4 <title>Canvas Hit Regions: clear test</title>
5 <script src="../../resources/js-test.js"></script>
6 </head>
7 <body> 3 <body>
8 <canvas id="canvas" width="400" height="400"> 4 <canvas id='canvas' width='400' height='400'>
9 <button id="yellow"></button> 5 <button id='yellow'></button>
10 </canvas> 6 </canvas>
11 <script src="./resources/canvas-hit-region-event.js"></script> 7 <script src='./resources/canvas-hit-region-event.js'></script>
12 <script> 8 <script>
13 9
14 var canvas = document.getElementById("canvas"); 10 test(function(t) {
15 var context = canvas.getContext("2d"); 11 var canvas = document.getElementById('canvas');
12 var context = canvas.getContext('2d');
16 13
17 shouldBe("internals.countHitRegions(context)", "0"); 14 assert_equals(internals.countHitRegions(context), 0);
18 15
19 context.fillStyle = "red"; 16 context.fillStyle = 'red';
20 context.rect(0, 0, 100, 100); 17 context.rect(0, 0, 100, 100);
21 context.fill(); 18 context.fill();
22 context.addHitRegion({ id : "red" }); 19 context.addHitRegion({ id : 'red' });
23 shouldBe("internals.countHitRegions(context)", "1"); 20 assert_equals(internals.countHitRegions(context), 1);
24 21
25 context.beginPath(); 22 context.beginPath();
26 context.fillStyle = "yellow"; 23 context.fillStyle = 'yellow';
27 context.rect(100, 100, 50, 50); 24 context.rect(100, 100, 50, 50);
28 context.fill(); 25 context.fill();
29 context.addHitRegion({ id : "yellow", control : document.getElementById("yello w") }); 26 context.addHitRegion({ id : 'yellow', control : document.getElementById('yel low') });
30 shouldBe("internals.countHitRegions(context)", "2"); 27 assert_equals(internals.countHitRegions(context), 2);
31 28
32 shouldBe("clickCanvas(60, 60)", "'red'"); 29 assert_equals(clickCanvas(60, 60), 'red');
33 shouldBe("clickCanvas(120, 120)", "'yellow'"); 30 assert_equals(clickCanvas(120, 120), 'yellow');
34 31
35 context.clearRect(50, 50, 50, 50); 32 context.clearRect(50, 50, 50, 50);
36 shouldBe("internals.countHitRegions(context)", "2"); 33 assert_equals(internals.countHitRegions(context), 2);
37 shouldBe("clickCanvas(60, 60)", "null"); 34 assert_equals(clickCanvas(60, 60), null);
38 shouldBe("clickCanvas(120, 120)", "'yellow'"); 35 assert_equals(clickCanvas(120, 120), 'yellow');
39 36
40 context.clearRect(100, 100, 50, 50); 37 context.clearRect(100, 100, 50, 50);
41 shouldBe("internals.countHitRegions(context)", "1"); 38 assert_equals(internals.countHitRegions(context), 1);
42 shouldBe("clickCanvas(120, 120)", "null"); 39 assert_equals(clickCanvas(120, 120), null);
43 40
44 context.beginPath(); 41 context.beginPath();
45 context.fillStyle = "red"; 42 context.fillStyle = 'red';
46 context.rect(60, 60, 40, 40); 43 context.rect(60, 60, 40, 40);
47 context.fill(); 44 context.fill();
48 shouldBe("clickCanvas(40, 40)", "'red'"); 45 assert_equals(clickCanvas(40, 40), 'red');
49 context.addHitRegion({ id : "red" });
50 shouldBe("internals.countHitRegions(context)", "1");
51 shouldBe("clickCanvas(62, 62)", "'red'");
52 shouldBe("clickCanvas(40, 40)", "null");
53 46
54 context.beginPath(); 47 context.addHitRegion({ id : 'red' });
55 context.fillStyle = "yellow"; 48 assert_equals(internals.countHitRegions(context), 1);
56 context.rect(0, 0, 50, 50); 49 assert_equals(clickCanvas(62, 62), 'red');
57 context.fill(); 50 assert_equals(clickCanvas(40, 40), null);
58 context.addHitRegion({ id : "yellow", control : document.getElementById("yello w") });
59 shouldBe("internals.countHitRegions(context)", "2");
60 shouldBe("clickCanvas(40, 40)", "'yellow'");
61 51
62 context.beginPath(); 52 context.beginPath();
63 context.fillStyle = "yellow"; 53 context.fillStyle = 'yellow';
64 context.rect(100, 0, 50, 50); 54 context.rect(0, 0, 50, 50);
65 context.fill(); 55 context.fill();
66 context.addHitRegion({ control : document.getElementById("yellow") }); 56 context.addHitRegion({ id : 'yellow', control : document.getElementById('yel low') });
67 shouldBe("internals.countHitRegions(context)", "2"); 57 assert_equals(internals.countHitRegions(context), 2);
68 shouldBe("clickCanvas(40, 40)", "null"); 58 assert_equals(clickCanvas(40, 40), 'yellow');
69 shouldBe("clickCanvas(101, 1)", "null");
70 59
71 context.beginPath(); 60 context.beginPath();
72 context.fillStyle = "blue"; 61 context.fillStyle = 'yellow';
73 context.rect(100, 50, 20, 20); 62 context.rect(100, 0, 50, 50);
74 context.fill(); 63 context.fill();
75 context.addHitRegion({ id : "blue" }); 64 context.addHitRegion({ control : document.getElementById('yellow') });
76 shouldBe("internals.countHitRegions(context)", "3"); 65 assert_equals(internals.countHitRegions(context), 2);
77 shouldBe("clickCanvas(101, 51)", "'blue'"); 66 assert_equals(clickCanvas(40, 40), null);
67 assert_equals(clickCanvas(101, 1), null);
78 68
79 context.removeHitRegion("blue"); 69 context.beginPath();
80 shouldBe("internals.countHitRegions(context)", "2"); 70 context.fillStyle = 'blue';
81 shouldBe("clickCanvas(101, 51)", "null"); 71 context.rect(100, 50, 20, 20);
72 context.fill();
73 context.addHitRegion({ id : 'blue' });
74 assert_equals(internals.countHitRegions(context), 3);
75 assert_equals(clickCanvas(101, 51), 'blue');
82 76
83 context.clearHitRegions(); 77 context.removeHitRegion('blue');
84 shouldBe("internals.countHitRegions(context)", "0"); 78 assert_equals(internals.countHitRegions(context), 2);
85 shouldBe("clickCanvas(62, 62)", "null"); 79 assert_equals(clickCanvas(101, 51), null);
86 80
87 context.clearRect(0, 0, 400, 400); 81 context.clearHitRegions();
88 shouldBe("internals.countHitRegions(context)", "0"); 82 assert_equals(internals.countHitRegions(context), 0);
83 assert_equals(clickCanvas(62, 62), null);
89 84
90 debug(""); 85 context.clearRect(0, 0, 400, 400);
86 assert_equals(internals.countHitRegions(context), 0);
87
88 }, 'Test canvas hit regions: clear test.');
91 89
92 </script> 90 </script>
93 </body> 91 </body>
94 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698