Remove "Mac Designed for iPad" as a discoverable flutter run
device (#161459)
It's confusing that the "Mac Designed for iPad" device is discoverabe for `flutter run`, but if you select it then it complains that's not a runnable target. It currently only works for `flutter attach`. Reverts 42317804ee Fixes https://github.com/flutter/flutter/issues/161250 ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
This commit is contained in:
parent
136d8e576a
commit
3850ba32e0
@ -218,6 +218,9 @@ known, it can be explicitly provided to attach via the command-line, e.g.
|
||||
|
||||
@override
|
||||
Future<void> validateCommand() async {
|
||||
// ARM macOS as an iOS target is hidden, except for attach.
|
||||
MacOSDesignedForIPadDevices.allowDiscovery = true;
|
||||
|
||||
await super.validateCommand();
|
||||
|
||||
final Device? targetDevice = await findTargetDevice();
|
||||
|
@ -25,7 +25,6 @@ import '../drive/drive_service.dart';
|
||||
import '../drive/web_driver_service.dart' show Browser;
|
||||
import '../globals.dart' as globals;
|
||||
import '../ios/devices.dart';
|
||||
import '../macos/macos_ipad_device.dart';
|
||||
import '../resident_runner.dart';
|
||||
import '../runner/flutter_command.dart'
|
||||
show FlutterCommandCategory, FlutterCommandResult, FlutterOptions;
|
||||
@ -270,9 +269,6 @@ class DriveCommand extends RunCommandBase {
|
||||
if (device is! AndroidDevice) {
|
||||
throwToolExit('--${FlutterOptions.kDeviceUser} is only supported for Android');
|
||||
}
|
||||
if (device is MacOSDesignedForIPadDevice) {
|
||||
throwToolExit('Mac Designed for iPad is currently not supported for flutter drive.');
|
||||
}
|
||||
}
|
||||
return super.validateCommand();
|
||||
}
|
||||
|
@ -19,7 +19,6 @@ import '../device.dart';
|
||||
import '../features.dart';
|
||||
import '../globals.dart' as globals;
|
||||
import '../ios/devices.dart';
|
||||
import '../macos/macos_ipad_device.dart';
|
||||
import '../project.dart';
|
||||
import '../reporting/reporting.dart';
|
||||
import '../resident_runner.dart';
|
||||
@ -684,15 +683,6 @@ class RunCommand extends RunCommandBase {
|
||||
if (devices == null) {
|
||||
throwToolExit(null);
|
||||
}
|
||||
|
||||
if (devices!.length == 1 && devices!.first is MacOSDesignedForIPadDevice) {
|
||||
throwToolExit('Mac Designed for iPad is currently not supported for flutter run -d.');
|
||||
}
|
||||
|
||||
if (globals.deviceManager!.hasSpecifiedAllDevices) {
|
||||
devices?.removeWhere((Device device) => device is MacOSDesignedForIPadDevice);
|
||||
}
|
||||
|
||||
if (globals.deviceManager!.hasSpecifiedAllDevices && runningWithPrebuiltApplication) {
|
||||
throwToolExit(
|
||||
'Using "-d all" with "--${FlutterOptions.kUseApplicationBinary}" is not supported',
|
||||
|
@ -152,7 +152,11 @@ class MacOSDesignedForIPadDevices extends PollingDeviceDiscovery {
|
||||
@override
|
||||
bool get canListAnything =>
|
||||
_iosWorkflow.canListDevices &&
|
||||
_operatingSystemUtils.hostPlatform == HostPlatform.darwin_arm64;
|
||||
_operatingSystemUtils.hostPlatform == HostPlatform.darwin_arm64 &&
|
||||
allowDiscovery;
|
||||
|
||||
/// Set to show ARM macOS as an iOS device target.
|
||||
static bool allowDiscovery = false;
|
||||
|
||||
@override
|
||||
Future<List<Device>> pollingGetDevices({Duration? timeout}) async {
|
||||
|
@ -25,6 +25,7 @@ import 'package:flutter_tools/src/device_port_forwarder.dart';
|
||||
import 'package:flutter_tools/src/device_vm_service_discovery_for_attach.dart';
|
||||
import 'package:flutter_tools/src/ios/application_package.dart';
|
||||
import 'package:flutter_tools/src/ios/devices.dart';
|
||||
import 'package:flutter_tools/src/macos/macos_ipad_device.dart';
|
||||
import 'package:flutter_tools/src/mdns_discovery.dart';
|
||||
import 'package:flutter_tools/src/project.dart';
|
||||
import 'package:flutter_tools/src/reporting/reporting.dart';
|
||||
@ -51,6 +52,10 @@ class FakeProcessInfo extends Fake implements ProcessInfo {
|
||||
}
|
||||
|
||||
void main() {
|
||||
tearDown(() {
|
||||
MacOSDesignedForIPadDevices.allowDiscovery = false;
|
||||
});
|
||||
|
||||
group('attach', () {
|
||||
late StreamLogger logger;
|
||||
late FileSystem testFileSystem;
|
||||
@ -1330,6 +1335,7 @@ void main() {
|
||||
expect(testLogger.statusText, containsIgnoringWhitespace('More than one device'));
|
||||
expect(testLogger.statusText, contains('xx1'));
|
||||
expect(testLogger.statusText, contains('yy2'));
|
||||
expect(MacOSDesignedForIPadDevices.allowDiscovery, isTrue);
|
||||
},
|
||||
overrides: <Type, Generator>{
|
||||
FileSystem: () => testFileSystem,
|
||||
|
@ -23,7 +23,6 @@ import 'package:flutter_tools/src/devfs.dart';
|
||||
import 'package:flutter_tools/src/device.dart';
|
||||
import 'package:flutter_tools/src/globals.dart' as globals;
|
||||
import 'package:flutter_tools/src/ios/devices.dart';
|
||||
import 'package:flutter_tools/src/macos/macos_ipad_device.dart';
|
||||
import 'package:flutter_tools/src/project.dart';
|
||||
import 'package:flutter_tools/src/reporting/reporting.dart';
|
||||
import 'package:flutter_tools/src/resident_runner.dart';
|
||||
@ -278,72 +277,6 @@ void main() {
|
||||
},
|
||||
);
|
||||
|
||||
testUsingContext(
|
||||
'Using flutter run -d with MacOSDesignedForIPadDevices throws an error',
|
||||
() async {
|
||||
final RunCommand command = RunCommand();
|
||||
testDeviceManager.devices = <Device>[FakeMacDesignedForIpadDevice()];
|
||||
|
||||
await expectLater(
|
||||
() => createTestCommandRunner(
|
||||
command,
|
||||
).run(<String>['run', '-d', 'mac-designed-for-ipad']),
|
||||
throwsToolExit(
|
||||
message: 'Mac Designed for iPad is currently not supported for flutter run -d',
|
||||
),
|
||||
);
|
||||
},
|
||||
overrides: <Type, Generator>{
|
||||
FileSystem: () => fs,
|
||||
ProcessManager: () => FakeProcessManager.any(),
|
||||
DeviceManager: () => testDeviceManager,
|
||||
Stdio: () => FakeStdio(),
|
||||
Cache: () => Cache.test(processManager: FakeProcessManager.any()),
|
||||
},
|
||||
);
|
||||
|
||||
testUsingContext(
|
||||
'Using flutter run -d all with a single MacOSDesignedForIPadDevices throws a tool error',
|
||||
() async {
|
||||
final RunCommand command = RunCommand();
|
||||
testDeviceManager.devices = <Device>[FakeMacDesignedForIpadDevice()];
|
||||
|
||||
await expectLater(
|
||||
() => createTestCommandRunner(command).run(<String>['run', '-d', 'all']),
|
||||
throwsToolExit(
|
||||
message: 'Mac Designed for iPad is currently not supported for flutter run -d',
|
||||
),
|
||||
);
|
||||
},
|
||||
overrides: <Type, Generator>{
|
||||
FileSystem: () => fs,
|
||||
ProcessManager: () => FakeProcessManager.any(),
|
||||
DeviceManager: () => testDeviceManager,
|
||||
Stdio: () => FakeStdio(),
|
||||
Cache: () => Cache.test(processManager: FakeProcessManager.any()),
|
||||
},
|
||||
);
|
||||
|
||||
testUsingContext(
|
||||
'Using flutter run -d all with MacOSDesignedForIPadDevices removes from device list, and attempts to launch',
|
||||
() async {
|
||||
final RunCommand command = TestRunCommandThatOnlyValidates();
|
||||
testDeviceManager.devices = <Device>[FakeMacDesignedForIpadDevice(), FakeDevice()];
|
||||
|
||||
await createTestCommandRunner(command).run(<String>['run', '-d', 'all']);
|
||||
|
||||
expect(command.devices?.length, 1);
|
||||
expect(command.devices?.single.id, 'fake_device');
|
||||
},
|
||||
overrides: <Type, Generator>{
|
||||
FileSystem: () => fs,
|
||||
ProcessManager: () => FakeProcessManager.any(),
|
||||
DeviceManager: () => testDeviceManager,
|
||||
Stdio: () => FakeStdio(),
|
||||
Cache: () => Cache.test(processManager: FakeProcessManager.any()),
|
||||
},
|
||||
);
|
||||
|
||||
testUsingContext(
|
||||
'exits and lists available devices when specified device not found',
|
||||
() async {
|
||||
@ -1684,26 +1617,6 @@ class FakeDevice extends Fake implements Device {
|
||||
}
|
||||
}
|
||||
|
||||
class FakeMacDesignedForIpadDevice extends Fake implements MacOSDesignedForIPadDevice {
|
||||
@override
|
||||
String get id => 'mac-designed-for-ipad';
|
||||
|
||||
@override
|
||||
bool get isConnected => true;
|
||||
|
||||
@override
|
||||
Future<TargetPlatform> get targetPlatform async => TargetPlatform.darwin;
|
||||
|
||||
@override
|
||||
DeviceConnectionInterface connectionInterface = DeviceConnectionInterface.attached;
|
||||
|
||||
@override
|
||||
bool isSupported() => true;
|
||||
|
||||
@override
|
||||
bool isSupportedForProject(FlutterProject project) => true;
|
||||
}
|
||||
|
||||
class FakeIOSDevice extends Fake implements IOSDevice {
|
||||
FakeIOSDevice({
|
||||
this.connectionInterface = DeviceConnectionInterface.attached,
|
||||
|
@ -21,7 +21,12 @@ import '../../src/fakes.dart';
|
||||
|
||||
void main() {
|
||||
group('MacOSDesignedForIPadDevices', () {
|
||||
tearDown(() {
|
||||
MacOSDesignedForIPadDevices.allowDiscovery = false;
|
||||
});
|
||||
|
||||
testWithoutContext('does not support non-macOS platforms', () async {
|
||||
MacOSDesignedForIPadDevices.allowDiscovery = true;
|
||||
final MacOSDesignedForIPadDevices discoverer = MacOSDesignedForIPadDevices(
|
||||
platform: FakePlatform(operatingSystem: 'windows'),
|
||||
logger: BufferLogger.test(),
|
||||
@ -34,7 +39,7 @@ void main() {
|
||||
expect(discoverer.supportsPlatform, isFalse);
|
||||
});
|
||||
|
||||
testWithoutContext('discovery is allowed', () async {
|
||||
testWithoutContext('discovery not allowed', () async {
|
||||
final MacOSDesignedForIPadDevices discoverer = MacOSDesignedForIPadDevices(
|
||||
platform: FakePlatform(operatingSystem: 'macos'),
|
||||
logger: BufferLogger.test(),
|
||||
@ -46,12 +51,11 @@ void main() {
|
||||
expect(discoverer.supportsPlatform, isTrue);
|
||||
|
||||
final List<Device> devices = await discoverer.devices();
|
||||
expect(devices, isNotNull);
|
||||
expect(devices.first.id, 'mac-designed-for-ipad');
|
||||
expect(devices.first is MacOSDesignedForIPadDevice, true);
|
||||
expect(devices, isEmpty);
|
||||
});
|
||||
|
||||
testWithoutContext('no device on x86', () async {
|
||||
MacOSDesignedForIPadDevices.allowDiscovery = true;
|
||||
final MacOSDesignedForIPadDevices discoverer = MacOSDesignedForIPadDevices(
|
||||
platform: FakePlatform(operatingSystem: 'macos'),
|
||||
logger: BufferLogger.test(),
|
||||
@ -67,6 +71,7 @@ void main() {
|
||||
});
|
||||
|
||||
testWithoutContext('no device on when iOS development off', () async {
|
||||
MacOSDesignedForIPadDevices.allowDiscovery = true;
|
||||
final MacOSDesignedForIPadDevices discoverer = MacOSDesignedForIPadDevices(
|
||||
platform: FakePlatform(operatingSystem: 'macos'),
|
||||
logger: BufferLogger.test(),
|
||||
@ -82,6 +87,7 @@ void main() {
|
||||
});
|
||||
|
||||
testWithoutContext('device discovery on arm', () async {
|
||||
MacOSDesignedForIPadDevices.allowDiscovery = true;
|
||||
final MacOSDesignedForIPadDevices discoverer = MacOSDesignedForIPadDevices(
|
||||
platform: FakePlatform(operatingSystem: 'macos'),
|
||||
logger: BufferLogger.test(),
|
||||
|
Loading…
x
Reference in New Issue
Block a user