diff --git a/packages/flutter_tools/lib/src/test/flutter_platform.dart b/packages/flutter_tools/lib/src/test/flutter_platform.dart index 26a4b350b83..4230329af84 100644 --- a/packages/flutter_tools/lib/src/test/flutter_platform.dart +++ b/packages/flutter_tools/lib/src/test/flutter_platform.dart @@ -28,6 +28,7 @@ import '../bundle.dart'; import '../compile.dart'; import '../dart/package_map.dart'; import '../globals.dart'; +import '../vmservice.dart'; import 'watcher.dart'; /// The timeout we give the test process to connect to the test harness @@ -450,6 +451,22 @@ class _FlutterPlatform extends PlatformPlugin { return remoteChannel; } + Future _compileExpressionService(String isolateId, String expression, + List definitions, List typeDefinitions, + String libraryUri, String klass, bool isStatic, + ) async { + if (compiler == null || compiler.compiler == null) { + throw 'Compiler is not set up properly to compile $expression'; + } + final CompilerOutput compilerOutput = + await compiler.compiler.compileExpression(expression, definitions, + typeDefinitions, libraryUri, klass, isStatic); + if (compilerOutput != null && compilerOutput.outputFilename != null) { + return base64.encode(fs.file(compilerOutput.outputFilename).readAsBytesSync()); + } + throw 'Failed to compile $expression'; + } + Future<_AsyncError> _startTest( String testPath, StreamChannel controller, @@ -573,6 +590,14 @@ class _FlutterPlatform extends PlatformPlugin { printTrace('test $ourTestCount: using observatory uri $detectedUri from pid ${process.pid}'); } processObservatoryUri = detectedUri; + { + printTrace('Connecting to service protocol: $processObservatoryUri'); + final Future localVmService = VMService.connect(processObservatoryUri, + compileExpression: _compileExpressionService); + localVmService.then((VMService vmservice) { + printTrace('Successfully connected to service protocol: $processObservatoryUri'); + }); + } gotProcessObservatoryUri.complete(); watcher?.handleStartedProcess( ProcessEvent(ourTestCount, process, processObservatoryUri));