OLD | NEW |
1 description("Series of tests to ensure fill() works with path and winding rule p
arameters."); | 1 description("Series of tests to ensure fill() 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 checkResult([255, 0, 0, 255], 5); | 46 checkResult([255, 0, 0, 255], 5); |
47 } else { | 47 } else { |
48 checkResult([0, 255, 0, 255], 5); | 48 checkResult([0, 255, 0, 255], 5); |
49 } | 49 } |
50 debug(''); | 50 debug(''); |
51 } | 51 } |
52 | 52 |
53 // Execute test. | 53 // Execute test. |
54 function prepareTestScenario() { | 54 function prepareTestScenario() { |
55 fillRules = [undefined, 'nonzero', 'evenodd']; | 55 fillRules = [undefined, 'nonzero', 'evenodd']; |
56 var path = new Path(); | 56 var path = new Path2D(); |
57 drawRectanglesOn(path); | 57 drawRectanglesOn(path); |
58 | 58 |
59 for (var i = 0; i < fillRules.length; i++) { | 59 for (var i = 0; i < fillRules.length; i++) { |
60 testFillWith(fillRules[i]); | 60 testFillWith(fillRules[i]); |
61 testFillWith(fillRules[i], path); | 61 testFillWith(fillRules[i], path); |
62 } | 62 } |
63 | 63 |
64 // Test exception cases. | 64 // Test exception cases. |
65 shouldThrow("ctx.fill(null)"); | 65 shouldThrow("ctx.fill(null)"); |
66 shouldThrow("ctx.fill(null, null)"); | 66 shouldThrow("ctx.fill(null, null)"); |
67 shouldThrow("ctx.fill(null, 'nonzero')"); | 67 shouldThrow("ctx.fill(null, 'nonzero')"); |
68 shouldThrow("ctx.fill([], 'nonzero')"); | 68 shouldThrow("ctx.fill([], 'nonzero')"); |
69 shouldThrow("ctx.fill({}, 'nonzero')"); | 69 shouldThrow("ctx.fill({}, 'nonzero')"); |
70 shouldThrow("ctx.fill(null, 'evenodd')"); | 70 shouldThrow("ctx.fill(null, 'evenodd')"); |
71 shouldThrow("ctx.fill([], 'evenodd')"); | 71 shouldThrow("ctx.fill([], 'evenodd')"); |
72 shouldThrow("ctx.fill({}, 'evenodd')"); | 72 shouldThrow("ctx.fill({}, 'evenodd')"); |
73 } | 73 } |
74 | 74 |
75 // Run test and allow variation of results. | 75 // Run test and allow variation of results. |
76 prepareTestScenario(); | 76 prepareTestScenario(); |
OLD | NEW |