OLD | NEW |
1 description("Series of tests to ensure clip() works with path and winding rule p
arameters."); | 1 description("Series of tests to ensure clip() works with path and winding rule p
arameters."); |
2 | 2 |
3 var ctx = document.getElementById('canvas').getContext('2d'); | 3 var ctx = document.getElementById('canvas').getContext('2d'); |
4 | 4 |
5 function pixelDataAtPoint() { | 5 function pixelDataAtPoint() { |
6 return ctx.getImageData(50, 50, 1, 1).data; | 6 return ctx.getImageData(50, 50, 1, 1).data; |
7 } | 7 } |
8 | 8 |
9 function checkResult(expectedColors, sigma) { | 9 function checkResult(expectedColors, sigma) { |
10 for (var i = 0; i < 4; i++) | 10 for (var i = 0; i < 4; i++) |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 checkResult([255, 0, 0, 255], 5); | 48 checkResult([255, 0, 0, 255], 5); |
49 } else { | 49 } else { |
50 checkResult([0, 255, 0, 255], 5); | 50 checkResult([0, 255, 0, 255], 5); |
51 } | 51 } |
52 debug(''); | 52 debug(''); |
53 } | 53 } |
54 | 54 |
55 // Execute test. | 55 // Execute test. |
56 function prepareTestScenario() { | 56 function prepareTestScenario() { |
57 fillRules = [undefined, 'nonzero', 'evenodd']; | 57 fillRules = [undefined, 'nonzero', 'evenodd']; |
58 var path = new Path(); | 58 var path = new Path2D(); |
59 drawRectanglesOn(path); | 59 drawRectanglesOn(path); |
60 | 60 |
61 for (var i = 0; i < fillRules.length; i++) { | 61 for (var i = 0; i < fillRules.length; i++) { |
62 testClipWith(fillRules[i]); | 62 testClipWith(fillRules[i]); |
63 testClipWith(fillRules[i], path); | 63 testClipWith(fillRules[i], path); |
64 } | 64 } |
65 | 65 |
66 // Test exception cases. | 66 // Test exception cases. |
67 shouldThrow("ctx.clip(null)"); | 67 shouldThrow("ctx.clip(null)"); |
68 shouldThrow("ctx.clip(null, null)"); | 68 shouldThrow("ctx.clip(null, null)"); |
69 shouldThrow("ctx.clip(null, 'nonzero')"); | 69 shouldThrow("ctx.clip(null, 'nonzero')"); |
70 shouldThrow("ctx.clip([], 'nonzero')"); | 70 shouldThrow("ctx.clip([], 'nonzero')"); |
71 shouldThrow("ctx.clip({}, 'nonzero')"); | 71 shouldThrow("ctx.clip({}, 'nonzero')"); |
72 shouldThrow("ctx.clip(null, 'evenodd')"); | 72 shouldThrow("ctx.clip(null, 'evenodd')"); |
73 shouldThrow("ctx.clip([], 'evenodd')"); | 73 shouldThrow("ctx.clip([], 'evenodd')"); |
74 shouldThrow("ctx.clip({}, 'evenodd')"); | 74 shouldThrow("ctx.clip({}, 'evenodd')"); |
75 } | 75 } |
76 | 76 |
77 // Run test and allow variation of results. | 77 // Run test and allow variation of results. |
78 prepareTestScenario(); | 78 prepareTestScenario(); |
OLD | NEW |