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

Side by Side 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 unified diff | Download patch
OLDNEW
1 <!doctype html> 1 <script src="../../resources/testharness.js"></script>
2 <html> 2 <script src="../../resources/testharnessreport.js"></script>
3 <head>
4 <script src="../../resources/js-test.js"></script>
5 </head>
6 <body> 3 <body>
7 <script src="script-tests/canvas-isPointInStroke-with-path.js"></script> 4 <script>
5 var ctx = document.createElement('canvas').getContext('2d');
6 document.body.appendChild(ctx.canvas);
7 ctx.strokeStyle = '#0ff';
8
9 // Create new path.
10 var path = new Path2D();
11 path.rect(20, 20, 100, 100);
12
13 function testPointInStroke(x, y, isPointInStroke) {
14 if(isPointInStroke)
15 assert_true(ctx.isPointInStroke(path, x, y));
16 else
17 assert_false(ctx.isPointInStroke(path, x, y));
18 }
19
20 testScenarios1 =
21 [
22 ['TestScenario 1, Case 1', 20, 20, true],
23 ['TestScenario 1, Case 2', 120, 20, true],
24 ['TestScenario 1, Case 3', 20, 120, true],
25 ['TestScenario 1, Case 4', 120, 120, true],
26 ['TestScenario 1, Case 5', 70, 20, true],
27 ['TestScenario 1, Case 6', 20, 70, true],
28 ['TestScenario 1, Case 7', 120, 70, true],
29 ['TestScenario 1, Case 8', 70, 120, true],
30
31 ['TestScenario 1, Case 9', 22, 22, false],
32 ['TestScenario 1, Case 10', 118, 22, false],
33 ['TestScenario 1, Case 11', 22, 118, false],
34 ['TestScenario 1, Case 12', 118, 118, false],
35 ['TestScenario 1, Case 13', 70, 18, false],
36 ['TestScenario 1, Case 14', 122, 70, false],
37 ['TestScenario 1, Case 15', 70, 122, false],
38 ['TestScenario 1, Case 16', 18, 70, false],
39 ['TestScenario 1, Case 17', NaN, 122, false],
40 ['TestScenario 1, Case 18', 18, NaN, false]
41 ];
42 generate_tests(testPointInStroke, testScenarios1);
43
44 test(function(t) {
45 assert_throws(new TypeError(), function() {ctx.isPointInStroke(null, 70, 20) ;});
46 assert_throws(new TypeError(), function() {ctx.isPointInStroke(undefined, 70 , 20);});
47 assert_throws(new TypeError(), function() {ctx.isPointInStroke([], 20, 70);} );
48 assert_throws(new TypeError(), function() {ctx.isPointInStroke({}, 120, 70); });
49 }, "isPointInStroke in Canvas throws exception with invalid parameters.");
50
51 ctx.lineWidth = 10;
52 testScenarios2 =
53 [
54 ['TestScenario 2, Case 1', 22, 22, true],
55 ['TestScenario 2, Case 2', 118, 22, true],
56 ['TestScenario 2, Case 3', 22, 118, true],
57 ['TestScenario 2, Case 4', 118, 118, true],
58 ['TestScenario 2, Case 5', 70, 18, true],
59 ['TestScenario 2, Case 6', 122, 70, true],
60 ['TestScenario 2, Case 7', 70, 122, true],
61 ['TestScenario 2, Case 8', 18, 70, true],
62
63 ['TestScenario 2, Case 9', 26, 70, false],
64 ['TestScenario 2, Case 10', 70, 26, false],
65 ['TestScenario 2, Case 11', 70, 114, false],
66 ['TestScenario 2, Case 12', 114, 70, false]
67 ];
68 generate_tests(testPointInStroke, testScenarios2);
69
70 test(function(t) {
71
72 path = new Path2D();
73 path.moveTo(10,10);
74 path.lineTo(110,20);
75 path.lineTo(10,30);
76 ctx.lineJoin = "bevel";
77 assert_false(ctx.isPointInStroke(path,113,20));
78
79 ctx.miterLimit = 40.0;
80 ctx.lineJoin = "miter";
81 assert_true(ctx.isPointInStroke(path,113,20));
82
83 ctx.miterLimit = 2.0;
84 assert_false(ctx.isPointInStroke(path,113,20));
85
86 path = new Path2D();
87 path.moveTo(10,10);
88 path.lineTo(110,10);
89 ctx.lineCap = "butt";
90 assert_false(ctx.isPointInStroke(path,112,10));
91
92 ctx.lineCap = "round";
93 assert_true(ctx.isPointInStroke(path,112,10));
94 assert_false(ctx.isPointInStroke(path,117,10));
95
96 ctx.lineCap = "square";
97 assert_true(ctx.isPointInStroke(path,112,10));
98 assert_false(ctx.isPointInStroke(path,117,10));
99
100 ctx.lineCap = "butt";
101 ctx.setLineDash([10,10]);
102 assert_true(ctx.isPointInStroke(path,15,10));
103 assert_false(ctx.isPointInStroke(path,25,10));
104 assert_true(ctx.isPointInStroke(path,35,10));
105
106 ctx.lineDashOffset = 10;
107 assert_false(ctx.isPointInStroke(path,15,10));
108 assert_true(ctx.isPointInStroke(path,25,10));
109 assert_false(ctx.isPointInStroke(path,35,10));
110
111 }, "Test the behavior of isPointInStroke in Canvas with path object");
112 </script>
8 </body> 113 </body>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698