Command flutter create respects disabled iOS and Android (#78406)

This commit is contained in:
Marcel Čampa 2021-03-22 17:53:05 +01:00 committed by GitHub
parent 47db96af1b
commit e85fe60d00
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 50 additions and 2 deletions

View File

@ -236,8 +236,8 @@ class CreateCommand extends CreateBase {
withPluginHook: generatePlugin,
androidLanguage: stringArg('android-language'),
iosLanguage: stringArg('ios-language'),
ios: platforms.contains('ios'),
android: platforms.contains('android'),
ios: featureFlags.isIOSEnabled && platforms.contains('ios'),
android: featureFlags.isAndroidEnabled && platforms.contains('android'),
web: featureFlags.isWebEnabled && platforms.contains('web'),
linux: featureFlags.isLinuxEnabled && platforms.contains('linux'),
macos: featureFlags.isMacOSEnabled && platforms.contains('macos'),

View File

@ -100,12 +100,16 @@ void main() {
await commandRunner.run(<String>[
'config',
'--enable-android',
'--enable-ios',
'--enable-web',
'--enable-linux-desktop',
'--enable-windows-desktop',
'--enable-macos-desktop',
]);
expect(globals.config.getValue('enable-android'), true);
expect(globals.config.getValue('enable-ios'), true);
expect(globals.config.getValue('enable-web'), true);
expect(globals.config.getValue('enable-linux-desktop'), true);
expect(globals.config.getValue('enable-windows-desktop'), true);
@ -115,6 +119,8 @@ void main() {
'config', '--clear-features',
]);
expect(globals.config.getValue('enable-android'), null);
expect(globals.config.getValue('enable-ios'), null);
expect(globals.config.getValue('enable-web'), null);
expect(globals.config.getValue('enable-linux-desktop'), null);
expect(globals.config.getValue('enable-windows-desktop'), null);
@ -122,12 +128,16 @@ void main() {
await commandRunner.run(<String>[
'config',
'--no-enable-android',
'--no-enable-ios',
'--no-enable-web',
'--no-enable-linux-desktop',
'--no-enable-windows-desktop',
'--no-enable-macos-desktop',
]);
expect(globals.config.getValue('enable-android'), false);
expect(globals.config.getValue('enable-ios'), false);
expect(globals.config.getValue('enable-web'), false);
expect(globals.config.getValue('enable-linux-desktop'), false);
expect(globals.config.getValue('enable-windows-desktop'), false);

View File

@ -693,6 +693,44 @@ void main() {
Logger: () => logger,
});
testUsingContext('app supports android and ios by default', () async {
Cache.flutterRoot = '../..';
final CreateCommand command = CreateCommand();
final CommandRunner<void> runner = createTestCommandRunner(command);
await runner.run(<String>['create', '--no-pub', projectDir.path]);
expect(projectDir.childDirectory('android'), exists);
expect(projectDir.childDirectory('ios'), exists);
}, overrides: <Type, Generator>{});
testUsingContext('app does not include android if disabled in config', () async {
Cache.flutterRoot = '../..';
final CreateCommand command = CreateCommand();
final CommandRunner<void> runner = createTestCommandRunner(command);
await runner.run(<String>['create', '--no-pub', projectDir.path]);
expect(projectDir.childDirectory('android'), isNot(exists));
}, overrides: <Type, Generator>{
FeatureFlags: () => TestFeatureFlags(isAndroidEnabled: false),
});
testUsingContext('app does not include ios if disabled in config', () async {
Cache.flutterRoot = '../..';
final CreateCommand command = CreateCommand();
final CommandRunner<void> runner = createTestCommandRunner(command);
await runner.run(<String>['create', '--no-pub', projectDir.path]);
expect(projectDir.childDirectory('ios'), isNot(exists));
}, overrides: <Type, Generator>{
FeatureFlags: () => TestFeatureFlags(isIOSEnabled: false),
});
testUsingContext('app does not include desktop or web by default', () async {
Cache.flutterRoot = '../..';