From 8ca55605c811e3814f45383499d283a835a0f4d0 Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Thu, 12 Dec 2019 13:55:42 -0800 Subject: [PATCH] [flutter_tool] forward device-vmservice-port to iOS device launch arguments (#46822) --- .../flutter_tools/lib/src/ios/devices.dart | 2 + .../test/general.shard/ios/devices_test.dart | 48 ++++++++++++++++++- 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/packages/flutter_tools/lib/src/ios/devices.dart b/packages/flutter_tools/lib/src/ios/devices.dart index 0eb510460c..7361c17a28 100644 --- a/packages/flutter_tools/lib/src/ios/devices.dart +++ b/packages/flutter_tools/lib/src/ios/devices.dart @@ -345,6 +345,8 @@ class IOSDevice extends Device { if (debuggingOptions.dumpSkpOnShaderCompilation) '--dump-skp-on-shader-compilation', if (debuggingOptions.verboseSystemLogs) '--verbose-logging', if (debuggingOptions.cacheSkSL) '--cache-sksl', + if (debuggingOptions.deviceVmServicePort != null) + '--observatory-port=${debuggingOptions.deviceVmServicePort}', if (platformArgs['trace-startup'] as bool ?? false) '--trace-startup', ]; diff --git a/packages/flutter_tools/test/general.shard/ios/devices_test.dart b/packages/flutter_tools/test/general.shard/ios/devices_test.dart index 7d7995e86b..f5848913b0 100644 --- a/packages/flutter_tools/test/general.shard/ios/devices_test.dart +++ b/packages/flutter_tools/test/general.shard/ios/devices_test.dart @@ -410,7 +410,7 @@ void main() { Usage: () => mockUsage, }); - testUsingContext(' succeeds in release mode', () async { + testUsingContext('succeeds in release mode', () async { final IOSDevice device = IOSDevice('123'); final LaunchResult launchResult = await device.startApp(mockApp, prebuiltApplication: true, @@ -428,7 +428,7 @@ void main() { ProcessManager: () => mockProcessManager, }); - testUsingContext(' succeeds with --cache-sksl', () async { + testUsingContext('succeeds with --cache-sksl', () async { final IOSDevice device = IOSDevice('123'); device.setLogReader(mockApp, mockLogReader); final Uri uri = Uri( @@ -472,6 +472,50 @@ void main() { IOSDeploy: () => mockIosDeploy, }); + testUsingContext('succeeds with --device-vmservice-port', () async { + final IOSDevice device = IOSDevice('123'); + device.setLogReader(mockApp, mockLogReader); + final Uri uri = Uri( + scheme: 'http', + host: '127.0.0.1', + port: 1234, + path: 'observatory', + ); + when(mockMDnsObservatoryDiscovery.getObservatoryUri(any, any, usesIpv6: anyNamed('usesIpv6'))) + .thenAnswer((Invocation invocation) => Future.value(uri)); + + List args; + when(mockIosDeploy.runApp( + deviceId: anyNamed('deviceId'), + bundlePath: anyNamed('bundlePath'), + launchArguments: anyNamed('launchArguments'), + )).thenAnswer((Invocation inv) { + args = inv.namedArguments[const Symbol('launchArguments')] as List; + return Future.value(0); + }); + + final LaunchResult launchResult = await device.startApp(mockApp, + prebuiltApplication: true, + debuggingOptions: DebuggingOptions.enabled( + const BuildInfo(BuildMode.debug, null), + deviceVmServicePort: 8181, + ), + platformArgs: {}, + ); + expect(launchResult.started, isTrue); + expect(args, contains('--observatory-port=8181')); + expect(await device.stopApp(mockApp), isFalse); + }, overrides: { + Artifacts: () => mockArtifacts, + Cache: () => mockCache, + FileSystem: () => mockFileSystem, + MDnsObservatoryDiscovery: () => mockMDnsObservatoryDiscovery, + Platform: () => macPlatform, + ProcessManager: () => mockProcessManager, + Usage: () => mockUsage, + IOSDeploy: () => mockIosDeploy, + }); + void testNonPrebuilt( String name, { @required bool showBuildSettingsFlakes,