From 3ce6c1f4baa18177d05f6e76aeff3aab6a111d14 Mon Sep 17 00:00:00 2001 From: Dan Field Date: Mon, 3 May 2021 15:15:10 -0700 Subject: [PATCH] [flutter drive] Do not start dds if --no-dds (#81784) --- .../lib/src/drive/drive_service.dart | 28 ++++++++++--------- .../drive/drive_service_test.dart | 7 ++++- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/packages/flutter_tools/lib/src/drive/drive_service.dart b/packages/flutter_tools/lib/src/drive/drive_service.dart index a6458c8328..81ffa83e4b 100644 --- a/packages/flutter_tools/lib/src/drive/drive_service.dart +++ b/packages/flutter_tools/lib/src/drive/drive_service.dart @@ -204,19 +204,21 @@ class FlutterDriverService extends DriverService { } _vmServiceUri = uri.toString(); _device = device; - try { - await device.dds.startDartDevelopmentService( - uri, - debuggingOptions.ddsPort, - ipv6, - debuggingOptions.disableServiceAuthCodes, - logger: _logger, - ); - _vmServiceUri = device.dds.uri.toString(); - } on dds.DartDevelopmentServiceException { - // If there's another flutter_tools instance still connected to the target - // application, DDS will already be running remotely and this call will fail. - // This can be ignored to continue to use the existing remote DDS instance. + if (debuggingOptions.enableDds) { + try { + await device.dds.startDartDevelopmentService( + uri, + debuggingOptions.ddsPort, + ipv6, + debuggingOptions.disableServiceAuthCodes, + logger: _logger, + ); + _vmServiceUri = device.dds.uri.toString(); + } on dds.DartDevelopmentServiceException { + // If there's another flutter_tools instance still connected to the target + // application, DDS will already be running remotely and this call will fail. + // This can be ignored to continue to use the existing remote DDS instance. + } } _vmService = await _vmServiceConnector(uri, device: _device); final DeviceLogReader logReader = await device.getLogReader(app: _applicationPackage); diff --git a/packages/flutter_tools/test/general.shard/drive/drive_service_test.dart b/packages/flutter_tools/test/general.shard/drive/drive_service_test.dart index 9b1c80afb1..469ce35c58 100644 --- a/packages/flutter_tools/test/general.shard/drive/drive_service_test.dart +++ b/packages/flutter_tools/test/general.shard/drive/drive_service_test.dart @@ -222,7 +222,7 @@ void main() { command: ['dart', 'foo.test', '-rexpanded'], exitCode: 11, environment: { - 'VM_SERVICE_URL': 'http://127.0.0.1:1234/' + 'VM_SERVICE_URL': 'http://127.0.0.1:63426/1UasC_ihpXY=/' }, ), ]); @@ -230,8 +230,12 @@ void main() { final Device device = FakeDevice(LaunchResult.succeeded( observatoryUri: Uri.parse('http://127.0.0.1:63426/1UasC_ihpXY=/'), )); + final FakeDartDevelopmentService dds = device.dds as FakeDartDevelopmentService; + expect(dds.started, false); await driverService.start(BuildInfo.profile, device, DebuggingOptions.enabled(BuildInfo.profile, enableDds: false), true); + expect(dds.started, false); + final int testResult = await driverService.startTest( 'foo.test', [], @@ -240,6 +244,7 @@ void main() { ); expect(testResult, 11); + expect(dds.started, false); }); testWithoutContext('Safely stops and uninstalls application', () async {