@@ -16,39 +16,38 @@ void main() {
1616}
1717
1818Future <void > testMain () async {
19- setUpUnitTests ();
20-
21- Future <Image > createTestImageByColor (Color color) async {
22- final PictureRecorder recorder = PictureRecorder ();
23- final Canvas canvas = Canvas (recorder, const Rect .fromLTRB (0 , 0 , 2 , 2 ));
24- canvas.drawColor (color, BlendMode .srcOver);
25- final Picture testPicture = recorder.endRecording ();
26- final Image testImage = await testPicture.toImage (2 , 2 );
27- return testImage;
28- }
29-
30- test ('Picture.toImage().toByteData()' , () async {
31- final Image testImage = await createTestImageByColor (const Color (0xFFCCDD00 ));
32-
33- final ByteData bytes = (await testImage.toByteData ())! ;
34- expect (bytes.buffer.asUint32List (), < int > [0xFF00DDCC , 0xFF00DDCC , 0xFF00DDCC , 0xFF00DDCC ]);
35-
36- final ByteData pngBytes = (await testImage.toByteData (format: ImageByteFormat .png))! ;
37-
38- // PNG-encoding is browser-specific, but the header is standard. We only
39- // test the header.
40- final List <int > pngHeader = < int > [137 , 80 , 78 , 71 , 13 , 10 , 26 , 10 ];
41- expect (pngBytes.buffer.asUint8List ().sublist (0 , pngHeader.length), pngHeader);
42-
43- // Firefox does not support WebGL in headless mode.
44- }, skip: isFirefox);
45-
46- test ('Image.toByteData(format: ImageByteFormat.rawStraightRgba)' , () async {
47- final Image testImage = await createTestImageByColor (const Color (0xAAFFFF00 ));
48-
49- final ByteData bytes = (await testImage.toByteData (format: ImageByteFormat .rawStraightRgba))! ;
50- expect (bytes.buffer.asUint32List (), < int > [0xAA00FFFF , 0xAA00FFFF , 0xAA00FFFF , 0xAA00FFFF ]);
51-
19+ group ('toByteData test' , () {
20+ setUpUnitTests ();
21+
22+ Future <Image > createTestImageByColor (Color color) async {
23+ final PictureRecorder recorder = PictureRecorder ();
24+ final Canvas canvas = Canvas (recorder, const Rect .fromLTRB (0 , 0 , 2 , 2 ));
25+ canvas.drawColor (color, BlendMode .srcOver);
26+ final Picture testPicture = recorder.endRecording ();
27+ final Image testImage = await testPicture.toImage (2 , 2 );
28+ return testImage;
29+ }
30+
31+ test ('Picture.toImage().toByteData()' , () async {
32+ final Image testImage = await createTestImageByColor (const Color (0xFFCCDD00 ));
33+
34+ final ByteData bytes = (await testImage.toByteData ())! ;
35+ expect (bytes.buffer.asUint32List (), < int > [0xFF00DDCC , 0xFF00DDCC , 0xFF00DDCC , 0xFF00DDCC ]);
36+
37+ final ByteData pngBytes = (await testImage.toByteData (format: ImageByteFormat .png))! ;
38+
39+ // PNG-encoding is browser-specific, but the header is standard. We only
40+ // test the header.
41+ final List <int > pngHeader = < int > [137 , 80 , 78 , 71 , 13 , 10 , 26 , 10 ];
42+ expect (pngBytes.buffer.asUint8List ().sublist (0 , pngHeader.length), pngHeader);
43+ });
44+
45+ test ('Image.toByteData(format: ImageByteFormat.rawStraightRgba)' , () async {
46+ final Image testImage = await createTestImageByColor (const Color (0xAAFFFF00 ));
47+
48+ final ByteData bytes = (await testImage.toByteData (format: ImageByteFormat .rawStraightRgba))! ;
49+ expect (bytes.buffer.asUint32List (), < int > [0xAA00FFFF , 0xAA00FFFF , 0xAA00FFFF , 0xAA00FFFF ]);
50+ });
5251 // Firefox does not support WebGL in headless mode.
5352 }, skip: isFirefox);
5453}
0 commit comments