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..fced4c9f80e6d4e292fa6aefe363baeb43f7bb90 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,111 @@ |
-<!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); |
+ |
+assert_throws(null, function() {ctx.isPointInStroke(null, 70, 20);}); |
Justin Novosad
2017/02/16 15:41:55
These asserts should be inside a test()
zakerinasab
2017/02/16 18:12:40
Done.
|
+assert_throws(null, function() {ctx.isPointInStroke(undefined, 70, 20);}); |
+assert_throws(null, function() {ctx.isPointInStroke([], 20, 70);}); |
+assert_throws(null, function() {ctx.isPointInStroke({}, 120, 70);}); |
+ |
+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> |