mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Do not list Android or iOS devices when feature disabled (#85145)
This commit is contained in:
parent
4606a74627
commit
2e5284a26b
@ -57,18 +57,16 @@ class AndroidWorkflow implements Workflow {
|
||||
&& _operatingSystemUtils.hostPlatform != HostPlatform.linux_arm64;
|
||||
|
||||
@override
|
||||
bool get canListDevices => _androidSdk != null
|
||||
bool get canListDevices => appliesToHostPlatform && _androidSdk != null
|
||||
&& _androidSdk?.adbPath != null;
|
||||
|
||||
@override
|
||||
bool get canLaunchDevices => _androidSdk != null
|
||||
bool get canLaunchDevices => appliesToHostPlatform && _androidSdk != null
|
||||
&& _androidSdk?.adbPath != null
|
||||
&& _androidSdk?.validateSdkWellFormed().isEmpty == true;
|
||||
|
||||
@override
|
||||
bool get canListEmulators => _androidSdk != null
|
||||
&& _androidSdk?.adbPath != null
|
||||
&& _androidSdk?.emulatorPath != null;
|
||||
bool get canListEmulators => canListDevices && _androidSdk?.emulatorPath != null;
|
||||
}
|
||||
|
||||
/// A validator that checks if the Android SDK and Java SDK are available and
|
||||
|
@ -25,12 +25,12 @@ class IOSWorkflow implements Workflow {
|
||||
|
||||
// We need xcode (+simctl) to list simulator devices, and libimobiledevice to list real devices.
|
||||
@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
|
||||
// for real devices.
|
||||
@override
|
||||
bool get canLaunchDevices => _xcode.isInstalledAndMeetsVersionCheck;
|
||||
bool get canLaunchDevices => appliesToHostPlatform && _xcode.isInstalledAndMeetsVersionCheck;
|
||||
|
||||
@override
|
||||
bool get canListEmulators => false;
|
||||
|
@ -73,6 +73,55 @@ void main() {
|
||||
);
|
||||
|
||||
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 {
|
||||
@ -496,6 +545,9 @@ class FakeAndroidSdk extends Fake implements AndroidSdk {
|
||||
@override
|
||||
AndroidSdkVersion latestVersion;
|
||||
|
||||
@override
|
||||
String emulatorPath;
|
||||
|
||||
@override
|
||||
List<String> validateSdkWellFormed() => <String>[];
|
||||
|
||||
|
@ -21,6 +21,8 @@ void main() {
|
||||
);
|
||||
|
||||
expect(iosWorkflow.appliesToHostPlatform, false);
|
||||
expect(iosWorkflow.canLaunchDevices, false);
|
||||
expect(iosWorkflow.canListDevices, false);
|
||||
});
|
||||
|
||||
testWithoutContext('iOS workflow is disabled on Linux', () {
|
||||
@ -31,6 +33,8 @@ void main() {
|
||||
);
|
||||
|
||||
expect(iosWorkflow.appliesToHostPlatform, false);
|
||||
expect(iosWorkflow.canLaunchDevices, false);
|
||||
expect(iosWorkflow.canListDevices, false);
|
||||
});
|
||||
|
||||
testWithoutContext('iOS workflow is disabled on windows', () {
|
||||
@ -41,16 +45,25 @@ void main() {
|
||||
);
|
||||
|
||||
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(
|
||||
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),
|
||||
);
|
||||
|
||||
expect(iosWorkflow.appliesToHostPlatform, true);
|
||||
expect(iosWorkflow.canLaunchDevices, false);
|
||||
expect(iosWorkflow.canListDevices, false);
|
||||
expect(iosWorkflow.canListEmulators, false);
|
||||
});
|
||||
|
||||
@ -74,5 +87,6 @@ void main() {
|
||||
expect(xcode.isSimctlInstalled, true);
|
||||
expect(iosWorkflow.canLaunchDevices, true);
|
||||
expect(iosWorkflow.canListDevices, true);
|
||||
expect(iosWorkflow.canListEmulators, false);
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user