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

This commit is contained in:
Jenn Magder
2021-06-23 15:41:04 -07:00
committed by GitHub
parent 4606a74627
commit 2e5284a26b
4 changed files with 73 additions and 9 deletions

View File

@@ -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>[];

View File

@@ -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);
});
}