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

Show macOS arm64 architecture in doctor and devices list (#69245)

parent bd121ecd
......@@ -621,6 +621,10 @@ abstract class Device {
/// The device's platform.
Future<TargetPlatform> get targetPlatform;
/// Platform name for display only.
Future<String> get targetPlatformDisplayName async =>
getNameForTargetPlatform(await targetPlatform);
Future<String> get sdkNameAndVersion;
/// Create a platform-specific [DevFSWriter] for the given [app], or
......@@ -749,7 +753,7 @@ abstract class Device {
table.add(<String>[
'${device.name} (${device.category})',
device.id,
getNameForTargetPlatform(targetPlatform),
await device.targetPlatformDisplayName,
'${await device.sdkNameAndVersion}$supportIndicator',
]);
}
......
......@@ -27,6 +27,7 @@ class MacOSDevice extends DesktopDevice {
@required OperatingSystemUtils operatingSystemUtils,
}) : _processManager = processManager,
_logger = logger,
_operatingSystemUtils = operatingSystemUtils,
super(
'macos',
platformType: PlatformType.macos,
......@@ -39,6 +40,7 @@ class MacOSDevice extends DesktopDevice {
final ProcessManager _processManager;
final Logger _logger;
final OperatingSystemUtils _operatingSystemUtils;
@override
bool isSupported() => true;
......@@ -46,9 +48,20 @@ class MacOSDevice extends DesktopDevice {
@override
String get name => 'macOS';
/// Returns [TargetPlatform.darwin_x64] even on macOS ARM devices.
///
/// Build system, artifacts rely on Rosetta to translate to x86_64 on ARM.
@override
Future<TargetPlatform> get targetPlatform async => TargetPlatform.darwin_x64;
@override
Future<String> get targetPlatformDisplayName async {
if (_operatingSystemUtils.hostPlatform == HostPlatform.darwin_arm) {
return 'darwin-arm64';
}
return super.targetPlatformDisplayName;
}
@override
bool isSupportedForProject(FlutterProject flutterProject) {
return flutterProject.macos.existsSync();
......
......@@ -604,6 +604,9 @@ void main() {
when(device.id).thenReturn(id);
when(device.isLocalEmulator).thenAnswer((_) async => false);
when(device.sdkNameAndVersion).thenAnswer((_) async => 'Android 46');
when(device.targetPlatformDisplayName)
.thenAnswer((_) async => 'android');
return device;
}
......
......@@ -1059,5 +1059,6 @@ class MockDevice extends Mock implements Device {
when(id).thenReturn('device-id');
when(isLocalEmulator).thenAnswer((_) => Future<bool>.value(false));
when(targetPlatform).thenAnswer((_) => Future<TargetPlatform>.value(TargetPlatform.android));
when(targetPlatformDisplayName).thenAnswer((_) async => 'android');
}
}
......@@ -238,6 +238,8 @@ void main() {
when(mockDevice.id).thenReturn('mock-id');
when(mockDevice.name).thenReturn('mock-name');
when(mockDevice.platformType).thenReturn(PlatformType.android);
when(mockDevice.targetPlatformDisplayName)
.thenAnswer((Invocation invocation) async => 'mock-platform');
when(mockDevice.sdkNameAndVersion).thenAnswer((Invocation invocation) => Future<String>.value('api-14'));
when(mockDeviceManager.getDevices()).thenAnswer((Invocation invocation) {
......
......@@ -166,6 +166,34 @@ void main() {
expect(device.isSupportedForProject(flutterProject), true);
});
testWithoutContext('target platform display name on x86_64', () async {
final FakeOperatingSystemUtils fakeOperatingSystemUtils =
FakeOperatingSystemUtils();
fakeOperatingSystemUtils.hostPlatform = HostPlatform.darwin_x64;
final MacOSDevice device = MacOSDevice(
fileSystem: MemoryFileSystem.test(),
logger: BufferLogger.test(),
processManager: FakeProcessManager.any(),
operatingSystemUtils: fakeOperatingSystemUtils,
);
expect(await device.targetPlatformDisplayName, 'darwin-x64');
});
testWithoutContext('target platform display name on ARM', () async {
final FakeOperatingSystemUtils fakeOperatingSystemUtils =
FakeOperatingSystemUtils();
fakeOperatingSystemUtils.hostPlatform = HostPlatform.darwin_arm;
final MacOSDevice device = MacOSDevice(
fileSystem: MemoryFileSystem.test(),
logger: BufferLogger.test(),
processManager: FakeProcessManager.any(),
operatingSystemUtils: fakeOperatingSystemUtils,
);
expect(await device.targetPlatformDisplayName, 'darwin-arm64');
});
testUsingContext('isSupportedForProject is false with no host app', () async {
final FileSystem fileSystem = MemoryFileSystem.test();
final MacOSDevice device = MacOSDevice(
......
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