@@ -296,6 +296,41 @@ Device 2 (mobile) • 456 • android • 1.2.3
296296 contains ('The Skia picture request failed, probably because the device was disconnected' ),
297297 );
298298 });
299+
300+ testWithoutContext ('Skia screenshot throws ToolExit on RPCError (e.g. Impeller enabled)' , () async {
301+ final fs = MemoryFileSystem .test ();
302+ final logger = BufferLogger .test ();
303+ final toolContext = FakeToolContext (fs: fs, logger: logger);
304+
305+ final fakeVmService = _FakeFlutterVmService (
306+ rpcError: vm_service.RPCError ('screenshotSkp' , - 32000 , 'Cannot capture SKP screenshot with Impeller enabled.' ),
307+ );
308+
309+ final command = ScreenshotCommand (
310+ toolContext: toolContext,
311+ vmServiceConnector:
312+ (
313+ Uri uri, {
314+ ReloadSources ? reloadSources,
315+ Restart ? restart,
316+ CompileExpression ? compileExpression,
317+ FlutterProject ? flutterProject,
318+ FlutterVersion ? flutterVersion,
319+ PrintStructuredErrorLogMethod ? printStructuredErrorLogMethod,
320+ CompressionOptions compression = CompressionOptions .compressionDefault,
321+ Device ? device,
322+ required Logger logger,
323+ }) async {
324+ return fakeVmService;
325+ },
326+ );
327+
328+ expect (
329+ () => createTestCommandRunner (command)
330+ .run (< String > ['screenshot' , '--type=skia' , '--vm-service-url=http://localhost:8181' ]),
331+ throwsToolExit (message: 'Cannot capture SKP screenshot with Impeller enabled.' ),
332+ );
333+ });
299334 });
300335}
301336
@@ -366,10 +401,16 @@ class _TestDeviceManager extends DeviceManager {
366401}
367402
368403class _FakeFlutterVmService extends Fake implements FlutterVmService {
369- _FakeFlutterVmService ({this .response});
404+ _FakeFlutterVmService ({this .response, this .rpcError });
370405
371406 final vm_service.Response ? response;
407+ final vm_service.RPCError ? rpcError;
372408
373409 @override
374- Future <vm_service.Response ?> screenshotSkp () async => response;
410+ Future <vm_service.Response ?> screenshotSkp () async {
411+ if (rpcError != null ) {
412+ throw rpcError! ;
413+ }
414+ return response;
415+ }
375416}
0 commit comments