OLD | NEW |
---|---|
(Empty) | |
1 description("Test ImageData constructor"); | |
2 | |
3 shouldBeDefined("ImageData"); | |
4 shouldBe("ImageData.length", "2"); | |
5 | |
6 imageData = new ImageData(100, 50); | |
7 | |
8 shouldBeNonNull("imageData"); | |
9 shouldBeNonNull("imageData.data"); | |
10 shouldBe("imageData.data[11]", "0"); | |
Justin Novosad
2014/03/24 14:21:09
Why 11? Should check at least one of each RGBA com
sof
2014/03/24 14:57:21
Good idea; switched to peeking&poking over RGBA va
| |
11 for (i = 0; i < imageData.data.length; ++i) { | |
12 imageData.data[i] = 231; | |
Justin Novosad
2014/03/24 14:21:09
Why set everything to 231? You only check element
| |
13 } | |
14 | |
15 shouldBe("imageData.width", "100"); | |
16 shouldBe("imageData.height", "50"); | |
17 shouldBe("imageData.data[32]", "231"); | |
18 | |
19 shouldThrow("new ImageData(10)"); | |
20 shouldThrow("new ImageData(0, 10)"); | |
21 shouldThrow("new ImageData(10, 0)"); | |
22 shouldThrow("new ImageData('width', 'height')"); | |
23 shouldThrow("new ImageData(1 << 31, 1 << 31)"); | |
24 | |
25 shouldThrow("new ImageData(new Uint8ClampedArray(0))"); | |
26 shouldThrow("new ImageData(new Uint8Array(100), 25)"); | |
27 shouldThrow("new ImageData(new Uint8ClampedArray(27), 2)"); | |
28 shouldThrow("new ImageData(new Uint8ClampedArray(104), 14)"); | |
29 shouldThrow("new ImageData(imageData.data, 0)"); | |
30 shouldThrow("new ImageData(imageData.data, 13)"); | |
31 shouldThrow("new ImageData(imageData.data, 1 << 31)"); | |
32 shouldThrow("new ImageData(imageData.data, 'biggish')"); | |
33 shouldThrow("new ImageData(imageData.data, 1 << 24, 1 << 31)"); | |
34 | |
35 imageDataFromData = new ImageData(imageData.data, 100); | |
Justin Novosad
2014/03/24 14:00:11
Would be good to exercise a successful call to thi
sof
2014/03/24 14:57:21
Done.
| |
36 shouldBe("imageDataFromData.width", "100"); | |
37 shouldBe("imageDataFromData.height", "50"); | |
38 shouldBe("imageDataFromData.data[34]", "imageData.data[34]"); | |
OLD | NEW |