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

Unified Diff: third_party/WebKit/LayoutTests/fast/canvas/canvas-isPointInPath-winding.html

Issue 2681423002: Use testharness.js instead of js-test.js in LayoutTests/fast/canvas tests. (Closed)
Patch Set: Adding exceptions to TestExpectations 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-isPointInPath-winding.html
diff --git a/third_party/WebKit/LayoutTests/fast/canvas/canvas-isPointInPath-winding.html b/third_party/WebKit/LayoutTests/fast/canvas/canvas-isPointInPath-winding.html
index 3da366513624241e128fad4a9eb4993c35c6eb52..82851c0fcd5211c55e957a60f741f1420a0edd04 100644
--- a/third_party/WebKit/LayoutTests/fast/canvas/canvas-isPointInPath-winding.html
+++ b/third_party/WebKit/LayoutTests/fast/canvas/canvas-isPointInPath-winding.html
@@ -1,8 +1,95 @@
-<!doctype html>
-<html>
-<head>
-<script src="../../resources/js-test.js"></script>
-</head>
-<body>
-<script src="script-tests/canvas-isPointInPath-winding.js"></script>
-</body>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<script>
+
+var canvas = document.createElement('canvas');
+canvas.width = 200;
+canvas.height = 200;
+ctx = canvas.getContext('2d');
+
+test(function(t) {
+ // Testing default isPointInPath');
+ ctx.beginPath();
+ ctx.rect(0, 0, 100, 100);
+ ctx.rect(25, 25, 50, 50);
+ assert_true(ctx.isPointInPath(50, 50));
+ assert_false(ctx.isPointInPath(NaN, 50));
+ assert_false(ctx.isPointInPath(50, NaN));
+
+ // Testing nonzero isPointInPath');
+ ctx.beginPath();
+ ctx.rect(0, 0, 100, 100);
+ ctx.rect(25, 25, 50, 50);
+ assert_true(ctx.isPointInPath(50, 50, 'nonzero'));
+
+ // Testing evenodd isPointInPath');
+ ctx.beginPath();
+ ctx.rect(0, 0, 100, 100);
+ ctx.rect(25, 25, 50, 50);
+ assert_false(ctx.isPointInPath(50, 50, 'evenodd'));
+
+ // reset path in context
+ ctx.beginPath();
+
+ // Testing default isPointInPath with Path object');
+ path = new Path2D();
+ path.rect(0, 0, 100, 100);
+ path.rect(25, 25, 50, 50);
+ assert_true(ctx.isPointInPath(path, 50, 50));
+ assert_true(ctx.isPointInPath(path, 50, 50, undefined));
+ assert_false(ctx.isPointInPath(path, NaN, 50));
+ assert_false(ctx.isPointInPath(path, 50, NaN));
+
+ // Testing nonzero isPointInPath with Path object');
+ path = new Path2D();
+ path.rect(0, 0, 100, 100);
+ path.rect(25, 25, 50, 50);
+ assert_true(ctx.isPointInPath(path, 50, 50, 'nonzero'));
+
+ // Testing evenodd isPointInPath with Path object');
+ path = new Path2D();
+ path.rect(0, 0, 100, 100);
+ path.rect(25, 25, 50, 50);
+ assert_false(ctx.isPointInPath(path, 50, 50, 'evenodd'));
+
+ // Testing invalid enumeration isPointInPath (w/ and w/o Path object');
+ assert_throws(null, function(){ ctx.isPointInPath(path, 50, 50, 'gazonk');});
+ assert_throws(null, function(){ ctx.isPointInPath(50, 50, 'gazonk');});
+
+ // Testing invalid type isPointInPath with Path object');
+ assert_throws(null, function(){ ctx.isPointInPath(null, 50, 50);});
+ assert_throws(null, function(){ ctx.isPointInPath(null, 50, 50, 'nonzero');});
+ assert_throws(null, function(){ ctx.isPointInPath(null, 50, 50, 'evenodd');});
+ assert_throws(null, function(){ ctx.isPointInPath(null, 50, 50, null);});
+ assert_throws(null, function(){ ctx.isPointInPath(path, 50, 50, null);});
+ assert_throws(null, function(){ ctx.isPointInPath(undefined, 50, 50);});
+ assert_throws(null, function(){ ctx.isPointInPath(undefined, 50, 50, 'nonzero');});
+ assert_throws(null, function(){ ctx.isPointInPath(undefined, 50, 50, 'evenodd');});
+ assert_throws(null, function(){ ctx.isPointInPath(undefined, 50, 50, undefined);});
+ assert_throws(null, function(){ ctx.isPointInPath([], 50, 50);});
+ assert_throws(null, function(){ ctx.isPointInPath([], 50, 50, 'nonzero');});
+ assert_throws(null, function(){ ctx.isPointInPath([], 50, 50, 'evenodd');});
+ assert_throws(null, function(){ ctx.isPointInPath({}, 50, 50);});
+ assert_throws(null, function(){ ctx.isPointInPath({}, 50, 50, 'nonzero');});
+ assert_throws(null, function(){ ctx.isPointInPath({}, 50, 50, 'evenodd');});
+
+ // Testing extremely large scale
+ ctx.save();
+ ctx.scale(Number.MAX_VALUE, Number.MAX_VALUE);
+ ctx.beginPath();
+ ctx.rect(-10, -10, 20, 20);
+ assert_true(ctx.isPointInPath(0, 0, 'nonzero'));
+ assert_true(ctx.isPointInPath(0, 0, 'evenodd'));
+ ctx.restore();
+
+ // Check with non-invertible ctm.
+ ctx.save();
+ ctx.scale(0, 0);
+ ctx.beginPath();
+ ctx.rect(-10, -10, 20, 20);
+ assert_false(ctx.isPointInPath(0, 0, 'nonzero'));
+ assert_false(ctx.isPointInPath(0, 0, 'evenodd'));
+ ctx.restore();
+}, "Series of tests to ensure correct results of the winding rule in isPointInPath.");
+
+</script>

Powered by Google App Engine
This is Rietveld 408576698