Chromium Code Reviews| Index: tests/html/canvasrenderingcontext2d_test.dart |
| diff --git a/tests/html/canvasrenderingcontext2d_test.dart b/tests/html/canvasrenderingcontext2d_test.dart |
| index 8de0001d8540ccf535173a8d836e964ea7814255..c53fdd0fa6c1a69e7316bdfce789efacc07c40ba 100644 |
| --- a/tests/html/canvasrenderingcontext2d_test.dart |
| +++ b/tests/html/canvasrenderingcontext2d_test.dart |
| @@ -159,14 +159,15 @@ main() { |
| }); |
| test('putImageData', () { |
| + context.fillStyle = 'green'; |
| + context.fillRect(0, 0, canvas.width, canvas.height); |
| + |
| ImageData expectedData = context.getImageData(0, 0, 10, 10); |
| expectedData.data[0] = 25; |
| expectedData.data[1] = 65; |
| expectedData.data[2] = 255; |
| // Set alpha to 255 to make the pixels show up. |
| expectedData.data[3] = 255; |
| - context.fillStyle = 'green'; |
| - context.fillRect(0, 0, canvas.width, canvas.height); |
| context.putImageData(expectedData, 0, 0); |
| @@ -174,6 +175,51 @@ main() { |
| // Make sure that we read back what we wrote. |
| expect(resultingData.data, expectedData.data); |
| }); |
| + |
| + test('putImageData dirty rectangle', () { |
| + context.fillStyle = 'green'; |
| + context.fillRect(0, 0, canvas.width, canvas.height); |
| + |
| + ImageData drawnData = context.getImageData(0, 0, 10, 10); |
| + drawnData.data[0] = 25; |
| + drawnData.data[1] = 65; |
| + drawnData.data[2] = 255; |
| + // Set alpha to 255 to make the pixels show up. |
| + drawnData.data[3] = 255; |
| + |
| + // Draw these pixels to the 8th pixel. |
| + drawnData.data[9 * 4 + 0] = 25; |
| + drawnData.data[9 * 4 + 1] = 65; |
| + drawnData.data[9 * 4 + 2] = 255; |
| + // Set alpha to 255 to make the pixels show up. |
| + drawnData.data[9 * 4 + 3] = 255; |
| + |
| + // Use a dirty rectangle to limit what pixels are drawn. |
| + context.putImageData(drawnData, 0, 0, 1, 1, 5, 5); |
|
sra1
2013/05/09 22:11:20
Have a separate test for passing 4/5/6 arguments t
|
| + |
| + // Expect the data to be all green, as we skip all drawn pixels. |
|
sra1
2013/05/09 22:11:20
Have one pixel actually change otherwise the test
|
| + ImageData expectedData = context.createImageData(10, 10); |
| + for (int i = 0; i < expectedData.data.length; i++) { |
| + switch (i % 4) { |
| + case 0: |
| + expectedData.data[i] = 0; |
| + break; |
| + case 1: |
| + expectedData.data[i] = 128; |
| + break; |
| + case 2: |
| + expectedData.data[i] = 0; |
| + break; |
| + case 3: |
| + expectedData.data[i] = 255; |
| + break; |
| + } |
| + } |
| + |
| + // Make sure that our data is all green. |
| + var resultingData = context.getImageData(0, 0, 10, 10); |
| + expect(resultingData.data, expectedData.data); |
| + }); |
| }); |
| group('arc', () { |