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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/fast/canvas/canvas-hit-regions-clear-test.html
diff --git a/third_party/WebKit/LayoutTests/fast/canvas/canvas-hit-regions-clear-test.html b/third_party/WebKit/LayoutTests/fast/canvas/canvas-hit-regions-clear-test.html
index 2a18062435ccbef803519aa6e8a5d05755bd8b6e..484f248a7644f100c0a8ee77871c510c862a1c94 100644
--- a/third_party/WebKit/LayoutTests/fast/canvas/canvas-hit-regions-clear-test.html
+++ b/third_party/WebKit/LayoutTests/fast/canvas/canvas-hit-regions-clear-test.html
@@ -1,94 +1,91 @@
-<!DOCTYPE html>
-<html>
-<head>
- <title>Canvas Hit Regions: clear test</title>
- <script src="../../resources/js-test.js"></script>
-</head>
+<script src='../../resources/testharness.js'></script>
+<script src='../../resources/testharnessreport.js'></script>
<body>
-<canvas id="canvas" width="400" height="400">
- <button id="yellow"></button>
+<canvas id='canvas' width='400' height='400'>
+ <button id='yellow'></button>
</canvas>
-<script src="./resources/canvas-hit-region-event.js"></script>
+<script src='./resources/canvas-hit-region-event.js'></script>
<script>
- var canvas = document.getElementById("canvas");
- var context = canvas.getContext("2d");
-
- shouldBe("internals.countHitRegions(context)", "0");
-
- context.fillStyle = "red";
- context.rect(0, 0, 100, 100);
- context.fill();
- context.addHitRegion({ id : "red" });
- shouldBe("internals.countHitRegions(context)", "1");
-
- context.beginPath();
- context.fillStyle = "yellow";
- context.rect(100, 100, 50, 50);
- context.fill();
- context.addHitRegion({ id : "yellow", control : document.getElementById("yellow") });
- shouldBe("internals.countHitRegions(context)", "2");
-
- shouldBe("clickCanvas(60, 60)", "'red'");
- shouldBe("clickCanvas(120, 120)", "'yellow'");
-
- context.clearRect(50, 50, 50, 50);
- shouldBe("internals.countHitRegions(context)", "2");
- shouldBe("clickCanvas(60, 60)", "null");
- shouldBe("clickCanvas(120, 120)", "'yellow'");
-
- context.clearRect(100, 100, 50, 50);
- shouldBe("internals.countHitRegions(context)", "1");
- shouldBe("clickCanvas(120, 120)", "null");
-
- context.beginPath();
- context.fillStyle = "red";
- context.rect(60, 60, 40, 40);
- context.fill();
- shouldBe("clickCanvas(40, 40)", "'red'");
- context.addHitRegion({ id : "red" });
- shouldBe("internals.countHitRegions(context)", "1");
- shouldBe("clickCanvas(62, 62)", "'red'");
- shouldBe("clickCanvas(40, 40)", "null");
-
- context.beginPath();
- context.fillStyle = "yellow";
- context.rect(0, 0, 50, 50);
- context.fill();
- context.addHitRegion({ id : "yellow", control : document.getElementById("yellow") });
- shouldBe("internals.countHitRegions(context)", "2");
- shouldBe("clickCanvas(40, 40)", "'yellow'");
-
- context.beginPath();
- context.fillStyle = "yellow";
- context.rect(100, 0, 50, 50);
- context.fill();
- context.addHitRegion({ control : document.getElementById("yellow") });
- shouldBe("internals.countHitRegions(context)", "2");
- shouldBe("clickCanvas(40, 40)", "null");
- shouldBe("clickCanvas(101, 1)", "null");
-
- context.beginPath();
- context.fillStyle = "blue";
- context.rect(100, 50, 20, 20);
- context.fill();
- context.addHitRegion({ id : "blue" });
- shouldBe("internals.countHitRegions(context)", "3");
- shouldBe("clickCanvas(101, 51)", "'blue'");
-
- context.removeHitRegion("blue");
- shouldBe("internals.countHitRegions(context)", "2");
- shouldBe("clickCanvas(101, 51)", "null");
-
- context.clearHitRegions();
- shouldBe("internals.countHitRegions(context)", "0");
- shouldBe("clickCanvas(62, 62)", "null");
-
- context.clearRect(0, 0, 400, 400);
- shouldBe("internals.countHitRegions(context)", "0");
-
- debug("");
+test(function(t) {
+ var canvas = document.getElementById('canvas');
+ var context = canvas.getContext('2d');
+
+ assert_equals(internals.countHitRegions(context), 0);
+
+ context.fillStyle = 'red';
+ context.rect(0, 0, 100, 100);
+ context.fill();
+ context.addHitRegion({ id : 'red' });
+ assert_equals(internals.countHitRegions(context), 1);
+
+ context.beginPath();
+ context.fillStyle = 'yellow';
+ context.rect(100, 100, 50, 50);
+ context.fill();
+ context.addHitRegion({ id : 'yellow', control : document.getElementById('yellow') });
+ assert_equals(internals.countHitRegions(context), 2);
+
+ assert_equals(clickCanvas(60, 60), 'red');
+ assert_equals(clickCanvas(120, 120), 'yellow');
+
+ context.clearRect(50, 50, 50, 50);
+ assert_equals(internals.countHitRegions(context), 2);
+ assert_equals(clickCanvas(60, 60), null);
+ assert_equals(clickCanvas(120, 120), 'yellow');
+
+ context.clearRect(100, 100, 50, 50);
+ assert_equals(internals.countHitRegions(context), 1);
+ assert_equals(clickCanvas(120, 120), null);
+
+ context.beginPath();
+ context.fillStyle = 'red';
+ context.rect(60, 60, 40, 40);
+ context.fill();
+ assert_equals(clickCanvas(40, 40), 'red');
+
+ context.addHitRegion({ id : 'red' });
+ assert_equals(internals.countHitRegions(context), 1);
+ assert_equals(clickCanvas(62, 62), 'red');
+ assert_equals(clickCanvas(40, 40), null);
+
+ context.beginPath();
+ context.fillStyle = 'yellow';
+ context.rect(0, 0, 50, 50);
+ context.fill();
+ context.addHitRegion({ id : 'yellow', control : document.getElementById('yellow') });
+ assert_equals(internals.countHitRegions(context), 2);
+ assert_equals(clickCanvas(40, 40), 'yellow');
+
+ context.beginPath();
+ context.fillStyle = 'yellow';
+ context.rect(100, 0, 50, 50);
+ context.fill();
+ context.addHitRegion({ control : document.getElementById('yellow') });
+ assert_equals(internals.countHitRegions(context), 2);
+ assert_equals(clickCanvas(40, 40), null);
+ assert_equals(clickCanvas(101, 1), null);
+
+ context.beginPath();
+ context.fillStyle = 'blue';
+ context.rect(100, 50, 20, 20);
+ context.fill();
+ context.addHitRegion({ id : 'blue' });
+ assert_equals(internals.countHitRegions(context), 3);
+ assert_equals(clickCanvas(101, 51), 'blue');
+
+ context.removeHitRegion('blue');
+ assert_equals(internals.countHitRegions(context), 2);
+ assert_equals(clickCanvas(101, 51), null);
+
+ context.clearHitRegions();
+ assert_equals(internals.countHitRegions(context), 0);
+ assert_equals(clickCanvas(62, 62), null);
+
+ context.clearRect(0, 0, 400, 400);
+ assert_equals(internals.countHitRegions(context), 0);
+
+}, 'Test canvas hit regions: clear test.');
</script>
</body>
-</html>

Powered by Google App Engine
This is Rietveld 408576698