Unverified Commit cbf2e168 authored by Jenn Magder's avatar Jenn Magder Committed by GitHub

Revert "Support iOS wireless debugging (#118104)" (#118826)

This reverts commit 5cd2d4c6.
parent 5cd2d4c6
......@@ -16,7 +16,7 @@ import '../base/logger.dart';
import '../base/platform.dart';
import '../base/signals.dart';
import '../base/terminal.dart';
import '../build_info.dart';
import '../build_info.dart';
import '../commands/daemon.dart';
import '../compile.dart';
import '../daemon.dart';
......@@ -24,7 +24,6 @@ import '../device.dart';
import '../device_port_forwarder.dart';
import '../fuchsia/fuchsia_device.dart';
import '../ios/devices.dart';
import '../ios/iproxy.dart';
import '../ios/simulators.dart';
import '../macos/macos_ipad_device.dart';
import '../mdns_discovery.dart';
......@@ -230,7 +229,7 @@ known, it can be explicitly provided to attach via the command-line, e.g.
}
if (debugPort != null && debugUri != null) {
throwToolExit(
'Either --debug-port or --debug-url can be provided, not both.');
'Either --debugPort or --debugUri can be provided, not both.');
}
if (userIdentifier != null) {
......@@ -283,9 +282,8 @@ known, it can be explicitly provided to attach via the command-line, e.g.
final String ipv6Loopback = InternetAddress.loopbackIPv6.address;
final String ipv4Loopback = InternetAddress.loopbackIPv4.address;
final String hostname = usesIpv6 ? ipv6Loopback : ipv4Loopback;
final bool isNetworkDevice = (device is IOSDevice) && device.interfaceType == IOSDeviceConnectionInterface.network;
if ((debugPort == null && debugUri == null) || isNetworkDevice) {
if (debugPort == null && debugUri == null) {
if (device is FuchsiaDevice) {
final String module = stringArgDeprecated('module')!;
if (module == null) {
......@@ -305,73 +303,16 @@ known, it can be explicitly provided to attach via the command-line, e.g.
rethrow;
}
} else if ((device is IOSDevice) || (device is IOSSimulator) || (device is MacOSDesignedForIPadDevice)) {
// Protocol Discovery relies on logging. On iOS earlier than 13, logging is gathered using syslog.
// syslog is not available for iOS 13+. For iOS 13+, Protocol Discovery gathers logs from the VMService.
// Since we don't have access to the VMService yet, Protocol Discovery cannot be used for iOS 13+.
// Also, network devices must be found using mDNS and cannot use Protocol Discovery.
final bool compatibleWithProtocolDiscovery = (device is IOSDevice) &&
device.majorSdkVersion < IOSDeviceLogReader.minimumUniversalLoggingSdkVersion &&
!isNetworkDevice;
_logger.printStatus('Waiting for a connection from Flutter on ${device.name}...');
final Status discoveryStatus = _logger.startSpinner(
timeout: const Duration(seconds: 30),
slowWarningCallback: () {
// If relying on mDNS to find Dart VM Service, remind the user to allow local network permissions.
if (!compatibleWithProtocolDiscovery) {
return 'The Dart VM Service was not discovered after 30 seconds. This is taking much longer than expected...\n\n'
'Click "Allow" to the prompt asking if you would like to find and connect devices on your local network. '
'If you selected "Don\'t Allow", you can turn it on in Settings > Your App Name > Local Network. '
"If you don't see your app in the Settings, uninstall the app and rerun to see the prompt again.\n";
}
return 'The Dart VM Service was not discovered after 30 seconds. This is taking much longer than expected...\n';
},
);
int? devicePort;
if (debugPort != null) {
devicePort = debugPort;
} else if (debugUri != null) {
devicePort = debugUri?.port;
} else if (deviceVmservicePort != null) {
devicePort = deviceVmservicePort;
}
final Future<Uri?> mDNSDiscoveryFuture = MDnsVmServiceDiscovery.instance!.getVMServiceUriForAttach(
appId,
device,
usesIpv6: usesIpv6,
isNetworkDevice: isNetworkDevice,
deviceVmservicePort: devicePort,
);
Future<Uri?>? protocolDiscoveryFuture;
if (compatibleWithProtocolDiscovery) {
final ProtocolDiscovery vmServiceDiscovery = ProtocolDiscovery.observatory(
device.getLogReader(),
portForwarder: device.portForwarder,
ipv6: ipv6!,
devicePort: devicePort,
hostPort: hostVmservicePort,
logger: _logger,
);
protocolDiscoveryFuture = vmServiceDiscovery.uri;
}
final Uri? foundUrl;
if (protocolDiscoveryFuture == null) {
foundUrl = await mDNSDiscoveryFuture;
} else {
foundUrl = await Future.any(
<Future<Uri?>>[mDNSDiscoveryFuture, protocolDiscoveryFuture]
final Uri? uriFromMdns =
await MDnsObservatoryDiscovery.instance!.getObservatoryUri(
appId,
device,
usesIpv6: usesIpv6,
deviceVmservicePort: deviceVmservicePort,
);
}
discoveryStatus.stop();
observatoryUri = foundUrl == null
observatoryUri = uriFromMdns == null
? null
: Stream<Uri>.value(foundUrl).asBroadcastStream();
: Stream<Uri>.value(uriFromMdns).asBroadcastStream();
}
// If MDNS discovery fails or we're not on iOS, fallback to ProtocolDiscovery.
if (observatoryUri == null) {
......@@ -394,7 +335,7 @@ known, it can be explicitly provided to attach via the command-line, e.g.
} else {
observatoryUri = Stream<Uri>
.fromFuture(
buildVMServiceUri(
buildObservatoryUri(
device,
debugUri?.host ?? hostname,
debugPort ?? debugUri!.port,
......
......@@ -4,7 +4,6 @@
import 'dart:async';
import 'package:args/args.dart';
import 'package:meta/meta.dart';
import 'package:package_config/package_config_types.dart';
......@@ -22,8 +21,6 @@ import '../dart/package_map.dart';
import '../device.dart';
import '../drive/drive_service.dart';
import '../globals.dart' as globals;
import '../ios/devices.dart';
import '../ios/iproxy.dart';
import '../resident_runner.dart';
import '../runner/flutter_command.dart' show FlutterCommandCategory, FlutterCommandResult, FlutterOptions;
import '../web/web_device.dart';
......@@ -206,27 +203,6 @@ class DriveCommand extends RunCommandBase {
@override
bool get cachePubGet => false;
String? get applicationBinaryPath => stringArgDeprecated(FlutterOptions.kUseApplicationBinary);
Future<Device?> get targetedDevice async {
return findTargetDevice(includeUnsupportedDevices: applicationBinaryPath == null);
}
// Network devices need `publish-port` to be enabled because it requires mDNS.
// If the flag wasn't provided as an actual argument and it's a network device,
// change it to be enabled.
@override
Future<bool> get disablePortPublication async {
final ArgResults? localArgResults = argResults;
final Device? device = await targetedDevice;
final bool isNetworkDevice = device is IOSDevice && device.interfaceType == IOSDeviceConnectionInterface.network;
if (isNetworkDevice && localArgResults != null && !localArgResults.wasParsed('publish-port')) {
_logger.printTrace('Network device is being used. Changing `publish-port` to be enabled.');
return false;
}
return !boolArgDeprecated('publish-port');
}
@override
Future<void> validateCommand() async {
if (userIdentifier != null) {
......@@ -247,7 +223,8 @@ class DriveCommand extends RunCommandBase {
if (await _fileSystem.type(testFile) != FileSystemEntityType.file) {
throwToolExit('Test file not found: $testFile');
}
final Device? device = await targetedDevice;
final String? applicationBinaryPath = stringArgDeprecated(FlutterOptions.kUseApplicationBinary);
final Device? device = await findTargetDevice(includeUnsupportedDevices: applicationBinaryPath == null);
if (device == null) {
throwToolExit(null);
}
......
......@@ -254,7 +254,7 @@ abstract class RunCommandBase extends FlutterCommand with DeviceBasedDevelopment
purgePersistentCache: purgePersistentCache,
deviceVmServicePort: deviceVmservicePort,
hostVmServicePort: hostVmservicePort,
disablePortPublication: await disablePortPublication,
disablePortPublication: disablePortPublication,
ddsPort: ddsPort,
devToolsServerAddress: devToolsServerAddress,
verboseSystemLogs: boolArgDeprecated('verbose-system-logs'),
......
......@@ -275,7 +275,7 @@ Future<T> runInContext<T>(
featureFlags: featureFlags,
platform: globals.platform,
),
MDnsVmServiceDiscovery: () => MDnsVmServiceDiscovery(
MDnsObservatoryDiscovery: () => MDnsObservatoryDiscovery(
logger: globals.logger,
flutterUsage: globals.flutterUsage,
),
......
......@@ -17,7 +17,6 @@ import 'base/utils.dart';
import 'build_info.dart';
import 'devfs.dart';
import 'device_port_forwarder.dart';
import 'ios/iproxy.dart';
import 'project.dart';
import 'vmservice.dart';
......@@ -918,13 +917,7 @@ class DebuggingOptions {
/// * https://github.com/dart-lang/sdk/blob/main/sdk/lib/html/doc/NATIVE_NULL_ASSERTIONS.md
final bool nativeNullAssertions;
List<String> getIOSLaunchArguments(
EnvironmentType environmentType,
String? route,
Map<String, Object?> platformArgs, {
bool ipv6 = false,
IOSDeviceConnectionInterface interfaceType = IOSDeviceConnectionInterface.none
}) {
List<String> getIOSLaunchArguments(EnvironmentType environmentType, String? route, Map<String, Object?> platformArgs) {
final String dartVmFlags = computeDartVmFlags(this);
return <String>[
if (enableDartProfiling) '--enable-dart-profiling',
......@@ -961,9 +954,6 @@ class DebuggingOptions {
// Use the suggested host port.
if (environmentType == EnvironmentType.simulator && hostVmServicePort != null)
'--observatory-port=$hostVmServicePort',
// Tell the observatory to listen on all interfaces, don't restrict to the loopback.
if (interfaceType == IOSDeviceConnectionInterface.network)
'--observatory-host=${ipv6 ? '::0' : '0.0.0.0'}',
];
}
......
......@@ -9,7 +9,6 @@ import 'package:process/process.dart';
import 'package:vm_service/vm_service.dart' as vm_service;
import '../application_package.dart';
import '../base/common.dart';
import '../base/file_system.dart';
import '../base/io.dart';
import '../base/logger.dart';
......@@ -22,7 +21,6 @@ import '../device.dart';
import '../device_port_forwarder.dart';
import '../globals.dart' as globals;
import '../macos/xcdevice.dart';
import '../mdns_discovery.dart';
import '../project.dart';
import '../protocol_discovery.dart';
import '../vmservice.dart';
......@@ -191,6 +189,15 @@ class IOSDevice extends Device {
return majorVersionString != null ? int.tryParse(majorVersionString) ?? 0 : 0;
}
@override
bool get supportsHotReload => interfaceType == IOSDeviceConnectionInterface.usb;
@override
bool get supportsHotRestart => interfaceType == IOSDeviceConnectionInterface.usb;
@override
bool get supportsFlutterExit => interfaceType == IOSDeviceConnectionInterface.usb;
@override
final String name;
......@@ -311,11 +318,7 @@ class IOSDevice extends Device {
@visibleForTesting Duration? discoveryTimeout,
}) async {
String? packageId;
if (interfaceType == IOSDeviceConnectionInterface.network &&
debuggingOptions.debuggingEnabled &&
debuggingOptions.disablePortPublication) {
throwToolExit('Cannot start app on wirelessly tethered iOS device. Try running again with the --publish-port flag');
}
if (!prebuiltApplication) {
_logger.printTrace('Building ${package.name} for $id');
......@@ -350,10 +353,8 @@ class IOSDevice extends Device {
EnvironmentType.physical,
route,
platformArgs,
ipv6: ipv6,
interfaceType: interfaceType,
);
Status startAppStatus = _logger.startProgress(
final Status installStatus = _logger.startProgress(
'Installing and launching...',
);
try {
......@@ -378,10 +379,9 @@ class IOSDevice extends Device {
deviceLogReader.debuggerStream = iosDeployDebugger;
}
}
// Don't port foward if debugging with a network device.
observatoryDiscovery = ProtocolDiscovery.observatory(
deviceLogReader,
portForwarder: interfaceType == IOSDeviceConnectionInterface.network ? null : portForwarder,
portForwarder: portForwarder,
hostPort: debuggingOptions.hostVmServicePort,
devicePort: debuggingOptions.deviceVmServicePort,
ipv6: ipv6,
......@@ -412,59 +412,12 @@ class IOSDevice extends Device {
return LaunchResult.succeeded();
}
_logger.printTrace('Application launched on the device. Waiting for Dart VM Service url.');
final int defaultTimeout = interfaceType == IOSDeviceConnectionInterface.network ? 45 : 30;
final Timer timer = Timer(discoveryTimeout ?? Duration(seconds: defaultTimeout), () {
_logger.printError('The Dart VM Service was not discovered after $defaultTimeout seconds. This is taking much longer than expected...');
// If debugging with a wireless device and the timeout is reached, remind the
// user to allow local network permissions.
if (interfaceType == IOSDeviceConnectionInterface.network) {
_logger.printError(
'\nClick "Allow" to the prompt asking if you would like to find and connect devices on your local network. '
'This is required for wireless debugging. If you selected "Don\'t Allow", '
'you can turn it on in Settings > Your App Name > Local Network. '
"If you don't see your app in the Settings, uninstall the app and rerun to see the prompt again."
);
} else {
iosDeployDebugger?.pauseDumpBacktraceResume();
}
_logger.printTrace('Application launched on the device. Waiting for observatory url.');
final Timer timer = Timer(discoveryTimeout ?? const Duration(seconds: 30), () {
_logger.printError('iOS Observatory not discovered after 30 seconds. This is taking much longer than expected...');
iosDeployDebugger?.pauseDumpBacktraceResume();
});
Uri? localUri;
if (interfaceType == IOSDeviceConnectionInterface.network) {
// Wait for Dart VM Service to start up.
final Uri? serviceURL = await observatoryDiscovery?.uri;
if (serviceURL == null) {
await iosDeployDebugger?.stopAndDumpBacktrace();
return LaunchResult.failed();
}
// If Dart VM Service URL with the device IP is not found within 5 seconds,
// change the status message to prompt users to click Allow. Wait 5 seconds because it
// should only show this message if they have not already approved the permissions.
// MDnsVmServiceDiscovery usually takes less than 5 seconds to find it.
final Timer mDNSLookupTimer = Timer(const Duration(seconds: 5), () {
startAppStatus.stop();
startAppStatus = _logger.startProgress(
'Waiting for approval of local network permissions...',
);
});
// Get Dart VM Service URL with the device IP as the host.
localUri = await MDnsVmServiceDiscovery.instance!.getVMServiceUriForLaunch(
packageId,
this,
usesIpv6: ipv6,
deviceVmservicePort: serviceURL.port,
isNetworkDevice: true,
);
mDNSLookupTimer.cancel();
} else {
localUri = await observatoryDiscovery?.uri;
}
final Uri? localUri = await observatoryDiscovery?.uri;
timer.cancel();
if (localUri == null) {
await iosDeployDebugger?.stopAndDumpBacktrace();
......@@ -476,7 +429,7 @@ class IOSDevice extends Device {
_logger.printError(e.message);
return LaunchResult.failed();
} finally {
startAppStatus.stop();
installStatus.stop();
}
}
......@@ -616,6 +569,7 @@ String decodeSyslog(String line) {
}
}
@visibleForTesting
class IOSDeviceLogReader extends DeviceLogReader {
IOSDeviceLogReader._(
this._iMobileDevice,
......
......@@ -227,16 +227,8 @@ class XCDevice {
/// [timeout] defaults to 2 seconds.
Future<List<IOSDevice>> getAvailableIOSDevices({ Duration? timeout }) async {
Status? loadDevicesStatus;
if (timeout != null && timeout.inSeconds > 2) {
loadDevicesStatus = _logger.startProgress(
'Loading devices...',
);
}
final List<Object>? allAvailableDevices = await _getAllDevices(timeout: timeout ?? const Duration(seconds: 2));
if (loadDevicesStatus != null) {
loadDevicesStatus.stop();
}
if (allAvailableDevices == null) {
return const <IOSDevice>[];
}
......@@ -313,6 +305,12 @@ class XCDevice {
final IOSDeviceConnectionInterface interface = _interfaceType(device);
// Only support USB devices, skip "network" interface (Xcode > Window > Devices and Simulators > Connect via network).
// TODO(jmagman): Remove this check once wirelessly detected devices can be observed and attached, https://github.com/flutter/flutter/issues/15072.
if (interface != IOSDeviceConnectionInterface.usb) {
continue;
}
String? sdkVersion = _sdkVersion(device);
if (sdkVersion != null) {
......
......@@ -569,7 +569,7 @@ abstract class FlutterCommand extends Command<void> {
);
}
Future<bool> get disablePortPublication async => !boolArgDeprecated('publish-port');
bool get disablePortPublication => !boolArgDeprecated('publish-port');
void usesIpv6Flag({required bool verboseHelp}) {
argParser.addFlag(ipv6Flag,
......
......@@ -21,8 +21,6 @@ import 'package:flutter_tools/src/commands/drive.dart';
import 'package:flutter_tools/src/dart/pub.dart';
import 'package:flutter_tools/src/device.dart';
import 'package:flutter_tools/src/drive/drive_service.dart';
import 'package:flutter_tools/src/ios/devices.dart';
import 'package:flutter_tools/src/ios/iproxy.dart';
import 'package:flutter_tools/src/project.dart';
import 'package:package_config/package_config.dart';
import 'package:test/fake.dart';
......@@ -408,94 +406,6 @@ void main() {
FileSystem: () => MemoryFileSystem.test(),
ProcessManager: () => FakeProcessManager.any(),
});
testUsingContext('Port publication not disabled for network device', () async {
final DriveCommand command = DriveCommand(
fileSystem: fileSystem,
logger: logger,
platform: platform,
signals: signals,
);
fileSystem.file('lib/main.dart').createSync(recursive: true);
fileSystem.file('test_driver/main_test.dart').createSync(recursive: true);
fileSystem.file('pubspec.yaml').createSync();
final Device networkDevice = FakeIosDevice()
..interfaceType = IOSDeviceConnectionInterface.network;
fakeDeviceManager.devices = <Device>[networkDevice];
await expectLater(() => createTestCommandRunner(command).run(<String>[
'drive',
]), throwsToolExit());
final DebuggingOptions options = await command.createDebuggingOptions(false);
expect(options.disablePortPublication, false);
}, overrides: <Type, Generator>{
Cache: () => Cache.test(processManager: FakeProcessManager.any()),
FileSystem: () => MemoryFileSystem.test(),
ProcessManager: () => FakeProcessManager.any(),
DeviceManager: () => fakeDeviceManager,
});
testUsingContext('Port publication is disabled for wired device', () async {
final DriveCommand command = DriveCommand(
fileSystem: fileSystem,
logger: logger,
platform: platform,
signals: signals,
);
fileSystem.file('lib/main.dart').createSync(recursive: true);
fileSystem.file('test_driver/main_test.dart').createSync(recursive: true);
fileSystem.file('pubspec.yaml').createSync();
await expectLater(() => createTestCommandRunner(command).run(<String>[
'drive',
]), throwsToolExit());
final Device usbDevice = FakeIosDevice()
..interfaceType = IOSDeviceConnectionInterface.usb;
fakeDeviceManager.devices = <Device>[usbDevice];
final DebuggingOptions options = await command.createDebuggingOptions(false);
expect(options.disablePortPublication, true);
}, overrides: <Type, Generator>{
Cache: () => Cache.test(processManager: FakeProcessManager.any()),
FileSystem: () => MemoryFileSystem.test(),
ProcessManager: () => FakeProcessManager.any(),
DeviceManager: () => fakeDeviceManager,
});
testUsingContext('Port publication does not default to enabled for network device if flag manually added', () async {
final DriveCommand command = DriveCommand(
fileSystem: fileSystem,
logger: logger,
platform: platform,
signals: signals,
);
fileSystem.file('lib/main.dart').createSync(recursive: true);
fileSystem.file('test_driver/main_test.dart').createSync(recursive: true);
fileSystem.file('pubspec.yaml').createSync();
final Device networkDevice = FakeIosDevice()
..interfaceType = IOSDeviceConnectionInterface.network;
fakeDeviceManager.devices = <Device>[networkDevice];
await expectLater(() => createTestCommandRunner(command).run(<String>[
'drive',
'--no-publish-port'
]), throwsToolExit());
final DebuggingOptions options = await command.createDebuggingOptions(false);
expect(options.disablePortPublication, true);
}, overrides: <Type, Generator>{
Cache: () => Cache.test(processManager: FakeProcessManager.any()),
FileSystem: () => MemoryFileSystem.test(),
ProcessManager: () => FakeProcessManager.any(),
DeviceManager: () => fakeDeviceManager,
});
}
// Unfortunately Device, despite not being immutable, has an `operator ==`.
......@@ -667,14 +577,3 @@ class FakeProcessSignal extends Fake implements io.ProcessSignal {
@override
Stream<io.ProcessSignal> watch() => controller.stream;
}
// 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 FakeIosDevice extends Fake implements IOSDevice {
@override
IOSDeviceConnectionInterface interfaceType = IOSDeviceConnectionInterface.usb;
@override
Future<TargetPlatform> get targetPlatform async => TargetPlatform.ios;
}
......@@ -11,7 +11,6 @@ import 'package:flutter_tools/src/base/utils.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/convert.dart';
import 'package:flutter_tools/src/device.dart';
import 'package:flutter_tools/src/ios/iproxy.dart';
import 'package:flutter_tools/src/project.dart';
import 'package:test/fake.dart';
......@@ -555,53 +554,6 @@ void main() {
);
});
testWithoutContext('Get launch arguments for physical device with iPv4 network connection', () {
final DebuggingOptions original = DebuggingOptions.enabled(
BuildInfo.debug,
);
final List<String> launchArguments = original.getIOSLaunchArguments(
EnvironmentType.physical,
null,
<String, Object?>{},
interfaceType: IOSDeviceConnectionInterface.network,
);
expect(
launchArguments.join(' '),
<String>[
'--enable-dart-profiling',
'--enable-checked-mode',
'--verify-entry-points',
'--observatory-host=0.0.0.0',
].join(' '),
);
});
testWithoutContext('Get launch arguments for physical device with iPv6 network connection', () {
final DebuggingOptions original = DebuggingOptions.enabled(
BuildInfo.debug,
);
final List<String> launchArguments = original.getIOSLaunchArguments(
EnvironmentType.physical,
null,
<String, Object?>{},
ipv6: true,
interfaceType: IOSDeviceConnectionInterface.network,
);
expect(
launchArguments.join(' '),
<String>[
'--enable-dart-profiling',
'--enable-checked-mode',
'--verify-entry-points',
'--observatory-host=::0',
].join(' '),
);
});
testWithoutContext('Get launch arguments for physical device with debugging disabled with available launch arguments', () {
final DebuggingOptions original = DebuggingOptions.disabled(
BuildInfo.debug,
......
......@@ -19,11 +19,9 @@ import 'package:flutter_tools/src/ios/devices.dart';
import 'package:flutter_tools/src/ios/ios_deploy.dart';
import 'package:flutter_tools/src/ios/iproxy.dart';
import 'package:flutter_tools/src/ios/mac.dart';
import 'package:flutter_tools/src/mdns_discovery.dart';
import 'package:test/fake.dart';
import '../../src/common.dart';
import '../../src/context.dart';
import '../../src/fake_devices.dart';
import '../../src/fake_process_manager.dart';
import '../../src/fakes.dart';
......@@ -68,10 +66,9 @@ const FakeCommand kLaunchDebugCommand = FakeCommand(command: <String>[
FakeCommand attachDebuggerCommand({
IOSink? stdin,
Completer<void>? completer,
bool isNetworkDevice = false,
}) {
return FakeCommand(
command: <String>[
command: const <String>[
'script',
'-t',
'0',
......@@ -82,12 +79,9 @@ FakeCommand attachDebuggerCommand({
'--bundle',
'/',
'--debug',
if (!isNetworkDevice) '--no-wifi',
'--no-wifi',
'--args',
if (isNetworkDevice)
'--enable-dart-profiling --enable-checked-mode --verify-entry-points --observatory-host=0.0.0.0'
else
'--enable-dart-profiling --enable-checked-mode --verify-entry-points',
'--enable-dart-profiling --enable-checked-mode --verify-entry-points',
],
completer: completer,
environment: const <String, String>{
......@@ -194,7 +188,7 @@ void main() {
expect(await device.stopApp(iosApp), false);
});
testWithoutContext('IOSDevice.startApp prints warning message if discovery takes longer than configured timeout for wired device', () async {
testWithoutContext('IOSDevice.startApp prints warning message if discovery takes longer than configured timeout', () async {
final FileSystem fileSystem = MemoryFileSystem.test();
final BufferLogger logger = BufferLogger.test();
final CompleterIOSink stdin = CompleterIOSink();
......@@ -232,59 +226,12 @@ void main() {
expect(launchResult.started, true);
expect(launchResult.hasObservatory, true);
expect(await device.stopApp(iosApp), false);
expect(logger.errorText, contains('The Dart VM Service was not discovered after 30 seconds. This is taking much longer than expected...'));
expect(logger.errorText, contains('iOS Observatory not discovered after 30 seconds. This is taking much longer than expected...'));
expect(utf8.decoder.convert(stdin.writes.first), contains('process interrupt'));
completer.complete();
expect(processManager, hasNoRemainingExpectations);
});
testUsingContext('IOSDevice.startApp prints warning message if discovery takes longer than configured timeout for wireless device', () async {
final FileSystem fileSystem = MemoryFileSystem.test();
final BufferLogger logger = BufferLogger.test();
final CompleterIOSink stdin = CompleterIOSink();
final Completer<void> completer = Completer<void>();
final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
attachDebuggerCommand(stdin: stdin, completer: completer, isNetworkDevice: true),
]);
final IOSDevice device = setUpIOSDevice(
processManager: processManager,
fileSystem: fileSystem,
logger: logger,
interfaceType: IOSDeviceConnectionInterface.network,
);
final IOSApp iosApp = PrebuiltIOSApp(
projectBundleId: 'app',
bundleName: 'Runner',
uncompressedBundle: fileSystem.currentDirectory,
applicationPackage: fileSystem.currentDirectory,
);
final FakeDeviceLogReader deviceLogReader = FakeDeviceLogReader();
device.portForwarder = const NoOpDevicePortForwarder();
device.setLogReader(iosApp, deviceLogReader);
// Start writing messages to the log reader.
deviceLogReader.addLine('Foo');
deviceLogReader.addLine('The Dart VM service is listening on http://127.0.0.1:456');
final LaunchResult launchResult = await device.startApp(iosApp,
prebuiltApplication: true,
debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug),
platformArgs: <String, dynamic>{},
discoveryTimeout: Duration.zero,
);
expect(launchResult.started, true);
expect(launchResult.hasObservatory, true);
expect(await device.stopApp(iosApp), false);
expect(logger.errorText, contains('The Dart VM Service was not discovered after 45 seconds. This is taking much longer than expected...'));
expect(logger.errorText, contains('Click "Allow" to the prompt asking if you would like to find and connect devices on your local network.'));
completer.complete();
expect(processManager, hasNoRemainingExpectations);
}, overrides: <Type, Generator>{
MDnsVmServiceDiscovery: () => FakeMDnsVmServiceDiscovery(),
});
testWithoutContext('IOSDevice.startApp succeeds in release mode', () async {
final FileSystem fileSystem = MemoryFileSystem.test();
final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
......@@ -558,7 +505,6 @@ IOSDevice setUpIOSDevice({
Logger? logger,
ProcessManager? processManager,
IOSDeploy? iosDeploy,
IOSDeviceConnectionInterface interfaceType = IOSDeviceConnectionInterface.usb,
}) {
final Artifacts artifacts = Artifacts.test();
final FakePlatform macPlatform = FakePlatform(
......@@ -596,7 +542,7 @@ IOSDevice setUpIOSDevice({
cache: cache,
),
cpuArchitecture: DarwinArch.arm64,
interfaceType: interfaceType,
interfaceType: IOSDeviceConnectionInterface.usb,
);
}
......@@ -608,18 +554,3 @@ class FakeDevicePortForwarder extends Fake implements DevicePortForwarder {
disposed = true;
}
}
class FakeMDnsVmServiceDiscovery extends Fake implements MDnsVmServiceDiscovery {
@override
Future<Uri?> getVMServiceUriForLaunch(
String applicationId,
Device device, {
bool usesIpv6 = false,
int? hostVmservicePort,
required int deviceVmservicePort,
bool isNetworkDevice = false,
Duration timeout = Duration.zero,
}) async {
return Uri.tryParse('http://0.0.0.0:1234');
}
}
......@@ -479,7 +479,7 @@ void main() {
stdout: devicesOutput,
));
final List<IOSDevice> devices = await xcdevice.getAvailableIOSDevices();
expect(devices, hasLength(4));
expect(devices, hasLength(3));
expect(devices[0].id, '00008027-00192736010F802E');
expect(devices[0].name, 'An iPhone (Space Gray)');
expect(await devices[0].sdkNameAndVersion, 'iOS 13.3 17C54');
......@@ -488,14 +488,10 @@ void main() {
expect(devices[1].name, 'iPad 1');
expect(await devices[1].sdkNameAndVersion, 'iOS 10.1 14C54');
expect(devices[1].cpuArchitecture, DarwinArch.armv7);
expect(devices[2].id, '234234234234234234345445687594e089dede3c44');
expect(devices[2].name, 'A networked iPad');
expect(devices[2].id, 'f577a7903cc54959be2e34bc4f7f80b7009efcf4');
expect(devices[2].name, 'iPad 2');
expect(await devices[2].sdkNameAndVersion, 'iOS 10.1 14C54');
expect(devices[2].cpuArchitecture, DarwinArch.arm64); // Defaults to arm64 for unknown architecture.
expect(devices[3].id, 'f577a7903cc54959be2e34bc4f7f80b7009efcf4');
expect(devices[3].name, 'iPad 2');
expect(await devices[3].sdkNameAndVersion, 'iOS 10.1 14C54');
expect(devices[3].cpuArchitecture, DarwinArch.arm64); // Defaults to arm64 for unknown architecture.
expect(fakeProcessManager, hasNoRemainingExpectations);
}, overrides: <Type, Generator>{
Platform: () => macPlatform,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment