@@ -35,7 +35,18 @@ void testMain() {
35
35
group ('CkCanvas' , () {
36
36
setUpCanvasKitTest ();
37
37
38
- test ('can restore a picture from a snapshot' , () async {
38
+ test ('renders using non-recording canvas if weak refs are supported' , () async {
39
+ expect (browserSupportsFinalizationRegistry, isTrue,
40
+ reason: 'This test specifically tests non-recording canvas, which '
41
+ 'only works if FinalizationRegistry is available.' );
42
+ final CkPictureRecorder recorder = CkPictureRecorder ();
43
+ final CkCanvas canvas = recorder.beginRecording (region);
44
+ expect (canvas.runtimeType, CkCanvas );
45
+ drawTestPicture (canvas);
46
+ await matchPictureGolden ('canvaskit_picture_original.png' , recorder.endRecording ());
47
+ });
48
+
49
+ test ('renders using a recording canvas if weak refs are not supported' , () async {
39
50
browserSupportsFinalizationRegistry = false ;
40
51
final CkPictureRecorder recorder = CkPictureRecorder ();
41
52
final CkCanvas canvas = recorder.beginRecording (region);
@@ -47,6 +58,7 @@ void testMain() {
47
58
48
59
final ByteData originalPixels = await (await originalPicture.toImage (50 , 50 )).toByteData () as ByteData ;
49
60
61
+ // Test that a picture restored from a snapshot looks the same.
50
62
final CkPictureSnapshot ? snapshot = canvas.pictureSnapshot;
51
63
expect (snapshot, isNotNull);
52
64
final SkPicture restoredSkPicture = snapshot! .toPicture ();
0 commit comments