| Index: third_party/WebKit/LayoutTests/fast/canvas/canvas-isPointInStroke.html
|
| diff --git a/third_party/WebKit/LayoutTests/fast/canvas/canvas-isPointInStroke.html b/third_party/WebKit/LayoutTests/fast/canvas/canvas-isPointInStroke.html
|
| index 4c0b8427a2e22cbc54cbc92903e464d99b9cab1c..ab62eda9b2951fbe6fe3595bc2d13ae79a2d07b0 100644
|
| --- a/third_party/WebKit/LayoutTests/fast/canvas/canvas-isPointInStroke.html
|
| +++ b/third_party/WebKit/LayoutTests/fast/canvas/canvas-isPointInStroke.html
|
| @@ -1,8 +1,120 @@
|
| -<!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.js"></script>
|
| +<script>
|
| +var ctx = document.createElement('canvas').getContext('2d');
|
| +document.body.appendChild(ctx.canvas);
|
| +ctx.strokeStyle = '#0ff';
|
| +
|
| +// Create new path.
|
| +ctx.beginPath();
|
| +ctx.rect(20,20,100,100);
|
| +
|
| +function testPointInStroke(x, y, isPointInStroke) {
|
| + if(isPointInStroke)
|
| + assert_true(ctx.isPointInStroke(x, y));
|
| + else
|
| + assert_false(ctx.isPointInStroke(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],
|
| + ];
|
| +
|
| +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, testScenarios1);
|
| +ctx.lineWidth = 10;
|
| +generate_tests(testPointInStroke, testScenarios2);
|
| +
|
| +test(function(t) {
|
| + ctx.beginPath();
|
| + ctx.moveTo(10,10);
|
| + ctx.lineTo(110,20);
|
| + ctx.lineTo(10,30);
|
| + ctx.lineJoin = "bevel";
|
| + assert_false(ctx.isPointInStroke(113,20));
|
| +
|
| + ctx.miterLimit = 40.0;
|
| + ctx.lineJoin = "miter";
|
| + assert_true(ctx.isPointInStroke(113,20));
|
| +
|
| + ctx.miterLimit = 2.0;
|
| + assert_false(ctx.isPointInStroke(113,20));
|
| +
|
| + ctx.beginPath();
|
| + ctx.moveTo(10,10);
|
| + ctx.lineTo(110,10);
|
| + ctx.lineCap = "butt";
|
| + assert_false(ctx.isPointInStroke(112,10));
|
| +
|
| + ctx.lineCap = "round";
|
| + assert_true(ctx.isPointInStroke(112,10));
|
| + assert_false(ctx.isPointInStroke(117,10));
|
| +
|
| + ctx.lineCap = "square";
|
| + assert_true(ctx.isPointInStroke(112,10));
|
| + assert_false(ctx.isPointInStroke(117,10));
|
| +
|
| + ctx.lineCap = "butt";
|
| + ctx.setLineDash([10,10]);
|
| + assert_true(ctx.isPointInStroke(15,10));
|
| + assert_false(ctx.isPointInStroke(25,10));
|
| + assert_true(ctx.isPointInStroke(35,10));
|
| +
|
| + ctx.lineDashOffset = 10;
|
| + assert_false(ctx.isPointInStroke(15,10));
|
| + assert_true(ctx.isPointInStroke(25,10));
|
| + assert_false(ctx.isPointInStroke(35,10));
|
| +
|
| + ctx.save();
|
| + ctx.scale(Number.MAX_VALUE, Number.MAX_VALUE);
|
| + ctx.beginPath();
|
| + ctx.moveTo(-10, -10);
|
| + ctx.lineTo(10, 10);
|
| + assert_true(ctx.isPointInStroke(0, 0));
|
| + ctx.restore();
|
| +
|
| + ctx.save();
|
| + ctx.scale(0, 0);
|
| + ctx.beginPath();
|
| + ctx.moveTo(-10, -10);
|
| + ctx.lineTo(10, 10);
|
| + assert_false(ctx.isPointInStroke(0, 0));
|
| + ctx.restore();
|
| +}, "Test the behavior of isPointInStroke in Canvas");
|
| +
|
| +</script>
|
| </body>
|
|
|