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: third_party/WebKit/LayoutTests/fast/canvas/canvas-isPointInStroke-with-path.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-isPointInStroke-with-path.html
diff --git a/third_party/WebKit/LayoutTests/fast/canvas/canvas-isPointInStroke-with-path.html b/third_party/WebKit/LayoutTests/fast/canvas/canvas-isPointInStroke-with-path.html
index 48c355dd9d660469ff51c7198e00c9370abdfce8..3ba08b0150d0c336c09da3b1a1360086d068e0d0 100644
--- a/third_party/WebKit/LayoutTests/fast/canvas/canvas-isPointInStroke-with-path.html
+++ b/third_party/WebKit/LayoutTests/fast/canvas/canvas-isPointInStroke-with-path.html
@@ -1,8 +1,113 @@
-<!doctype html>
-<html>
-<head>
-<script src="../../resources/js-test.js"></script>
-</head>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
<body>
-<script src="script-tests/canvas-isPointInStroke-with-path.js"></script>
+<script>
+var ctx = document.createElement('canvas').getContext('2d');
+document.body.appendChild(ctx.canvas);
+ctx.strokeStyle = '#0ff';
+
+// Create new path.
+var path = new Path2D();
+path.rect(20, 20, 100, 100);
+
+function testPointInStroke(x, y, isPointInStroke) {
+ if(isPointInStroke)
+ assert_true(ctx.isPointInStroke(path, x, y));
+ else
+ assert_false(ctx.isPointInStroke(path, x, y));
+}
+
+testScenarios1 =
+ [
+ ['TestScenario 1, Case 1', 20, 20, true],
+ ['TestScenario 1, Case 2', 120, 20, true],
+ ['TestScenario 1, Case 3', 20, 120, true],
+ ['TestScenario 1, Case 4', 120, 120, true],
+ ['TestScenario 1, Case 5', 70, 20, true],
+ ['TestScenario 1, Case 6', 20, 70, true],
+ ['TestScenario 1, Case 7', 120, 70, true],
+ ['TestScenario 1, Case 8', 70, 120, true],
+
+ ['TestScenario 1, Case 9', 22, 22, false],
+ ['TestScenario 1, Case 10', 118, 22, false],
+ ['TestScenario 1, Case 11', 22, 118, false],
+ ['TestScenario 1, Case 12', 118, 118, false],
+ ['TestScenario 1, Case 13', 70, 18, false],
+ ['TestScenario 1, Case 14', 122, 70, false],
+ ['TestScenario 1, Case 15', 70, 122, false],
+ ['TestScenario 1, Case 16', 18, 70, false],
+ ['TestScenario 1, Case 17', NaN, 122, false],
+ ['TestScenario 1, Case 18', 18, NaN, false]
+ ];
+generate_tests(testPointInStroke, testScenarios1);
+
+test(function(t) {
+ assert_throws(new TypeError(), function() {ctx.isPointInStroke(null, 70, 20);});
+ assert_throws(new TypeError(), function() {ctx.isPointInStroke(undefined, 70, 20);});
+ assert_throws(new TypeError(), function() {ctx.isPointInStroke([], 20, 70);});
+ assert_throws(new TypeError(), function() {ctx.isPointInStroke({}, 120, 70);});
+}, "isPointInStroke in Canvas throws exception with invalid parameters.");
+
+ctx.lineWidth = 10;
+testScenarios2 =
+ [
+ ['TestScenario 2, Case 1', 22, 22, true],
+ ['TestScenario 2, Case 2', 118, 22, true],
+ ['TestScenario 2, Case 3', 22, 118, true],
+ ['TestScenario 2, Case 4', 118, 118, true],
+ ['TestScenario 2, Case 5', 70, 18, true],
+ ['TestScenario 2, Case 6', 122, 70, true],
+ ['TestScenario 2, Case 7', 70, 122, true],
+ ['TestScenario 2, Case 8', 18, 70, true],
+
+ ['TestScenario 2, Case 9', 26, 70, false],
+ ['TestScenario 2, Case 10', 70, 26, false],
+ ['TestScenario 2, Case 11', 70, 114, false],
+ ['TestScenario 2, Case 12', 114, 70, false]
+ ];
+generate_tests(testPointInStroke, testScenarios2);
+
+test(function(t) {
+
+ path = new Path2D();
+ path.moveTo(10,10);
+ path.lineTo(110,20);
+ path.lineTo(10,30);
+ ctx.lineJoin = "bevel";
+ assert_false(ctx.isPointInStroke(path,113,20));
+
+ ctx.miterLimit = 40.0;
+ ctx.lineJoin = "miter";
+ assert_true(ctx.isPointInStroke(path,113,20));
+
+ ctx.miterLimit = 2.0;
+ assert_false(ctx.isPointInStroke(path,113,20));
+
+ path = new Path2D();
+ path.moveTo(10,10);
+ path.lineTo(110,10);
+ ctx.lineCap = "butt";
+ assert_false(ctx.isPointInStroke(path,112,10));
+
+ ctx.lineCap = "round";
+ assert_true(ctx.isPointInStroke(path,112,10));
+ assert_false(ctx.isPointInStroke(path,117,10));
+
+ ctx.lineCap = "square";
+ assert_true(ctx.isPointInStroke(path,112,10));
+ assert_false(ctx.isPointInStroke(path,117,10));
+
+ ctx.lineCap = "butt";
+ ctx.setLineDash([10,10]);
+ assert_true(ctx.isPointInStroke(path,15,10));
+ assert_false(ctx.isPointInStroke(path,25,10));
+ assert_true(ctx.isPointInStroke(path,35,10));
+
+ ctx.lineDashOffset = 10;
+ assert_false(ctx.isPointInStroke(path,15,10));
+ assert_true(ctx.isPointInStroke(path,25,10));
+ assert_false(ctx.isPointInStroke(path,35,10));
+
+}, "Test the behavior of isPointInStroke in Canvas with path object");
+</script>
</body>

Powered by Google App Engine
This is Rietveld 408576698