From d7d12412e5ba55ebbc508de983f731b28efaddb1 Mon Sep 17 00:00:00 2001 From: Ben Konyi Date: Thu, 27 Aug 2020 16:35:00 -0700 Subject: [PATCH] Re-enable the Dart Development Service (DDS) (#64671) This change re-enables DDS and outputs the DDS URI in place of the VM service URI on the console. If --disable-dds is not provided, --host-vmservice-port will be used to determine the port for DDS rather than the host port for the VM service, which will instead be randomly chosen. --- .../lib/src/android/android_device.dart | 2 +- packages/flutter_tools/lib/src/base/dds.dart | 17 ++++------- .../flutter_tools/lib/src/commands/drive.dart | 9 ++++-- .../flutter_tools/lib/src/commands/run.dart | 16 +++++----- .../flutter_tools/lib/src/commands/test.dart | 2 ++ .../flutter_tools/lib/src/desktop_device.dart | 2 +- .../lib/src/fuchsia/fuchsia_device.dart | 14 ++++++--- .../flutter_tools/lib/src/ios/devices.dart | 4 +-- .../flutter_tools/lib/src/ios/simulators.dart | 9 ++++-- .../lib/src/resident_runner.dart | 8 ++++- .../lib/src/runner/flutter_command.dart | 2 ++ .../lib/src/test/flutter_platform.dart | 30 ++++++++++++++----- .../flutter_tools/lib/src/test/runner.dart | 3 ++ .../lib/src/tester/flutter_tester.dart | 4 +-- .../commands.shard/hermetic/attach_test.dart | 13 ++++---- .../commands.shard/hermetic/drive_test.dart | 3 +- .../commands.shard/hermetic/test_test.dart | 1 + .../test/general.shard/cold_test.dart | 2 ++ .../fuchsia/fuchsia_device_test.dart | 9 ++++-- .../test/general.shard/hot_test.dart | 2 ++ .../ios/ios_device_start_prebuilt_test.dart | 6 +++- .../general.shard/resident_runner_test.dart | 5 +++- .../vmservice_integration_test.dart | 3 +- 23 files changed, 111 insertions(+), 55 deletions(-) diff --git a/packages/flutter_tools/lib/src/android/android_device.dart b/packages/flutter_tools/lib/src/android/android_device.dart index a2579f53a2..bd70e8d30d 100644 --- a/packages/flutter_tools/lib/src/android/android_device.dart +++ b/packages/flutter_tools/lib/src/android/android_device.dart @@ -620,7 +620,7 @@ class AndroidDevice extends Device { observatoryDiscovery = ProtocolDiscovery.observatory( await getLogReader(), portForwarder: portForwarder, - hostPort: debuggingOptions.hostVmServicePort, + hostPort: debuggingOptions.disableDds ? debuggingOptions.hostVmServicePort : 0, devicePort: debuggingOptions.deviceVmServicePort, ipv6: ipv6, ); diff --git a/packages/flutter_tools/lib/src/base/dds.dart b/packages/flutter_tools/lib/src/base/dds.dart index 4bd4c82d48..84a672065c 100644 --- a/packages/flutter_tools/lib/src/base/dds.dart +++ b/packages/flutter_tools/lib/src/base/dds.dart @@ -15,30 +15,24 @@ import 'logger.dart'; class DartDevelopmentService { DartDevelopmentService({@required this.logger}); - // TODO(bkonyi): enable once VM service can handle SSE forwarding for - // Devtools (https://github.com/flutter/flutter/issues/62507) - static const bool ddsDisabled = true; final Logger logger; dds.DartDevelopmentService _ddsInstance; + Uri get uri => _ddsInstance.uri; + Future startDartDevelopmentService( Uri observatoryUri, + int hostPort, bool ipv6, + bool disableServiceAuthCodes, ) async { - if (ddsDisabled) { - logger.printTrace( - 'DDS is currently disabled due to ' - 'https://github.com/flutter/flutter/issues/62507' - ); - return; - } final Uri ddsUri = Uri( scheme: 'http', host: (ipv6 ? io.InternetAddress.loopbackIPv6 : io.InternetAddress.loopbackIPv4 ).host, - port: 0, + port: hostPort ?? 0, ); logger.printTrace( 'Launching a Dart Developer Service (DDS) instance at $ddsUri, ' @@ -48,6 +42,7 @@ class DartDevelopmentService { _ddsInstance = await dds.DartDevelopmentService.startDartDevelopmentService( observatoryUri, serviceUri: ddsUri, + enableAuthCodes: !disableServiceAuthCodes, ); logger.printTrace('DDS is listening at ${_ddsInstance.uri}.'); } on dds.DartDevelopmentServiceException catch (e) { diff --git a/packages/flutter_tools/lib/src/commands/drive.dart b/packages/flutter_tools/lib/src/commands/drive.dart index 0980e6899c..d0fcd1ceb5 100644 --- a/packages/flutter_tools/lib/src/commands/drive.dart +++ b/packages/flutter_tools/lib/src/commands/drive.dart @@ -240,7 +240,12 @@ class DriveCommand extends RunCommandBase { // If there's another flutter_tools instance still connected to the target // application, DDS will already be running remotely and this call will fail. // We can ignore this and continue to use the remote DDS instance. - await device.dds.startDartDevelopmentService(Uri.parse(observatoryUri), ipv6); + await device.dds.startDartDevelopmentService( + Uri.parse(observatoryUri), + hostVmservicePort, + ipv6, + disableServiceAuthCodes, + ); } on dds.DartDevelopmentServiceException catch(_) { globals.printTrace('Note: DDS is already connected to $observatoryUri.'); } @@ -478,7 +483,7 @@ Future _startApp( debuggingOptions: DebuggingOptions.enabled( command.getBuildInfo(), startPaused: true, - hostVmServicePort: command.hostVmservicePort, + hostVmServicePort: (webUri != null || command.disableDds) ? command.hostVmservicePort : 0, verboseSystemLogs: command.verboseSystemLogs, cacheSkSL: command.cacheSkSL, dumpSkpOnShaderCompilation: command.dumpSkpOnShaderCompilation, diff --git a/packages/flutter_tools/lib/src/commands/run.dart b/packages/flutter_tools/lib/src/commands/run.dart index fd5b739068..12d4deab3b 100644 --- a/packages/flutter_tools/lib/src/commands/run.dart +++ b/packages/flutter_tools/lib/src/commands/run.dart @@ -66,7 +66,12 @@ abstract class RunCommandBase extends FlutterCommand with DeviceBasedDevelopment help: 'A file to write the attached vmservice uri to after an' ' application is started.', valueHelp: 'project/example/out.txt' - ); + ) + ..addFlag('disable-service-auth-codes', + negatable: false, + hide: !verboseHelp, + help: 'No longer require an authentication code to connect to the VM ' + 'service (not recommended).'); usesWebOptions(hide: !verboseHelp); usesTargetOption(); usesPortOptions(); @@ -75,13 +80,14 @@ abstract class RunCommandBase extends FlutterCommand with DeviceBasedDevelopment usesTrackWidgetCreation(verboseHelp: verboseHelp); addNullSafetyModeOptions(hide: !verboseHelp); usesDeviceUserOption(); + addDdsOptions(verboseHelp: verboseHelp); } bool get traceStartup => boolArg('trace-startup'); bool get cacheSkSL => boolArg('cache-sksl'); bool get dumpSkpOnShaderCompilation => boolArg('dump-skp-on-shader-compilation'); bool get purgePersistentCache => boolArg('purge-persistent-cache'); - + bool get disableServiceAuthCodes => boolArg('disable-service-auth-codes'); String get route => stringArg('route'); } @@ -205,11 +211,6 @@ class RunCommand extends RunCommandBase { 'results out to "refresh_benchmark.json", and exit. This flag is ' 'intended for use in generating automated flutter benchmarks.', ) - ..addFlag('disable-service-auth-codes', - negatable: false, - hide: !verboseHelp, - help: 'No longer require an authentication code to connect to the VM ' - 'service (not recommended).') ..addFlag('web-initialize-platform', negatable: true, defaultsTo: true, @@ -226,7 +227,6 @@ class RunCommand extends RunCommandBase { 'Currently this is only supported on Android devices. This option ' 'cannot be paired with --use-application-binary.' ); - addDdsOptions(verboseHelp: verboseHelp); } @override diff --git a/packages/flutter_tools/lib/src/commands/test.dart b/packages/flutter_tools/lib/src/commands/test.dart index a990b39888..824c785ef7 100644 --- a/packages/flutter_tools/lib/src/commands/test.dart +++ b/packages/flutter_tools/lib/src/commands/test.dart @@ -130,6 +130,7 @@ class TestCommand extends FlutterCommand { 'This flag is ignored if --start-paused or coverage are requested. ' 'The vmservice will be enabled no matter what in those cases.' ); + addDdsOptions(verboseHelp: verboseHelp); } /// The interface for starting and configuring the tester. @@ -254,6 +255,7 @@ class TestCommand extends FlutterCommand { enableObservatory: collector != null || startPaused || boolArg('enable-vmservice'), startPaused: startPaused, disableServiceAuthCodes: disableServiceAuthCodes, + disableDds: disableDds, ipv6: boolArg('ipv6'), machine: machine, buildMode: BuildMode.debug, diff --git a/packages/flutter_tools/lib/src/desktop_device.dart b/packages/flutter_tools/lib/src/desktop_device.dart index 26561e5c53..74743ec56c 100644 --- a/packages/flutter_tools/lib/src/desktop_device.dart +++ b/packages/flutter_tools/lib/src/desktop_device.dart @@ -134,7 +134,7 @@ abstract class DesktopDevice extends Device { } final ProtocolDiscovery observatoryDiscovery = ProtocolDiscovery.observatory(_deviceLogReader, devicePort: debuggingOptions?.deviceVmServicePort, - hostPort: debuggingOptions?.hostVmServicePort, + hostPort: (debuggingOptions?.disableDds ?? false) ? debuggingOptions?.hostVmServicePort : 0, ipv6: ipv6, ); try { diff --git a/packages/flutter_tools/lib/src/fuchsia/fuchsia_device.dart b/packages/flutter_tools/lib/src/fuchsia/fuchsia_device.dart index 37fef4400c..8ef7d92998 100644 --- a/packages/flutter_tools/lib/src/fuchsia/fuchsia_device.dart +++ b/packages/flutter_tools/lib/src/fuchsia/fuchsia_device.dart @@ -55,8 +55,14 @@ Future _kDefaultFuchsiaIsolateDiscoveryConnector(Uri uri) Future _kDefaultDartDevelopmentServiceStarter( Device device, Uri observatoryUri, + bool disableServiceAuthCodes, ) async { - await device.dds.startDartDevelopmentService(observatoryUri, true); + await device.dds.startDartDevelopmentService( + observatoryUri, + 0, + true, + disableServiceAuthCodes, + ); } /// Read the log for a particular device. @@ -738,7 +744,7 @@ class FuchsiaIsolateDiscoveryProtocol { final String _isolateName; final Completer _foundUri = Completer(); final Future Function(Uri) _vmServiceConnector; - final Future Function(Device, Uri) _ddsStarter; + final Future Function(Device, Uri, bool) _ddsStarter; // whether to only poll once. final bool _pollOnce; Timer _pollingTimer; @@ -781,8 +787,8 @@ class FuchsiaIsolateDiscoveryProtocol { final int localPort = await _device.portForwarder.forward(port); try { final Uri uri = Uri.parse('http://[$_ipv6Loopback]:$localPort'); - await _ddsStarter(_device, uri); - service = await _vmServiceConnector(uri); + await _ddsStarter(_device, uri, true); + service = await _vmServiceConnector(_device.dds.uri); _ports[port] = service; } on SocketException catch (err) { globals.printTrace('Failed to connect to $localPort: $err'); diff --git a/packages/flutter_tools/lib/src/ios/devices.dart b/packages/flutter_tools/lib/src/ios/devices.dart index 6e5266cc95..45509b3879 100644 --- a/packages/flutter_tools/lib/src/ios/devices.dart +++ b/packages/flutter_tools/lib/src/ios/devices.dart @@ -399,7 +399,7 @@ class IOSDevice extends Device { observatoryDiscovery = ProtocolDiscovery.observatory( getLogReader(app: package), portForwarder: portForwarder, - hostPort: debuggingOptions.hostVmServicePort, + hostPort: debuggingOptions.disableDds ? debuggingOptions.hostVmServicePort : 0, devicePort: debuggingOptions.deviceVmServicePort, ipv6: ipv6, ); @@ -436,7 +436,7 @@ class IOSDevice extends Device { assumedDevicePort: assumedObservatoryPort, device: this, usesIpv6: ipv6, - hostVmservicePort: debuggingOptions.hostVmServicePort, + hostVmservicePort: debuggingOptions.disableDds ? debuggingOptions.hostVmServicePort : 0, packageId: packageId, packageName: FlutterProject.current().manifest.appName, ); diff --git a/packages/flutter_tools/lib/src/ios/simulators.dart b/packages/flutter_tools/lib/src/ios/simulators.dart index dcba2bbbc2..e21017b1e2 100644 --- a/packages/flutter_tools/lib/src/ios/simulators.dart +++ b/packages/flutter_tools/lib/src/ios/simulators.dart @@ -424,8 +424,11 @@ class IOSSimulator extends Device { if (debuggingOptions.skiaDeterministicRendering) '--skia-deterministic-rendering', if (debuggingOptions.useTestFonts) '--use-test-fonts', if (debuggingOptions.traceAllowlist != null) '--trace-allowlist="${debuggingOptions.traceAllowlist}"', - if (dartVmFlags.isNotEmpty) '--dart-flags=$dartVmFlags' - '--observatory-port=${debuggingOptions.hostVmServicePort ?? 0}', + if (dartVmFlags.isNotEmpty) '--dart-flags=$dartVmFlags', + if (debuggingOptions.disableDds) + '--observatory-port=${debuggingOptions.hostVmServicePort ?? 0}' + else + '--observatory-port=0' ], ]; @@ -434,7 +437,7 @@ class IOSSimulator extends Device { observatoryDiscovery = ProtocolDiscovery.observatory( getLogReader(app: package), ipv6: ipv6, - hostPort: debuggingOptions.hostVmServicePort, + hostPort: debuggingOptions.disableDds ? debuggingOptions.hostVmServicePort : 0, devicePort: debuggingOptions.deviceVmServicePort, ); } diff --git a/packages/flutter_tools/lib/src/resident_runner.dart b/packages/flutter_tools/lib/src/resident_runner.dart index ec645f39e5..72cda230b7 100644 --- a/packages/flutter_tools/lib/src/resident_runner.dart +++ b/packages/flutter_tools/lib/src/resident_runner.dart @@ -205,6 +205,8 @@ class FlutterDevice { ReloadMethod reloadMethod, GetSkSLMethod getSkSLMethod, PrintStructuredErrorLogMethod printStructuredErrorLogMethod, + int hostVmServicePort, + bool disableServiceAuthCodes = false, bool disableDds = false, bool ipv6 = false, }) { @@ -220,12 +222,14 @@ class FlutterDevice { if (!disableDds) { await device.dds.startDartDevelopmentService( observatoryUri, + hostVmServicePort, ipv6, + disableServiceAuthCodes, ); } try { service = await connectToVmService( - observatoryUri, + disableDds ? observatoryUri : device.dds.uri, reloadSources: reloadSources, restart: restart, compileExpression: compileExpression, @@ -1232,10 +1236,12 @@ abstract class ResidentRunner { restart: restart, compileExpression: compileExpression, disableDds: debuggingOptions.disableDds, + hostVmServicePort: debuggingOptions.hostVmServicePort, reloadMethod: reloadMethod, getSkSLMethod: getSkSLMethod, printStructuredErrorLogMethod: printStructuredErrorLog, ipv6: ipv6, + disableServiceAuthCodes: debuggingOptions.disableServiceAuthCodes ); // This will wait for at least one flutter view before returning. final Status status = globals.logger.startProgress( diff --git a/packages/flutter_tools/lib/src/runner/flutter_command.dart b/packages/flutter_tools/lib/src/runner/flutter_command.dart index 2100e93913..ec22de5c12 100644 --- a/packages/flutter_tools/lib/src/runner/flutter_command.dart +++ b/packages/flutter_tools/lib/src/runner/flutter_command.dart @@ -312,6 +312,8 @@ abstract class FlutterCommand extends Command { ); } + bool get disableDds => boolArg('disable-dds'); + /// Gets the vmservice port provided to in the 'observatory-port' or /// 'host-vmservice-port option. /// diff --git a/packages/flutter_tools/lib/src/test/flutter_platform.dart b/packages/flutter_tools/lib/src/test/flutter_platform.dart index 8fd501c4ba..85ed046c0b 100644 --- a/packages/flutter_tools/lib/src/test/flutter_platform.dart +++ b/packages/flutter_tools/lib/src/test/flutter_platform.dart @@ -4,6 +4,7 @@ import 'dart:async'; +import 'package:dds/dds.dart'; import 'package:meta/meta.dart'; import 'package:package_config/package_config.dart'; import 'package:stream_channel/stream_channel.dart'; @@ -52,6 +53,7 @@ FlutterPlatform installHook({ bool machine = false, bool startPaused = false, bool disableServiceAuthCodes = false, + bool disableDds = false, int port = 0, String precompiledDillPath, Map precompiledDillFiles, @@ -89,6 +91,7 @@ FlutterPlatform installHook({ enableObservatory: enableObservatory, startPaused: startPaused, disableServiceAuthCodes: disableServiceAuthCodes, + disableDds: disableDds, explicitObservatoryPort: observatoryPort, host: _kHosts[serverType], port: port, @@ -233,6 +236,7 @@ class FlutterPlatform extends PlatformPlugin { this.machine, this.startPaused, this.disableServiceAuthCodes, + this.disableDds, this.explicitObservatoryPort, this.host, this.port, @@ -255,6 +259,7 @@ class FlutterPlatform extends PlatformPlugin { final bool machine; final bool startPaused; final bool disableServiceAuthCodes; + final bool disableDds; final int explicitObservatoryPort; final InternetAddress host; final int port; @@ -402,7 +407,7 @@ class FlutterPlatform extends PlatformPlugin { controllerSinkClosed = true; })); - // Prepare our WebSocket server to talk to the engine subproces. + // Prepare our WebSocket server to talk to the engine subprocess. final HttpServer server = await bind(host, port); finalizers.add(() async { globals.printTrace('test $ourTestCount: shutting down test harness socket server'); @@ -496,15 +501,16 @@ class FlutterPlatform extends PlatformPlugin { assert(processObservatoryUri == null); assert(explicitObservatoryPort == null || explicitObservatoryPort == detectedUri.port); - if (startPaused && !machine) { - globals.printStatus('The test process has been started.'); - globals.printStatus('You can now connect to it using observatory. To connect, load the following Web site in your browser:'); - globals.printStatus(' $detectedUri'); - globals.printStatus('You should first set appropriate breakpoints, then resume the test in the debugger.'); + if (!disableDds) { + final DartDevelopmentService dds = await DartDevelopmentService.startDartDevelopmentService( + detectedUri, + enableAuthCodes: !disableServiceAuthCodes, + ); + processObservatoryUri = dds.uri; + globals.printTrace('Dart Development Service started at ${dds.uri}, forwarding to VM service at ${dds.remoteVmServiceUri}.'); } else { - globals.printTrace('test $ourTestCount: using observatory uri $detectedUri from pid ${process.pid}'); + processObservatoryUri = detectedUri; } - processObservatoryUri = detectedUri; { globals.printTrace('Connecting to service protocol: $processObservatoryUri'); final Future localVmService = connectToVmService(processObservatoryUri, @@ -513,6 +519,14 @@ class FlutterPlatform extends PlatformPlugin { globals.printTrace('Successfully connected to service protocol: $processObservatoryUri'); })); } + if (startPaused && !machine) { + globals.printStatus('The test process has been started.'); + globals.printStatus('You can now connect to it using observatory. To connect, load the following Web site in your browser:'); + globals.printStatus(' $processObservatoryUri'); + globals.printStatus('You should first set appropriate breakpoints, then resume the test in the debugger.'); + } else { + globals.printTrace('test $ourTestCount: using observatory uri $processObservatoryUri from pid ${process.pid}'); + } gotProcessObservatoryUri.complete(); watcher?.handleStartedProcess( ProcessEvent(ourTestCount, process, processObservatoryUri)); diff --git a/packages/flutter_tools/lib/src/test/runner.dart b/packages/flutter_tools/lib/src/test/runner.dart index daa1cff67e..29fea56ede 100644 --- a/packages/flutter_tools/lib/src/test/runner.dart +++ b/packages/flutter_tools/lib/src/test/runner.dart @@ -36,6 +36,7 @@ abstract class FlutterTestRunner { bool enableObservatory = false, bool startPaused = false, bool disableServiceAuthCodes = false, + bool disableDds = false, bool ipv6 = false, bool machine = false, String precompiledDillPath, @@ -71,6 +72,7 @@ class _FlutterTestRunnerImpl implements FlutterTestRunner { bool enableObservatory = false, bool startPaused = false, bool disableServiceAuthCodes = false, + bool disableDds = false, bool ipv6 = false, bool machine = false, String precompiledDillPath, @@ -169,6 +171,7 @@ class _FlutterTestRunnerImpl implements FlutterTestRunner { machine: machine, startPaused: startPaused, disableServiceAuthCodes: disableServiceAuthCodes, + disableDds: disableDds, serverType: serverType, precompiledDillPath: precompiledDillPath, precompiledDillFiles: precompiledDillFiles, diff --git a/packages/flutter_tools/lib/src/tester/flutter_tester.dart b/packages/flutter_tools/lib/src/tester/flutter_tester.dart index ff38ddc5ae..a65d338b0a 100644 --- a/packages/flutter_tools/lib/src/tester/flutter_tester.dart +++ b/packages/flutter_tools/lib/src/tester/flutter_tester.dart @@ -178,7 +178,7 @@ class FlutterTesterDevice extends Device { if (debuggingOptions.disableServiceAuthCodes) '--disable-service-auth-codes', if (debuggingOptions.hasObservatoryPort) - '--observatory-port=${debuggingOptions.hostVmServicePort}', + '--observatory-port=${debuggingOptions.disableDds ? debuggingOptions.hostVmServicePort : 0}', applicationKernelFilePath ]; @@ -205,7 +205,7 @@ class FlutterTesterDevice extends Device { observatoryDiscovery = ProtocolDiscovery.observatory( getLogReader(), - hostPort: debuggingOptions.hostVmServicePort, + hostPort: debuggingOptions.disableDds ? debuggingOptions.hostVmServicePort : 0, devicePort: debuggingOptions.deviceVmServicePort, ipv6: ipv6, ); diff --git a/packages/flutter_tools/test/commands.shard/hermetic/attach_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/attach_test.dart index c2a94e13f6..c617e97d71 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/attach_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/attach_test.dart @@ -90,8 +90,8 @@ void main() { when(portForwarder.unforward(any)) .thenAnswer((_) async {}); when(device.dds).thenReturn(mockDds); - when(mockDds.startDartDevelopmentService(any, false)).thenReturn(null); - + when(mockDds.startDartDevelopmentService(any, any, false, any)).thenReturn(null); + when(mockDds.uri).thenReturn(Uri.parse('http://localhost:8181')); final HttpClientRequest httpClientRequest = MockHttpClientRequest(); httpClient = MockHttpClient(); when(httpClient.putUrl(any)) @@ -317,7 +317,8 @@ void main() { )).thenReturn(mockHotRunner); when(mockHotRunner.exited).thenReturn(false); when(mockHotRunner.isWaitingForObservatory).thenReturn(false); - when(mockDds.startDartDevelopmentService(any, false)).thenReturn(null); + when(mockDds.startDartDevelopmentService(any, any, false, any)).thenReturn(null); + when(mockDds.uri).thenReturn(Uri.parse('http://localhost:8181')); testDeviceManager.addDevice(device); when(device.getLogReader(includePastLogs: anyNamed('includePastLogs'))) @@ -396,7 +397,8 @@ void main() { )).thenReturn(mockHotRunner); when(mockHotRunner.exited).thenReturn(false); when(mockHotRunner.isWaitingForObservatory).thenReturn(false); - when(mockDds.startDartDevelopmentService(any, false)).thenReturn(null); + when(mockDds.startDartDevelopmentService(any, any, false, any)).thenReturn(null); + when(mockDds.uri).thenReturn(Uri.parse('http://localhost:8181')); testDeviceManager.addDevice(device); @@ -442,8 +444,9 @@ void main() { .thenAnswer((_) async {}); when(device.dds) .thenReturn(mockDds); - when(mockDds.startDartDevelopmentService(any, any)) + when(mockDds.startDartDevelopmentService(any, any, any, any)) .thenReturn(null); + when(mockDds.uri).thenReturn(Uri.parse('http://localhost:8181')); }); testUsingContext('succeeds in ipv4 mode', () async { diff --git a/packages/flutter_tools/test/commands.shard/hermetic/drive_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/drive_test.dart index 8a36a9efc2..cb4c16d2fe 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/drive_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/drive_test.dart @@ -71,7 +71,8 @@ void main() { void applyDdsMocks(Device device) { final MockDartDevelopmentService mockDds = MockDartDevelopmentService(); when(device.dds).thenReturn(mockDds); - when(mockDds.startDartDevelopmentService(any, any)).thenReturn(null); + when(mockDds.startDartDevelopmentService(any, any, any, any)).thenReturn(null); + when(mockDds.uri).thenReturn(Uri.parse('http://localhost:8181')); } testUsingContext('returns 1 when test file is not found', () async { diff --git a/packages/flutter_tools/test/commands.shard/hermetic/test_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/test_test.dart index 83030d9a5e..0788868c2d 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/test_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/test_test.dart @@ -168,6 +168,7 @@ class FakeFlutterTestRunner implements FlutterTestRunner { String excludeTags, bool enableObservatory = false, bool startPaused = false, + bool disableDds = false, bool disableServiceAuthCodes = false, bool ipv6 = false, bool machine = false, diff --git a/packages/flutter_tools/test/general.shard/cold_test.dart b/packages/flutter_tools/test/general.shard/cold_test.dart index 3141df0705..8ef7fd39b1 100644 --- a/packages/flutter_tools/test/general.shard/cold_test.dart +++ b/packages/flutter_tools/test/general.shard/cold_test.dart @@ -140,6 +140,8 @@ class TestFlutterDevice extends FlutterDevice { GetSkSLMethod getSkSLMethod, PrintStructuredErrorLogMethod printStructuredErrorLogMethod, bool disableDds = false, + bool disableServiceAuthCodes = false, + int hostVmServicePort, bool ipv6 = false, }) async { throw exception; diff --git a/packages/flutter_tools/test/general.shard/fuchsia/fuchsia_device_test.dart b/packages/flutter_tools/test/general.shard/fuchsia/fuchsia_device_test.dart index 4c92500387..c6ed5a3214 100644 --- a/packages/flutter_tools/test/general.shard/fuchsia/fuchsia_device_test.dart +++ b/packages/flutter_tools/test/general.shard/fuchsia/fuchsia_device_test.dart @@ -10,6 +10,7 @@ import 'package:flutter_tools/src/application_package.dart'; import 'package:flutter_tools/src/artifacts.dart'; import 'package:flutter_tools/src/base/common.dart'; import 'package:flutter_tools/src/base/context.dart'; +import 'package:flutter_tools/src/base/dds.dart'; import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/io.dart'; import 'package:flutter_tools/src/base/logger.dart'; @@ -769,10 +770,13 @@ void main() { fuchsiaDevice, expectedIsolateName, (Uri uri) async => fakeVmServiceHost.vmService, - (Device device, Uri uri) => null, + (Device device, Uri uri, bool enableServiceAuthCodes) => null, true, // only poll once. ); - + final MockDartDevelopmentService mockDds = MockDartDevelopmentService(); + when(fuchsiaDevice.dds).thenReturn(mockDds); + when(mockDds.startDartDevelopmentService(any, any, any, any)).thenReturn(null); + when(mockDds.uri).thenReturn(Uri.parse('example')); when(fuchsiaDevice.servicePorts()) .thenAnswer((Invocation invocation) async => [1]); when(portForwarder.forward(1)) @@ -1600,5 +1604,6 @@ class MockFuchsiaSdk extends Mock implements FuchsiaSdk { final FuchsiaDevFinder fuchsiaDevFinder; } +class MockDartDevelopmentService extends Mock implements DartDevelopmentService {} class MockFuchsiaWorkflow extends Mock implements FuchsiaWorkflow {} class MockCache extends Mock implements Cache {} diff --git a/packages/flutter_tools/test/general.shard/hot_test.dart b/packages/flutter_tools/test/general.shard/hot_test.dart index 3d11937fb7..789e3292f1 100644 --- a/packages/flutter_tools/test/general.shard/hot_test.dart +++ b/packages/flutter_tools/test/general.shard/hot_test.dart @@ -578,8 +578,10 @@ class TestFlutterDevice extends FlutterDevice { ReloadMethod reloadMethod, GetSkSLMethod getSkSLMethod, PrintStructuredErrorLogMethod printStructuredErrorLogMethod, + bool disableServiceAuthCodes = false, bool disableDds = false, bool ipv6 = false, + int hostVmServicePort }) async { throw exception; } diff --git a/packages/flutter_tools/test/general.shard/ios/ios_device_start_prebuilt_test.dart b/packages/flutter_tools/test/general.shard/ios/ios_device_start_prebuilt_test.dart index 561ed85039..a4d9f8f870 100644 --- a/packages/flutter_tools/test/general.shard/ios/ios_device_start_prebuilt_test.dart +++ b/packages/flutter_tools/test/general.shard/ios/ios_device_start_prebuilt_test.dart @@ -7,6 +7,7 @@ import 'dart:async'; import 'package:file/memory.dart'; import 'package:flutter_tools/src/application_package.dart'; import 'package:flutter_tools/src/artifacts.dart'; +import 'package:flutter_tools/src/base/dds.dart'; import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/io.dart' as io; import 'package:flutter_tools/src/base/logger.dart'; @@ -135,7 +136,8 @@ void main() { when(MDnsObservatoryDiscovery.instance.getObservatoryUri( any, any, - usesIpv6: anyNamed('usesIpv6') + usesIpv6: anyNamed('usesIpv6'), + hostVmservicePort: anyNamed('hostVmservicePort') )).thenAnswer((Invocation invocation) async => uri); final LaunchResult launchResult = await device.startApp(iosApp, @@ -367,6 +369,7 @@ void main() { any, any, usesIpv6: anyNamed('usesIpv6'), + hostVmservicePort: anyNamed('hostVmservicePort') )).thenAnswer((Invocation invocation) async => uri); final LaunchResult launchResult = await device.startApp(iosApp, @@ -454,3 +457,4 @@ class MockMDnsObservatoryDiscovery extends Mock implements MDnsObservatoryDiscov class MockArtifacts extends Mock implements Artifacts {} class MockCache extends Mock implements Cache {} class MockVmService extends Mock implements VmService {} +class MockDartDevelopmentService extends Mock implements DartDevelopmentService {} \ No newline at end of file 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 2726bf8624..0388176bca 100644 --- a/packages/flutter_tools/test/general.shard/resident_runner_test.dart +++ b/packages/flutter_tools/test/general.shard/resident_runner_test.dart @@ -2095,7 +2095,8 @@ void main() { final MockDeviceLogReader mockLogReader = MockDeviceLogReader(); when(mockDevice.getLogReader(app: anyNamed('app'))).thenReturn(mockLogReader); when(mockDevice.dds).thenReturn(mockDds); - when(mockDds.startDartDevelopmentService(any, any)).thenReturn(null); + when(mockDds.startDartDevelopmentService(any, any, any, any)).thenReturn(null); + when(mockDds.uri).thenReturn(Uri.parse('http://localhost:8181')); final TestFlutterDevice flutterDevice = TestFlutterDevice( mockDevice, @@ -2182,10 +2183,12 @@ class FakeFlutterDevice extends FlutterDevice { ReloadSources reloadSources, Restart restart, bool disableDds = false, + bool disableServiceAuthCodes = false, bool ipv6 = false, CompileExpression compileExpression, ReloadMethod reloadMethod, GetSkSLMethod getSkSLMethod, + int hostVmServicePort, PrintStructuredErrorLogMethod printStructuredErrorLogMethod, }) async { } diff --git a/packages/flutter_tools/test/integration.shard/vmservice_integration_test.dart b/packages/flutter_tools/test/integration.shard/vmservice_integration_test.dart index 122636f1b4..2466b7cdaa 100644 --- a/packages/flutter_tools/test/integration.shard/vmservice_integration_test.dart +++ b/packages/flutter_tools/test/integration.shard/vmservice_integration_test.dart @@ -6,7 +6,6 @@ import 'dart:async'; import 'dart:io'; // ignore: dart_io_import import 'package:file/file.dart'; -import 'package:flutter_tools/src/base/dds.dart'; import 'package:flutter_tools/src/base/file_system.dart'; import 'package:matcher/matcher.dart'; import 'package:vm_service/vm_service.dart'; @@ -47,7 +46,7 @@ void main() { for (final Protocol protocol in protocolList.protocols) { expect(protocol.protocolName, anyOf('VM Service', 'DDS')); } - }, skip: DartDevelopmentService.ddsDisabled); + }); test('flutterVersion can be called', () async { final Response response =