@@ -591,6 +591,73 @@ void main() {
591591 },
592592 );
593593
594+ test (
595+ 'capture_ui_snapshot onSuccess: images move to ImageContent blocks '
596+ 'and leave the bundle JSON' ,
597+ () async {
598+ final runner = FakeCommandRunner ()
599+ ..nextExecuteResult = CoreResult .success (
600+ data: {
601+ 'message' : 'Captured UI snapshot bundle.' ,
602+ 'screenshots' : {
603+ 'images' : ['base64dataA' , 'base64dataB' ],
604+ 'fileUrls' : < String > [],
605+ 'captureMode' : 'flutter_layer' ,
606+ },
607+ 'imageSummaries' : [
608+ {'id' : 'image_1' , 'source' : 'inline_base64' },
609+ {'id' : 'image_2' , 'source' : 'inline_base64' },
610+ ],
611+ },
612+ );
613+ final ctx = _registeredCtx (runner: runner);
614+ final reg = ctx.registrationFor ('capture_ui_snapshot' )! ;
615+ final result = await reg.handler (const < String , Object ? > {});
616+ expect (result.ok, isTrue);
617+ expect (result.artifacts, hasLength (3 ));
618+
619+ final bundle =
620+ jsonDecode (result.artifacts.first.text! ) as Map <String , Object ?>;
621+ final screenshots = bundle['screenshots' ]! as Map <String , Object ?>;
622+ expect (screenshots['images' ], isEmpty);
623+ expect (screenshots['captureMode' ], 'flutter_layer' );
624+ expect (bundle['imageSummaries' ], hasLength (2 ));
625+
626+ final images = result.artifacts
627+ .where ((final a) => a.mimeType == 'image/png' )
628+ .toList ();
629+ expect (images, hasLength (2 ));
630+ expect (images[0 ].text, 'base64dataA' );
631+ expect (images[1 ].text, 'base64dataB' );
632+ },
633+ );
634+
635+ test (
636+ 'capture_ui_snapshot onSuccess: fileUrls bundle stays a single '
637+ 'TextContent' ,
638+ () async {
639+ final runner = FakeCommandRunner ()
640+ ..nextExecuteResult = CoreResult .success (
641+ data: {
642+ 'screenshots' : {
643+ 'images' : < String > [],
644+ 'fileUrls' : ['file:///tmp/screen0.png' ],
645+ },
646+ },
647+ );
648+ final ctx = _registeredCtx (runner: runner);
649+ final reg = ctx.registrationFor ('capture_ui_snapshot' )! ;
650+ final result = await reg.handler (const < String , Object ? > {});
651+ expect (result.ok, isTrue);
652+ expect (result.artifacts, hasLength (1 ));
653+ expect (result.artifacts.single.mimeType, 'text/plain' );
654+ final bundle =
655+ jsonDecode (result.artifacts.single.text! ) as Map <String , Object ?>;
656+ final screenshots = bundle['screenshots' ]! as Map <String , Object ?>;
657+ expect (screenshots['fileUrls' ], ['file:///tmp/screen0.png' ]);
658+ },
659+ );
660+
594661 test (
595662 'capture_ui_snapshot handler short-circuits on override failure' ,
596663 () async {
0 commit comments