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

Unified Diff: LayoutTests/fast/canvas/script-tests/canvas-isPointInPath-winding.js

Issue 179383002: Add versions of isPointIn*() that take a Path parameter. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase again Created 6 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: LayoutTests/fast/canvas/script-tests/canvas-isPointInPath-winding.js
diff --git a/LayoutTests/fast/canvas/script-tests/canvas-isPointInPath-winding.js b/LayoutTests/fast/canvas/script-tests/canvas-isPointInPath-winding.js
index 30d0a46d65d8d0611587f19446c9c67b4fd4fd7f..8dc6d26dab0598190c055504a5996639c7a40e2d 100644
--- a/LayoutTests/fast/canvas/script-tests/canvas-isPointInPath-winding.js
+++ b/LayoutTests/fast/canvas/script-tests/canvas-isPointInPath-winding.js
@@ -1,24 +1,19 @@
description("Series of tests to ensure correct results of the winding rule in isPointInPath.");
-
var tmpimg = document.createElement('canvas');
tmpimg.width = 200;
tmpimg.height = 200;
ctx = tmpimg.getContext('2d');
-// Create the image for blending test with images.
-var img = document.createElement('canvas');
-img.width = 100;
-img.height = 100;
-var imgCtx = img.getContext('2d');
-
// Execute test.
function prepareTestScenario() {
debug('Testing default isPointInPath');
ctx.beginPath();
ctx.rect(0, 0, 100, 100);
ctx.rect(25, 25, 50, 50);
- shouldBeTrue("ctx.isPointInPath(50, 50)");
+ shouldBeTrue("ctx.isPointInPath(50, 50)");
+ shouldBeFalse("ctx.isPointInPath(NaN, 50)");
+ shouldBeFalse("ctx.isPointInPath(50, NaN)");
debug('');
debug('Testing nonzero isPointInPath');
@@ -32,7 +27,52 @@ function prepareTestScenario() {
ctx.beginPath();
ctx.rect(0, 0, 100, 100);
ctx.rect(25, 25, 50, 50);
- shouldBeFalse("ctx.isPointInPath(50, 50, 'evenodd')");
+ shouldBeFalse("ctx.isPointInPath(50, 50, 'evenodd')");
+ debug('');
+
+ // reset path in context
+ ctx.beginPath();
+
+ debug('Testing default isPointInPath with Path object');
+ path = new Path();
+ path.rect(0, 0, 100, 100);
+ path.rect(25, 25, 50, 50);
+ shouldBeTrue("ctx.isPointInPath(path, 50, 50)");
+ shouldBeFalse("ctx.isPointInPath(path, NaN, 50)");
+ shouldBeFalse("ctx.isPointInPath(path, 50, NaN)");
+ debug('');
+
+ debug('Testing nonzero isPointInPath with Path object');
+ path = new Path();
+ path.rect(0, 0, 100, 100);
+ path.rect(25, 25, 50, 50);
+ shouldBeTrue("ctx.isPointInPath(path, 50, 50, 'nonzero')");
+ debug('');
+
+ debug('Testing evenodd isPointInPath with Path object');
+ path = new Path();
+ path.rect(0, 0, 100, 100);
+ path.rect(25, 25, 50, 50);
+ shouldBeFalse("ctx.isPointInPath(path, 50, 50, 'evenodd')");
+ debug('');
+
+ debug('Testing null isPointInPath with Path object');
+ path = null;
+ shouldThrow("ctx.isPointInPath(null, 50, 50)");
+ shouldThrow("ctx.isPointInPath(null, 50, 50, 'nonzero')");
+ shouldThrow("ctx.isPointInPath(null, 50, 50, 'evenodd')");
+ shouldThrow("ctx.isPointInPath(path, 50, 50)");
+ shouldThrow("ctx.isPointInPath(path, 50, 50, 'nonzero')");
+ shouldThrow("ctx.isPointInPath(path, 50, 50, 'evenodd')");
+ debug('');
+
+ debug('Testing invalid type isPointInPath with Path object');
+ shouldThrow("ctx.isPointInPath([], 50, 50)");
+ shouldThrow("ctx.isPointInPath([], 50, 50, 'nonzero')");
+ shouldThrow("ctx.isPointInPath([], 50, 50, 'evenodd')");
+ shouldThrow("ctx.isPointInPath({}, 50, 50)");
+ shouldThrow("ctx.isPointInPath({}, 50, 50, 'nonzero')");
+ shouldThrow("ctx.isPointInPath({}, 50, 50, 'evenodd')");
debug('');
}

Powered by Google App Engine
This is Rietveld 408576698