From 8f834cf15071fdb4c67cdcb8f6b73199c0cba81b Mon Sep 17 00:00:00 2001 From: Lau Ching Jun Date: Fri, 15 Jul 2022 12:33:07 -0700 Subject: [PATCH] Read dart_plugin_registrant path from FlutterProject to support non-standard path. (#107617) --- packages/flutter_tools/lib/src/compile.dart | 42 +- packages/flutter_tools/lib/src/devfs.dart | 2 + .../lib/src/isolated/devfs_web.dart | 2 + .../lib/src/resident_runner.dart | 1 + packages/flutter_tools/lib/src/run_hot.dart | 1 + .../compile_incremental_test.dart | 38 ++ .../test/general.shard/devfs_test.dart | 2 +- .../general.shard/resident_runner_test.dart | 2 + .../resident_web_runner_test.dart | 496 +++++++++++------- .../test/test_compiler_test.dart | 1 + .../general.shard/web/devfs_web_test.dart | 1 + 11 files changed, 376 insertions(+), 212 deletions(-) diff --git a/packages/flutter_tools/lib/src/compile.dart b/packages/flutter_tools/lib/src/compile.dart index 8733f87396d8..a9debe39cd5b 100644 --- a/packages/flutter_tools/lib/src/compile.dart +++ b/packages/flutter_tools/lib/src/compile.dart @@ -328,7 +328,7 @@ class KernelCompiler { dartPluginRegistrant.path, '--source', 'package:flutter/src/dart_plugin_registrant.dart', - '-Dflutter.dart_plugin_registrant=${dartPluginRegistrant.uri}', + '-Dflutter.dart_plugin_registrant=${toMultiRootPath(dartPluginRegistrant.uri, _fileSystemScheme, _fileSystemRoots, _fileSystem.path.separator == r'\')}', ], // See: https://github.com/flutter/flutter/issues/103994 '--verbosity=error', @@ -375,7 +375,7 @@ class _RecompileRequest extends _CompilationRequest { this.outputPath, this.packageConfig, this.suppressErrors, - {this.additionalSource} + {this.additionalSourceUri} ); Uri mainUri; @@ -383,7 +383,7 @@ class _RecompileRequest extends _CompilationRequest { String outputPath; PackageConfig packageConfig; bool suppressErrors; - final String? additionalSource; + final Uri? additionalSourceUri; @override Future _run(DefaultResidentCompiler compiler) async => @@ -499,6 +499,7 @@ abstract class ResidentCompiler { String? projectRootPath, bool suppressErrors = false, bool checkDartPluginRegistry = false, + File? dartPluginRegistrant, }); Future compileExpression( @@ -642,6 +643,7 @@ class DefaultResidentCompiler implements ResidentCompiler { required PackageConfig packageConfig, bool suppressErrors = false, bool checkDartPluginRegistry = false, + File? dartPluginRegistrant, String? projectRootPath, FileSystem? fs, }) async { @@ -649,20 +651,10 @@ class DefaultResidentCompiler implements ResidentCompiler { if (!_controller.hasListener) { _controller.stream.listen(_handleCompilationRequest); } - String? additionalSource; + Uri? additionalSourceUri; // `dart_plugin_registrant.dart` contains the Dart plugin registry. - if (checkDartPluginRegistry && projectRootPath != null && fs != null) { - final File dartPluginRegistrantDart = fs.file( - fs.path.join( - projectRootPath, - '.dart_tool', - 'flutter_build', - 'dart_plugin_registrant.dart', - ), - ); - if (dartPluginRegistrantDart != null && dartPluginRegistrantDart.existsSync()) { - additionalSource = dartPluginRegistrantDart.path; - } + if (checkDartPluginRegistry && dartPluginRegistrant != null && dartPluginRegistrant.existsSync()) { + additionalSourceUri = dartPluginRegistrant.uri; } final Completer completer = Completer(); _controller.add(_RecompileRequest( @@ -672,7 +664,7 @@ class DefaultResidentCompiler implements ResidentCompiler { outputPath, packageConfig, suppressErrors, - additionalSource: additionalSource, + additionalSourceUri: additionalSourceUri, )); return completer.future; } @@ -685,9 +677,15 @@ class DefaultResidentCompiler implements ResidentCompiler { final String mainUri = request.packageConfig.toPackageUri(request.mainUri)?.toString() ?? toMultiRootPath(request.mainUri, fileSystemScheme, fileSystemRoots, _platform.isWindows); + String? additionalSourceUri; + if (request.additionalSourceUri != null) { + additionalSourceUri = request.packageConfig.toPackageUri(request.additionalSourceUri!)?.toString() ?? + toMultiRootPath(request.additionalSourceUri!, fileSystemScheme, fileSystemRoots, _platform.isWindows); + } + final Process? server = _server; if (server == null) { - return _compile(mainUri, request.outputPath, additionalSource: request.additionalSource); + return _compile(mainUri, request.outputPath, additionalSourceUri: additionalSourceUri); } final String inputKey = Uuid().generateV4(); @@ -733,7 +731,7 @@ class DefaultResidentCompiler implements ResidentCompiler { Future _compile( String scriptUri, String? outputPath, - {String? additionalSource} + {String? additionalSourceUri} ) async { final String frontendServer = _artifacts.getArtifactPath( Artifact.frontendServerSnapshotForEngineDartSdk @@ -786,12 +784,12 @@ class DefaultResidentCompiler implements ResidentCompiler { initializeFromDill!, ], if (assumeInitializeFromDillUpToDate) '--assume-initialize-from-dill-up-to-date', - if (additionalSource != null) ...[ + if (additionalSourceUri != null) ...[ '--source', - additionalSource, + additionalSourceUri, '--source', 'package:flutter/src/dart_plugin_registrant.dart', - '-Dflutter.dart_plugin_registrant=${Uri.file(additionalSource)}', + '-Dflutter.dart_plugin_registrant=$additionalSourceUri', ], if (platformDill != null) ...[ '--platform', diff --git a/packages/flutter_tools/lib/src/devfs.dart b/packages/flutter_tools/lib/src/devfs.dart index 5664bc115302..39d47685760b 100644 --- a/packages/flutter_tools/lib/src/devfs.dart +++ b/packages/flutter_tools/lib/src/devfs.dart @@ -581,6 +581,7 @@ class DevFS { bool bundleFirstUpload = false, bool fullRestart = false, String? projectRootPath, + File? dartPluginRegistrant, }) async { assert(trackWidgetCreation != null); assert(generator != null); @@ -610,6 +611,7 @@ class DevFS { projectRootPath: projectRootPath, packageConfig: packageConfig, checkDartPluginRegistry: true, // The entry point is assumed not to have changed. + dartPluginRegistrant: dartPluginRegistrant, ).then((CompilerOutput? result) { compileTimer.stop(); return result; diff --git a/packages/flutter_tools/lib/src/isolated/devfs_web.dart b/packages/flutter_tools/lib/src/isolated/devfs_web.dart index 4291befea150..bf4115467200 100644 --- a/packages/flutter_tools/lib/src/isolated/devfs_web.dart +++ b/packages/flutter_tools/lib/src/isolated/devfs_web.dart @@ -799,6 +799,7 @@ class WebDevFS implements DevFS { bool bundleFirstUpload = false, bool fullRestart = false, String? projectRootPath, + File? dartPluginRegistrant, }) async { assert(trackWidgetCreation != null); assert(generator != null); @@ -866,6 +867,7 @@ class WebDevFS implements DevFS { packageConfig: packageConfig, projectRootPath: projectRootPath, fs: globals.fs, + dartPluginRegistrant: dartPluginRegistrant, ); if (compilerOutput == null || compilerOutput.errorCount > 0) { return UpdateFSReport(); diff --git a/packages/flutter_tools/lib/src/resident_runner.dart b/packages/flutter_tools/lib/src/resident_runner.dart index 8a0312c00f1e..38a79c6a8a40 100644 --- a/packages/flutter_tools/lib/src/resident_runner.dart +++ b/packages/flutter_tools/lib/src/resident_runner.dart @@ -563,6 +563,7 @@ class FlutterDevice { invalidatedFiles: invalidatedFiles, packageConfig: packageConfig, devFSWriter: devFSWriter, + dartPluginRegistrant: FlutterProject.current().dartPluginRegistrant, ); } on DevFSException { devFSStatus.cancel(); diff --git a/packages/flutter_tools/lib/src/run_hot.dart b/packages/flutter_tools/lib/src/run_hot.dart index 8629638317ab..f849bc02c183 100644 --- a/packages/flutter_tools/lib/src/run_hot.dart +++ b/packages/flutter_tools/lib/src/run_hot.dart @@ -373,6 +373,7 @@ class HotRunner extends ResidentRunner { // should only be displayed once. suppressErrors: applicationBinary == null, checkDartPluginRegistry: true, + dartPluginRegistrant: FlutterProject.current().dartPluginRegistrant, outputPath: dillOutputPath, packageConfig: debuggingOptions.buildInfo.packageConfig, projectRootPath: FlutterProject.current().directory.absolute.path, diff --git a/packages/flutter_tools/test/general.shard/compile_incremental_test.dart b/packages/flutter_tools/test/general.shard/compile_incremental_test.dart index 955deb035b01..52f1511dabb5 100644 --- a/packages/flutter_tools/test/general.shard/compile_incremental_test.dart +++ b/packages/flutter_tools/test/general.shard/compile_incremental_test.dart @@ -4,6 +4,7 @@ import 'dart:async'; +import 'package:file/file.dart'; import 'package:file/memory.dart'; import 'package:flutter_tools/src/artifacts.dart'; import 'package:flutter_tools/src/base/async_guard.dart'; @@ -394,6 +395,43 @@ void main() { 'line2\nline3\n' )); }); + + testWithoutContext('incremental compile with dartPluginRegistrant', () async { + fakeProcessManager.addCommand(FakeCommand( + command: const [ + ...frontendServerCommand, + '--filesystem-root', + '/foo/bar/fizz', + '--filesystem-scheme', + 'scheme', + '--source', + 'some/dir/plugin_registrant.dart', + '--source', + 'package:flutter/src/dart_plugin_registrant.dart', + '-Dflutter.dart_plugin_registrant=some/dir/plugin_registrant.dart', + '--verbosity=error', + ], + stdout: 'result abc\nline1\nline2\nabc\nabc /path/to/main.dart.dill 0', + stdin: frontendServerStdIn, + )); + + final MemoryFileSystem fs = MemoryFileSystem(); + final File dartPluginRegistrant = fs.file('some/dir/plugin_registrant.dart')..createSync(recursive: true); + final CompilerOutput? output = await generatorWithScheme.recompile( + Uri.parse('file:///foo/bar/fizz/main.dart'), + null /* invalidatedFiles */, + outputPath: '/build/', + packageConfig: PackageConfig.empty, + fs: fs, + projectRootPath: '', + checkDartPluginRegistry: true, + dartPluginRegistrant: dartPluginRegistrant, + ); + expect(frontendServerStdIn.getAndClear(), 'compile scheme:///main.dart\n'); + expect(testLogger.errorText, equals('line1\nline2\n')); + expect(output?.outputFilename, equals('/path/to/main.dart.dill')); + expect(fakeProcessManager, hasNoRemainingExpectations); + }); } Future _recompile( diff --git a/packages/flutter_tools/test/general.shard/devfs_test.dart b/packages/flutter_tools/test/general.shard/devfs_test.dart index 0b0579baecca..3f507b506d34 100644 --- a/packages/flutter_tools/test/general.shard/devfs_test.dart +++ b/packages/flutter_tools/test/general.shard/devfs_test.dart @@ -581,7 +581,7 @@ class FakeResidentCompiler extends Fake implements ResidentCompiler { Future Function(Uri mainUri, List? invalidatedFiles)? onRecompile; @override - Future recompile(Uri mainUri, List? invalidatedFiles, {String? outputPath, PackageConfig? packageConfig, String? projectRootPath, FileSystem? fs, bool suppressErrors = false, bool checkDartPluginRegistry = false}) { + Future recompile(Uri mainUri, List? invalidatedFiles, {String? outputPath, PackageConfig? packageConfig, String? projectRootPath, FileSystem? fs, bool suppressErrors = false, bool checkDartPluginRegistry = false, File? dartPluginRegistrant}) { return onRecompile?.call(mainUri, invalidatedFiles) ?? Future.value(const CompilerOutput('', 1, [])); } diff --git a/packages/flutter_tools/test/general.shard/resident_runner_test.dart b/packages/flutter_tools/test/general.shard/resident_runner_test.dart index d27e8046d351..9d82965f2a50 100644 --- a/packages/flutter_tools/test/general.shard/resident_runner_test.dart +++ b/packages/flutter_tools/test/general.shard/resident_runner_test.dart @@ -2464,6 +2464,7 @@ class FakeResidentCompiler extends Fake implements ResidentCompiler { @required FileSystem fs, bool suppressErrors = false, bool checkDartPluginRegistry = false, + File dartPluginRegistrant, }) async { didSuppressErrors = suppressErrors; return nextOutput ?? const CompilerOutput('foo.dill', 0, []); @@ -2623,6 +2624,7 @@ class FakeDevFS extends Fake implements DevFS { bool bundleFirstUpload = false, bool fullRestart = false, String projectRootPath, + File dartPluginRegistrant, }) async { return nextUpdateReport; } diff --git a/packages/flutter_tools/test/general.shard/resident_web_runner_test.dart b/packages/flutter_tools/test/general.shard/resident_web_runner_test.dart index 6eccf1abf6a5..fcbb3b30e23c 100644 --- a/packages/flutter_tools/test/general.shard/resident_web_runner_test.dart +++ b/packages/flutter_tools/test/general.shard/resident_web_runner_test.dart @@ -42,7 +42,8 @@ import '../src/common.dart'; import '../src/context.dart'; import '../src/fake_vm_services.dart'; -const List kAttachLogExpectations = [ +const List kAttachLogExpectations = + [ FakeVmServiceRequest( method: 'streamListen', args: { @@ -57,34 +58,23 @@ const List kAttachLogExpectations = ), ]; -const List kAttachIsolateExpectations = [ - FakeVmServiceRequest( - method: 'streamListen', - args: { - 'streamId': 'Isolate', - } - ), - FakeVmServiceRequest( - method: 'registerService', - args: { - 'service': 'reloadSources', - 'alias': 'Flutter Tools', - } - ), - FakeVmServiceRequest( - method: 'registerService', - args: { - 'service': 'flutterVersion', - 'alias': 'Flutter Tools', - } - ), - FakeVmServiceRequest( - method: 'registerService', - args: { - 'service': 'flutterMemoryInfo', - 'alias': 'Flutter Tools', - } - ), +const List kAttachIsolateExpectations = + [ + FakeVmServiceRequest(method: 'streamListen', args: { + 'streamId': 'Isolate', + }), + FakeVmServiceRequest(method: 'registerService', args: { + 'service': 'reloadSources', + 'alias': 'Flutter Tools', + }), + FakeVmServiceRequest(method: 'registerService', args: { + 'service': 'flutterVersion', + 'alias': 'Flutter Tools', + }), + FakeVmServiceRequest(method: 'registerService', args: { + 'service': 'flutterMemoryInfo', + 'alias': 'Flutter Tools', + }), FakeVmServiceRequest( method: 'streamListen', args: { @@ -148,7 +138,9 @@ void main() { chromeConnection.tabs.add(chromeTab); } - testUsingContext('runner with web server device does not support debugging without --start-paused', () { + testUsingContext( + 'runner with web server device does not support debugging without --start-paused', + () { final ResidentRunner residentWebRunner = setUpResidentRunner(flutterDevice); flutterDevice.device = WebServerDevice( logger: BufferLogger.test(), @@ -156,7 +148,8 @@ void main() { fakeVmServiceHost = FakeVmServiceHost(requests: []); final ResidentRunner profileResidentWebRunner = ResidentWebRunner( flutterDevice, - flutterProject: FlutterProject.fromDirectoryTest(fileSystem.currentDirectory), + flutterProject: + FlutterProject.fromDirectoryTest(fileSystem.currentDirectory), debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug), ipv6: true, fileSystem: fileSystem, @@ -176,7 +169,9 @@ void main() { ProcessManager: () => processManager, }); - testUsingContext('runner with web server device supports debugging with --start-paused', () { + testUsingContext( + 'runner with web server device supports debugging with --start-paused', + () { fakeVmServiceHost = FakeVmServiceHost(requests: []); setupMocks(); flutterDevice.device = WebServerDevice( @@ -184,8 +179,10 @@ void main() { ); final ResidentRunner profileResidentWebRunner = ResidentWebRunner( flutterDevice, - flutterProject: FlutterProject.fromDirectoryTest(fileSystem.currentDirectory), - debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug, startPaused: true), + flutterProject: + FlutterProject.fromDirectoryTest(fileSystem.currentDirectory), + debuggingOptions: + DebuggingOptions.enabled(BuildInfo.debug, startPaused: true), ipv6: true, fileSystem: fileSystem, logger: BufferLogger.test(), @@ -202,7 +199,8 @@ void main() { testUsingContext('profile does not supportsServiceProtocol', () { final ResidentRunner residentWebRunner = ResidentWebRunner( flutterDevice, - flutterProject: FlutterProject.fromDirectoryTest(fileSystem.currentDirectory), + flutterProject: + FlutterProject.fromDirectoryTest(fileSystem.currentDirectory), debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug), ipv6: true, fileSystem: fileSystem, @@ -214,7 +212,8 @@ void main() { flutterDevice.device = chromeDevice; final ResidentRunner profileResidentWebRunner = ResidentWebRunner( flutterDevice, - flutterProject: FlutterProject.fromDirectoryTest(fileSystem.currentDirectory), + flutterProject: + FlutterProject.fromDirectoryTest(fileSystem.currentDirectory), debuggingOptions: DebuggingOptions.enabled(BuildInfo.profile), ipv6: true, fileSystem: fileSystem, @@ -232,70 +231,99 @@ void main() { testUsingContext('Can successfully run and connect to vmservice', () async { final BufferLogger logger = BufferLogger.test(); - final ResidentRunner residentWebRunner = setUpResidentRunner(flutterDevice, logger: logger); - fakeVmServiceHost = FakeVmServiceHost(requests: kAttachExpectations.toList()); + final ResidentRunner residentWebRunner = + setUpResidentRunner(flutterDevice, logger: logger); + fakeVmServiceHost = + FakeVmServiceHost(requests: kAttachExpectations.toList()); setupMocks(); - final Completer connectionInfoCompleter = Completer(); + final Completer connectionInfoCompleter = + Completer(); unawaited(residentWebRunner.run( connectionInfoCompleter: connectionInfoCompleter, )); - final DebugConnectionInfo debugConnectionInfo = await connectionInfoCompleter.future; + final DebugConnectionInfo debugConnectionInfo = + await connectionInfoCompleter.future; expect(appConnection.ranMain, true); - expect(logger.statusText, contains('Debug service listening on ws://127.0.0.1/abcd/')); + expect(logger.statusText, + contains('Debug service listening on ws://127.0.0.1/abcd/')); expect(debugConnectionInfo.wsUri.toString(), 'ws://127.0.0.1/abcd/'); }, overrides: { FileSystem: () => fileSystem, ProcessManager: () => processManager, }); - testUsingContext('WebRunner copies compiled app.dill to cache during startup', () async { + testUsingContext('WebRunner copies compiled app.dill to cache during startup', + () async { final DebuggingOptions debuggingOptions = DebuggingOptions.enabled( const BuildInfo(BuildMode.debug, null, treeShakeIcons: false), ); - final ResidentRunner residentWebRunner = setUpResidentRunner(flutterDevice, debuggingOptions: debuggingOptions); - fakeVmServiceHost = FakeVmServiceHost(requests: kAttachExpectations.toList()); + final ResidentRunner residentWebRunner = + setUpResidentRunner(flutterDevice, debuggingOptions: debuggingOptions); + fakeVmServiceHost = + FakeVmServiceHost(requests: kAttachExpectations.toList()); setupMocks(); - residentWebRunner.artifactDirectory.childFile('app.dill').writeAsStringSync('ABC'); - final Completer connectionInfoCompleter = Completer(); + residentWebRunner.artifactDirectory + .childFile('app.dill') + .writeAsStringSync('ABC'); + final Completer connectionInfoCompleter = + Completer(); unawaited(residentWebRunner.run( connectionInfoCompleter: connectionInfoCompleter, )); await connectionInfoCompleter.future; - expect(await fileSystem.file(fileSystem.path.join('build', 'cache.dill')).readAsString(), 'ABC'); + expect( + await fileSystem + .file(fileSystem.path.join('build', 'cache.dill')) + .readAsString(), + 'ABC'); }, overrides: { FileSystem: () => fileSystem, ProcessManager: () => processManager, }); - testUsingContext('WebRunner copies compiled app.dill to cache during startup with track-widget-creation', () async { + testUsingContext( + 'WebRunner copies compiled app.dill to cache during startup with track-widget-creation', + () async { final ResidentRunner residentWebRunner = setUpResidentRunner(flutterDevice); - fakeVmServiceHost = FakeVmServiceHost(requests: kAttachExpectations.toList()); + fakeVmServiceHost = + FakeVmServiceHost(requests: kAttachExpectations.toList()); setupMocks(); - residentWebRunner.artifactDirectory.childFile('app.dill').writeAsStringSync('ABC'); - final Completer connectionInfoCompleter = Completer(); + residentWebRunner.artifactDirectory + .childFile('app.dill') + .writeAsStringSync('ABC'); + final Completer connectionInfoCompleter = + Completer(); unawaited(residentWebRunner.run( connectionInfoCompleter: connectionInfoCompleter, )); await connectionInfoCompleter.future; - expect(await fileSystem.file(fileSystem.path.join('build', 'cache.dill.track.dill')).readAsString(), 'ABC'); + expect( + await fileSystem + .file(fileSystem.path.join('build', 'cache.dill.track.dill')) + .readAsString(), + 'ABC'); }, overrides: { FileSystem: () => fileSystem, ProcessManager: () => processManager, }); // Regression test for https://github.com/flutter/flutter/issues/60613 - testUsingContext('ResidentWebRunner calls appFailedToStart if initial compilation fails', () async { - fakeVmServiceHost = FakeVmServiceHost(requests: kAttachExpectations.toList()); + testUsingContext( + 'ResidentWebRunner calls appFailedToStart if initial compilation fails', + () async { + fakeVmServiceHost = + FakeVmServiceHost(requests: kAttachExpectations.toList()); setupMocks(); final ResidentRunner residentWebRunner = setUpResidentRunner(flutterDevice); - fileSystem.file(globals.fs.path.join('lib', 'main.dart')) - .createSync(recursive: true); + fileSystem + .file(globals.fs.path.join('lib', 'main.dart')) + .createSync(recursive: true); webDevFS.report = UpdateFSReport(); expect(await residentWebRunner.run(), 1); @@ -306,15 +334,18 @@ void main() { ProcessManager: () => processManager, }); - testUsingContext('Can successfully run without an index.html including status warning', () async { + testUsingContext( + 'Can successfully run without an index.html including status warning', + () async { final BufferLogger logger = BufferLogger.test(); - fakeVmServiceHost = FakeVmServiceHost(requests: kAttachExpectations.toList()); + fakeVmServiceHost = + FakeVmServiceHost(requests: kAttachExpectations.toList()); setupMocks(); - fileSystem.file(fileSystem.path.join('web', 'index.html')) - .deleteSync(); + fileSystem.file(fileSystem.path.join('web', 'index.html')).deleteSync(); final ResidentWebRunner residentWebRunner = ResidentWebRunner( flutterDevice, - flutterProject: FlutterProject.fromDirectoryTest(fileSystem.currentDirectory), + flutterProject: + FlutterProject.fromDirectoryTest(fileSystem.currentDirectory), debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug), ipv6: true, stayResident: false, @@ -326,18 +357,21 @@ void main() { expect(await residentWebRunner.run(), 0); expect(logger.statusText, - contains('This application is not configured to build on the web')); + contains('This application is not configured to build on the web')); }, overrides: { FileSystem: () => fileSystem, ProcessManager: () => processManager, }); - testUsingContext('Can successfully run and disconnect with --no-resident', () async { - fakeVmServiceHost = FakeVmServiceHost(requests: kAttachExpectations.toList()); + testUsingContext('Can successfully run and disconnect with --no-resident', + () async { + fakeVmServiceHost = + FakeVmServiceHost(requests: kAttachExpectations.toList()); setupMocks(); final ResidentRunner residentWebRunner = ResidentWebRunner( flutterDevice, - flutterProject: FlutterProject.fromDirectoryTest(fileSystem.currentDirectory), + flutterProject: + FlutterProject.fromDirectoryTest(fileSystem.currentDirectory), debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug), ipv6: true, stayResident: false, @@ -353,31 +387,32 @@ void main() { ProcessManager: () => processManager, }); - testUsingContext('Listens to stdout and stderr streams before running main', () async { + testUsingContext('Listens to stdout and stderr streams before running main', + () async { final BufferLogger logger = BufferLogger.test(); - final ResidentRunner residentWebRunner = setUpResidentRunner(flutterDevice, logger: logger); + final ResidentRunner residentWebRunner = + setUpResidentRunner(flutterDevice, logger: logger); fakeVmServiceHost = FakeVmServiceHost(requests: [ ...kAttachLogExpectations, FakeVmServiceStreamResponse( streamId: 'Stdout', event: vm_service.Event( - timestamp: 0, - kind: vm_service.EventStreams.kStdout, - bytes: base64.encode(utf8.encode('THIS MESSAGE IS IMPORTANT')) - ), + timestamp: 0, + kind: vm_service.EventStreams.kStdout, + bytes: base64.encode(utf8.encode('THIS MESSAGE IS IMPORTANT'))), ), FakeVmServiceStreamResponse( streamId: 'Stderr', event: vm_service.Event( - timestamp: 0, - kind: vm_service.EventStreams.kStderr, - bytes: base64.encode(utf8.encode('SO IS THIS')) - ), + timestamp: 0, + kind: vm_service.EventStreams.kStderr, + bytes: base64.encode(utf8.encode('SO IS THIS'))), ), ...kAttachIsolateExpectations, ]); setupMocks(); - final Completer connectionInfoCompleter = Completer(); + final Completer connectionInfoCompleter = + Completer(); unawaited(residentWebRunner.run( connectionInfoCompleter: connectionInfoCompleter, )); @@ -390,8 +425,10 @@ void main() { ProcessManager: () => processManager, }); - testUsingContext('Listens to extension events with structured errors', () async { - final ResidentRunner residentWebRunner = setUpResidentRunner(flutterDevice, logger: testLogger); + testUsingContext('Listens to extension events with structured errors', + () async { + final ResidentRunner residentWebRunner = + setUpResidentRunner(flutterDevice, logger: testLogger); final Map extensionData = { 'test': 'data', 'renderedErrorText': 'error text', @@ -437,7 +474,8 @@ void main() { ]); setupMocks(); - final Completer connectionInfoCompleter = Completer(); + final Completer connectionInfoCompleter = + Completer(); unawaited(residentWebRunner.run( connectionInfoCompleter: connectionInfoCompleter, )); @@ -454,17 +492,21 @@ void main() { testUsingContext('Does not run main with --start-paused', () async { final ResidentRunner residentWebRunner = ResidentWebRunner( flutterDevice, - flutterProject: FlutterProject.fromDirectoryTest(fileSystem.currentDirectory), - debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug, startPaused: true), + flutterProject: + FlutterProject.fromDirectoryTest(fileSystem.currentDirectory), + debuggingOptions: + DebuggingOptions.enabled(BuildInfo.debug, startPaused: true), ipv6: true, fileSystem: fileSystem, logger: BufferLogger.test(), usage: globals.flutterUsage, systemClock: globals.systemClock, ); - fakeVmServiceHost = FakeVmServiceHost(requests: kAttachExpectations.toList()); + fakeVmServiceHost = + FakeVmServiceHost(requests: kAttachExpectations.toList()); setupMocks(); - final Completer connectionInfoCompleter = Completer(); + final Completer connectionInfoCompleter = + Completer(); unawaited(residentWebRunner.run( connectionInfoCompleter: connectionInfoCompleter, @@ -487,11 +529,10 @@ void main() { fakeVmServiceHost = FakeVmServiceHost(requests: [ ...kAttachExpectations, const FakeVmServiceRequest( - method: 'hotRestart', - jsonResponse: { - 'type': 'Success', - } - ), + method: 'hotRestart', + jsonResponse: { + 'type': 'Success', + }), const FakeVmServiceRequest( method: 'streamListen', args: { @@ -501,7 +542,8 @@ void main() { ]); setupMocks(); final TestChromiumLauncher chromiumLauncher = TestChromiumLauncher(); - final Chromium chrome = Chromium(1, chromeConnection, chromiumLauncher: chromiumLauncher); + final Chromium chrome = + Chromium(1, chromeConnection, chromiumLauncher: chromiumLauncher); chromiumLauncher.setInstance(chrome); flutterDevice.device = GoogleChromeDevice( @@ -513,11 +555,13 @@ void main() { ); webDevFS.report = UpdateFSReport(success: true); - final Completer connectionInfoCompleter = Completer(); + final Completer connectionInfoCompleter = + Completer(); unawaited(residentWebRunner.run( connectionInfoCompleter: connectionInfoCompleter, )); - final DebugConnectionInfo debugConnectionInfo = await connectionInfoCompleter.future; + final DebugConnectionInfo debugConnectionInfo = + await connectionInfoCompleter.future; expect(debugConnectionInfo, isNotNull); @@ -529,7 +573,15 @@ void main() { // ensure that analytics are sent. expect(testUsage.events, [ - TestUsageEvent('hot', 'restart', parameters: CustomDimensions.fromMap({'cd27': 'web-javascript', 'cd28': '', 'cd29': 'false', 'cd30': 'true', 'cd13': '0', 'cd48': 'false'})), + TestUsageEvent('hot', 'restart', + parameters: CustomDimensions.fromMap({ + 'cd27': 'web-javascript', + 'cd28': '', + 'cd29': 'false', + 'cd30': 'true', + 'cd13': '0', + 'cd48': 'false' + })), ]); expect(testUsage.timings, const [ TestTimingEvent('hot', 'web-incremental-restart', Duration.zero), @@ -550,15 +602,15 @@ void main() { fakeVmServiceHost = FakeVmServiceHost(requests: [ ...kAttachExpectations, const FakeVmServiceRequest( - method: 'hotRestart', - jsonResponse: { - 'type': 'Success', - } - ), + method: 'hotRestart', + jsonResponse: { + 'type': 'Success', + }), ]); setupMocks(); final TestChromiumLauncher chromiumLauncher = TestChromiumLauncher(); - final Chromium chrome = Chromium(1, chromeConnection, chromiumLauncher: chromiumLauncher); + final Chromium chrome = + Chromium(1, chromeConnection, chromiumLauncher: chromiumLauncher); chromiumLauncher.setInstance(chrome); flutterDevice.device = GoogleChromeDevice( @@ -570,16 +622,19 @@ void main() { ); webDevFS.report = UpdateFSReport(success: true); - final Completer connectionInfoCompleter = Completer(); + final Completer connectionInfoCompleter = + Completer(); unawaited(residentWebRunner.run( connectionInfoCompleter: connectionInfoCompleter, )); await connectionInfoCompleter.future; - final OperationResult result = await residentWebRunner.restart(fullRestart: true); + final OperationResult result = + await residentWebRunner.restart(fullRestart: true); // Ensure that generated entrypoint is generated correctly. expect(webDevFS.mainUri, isNotNull); - final String entrypointContents = fileSystem.file(webDevFS.mainUri).readAsStringSync(); + final String entrypointContents = + fileSystem.file(webDevFS.mainUri).readAsStringSync(); expect(entrypointContents, contains('// Flutter web bootstrap script')); expect(entrypointContents, contains("import 'dart:ui' as ui;")); expect(entrypointContents, contains('await ui.webOnlyWarmupEngine(')); @@ -587,9 +642,17 @@ void main() { expect(logger.statusText, contains('Restarted application in')); expect(result.code, 0); - // ensure that analytics are sent. + // ensure that analytics are sent. expect(testUsage.events, [ - TestUsageEvent('hot', 'restart', parameters: CustomDimensions.fromMap({'cd27': 'web-javascript', 'cd28': '', 'cd29': 'false', 'cd30': 'true', 'cd13': '0', 'cd48': 'false'})), + TestUsageEvent('hot', 'restart', + parameters: CustomDimensions.fromMap({ + 'cd27': 'web-javascript', + 'cd28': '', + 'cd29': 'false', + 'cd30': 'true', + 'cd13': '0', + 'cd48': 'false' + })), ]); expect(testUsage.timings, const [ TestTimingEvent('hot', 'web-incremental-restart', Duration.zero), @@ -600,29 +663,32 @@ void main() { ProcessManager: () => processManager, }); - testUsingContext('Can hot restart after attaching with web-server device', () async { + testUsingContext('Can hot restart after attaching with web-server device', + () async { final BufferLogger logger = BufferLogger.test(); final ResidentRunner residentWebRunner = setUpResidentRunner( flutterDevice, logger: logger, systemClock: SystemClock.fixed(DateTime(2001)), ); - fakeVmServiceHost = FakeVmServiceHost(requests :kAttachExpectations); + fakeVmServiceHost = FakeVmServiceHost(requests: kAttachExpectations); setupMocks(); flutterDevice.device = webServerDevice; webDevFS.report = UpdateFSReport(success: true); - final Completer connectionInfoCompleter = Completer(); + final Completer connectionInfoCompleter = + Completer(); unawaited(residentWebRunner.run( connectionInfoCompleter: connectionInfoCompleter, )); await connectionInfoCompleter.future; - final OperationResult result = await residentWebRunner.restart(fullRestart: true); + final OperationResult result = + await residentWebRunner.restart(fullRestart: true); expect(logger.statusText, contains('Restarted application in')); expect(result.code, 0); - // web-server device does not send restart analytics + // web-server device does not send restart analytics expect(testUsage.events, isEmpty); expect(testUsage.timings, isEmpty); }, overrides: { @@ -633,7 +699,8 @@ void main() { testUsingContext('web resident runner is debuggable', () { final ResidentRunner residentWebRunner = setUpResidentRunner(flutterDevice); - fakeVmServiceHost = FakeVmServiceHost(requests: kAttachExpectations.toList()); + fakeVmServiceHost = + FakeVmServiceHost(requests: kAttachExpectations.toList()); expect(residentWebRunner.debuggingEnabled, true); }, overrides: { @@ -647,7 +714,8 @@ void main() { setupMocks(); webDevFS.report = UpdateFSReport(); - final Completer connectionInfoCompleter = Completer(); + final Completer connectionInfoCompleter = + Completer(); unawaited(residentWebRunner.run( connectionInfoCompleter: connectionInfoCompleter, )); @@ -661,9 +729,12 @@ void main() { ProcessManager: () => processManager, }); - testUsingContext('Faithfully displays stdout messages with leading/trailing spaces', () async { + testUsingContext( + 'Faithfully displays stdout messages with leading/trailing spaces', + () async { final BufferLogger logger = BufferLogger.test(); - final ResidentRunner residentWebRunner = setUpResidentRunner(flutterDevice, logger: logger); + final ResidentRunner residentWebRunner = + setUpResidentRunner(flutterDevice, logger: logger); fakeVmServiceHost = FakeVmServiceHost(requests: [ ...kAttachLogExpectations, FakeVmServiceStreamResponse( @@ -672,21 +743,25 @@ void main() { timestamp: 0, kind: vm_service.EventStreams.kStdout, bytes: base64.encode( - utf8.encode(' This is a message with 4 leading and trailing spaces '), + utf8.encode( + ' This is a message with 4 leading and trailing spaces '), ), ), ), ...kAttachIsolateExpectations, ]); setupMocks(); - final Completer connectionInfoCompleter = Completer(); + final Completer connectionInfoCompleter = + Completer(); unawaited(residentWebRunner.run( connectionInfoCompleter: connectionInfoCompleter, )); await connectionInfoCompleter.future; - expect(logger.statusText, - contains(' This is a message with 4 leading and trailing spaces ')); + expect( + logger.statusText, + contains( + ' This is a message with 4 leading and trailing spaces ')); expect(fakeVmServiceHost.hasRemainingExpectations, false); }, overrides: { FileSystem: () => fileSystem, @@ -695,16 +770,19 @@ void main() { testUsingContext('Fails on compilation errors in hot restart', () async { final ResidentRunner residentWebRunner = setUpResidentRunner(flutterDevice); - fakeVmServiceHost = FakeVmServiceHost(requests: kAttachExpectations.toList()); + fakeVmServiceHost = + FakeVmServiceHost(requests: kAttachExpectations.toList()); setupMocks(); - final Completer connectionInfoCompleter = Completer(); + final Completer connectionInfoCompleter = + Completer(); unawaited(residentWebRunner.run( connectionInfoCompleter: connectionInfoCompleter, )); await connectionInfoCompleter.future; webDevFS.report = UpdateFSReport(); - final OperationResult result = await residentWebRunner.restart(fullRestart: true); + final OperationResult result = + await residentWebRunner.restart(fullRestart: true); expect(result.code, 1); expect(result.message, contains('Failed to recompile application.')); @@ -716,7 +794,9 @@ void main() { ProcessManager: () => processManager, }); - testUsingContext('Fails non-fatally on vmservice response error for hot restart', () async { + testUsingContext( + 'Fails non-fatally on vmservice response error for hot restart', + () async { final ResidentRunner residentWebRunner = setUpResidentRunner(flutterDevice); fakeVmServiceHost = FakeVmServiceHost(requests: [ ...kAttachExpectations, @@ -728,7 +808,8 @@ void main() { ), ]); setupMocks(); - final Completer connectionInfoCompleter = Completer(); + final Completer connectionInfoCompleter = + Completer(); unawaited(residentWebRunner.run( connectionInfoCompleter: connectionInfoCompleter, )); @@ -753,7 +834,8 @@ void main() { ), ]); setupMocks(); - final Completer connectionInfoCompleter = Completer(); + final Completer connectionInfoCompleter = + Completer(); unawaited(residentWebRunner.run( connectionInfoCompleter: connectionInfoCompleter, )); @@ -761,16 +843,17 @@ void main() { final OperationResult result = await residentWebRunner.restart(); expect(result.code, 1); - expect(result.message, - contains(RPCErrorCodes.kInternalError.toString())); + expect(result.message, contains(RPCErrorCodes.kInternalError.toString())); }, overrides: { FileSystem: () => fileSystem, ProcessManager: () => processManager, }); - testUsingContext('printHelp without details shows hot restart help message', () async { + testUsingContext('printHelp without details shows hot restart help message', + () async { final BufferLogger logger = BufferLogger.test(); - final ResidentRunner residentWebRunner = setUpResidentRunner(flutterDevice, logger: logger); + final ResidentRunner residentWebRunner = + setUpResidentRunner(flutterDevice, logger: logger); fakeVmServiceHost = FakeVmServiceHost(requests: []); residentWebRunner.printHelp(details: false); @@ -780,14 +863,16 @@ void main() { ProcessManager: () => processManager, }); - testUsingContext('cleanup of resources is safe to call multiple times', () async { + testUsingContext('cleanup of resources is safe to call multiple times', + () async { final ResidentRunner residentWebRunner = setUpResidentRunner(flutterDevice); mockDevice.dds = DartDevelopmentService(); fakeVmServiceHost = FakeVmServiceHost(requests: [ ...kAttachExpectations, ]); setupMocks(); - final Completer connectionInfoCompleter = Completer(); + final Completer connectionInfoCompleter = + Completer(); unawaited(residentWebRunner.run( connectionInfoCompleter: connectionInfoCompleter, )); @@ -809,7 +894,8 @@ void main() { ...kAttachExpectations, ]); setupMocks(); - final Completer connectionInfoCompleter = Completer(); + final Completer connectionInfoCompleter = + Completer(); final Future result = residentWebRunner.run( connectionInfoCompleter: connectionInfoCompleter, ); @@ -825,29 +911,34 @@ void main() { testUsingContext('Prints target and device name on run', () async { final BufferLogger logger = BufferLogger.test(); - final ResidentRunner residentWebRunner = setUpResidentRunner(flutterDevice, logger: logger); + final ResidentRunner residentWebRunner = + setUpResidentRunner(flutterDevice, logger: logger); fakeVmServiceHost = FakeVmServiceHost(requests: [ ...kAttachExpectations, ]); setupMocks(); mockDevice.name = 'Chromez'; - final Completer connectionInfoCompleter = Completer(); + final Completer connectionInfoCompleter = + Completer(); unawaited(residentWebRunner.run( connectionInfoCompleter: connectionInfoCompleter, )); await connectionInfoCompleter.future; - expect(logger.statusText, contains( - 'Launching ${fileSystem.path.join('lib', 'main.dart')} on ' - 'Chromez in debug mode', - )); + expect( + logger.statusText, + contains( + 'Launching ${fileSystem.path.join('lib', 'main.dart')} on ' + 'Chromez in debug mode', + )); expect(fakeVmServiceHost.hasRemainingExpectations, false); }, overrides: { FileSystem: () => fileSystem, ProcessManager: () => processManager, }); - testUsingContext('Sends launched app.webLaunchUrl event for Chrome device', () async { + testUsingContext('Sends launched app.webLaunchUrl event for Chrome device', + () async { final BufferLogger logger = BufferLogger.test(); fakeVmServiceHost = FakeVmServiceHost(requests: [ ...kAttachLogExpectations, @@ -856,7 +947,8 @@ void main() { setupMocks(); final FakeChromeConnection chromeConnection = FakeChromeConnection(); final TestChromiumLauncher chromiumLauncher = TestChromiumLauncher(); - final Chromium chrome = Chromium(1, chromeConnection, chromiumLauncher: chromiumLauncher); + final Chromium chrome = + Chromium(1, chromeConnection, chromiumLauncher: chromiumLauncher); chromiumLauncher.setInstance(chrome); flutterDevice.device = GoogleChromeDevice( @@ -873,7 +965,8 @@ void main() { final ResidentWebRunner runner = ResidentWebRunner( flutterDevice, - flutterProject: FlutterProject.fromDirectoryTest(fileSystem.currentDirectory), + flutterProject: + FlutterProject.fromDirectoryTest(fileSystem.currentDirectory), debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug), ipv6: true, fileSystem: fileSystem, @@ -882,29 +975,34 @@ void main() { systemClock: globals.systemClock, ); - final Completer connectionInfoCompleter = Completer(); + final Completer connectionInfoCompleter = + Completer(); unawaited(runner.run( connectionInfoCompleter: connectionInfoCompleter, )); await connectionInfoCompleter.future; // Ensure we got the URL and that it was already launched. - expect(logger.eventText, - contains(json.encode({ - 'name': 'app.webLaunchUrl', - 'args': { - 'url': 'http://localhost:8765/app/', - 'launched': true, - }, - }, - ))); + expect( + logger.eventText, + contains(json.encode( + { + 'name': 'app.webLaunchUrl', + 'args': { + 'url': 'http://localhost:8765/app/', + 'launched': true, + }, + }, + ))); expect(fakeVmServiceHost.hasRemainingExpectations, false); }, overrides: { FileSystem: () => fileSystem, ProcessManager: () => processManager, }); - testUsingContext('Sends unlaunched app.webLaunchUrl event for Web Server device', () async { + testUsingContext( + 'Sends unlaunched app.webLaunchUrl event for Web Server device', + () async { final BufferLogger logger = BufferLogger.test(); fakeVmServiceHost = FakeVmServiceHost(requests: []); setupMocks(); @@ -915,7 +1013,8 @@ void main() { final ResidentWebRunner runner = ResidentWebRunner( flutterDevice, - flutterProject: FlutterProject.fromDirectoryTest(fileSystem.currentDirectory), + flutterProject: + FlutterProject.fromDirectoryTest(fileSystem.currentDirectory), debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug), ipv6: true, fileSystem: fileSystem, @@ -924,22 +1023,25 @@ void main() { systemClock: globals.systemClock, ); - final Completer connectionInfoCompleter = Completer(); + final Completer connectionInfoCompleter = + Completer(); unawaited(runner.run( connectionInfoCompleter: connectionInfoCompleter, )); await connectionInfoCompleter.future; // Ensure we got the URL and that it was not already launched. - expect(logger.eventText, - contains(json.encode({ - 'name': 'app.webLaunchUrl', - 'args': { - 'url': 'http://localhost:8765/app/', - 'launched': false, - }, - }, - ))); + expect( + logger.eventText, + contains(json.encode( + { + 'name': 'app.webLaunchUrl', + 'args': { + 'url': 'http://localhost:8765/app/', + 'launched': false, + }, + }, + ))); expect(fakeVmServiceHost.hasRemainingExpectations, false); }, overrides: { FileSystem: () => fileSystem, @@ -950,8 +1052,8 @@ void main() { // perf regression in hot restart. testUsingContext('Does not generate dart_plugin_registrant.dart', () async { // Create necessary files for [DartPluginRegistrantTarget] - final File packageConfig = globals.fs.directory('.dart_tool') - .childFile('package_config.json'); + final File packageConfig = + globals.fs.directory('.dart_tool').childFile('package_config.json'); packageConfig.createSync(recursive: true); packageConfig.writeAsStringSync(''' { @@ -967,12 +1069,14 @@ void main() { } '''); // Start with a dart_plugin_registrant.dart file. - globals.fs.directory('.dart_tool') - .childDirectory('flutter_build') - .childFile('dart_plugin_registrant.dart') - .createSync(recursive: true); + globals.fs + .directory('.dart_tool') + .childDirectory('flutter_build') + .childFile('dart_plugin_registrant.dart') + .createSync(recursive: true); - final FlutterProject project = FlutterProject.fromDirectoryTest(fileSystem.currentDirectory); + final FlutterProject project = + FlutterProject.fromDirectoryTest(fileSystem.currentDirectory); final ResidentRunner residentWebRunner = setUpResidentRunner(flutterDevice); await residentWebRunner.runSourceGenerators(); @@ -987,9 +1091,11 @@ void main() { ProcessManager: () => processManager, }); - testUsingContext('Successfully turns WebSocketException into ToolExit', () async { + testUsingContext('Successfully turns WebSocketException into ToolExit', + () async { final BufferLogger logger = BufferLogger.test(); - final ResidentRunner residentWebRunner = setUpResidentRunner(flutterDevice, logger: logger); + final ResidentRunner residentWebRunner = + setUpResidentRunner(flutterDevice, logger: logger); fakeVmServiceHost = FakeVmServiceHost(requests: []); setupMocks(); webDevFS.exception = const WebSocketException(); @@ -1002,7 +1108,8 @@ void main() { ProcessManager: () => processManager, }); - testUsingContext('Successfully turns AppConnectionException into ToolExit', () async { + testUsingContext('Successfully turns AppConnectionException into ToolExit', + () async { final ResidentRunner residentWebRunner = setUpResidentRunner(flutterDevice); fakeVmServiceHost = FakeVmServiceHost(requests: []); setupMocks(); @@ -1015,7 +1122,8 @@ void main() { ProcessManager: () => processManager, }); - testUsingContext('Successfully turns ChromeDebugError into ToolExit', () async { + testUsingContext('Successfully turns ChromeDebugError into ToolExit', + () async { final ResidentRunner residentWebRunner = setUpResidentRunner(flutterDevice); fakeVmServiceHost = FakeVmServiceHost(requests: []); setupMocks(); @@ -1044,7 +1152,8 @@ void main() { testUsingContext('Rethrows unknown Error type from dwds tooling', () async { final BufferLogger logger = BufferLogger.test(); - final ResidentRunner residentWebRunner = setUpResidentRunner(flutterDevice, logger: logger); + final ResidentRunner residentWebRunner = + setUpResidentRunner(flutterDevice, logger: logger); fakeVmServiceHost = FakeVmServiceHost(requests: []); setupMocks(); webDevFS.exception = StateError(''); @@ -1057,15 +1166,18 @@ void main() { }); } -ResidentRunner setUpResidentRunner(FlutterDevice flutterDevice, { +ResidentRunner setUpResidentRunner( + FlutterDevice flutterDevice, { Logger logger, SystemClock systemClock, DebuggingOptions debuggingOptions, }) { return ResidentWebRunner( flutterDevice, - flutterProject: FlutterProject.fromDirectoryTest(globals.fs.currentDirectory), - debuggingOptions: debuggingOptions ?? DebuggingOptions.enabled(BuildInfo.debug), + flutterProject: + FlutterProject.fromDirectoryTest(globals.fs.currentDirectory), + debuggingOptions: + debuggingOptions ?? DebuggingOptions.enabled(BuildInfo.debug), ipv6: true, usage: globals.flutterUsage, systemClock: systemClock ?? SystemClock.fixed(DateTime.now()), @@ -1078,7 +1190,7 @@ ResidentRunner setUpResidentRunner(FlutterDevice flutterDevice, { // Unfortunately Device, despite not being immutable, has an `operator ==`. // Until we fix that, we have to also ignore related lints here. // ignore: avoid_implementing_value_types -class FakeWebServerDevice extends FakeDevice implements WebServerDevice { } +class FakeWebServerDevice extends FakeDevice implements WebServerDevice {} // Unfortunately Device, despite not being immutable, has an `operator ==`. // Until we fix that, we have to also ignore related lints here. @@ -1126,7 +1238,8 @@ class FakeDebugConnection extends Fake implements DebugConnection { FakeVmServiceHost Function() fakeVmServiceHost; @override - vm_service.VmService get vmService => fakeVmServiceHost.call().vmService.service; + vm_service.VmService get vmService => + fakeVmServiceHost.call().vmService.service; @override String uri; @@ -1155,9 +1268,9 @@ class FakeAppConnection extends Fake implements AppConnection { // Unfortunately Device, despite not being immutable, has an `operator ==`. // Until we fix that, we have to also ignore related lints here. // ignore: avoid_implementing_value_types -class FakeChromeDevice extends Fake implements ChromiumDevice { } +class FakeChromeDevice extends Fake implements ChromiumDevice {} -class FakeWipDebugger extends Fake implements WipDebugger { } +class FakeWipDebugger extends Fake implements WipDebugger {} class FakeResidentCompiler extends Fake implements ResidentCompiler { @override @@ -1170,15 +1283,16 @@ class FakeResidentCompiler extends Fake implements ResidentCompiler { @required FileSystem fs, bool suppressErrors = false, bool checkDartPluginRegistry = false, + File dartPluginRegistrant, }) async { return const CompilerOutput('foo.dill', 0, []); } @override - void accept() { } + void accept() {} @override - void reset() { } + void reset() {} @override Future reject() async { @@ -1186,7 +1300,7 @@ class FakeResidentCompiler extends Fake implements ResidentCompiler { } @override - void addFileSystemRoot(String root) { } + void addFileSystemRoot(String root) {} } class FakeWebDevFS extends Fake implements WebDevFS { @@ -1229,6 +1343,7 @@ class FakeWebDevFS extends Fake implements WebDevFS { bool bundleFirstUpload = false, bool fullRestart = false, String projectRootPath, + File dartPluginRegistrant, }) async { this.mainUri = mainUri; return report; @@ -1249,7 +1364,8 @@ class FakeChromeConnection extends Fake implements ChromeConnection { final List tabs = []; @override - Future getTab(bool Function(ChromeTab tab) accept, {Duration retryFor}) async { + Future getTab(bool Function(ChromeTab tab) accept, + {Duration retryFor}) async { return tabs.firstWhere(accept); } @@ -1347,16 +1463,16 @@ class FakeFlutterDevice extends Fake implements FlutterDevice { DevFS get devFS => _devFS; @override - set devFS(DevFS value) { } + set devFS(DevFS value) {} @override Device device; @override - Future stopEchoingDeviceLog() async { } + Future stopEchoingDeviceLog() async {} @override - Future initLogReader() async { } + Future initLogReader() async {} @override Future setupDevFS(String fsName, Directory rootDirectory) async { @@ -1364,7 +1480,8 @@ class FakeFlutterDevice extends Fake implements FlutterDevice { } @override - Future exitApps({Duration timeoutDelay = const Duration(seconds: 10)}) async { } + Future exitApps( + {Duration timeoutDelay = const Duration(seconds: 10)}) async {} @override Future connect({ @@ -1380,7 +1497,7 @@ class FakeFlutterDevice extends Fake implements FlutterDevice { bool cacheStartupProfile = false, @required bool allowExistingDdsInstance, bool ipv6 = false, - }) async { } + }) async {} @override Future updateDevFS({ @@ -1396,6 +1513,7 @@ class FakeFlutterDevice extends Fake implements FlutterDevice { String dillOutputPath, List invalidatedFiles, PackageConfig packageConfig, + File dartPluginRegistrant, }) async { if (reportError != null) { throw reportError; @@ -1404,5 +1522,5 @@ class FakeFlutterDevice extends Fake implements FlutterDevice { } @override - Future updateReloadStatus(bool wasReloadSuccessful) async { } + Future updateReloadStatus(bool wasReloadSuccessful) async {} } diff --git a/packages/flutter_tools/test/general.shard/test/test_compiler_test.dart b/packages/flutter_tools/test/general.shard/test/test_compiler_test.dart index cb743f8d39ce..5ff3c7566ff9 100644 --- a/packages/flutter_tools/test/general.shard/test/test_compiler_test.dart +++ b/packages/flutter_tools/test/general.shard/test/test_compiler_test.dart @@ -200,6 +200,7 @@ class FakeResidentCompiler extends Fake implements ResidentCompiler { FileSystem? fs, bool suppressErrors = false, bool checkDartPluginRegistry = false, + File? dartPluginRegistrant, }) async { if (compilerOutput != null) { fileSystem!.file(compilerOutput!.outputFilename).createSync(recursive: true); diff --git a/packages/flutter_tools/test/general.shard/web/devfs_web_test.dart b/packages/flutter_tools/test/general.shard/web/devfs_web_test.dart index c6afde1ea3e7..32d080db3b29 100644 --- a/packages/flutter_tools/test/general.shard/web/devfs_web_test.dart +++ b/packages/flutter_tools/test/general.shard/web/devfs_web_test.dart @@ -1120,6 +1120,7 @@ class FakeResidentCompiler extends Fake implements ResidentCompiler { FileSystem fs, bool suppressErrors = false, bool checkDartPluginRegistry = false, + File dartPluginRegistrant, }) async { return output; }