@@ -35,7 +35,18 @@ void testMain() {
3535 group ('CkCanvas' , () {
3636 setUpCanvasKitTest ();
3737
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 {
3950 browserSupportsFinalizationRegistry = false ;
4051 final CkPictureRecorder recorder = CkPictureRecorder ();
4152 final CkCanvas canvas = recorder.beginRecording (region);
@@ -47,6 +58,7 @@ void testMain() {
4758
4859 final ByteData originalPixels = await (await originalPicture.toImage (50 , 50 )).toByteData () as ByteData ;
4960
61+ // Test that a picture restored from a snapshot looks the same.
5062 final CkPictureSnapshot ? snapshot = canvas.pictureSnapshot;
5163 expect (snapshot, isNotNull);
5264 final SkPicture restoredSkPicture = snapshot! .toPicture ();
0 commit comments