@@ -18,47 +18,39 @@ const Color _kBlack = Color.fromRGBO(0, 0, 0, 1.0);
18
18
const Color _kGreen = Color .fromRGBO (0 , 255 , 0 , 1.0 );
19
19
20
20
void main () {
21
- group ('Image.toByteData' , () {
22
- group ('RGBA format' , () {
23
- test ('works with simple image' , () async {
24
- final Image image = await Square4x4Image .image;
25
- final ByteData data = await image.toByteData ();
26
- expect (Uint8List .view (data.buffer), Square4x4Image .bytes);
27
- });
28
-
29
- test ('converts grayscale images' , () async {
30
- final Image image = await GrayscaleImage .load ();
31
- final ByteData data = await image.toByteData ();
32
- final Uint8List bytes = data.buffer.asUint8List ();
33
- expect (bytes, hasLength (16 ));
34
- expect (bytes, GrayscaleImage .bytesAsRgba);
35
- });
36
- });
37
-
38
- group ('Unmodified format' , () {
39
- test ('works with simple image' , () async {
40
- final Image image = await Square4x4Image .image;
41
- final ByteData data = await image.toByteData (format: ImageByteFormat .rawUnmodified);
42
- expect (Uint8List .view (data.buffer), Square4x4Image .bytes);
43
- });
44
-
45
- test ('works with grayscale images' , () async {
46
- final Image image = await GrayscaleImage .load ();
47
- final ByteData data = await image.toByteData (format: ImageByteFormat .rawUnmodified);
48
- final Uint8List bytes = data.buffer.asUint8List ();
49
- expect (bytes, hasLength (4 ));
50
- expect (bytes, GrayscaleImage .bytesUnmodified);
51
- });
52
- });
53
-
54
- group ('PNG format' , () {
55
- test ('works with simple image' , () async {
56
- final Image image = await Square4x4Image .image;
57
- final ByteData data = await image.toByteData (format: ImageByteFormat .png);
58
- final List <int > expected = await readFile ('square.png' );
59
- expect (Uint8List .view (data.buffer), expected);
60
- });
61
- });
21
+ test ('Image.toByteData RGBA format works with simple image' , () async {
22
+ final Image image = await Square4x4Image .image;
23
+ final ByteData data = await image.toByteData ();
24
+ expect (Uint8List .view (data.buffer), Square4x4Image .bytes);
25
+ });
26
+
27
+ test ('Image.toByteData RGBA format converts grayscale images' , () async {
28
+ final Image image = await GrayscaleImage .load ();
29
+ final ByteData data = await image.toByteData ();
30
+ final Uint8List bytes = data.buffer.asUint8List ();
31
+ expect (bytes, hasLength (16 ));
32
+ expect (bytes, GrayscaleImage .bytesAsRgba);
33
+ });
34
+
35
+ test ('Image.toByteData Unmodified format works with simple image' , () async {
36
+ final Image image = await Square4x4Image .image;
37
+ final ByteData data = await image.toByteData (format: ImageByteFormat .rawUnmodified);
38
+ expect (Uint8List .view (data.buffer), Square4x4Image .bytes);
39
+ });
40
+
41
+ test ('Image.toByteData Unmodified format works with grayscale images' , () async {
42
+ final Image image = await GrayscaleImage .load ();
43
+ final ByteData data = await image.toByteData (format: ImageByteFormat .rawUnmodified);
44
+ final Uint8List bytes = data.buffer.asUint8List ();
45
+ expect (bytes, hasLength (4 ));
46
+ expect (bytes, GrayscaleImage .bytesUnmodified);
47
+ });
48
+
49
+ test ('Image.toByteData PNG format works with simple image' , () async {
50
+ final Image image = await Square4x4Image .image;
51
+ final ByteData data = await image.toByteData (format: ImageByteFormat .png);
52
+ final List <int > expected = await readFile ('square.png' );
53
+ expect (Uint8List .view (data.buffer), expected);
62
54
});
63
55
}
64
56
0 commit comments