Unverified Commit 2e5284a2 authored by Jenn Magder's avatar Jenn Magder Committed by GitHub

Do not list Android or iOS devices when feature disabled (#85145)

parent 4606a746
...@@ -57,18 +57,16 @@ class AndroidWorkflow implements Workflow { ...@@ -57,18 +57,16 @@ class AndroidWorkflow implements Workflow {
&& _operatingSystemUtils.hostPlatform != HostPlatform.linux_arm64; && _operatingSystemUtils.hostPlatform != HostPlatform.linux_arm64;
@override @override
bool get canListDevices => _androidSdk != null bool get canListDevices => appliesToHostPlatform && _androidSdk != null
&& _androidSdk?.adbPath != null; && _androidSdk?.adbPath != null;
@override @override
bool get canLaunchDevices => _androidSdk != null bool get canLaunchDevices => appliesToHostPlatform && _androidSdk != null
&& _androidSdk?.adbPath != null && _androidSdk?.adbPath != null
&& _androidSdk?.validateSdkWellFormed().isEmpty == true; && _androidSdk?.validateSdkWellFormed().isEmpty == true;
@override @override
bool get canListEmulators => _androidSdk != null bool get canListEmulators => canListDevices && _androidSdk?.emulatorPath != null;
&& _androidSdk?.adbPath != null
&& _androidSdk?.emulatorPath != null;
} }
/// A validator that checks if the Android SDK and Java SDK are available and /// A validator that checks if the Android SDK and Java SDK are available and
......
...@@ -25,12 +25,12 @@ class IOSWorkflow implements Workflow { ...@@ -25,12 +25,12 @@ class IOSWorkflow implements Workflow {
// We need xcode (+simctl) to list simulator devices, and libimobiledevice to list real devices. // We need xcode (+simctl) to list simulator devices, and libimobiledevice to list real devices.
@override @override
bool get canListDevices => _xcode.isInstalledAndMeetsVersionCheck && _xcode.isSimctlInstalled; bool get canListDevices => appliesToHostPlatform && _xcode.isInstalledAndMeetsVersionCheck && _xcode.isSimctlInstalled;
// We need xcode to launch simulator devices, and ios-deploy // We need xcode to launch simulator devices, and ios-deploy
// for real devices. // for real devices.
@override @override
bool get canLaunchDevices => _xcode.isInstalledAndMeetsVersionCheck; bool get canLaunchDevices => appliesToHostPlatform && _xcode.isInstalledAndMeetsVersionCheck;
@override @override
bool get canListEmulators => false; bool get canListEmulators => false;
......
...@@ -73,6 +73,55 @@ void main() { ...@@ -73,6 +73,55 @@ void main() {
); );
expect(androidWorkflow.appliesToHostPlatform, false); expect(androidWorkflow.appliesToHostPlatform, false);
expect(androidWorkflow.canLaunchDevices, false);
expect(androidWorkflow.canListDevices, false);
expect(androidWorkflow.canListEmulators, false);
});
testWithoutContext('AndroidWorkflow is disabled if feature is disabled', () {
final FakeAndroidSdk androidSdk = FakeAndroidSdk();
androidSdk.adbPath = 'path/to/adb';
final AndroidWorkflow androidWorkflow = AndroidWorkflow(
featureFlags: TestFeatureFlags(isAndroidEnabled: false),
androidSdk: androidSdk,
operatingSystemUtils: FakeOperatingSystemUtils(),
);
expect(androidWorkflow.appliesToHostPlatform, false);
expect(androidWorkflow.canLaunchDevices, false);
expect(androidWorkflow.canListDevices, false);
expect(androidWorkflow.canListEmulators, false);
});
testWithoutContext('AndroidWorkflow cannot list emulators if emulatorPath is null', () {
final FakeAndroidSdk androidSdk = FakeAndroidSdk();
androidSdk.adbPath = 'path/to/adb';
final AndroidWorkflow androidWorkflow = AndroidWorkflow(
featureFlags: TestFeatureFlags(),
androidSdk: androidSdk,
operatingSystemUtils: FakeOperatingSystemUtils(),
);
expect(androidWorkflow.appliesToHostPlatform, true);
expect(androidWorkflow.canLaunchDevices, true);
expect(androidWorkflow.canListDevices, true);
expect(androidWorkflow.canListEmulators, false);
});
testWithoutContext('AndroidWorkflow can list emulators', () {
final FakeAndroidSdk androidSdk = FakeAndroidSdk();
androidSdk.adbPath = 'path/to/adb';
androidSdk.emulatorPath = 'path/to/emulator';
final AndroidWorkflow androidWorkflow = AndroidWorkflow(
featureFlags: TestFeatureFlags(),
androidSdk: androidSdk,
operatingSystemUtils: FakeOperatingSystemUtils(),
);
expect(androidWorkflow.appliesToHostPlatform, true);
expect(androidWorkflow.canLaunchDevices, true);
expect(androidWorkflow.canListDevices, true);
expect(androidWorkflow.canListEmulators, true);
}); });
testWithoutContext('licensesAccepted returns LicensesAccepted.unknown if cannot find sdkmanager', () async { testWithoutContext('licensesAccepted returns LicensesAccepted.unknown if cannot find sdkmanager', () async {
...@@ -496,6 +545,9 @@ class FakeAndroidSdk extends Fake implements AndroidSdk { ...@@ -496,6 +545,9 @@ class FakeAndroidSdk extends Fake implements AndroidSdk {
@override @override
AndroidSdkVersion latestVersion; AndroidSdkVersion latestVersion;
@override
String emulatorPath;
@override @override
List<String> validateSdkWellFormed() => <String>[]; List<String> validateSdkWellFormed() => <String>[];
......
...@@ -21,6 +21,8 @@ void main() { ...@@ -21,6 +21,8 @@ void main() {
); );
expect(iosWorkflow.appliesToHostPlatform, false); expect(iosWorkflow.appliesToHostPlatform, false);
expect(iosWorkflow.canLaunchDevices, false);
expect(iosWorkflow.canListDevices, false);
}); });
testWithoutContext('iOS workflow is disabled on Linux', () { testWithoutContext('iOS workflow is disabled on Linux', () {
...@@ -31,6 +33,8 @@ void main() { ...@@ -31,6 +33,8 @@ void main() {
); );
expect(iosWorkflow.appliesToHostPlatform, false); expect(iosWorkflow.appliesToHostPlatform, false);
expect(iosWorkflow.canLaunchDevices, false);
expect(iosWorkflow.canListDevices, false);
}); });
testWithoutContext('iOS workflow is disabled on windows', () { testWithoutContext('iOS workflow is disabled on windows', () {
...@@ -41,16 +45,25 @@ void main() { ...@@ -41,16 +45,25 @@ void main() {
); );
expect(iosWorkflow.appliesToHostPlatform, false); expect(iosWorkflow.appliesToHostPlatform, false);
expect(iosWorkflow.canLaunchDevices, false);
expect(iosWorkflow.canListDevices, false);
}); });
testWithoutContext('iOS workflow is enabled on macOS', () { testWithoutContext('iOS workflow applies on macOS, no Xcode', () {
final IOSWorkflow iosWorkflow = IOSWorkflow( final IOSWorkflow iosWorkflow = IOSWorkflow(
platform: FakePlatform(operatingSystem: 'macos'), platform: FakePlatform(operatingSystem: 'macos'),
xcode: Xcode.test(processManager: FakeProcessManager.any()), xcode: Xcode.test(processManager: FakeProcessManager.any(),
xcodeProjectInterpreter: XcodeProjectInterpreter.test(
processManager: FakeProcessManager.any(),
version: null,
),
),
featureFlags: TestFeatureFlags(isIOSEnabled: true), featureFlags: TestFeatureFlags(isIOSEnabled: true),
); );
expect(iosWorkflow.appliesToHostPlatform, true); expect(iosWorkflow.appliesToHostPlatform, true);
expect(iosWorkflow.canLaunchDevices, false);
expect(iosWorkflow.canListDevices, false);
expect(iosWorkflow.canListEmulators, false); expect(iosWorkflow.canListEmulators, false);
}); });
...@@ -74,5 +87,6 @@ void main() { ...@@ -74,5 +87,6 @@ void main() {
expect(xcode.isSimctlInstalled, true); expect(xcode.isSimctlInstalled, true);
expect(iosWorkflow.canLaunchDevices, true); expect(iosWorkflow.canLaunchDevices, true);
expect(iosWorkflow.canListDevices, true); expect(iosWorkflow.canListDevices, true);
expect(iosWorkflow.canListEmulators, false);
}); });
} }
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