Rename 'application' back to 'module', and make 'app' the default again for templates. (#22888)
We decided that redefining the default for templates was premature. We're going to go back to having "module" in experimental land again, and we'll try again when we have the feature set fully baked. This keeps the writing of the .metadata files, and writing the template type to them, because that was a good improvement, and there are still a bunch of added tests that improve our coverage.
This commit is contained in:
@@ -43,46 +43,12 @@ void main() {
|
||||
tryToDelete(tempDir);
|
||||
});
|
||||
|
||||
// Verify that we create a default project ('application') that is
|
||||
// Verify that we create a default project ('app') that is
|
||||
// well-formed.
|
||||
testUsingContext('can create a default project', () async {
|
||||
await _createAndAnalyzeProject(projectDir, <String>[], <String>[
|
||||
'.android/app/',
|
||||
'.gitignore',
|
||||
'.ios/Flutter',
|
||||
'.metadata',
|
||||
'lib/main.dart',
|
||||
'pubspec.yaml',
|
||||
'README.md',
|
||||
'test/widget_test.dart',
|
||||
], unexpectedPaths: <String>[
|
||||
'android/',
|
||||
'ios/',
|
||||
]);
|
||||
return _runFlutterTest(projectDir);
|
||||
}, timeout: allowForRemotePubInvocation);
|
||||
|
||||
testUsingContext('can create a default project if empty directory exists', () async {
|
||||
await projectDir.create(recursive: true);
|
||||
return _createAndAnalyzeProject(projectDir, <String>[], <String>[
|
||||
'.android/app/',
|
||||
'.gitignore',
|
||||
'.ios/Flutter',
|
||||
'.metadata',
|
||||
'lib/main.dart',
|
||||
'pubspec.yaml',
|
||||
'README.md',
|
||||
'test/widget_test.dart',
|
||||
], unexpectedPaths: <String>[
|
||||
'android/',
|
||||
'ios/',
|
||||
]);
|
||||
}, timeout: allowForRemotePubInvocation);
|
||||
|
||||
testUsingContext('creates a legacy app project correctly', () async {
|
||||
await _createAndAnalyzeProject(
|
||||
projectDir,
|
||||
<String>['--template=app'],
|
||||
<String>[],
|
||||
<String>[
|
||||
'android/app/src/main/java/com/example/flutterproject/MainActivity.java',
|
||||
'android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java',
|
||||
@@ -95,22 +61,26 @@ void main() {
|
||||
return _runFlutterTest(projectDir);
|
||||
}, timeout: allowForRemotePubInvocation);
|
||||
|
||||
testUsingContext('cannot create a project if non-empty non-project directory exists with .metadata', () async {
|
||||
await projectDir.absolute.childDirectory('blag').create(recursive: true);
|
||||
await projectDir.absolute.childFile('.metadata').writeAsString('project_type: blag\n');
|
||||
expect(() async => await _createAndAnalyzeProject(projectDir, <String>[], <String>[
|
||||
], unexpectedPaths: <String>[
|
||||
'android/',
|
||||
'ios/',
|
||||
'.android/',
|
||||
'.ios/',
|
||||
]), throwsToolExit(message: 'Sorry, unable to detect the type of project to recreate'));
|
||||
testUsingContext('can create a default project if empty directory exists', () async {
|
||||
await projectDir.create(recursive: true);
|
||||
await _createAndAnalyzeProject(
|
||||
projectDir,
|
||||
<String>[],
|
||||
<String>[
|
||||
'android/app/src/main/java/com/example/flutterproject/MainActivity.java',
|
||||
'android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java',
|
||||
'flutter_project.iml',
|
||||
'ios/Flutter/AppFrameworkInfo.plist',
|
||||
'ios/Runner/AppDelegate.m',
|
||||
'ios/Runner/GeneratedPluginRegistrant.h',
|
||||
],
|
||||
);
|
||||
}, timeout: allowForRemotePubInvocation);
|
||||
|
||||
testUsingContext('Will create an application project if non-empty non-project directory exists without .metadata', () async {
|
||||
await projectDir.absolute.childDirectory('blag').create(recursive: true);
|
||||
await projectDir.absolute.childDirectory('.idea').create(recursive: true);
|
||||
return _createAndAnalyzeProject(projectDir, <String>[], <String>[
|
||||
testUsingContext('creates a module project correctly', () async {
|
||||
await _createAndAnalyzeProject(projectDir, <String>[
|
||||
'--template=module'
|
||||
], <String>[
|
||||
'.android/app/',
|
||||
'.gitignore',
|
||||
'.ios/Flutter',
|
||||
@@ -123,23 +93,51 @@ void main() {
|
||||
'android/',
|
||||
'ios/',
|
||||
]);
|
||||
return _runFlutterTest(projectDir);
|
||||
}, timeout: allowForRemotePubInvocation);
|
||||
|
||||
testUsingContext('detects and recreates an application project correctly', () async {
|
||||
await projectDir.absolute.childDirectory('lib').create(recursive: true);
|
||||
await projectDir.absolute.childDirectory('.ios').create(recursive: true);
|
||||
return _createAndAnalyzeProject(projectDir, <String>[], <String>[
|
||||
'.android/app/',
|
||||
'.gitignore',
|
||||
'.ios/Flutter',
|
||||
'.metadata',
|
||||
'lib/main.dart',
|
||||
'pubspec.yaml',
|
||||
'README.md',
|
||||
'test/widget_test.dart',
|
||||
testUsingContext('cannot create a project if non-empty non-project directory exists with .metadata', () async {
|
||||
await projectDir.absolute.childDirectory('blag').create(recursive: true);
|
||||
await projectDir.absolute.childFile('.metadata').writeAsString('project_type: blag\n');
|
||||
expect(
|
||||
() async => await _createAndAnalyzeProject(projectDir, <String>[], <String>[], unexpectedPaths: <String>[
|
||||
'android/',
|
||||
'ios/',
|
||||
'.android/',
|
||||
'.ios/',
|
||||
]),
|
||||
throwsToolExit(message: 'Sorry, unable to detect the type of project to recreate'));
|
||||
}, timeout: allowForRemotePubInvocation);
|
||||
|
||||
testUsingContext('Will create an app project if non-empty non-project directory exists without .metadata', () async {
|
||||
await projectDir.absolute.childDirectory('blag').create(recursive: true);
|
||||
await projectDir.absolute.childDirectory('.idea').create(recursive: true);
|
||||
await _createAndAnalyzeProject(projectDir, <String>[], <String>[
|
||||
'android/app/src/main/java/com/example/flutterproject/MainActivity.java',
|
||||
'android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java',
|
||||
'flutter_project.iml',
|
||||
'ios/Flutter/AppFrameworkInfo.plist',
|
||||
'ios/Runner/AppDelegate.m',
|
||||
'ios/Runner/GeneratedPluginRegistrant.h',
|
||||
], unexpectedPaths: <String>[
|
||||
'android/',
|
||||
'ios/',
|
||||
'.android/',
|
||||
'.ios/',
|
||||
]);
|
||||
}, timeout: allowForRemotePubInvocation);
|
||||
|
||||
testUsingContext('detects and recreates an app project correctly', () async {
|
||||
await projectDir.absolute.childDirectory('lib').create(recursive: true);
|
||||
await projectDir.absolute.childDirectory('ios').create(recursive: true);
|
||||
await _createAndAnalyzeProject(projectDir, <String>[], <String>[
|
||||
'android/app/src/main/java/com/example/flutterproject/MainActivity.java',
|
||||
'android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java',
|
||||
'flutter_project.iml',
|
||||
'ios/Flutter/AppFrameworkInfo.plist',
|
||||
'ios/Runner/AppDelegate.m',
|
||||
'ios/Runner/GeneratedPluginRegistrant.h',
|
||||
], unexpectedPaths: <String>[
|
||||
'.android/',
|
||||
'.ios/',
|
||||
]);
|
||||
}, timeout: allowForRemotePubInvocation);
|
||||
|
||||
@@ -193,41 +191,6 @@ void main() {
|
||||
);
|
||||
}, timeout: allowForRemotePubInvocation);
|
||||
|
||||
testUsingContext('detects and recreates a legacy app project correctly', () async {
|
||||
await projectDir.absolute.childDirectory('lib').create(recursive: true);
|
||||
await projectDir.absolute.childDirectory('ios').childDirectory('Flutter').create(recursive: true);
|
||||
return _createAndAnalyzeProject(
|
||||
projectDir,
|
||||
<String>[],
|
||||
<String>[
|
||||
'android/app/src/main/java/com/example/flutterproject/MainActivity.java',
|
||||
'android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java',
|
||||
'flutter_project.iml',
|
||||
'ios/Flutter/AppFrameworkInfo.plist',
|
||||
'ios/Runner/AppDelegate.m',
|
||||
'ios/Runner/GeneratedPluginRegistrant.h',
|
||||
],
|
||||
);
|
||||
}, timeout: allowForRemotePubInvocation);
|
||||
|
||||
testUsingContext('can create a legacy module project', () async {
|
||||
return _createAndAnalyzeProject(projectDir, <String>[
|
||||
'--template=module',
|
||||
], <String>[
|
||||
'.android/app/',
|
||||
'.gitignore',
|
||||
'.ios/Flutter',
|
||||
'.metadata',
|
||||
'lib/main.dart',
|
||||
'pubspec.yaml',
|
||||
'README.md',
|
||||
'test/widget_test.dart',
|
||||
], unexpectedPaths: <String>[
|
||||
'android/',
|
||||
'ios/',
|
||||
]);
|
||||
}, timeout: allowForRemotePubInvocation);
|
||||
|
||||
testUsingContext('kotlin/swift legacy app project', () async {
|
||||
return _createProject(
|
||||
projectDir,
|
||||
@@ -343,9 +306,9 @@ void main() {
|
||||
);
|
||||
}, timeout: allowForRemotePubInvocation);
|
||||
|
||||
testUsingContext('application project with pub', () async {
|
||||
testUsingContext('module project with pub', () async {
|
||||
return _createProject(projectDir, <String>[
|
||||
'--template=application'
|
||||
'--template=module'
|
||||
], <String>[
|
||||
'.android/build.gradle',
|
||||
'.android/Flutter/build.gradle',
|
||||
@@ -375,7 +338,7 @@ void main() {
|
||||
]);
|
||||
}, timeout: allowForRemotePubInvocation);
|
||||
|
||||
testUsingContext('has correct content and formatting with applicaiton template', () async {
|
||||
testUsingContext('has correct content and formatting with module template', () async {
|
||||
Cache.flutterRoot = '../..';
|
||||
when(mockFlutterVersion.frameworkRevision).thenReturn(frameworkRevision);
|
||||
when(mockFlutterVersion.channel).thenReturn(frameworkChannel);
|
||||
@@ -383,7 +346,7 @@ void main() {
|
||||
final CreateCommand command = CreateCommand();
|
||||
final CommandRunner<void> runner = createTestCommandRunner(command);
|
||||
|
||||
await runner.run(<String>['create', '--template=application', '--no-pub', '--org', 'com.foo.bar', projectDir.path]);
|
||||
await runner.run(<String>['create', '--template=module', '--no-pub', '--org', 'com.foo.bar', projectDir.path]);
|
||||
|
||||
void expectExists(String relPath) {
|
||||
expect(fs.isFileSync('${projectDir.path}/$relPath'), true);
|
||||
@@ -446,7 +409,7 @@ void main() {
|
||||
FlutterVersion: () => mockFlutterVersion,
|
||||
}, timeout: allowForCreateFlutterProject);
|
||||
|
||||
testUsingContext('has correct content and formatting with legacy app template', () async {
|
||||
testUsingContext('has correct content and formatting with app template', () async {
|
||||
Cache.flutterRoot = '../..';
|
||||
when(mockFlutterVersion.frameworkRevision).thenReturn(frameworkRevision);
|
||||
when(mockFlutterVersion.channel).thenReturn(frameworkChannel);
|
||||
@@ -526,9 +489,12 @@ void main() {
|
||||
await runner.run(<String>['create', '--no-pub', projectDir.path]);
|
||||
|
||||
await runner.run(<String>['create', '--no-pub', projectDir.path]);
|
||||
|
||||
final String metadata = fs.file(fs.path.join(projectDir.path, '.metadata')).readAsStringSync();
|
||||
expect(metadata, contains('project_type: app\n'));
|
||||
}, timeout: allowForCreateFlutterProject);
|
||||
|
||||
testUsingContext('can re-gen default template over existing legacy app project with no metadta and detect the type', () async {
|
||||
testUsingContext('can re-gen default template over existing app project with no metadta and detect the type', () async {
|
||||
Cache.flutterRoot = '../..';
|
||||
|
||||
final CreateCommand command = CreateCommand();
|
||||
@@ -545,7 +511,7 @@ void main() {
|
||||
expect(metadata, contains('project_type: app\n'));
|
||||
}, timeout: allowForCreateFlutterProject);
|
||||
|
||||
testUsingContext('can re-gen default template over existing legacy app project and detect the type', () async {
|
||||
testUsingContext('can re-gen app template over existing app project and detect the type', () async {
|
||||
Cache.flutterRoot = '../..';
|
||||
|
||||
final CreateCommand command = CreateCommand();
|
||||
@@ -559,6 +525,20 @@ void main() {
|
||||
expect(metadata, contains('project_type: app\n'));
|
||||
}, timeout: allowForCreateFlutterProject);
|
||||
|
||||
testUsingContext('can re-gen template over existing module project and detect the type', () async {
|
||||
Cache.flutterRoot = '../..';
|
||||
|
||||
final CreateCommand command = CreateCommand();
|
||||
final CommandRunner<void> runner = createTestCommandRunner(command);
|
||||
|
||||
await runner.run(<String>['create', '--no-pub', '--template=module', projectDir.path]);
|
||||
|
||||
await runner.run(<String>['create', '--no-pub', projectDir.path]);
|
||||
|
||||
final String metadata = fs.file(fs.path.join(projectDir.path, '.metadata')).readAsStringSync();
|
||||
expect(metadata, contains('project_type: module\n'));
|
||||
}, timeout: allowForCreateFlutterProject);
|
||||
|
||||
testUsingContext('can re-gen default template over existing plugin project and detect the type', () async {
|
||||
Cache.flutterRoot = '../..';
|
||||
|
||||
@@ -587,10 +567,10 @@ void main() {
|
||||
expect(metadata, contains('project_type: package'));
|
||||
}, timeout: allowForCreateFlutterProject);
|
||||
|
||||
testUsingContext('can re-gen application .android/ folder, reusing custom org', () async {
|
||||
testUsingContext('can re-gen module .android/ folder, reusing custom org', () async {
|
||||
await _createProject(
|
||||
projectDir,
|
||||
<String>['--template=application', '--org', 'com.bar.foo'],
|
||||
<String>['--template=module', '--org', 'com.bar.foo'],
|
||||
<String>[],
|
||||
);
|
||||
projectDir.childDirectory('.android').deleteSync(recursive: true);
|
||||
@@ -603,10 +583,10 @@ void main() {
|
||||
);
|
||||
}, timeout: allowForRemotePubInvocation);
|
||||
|
||||
testUsingContext('can re-gen application .ios/ folder, reusing custom org', () async {
|
||||
testUsingContext('can re-gen module .ios/ folder, reusing custom org', () async {
|
||||
await _createProject(
|
||||
projectDir,
|
||||
<String>['--template=application', '--org', 'com.bar.foo'],
|
||||
<String>['--template=module', '--org', 'com.bar.foo'],
|
||||
<String>[],
|
||||
);
|
||||
projectDir.childDirectory('.ios').deleteSync(recursive: true);
|
||||
@@ -618,7 +598,7 @@ void main() {
|
||||
);
|
||||
}, timeout: allowForRemotePubInvocation);
|
||||
|
||||
testUsingContext('can re-gen legacy app android/ folder, reusing custom org', () async {
|
||||
testUsingContext('can re-gen app android/ folder, reusing custom org', () async {
|
||||
await _createProject(
|
||||
projectDir,
|
||||
<String>['--no-pub', '--template=app', '--org', 'com.bar.foo'],
|
||||
@@ -637,7 +617,7 @@ void main() {
|
||||
);
|
||||
}, timeout: allowForCreateFlutterProject);
|
||||
|
||||
testUsingContext('can re-gen legacy app ios/ folder, reusing custom org', () async {
|
||||
testUsingContext('can re-gen app ios/ folder, reusing custom org', () async {
|
||||
await _createProject(
|
||||
projectDir,
|
||||
<String>['--no-pub', '--template=app', '--org', 'com.bar.foo'],
|
||||
|
||||
@@ -45,8 +45,8 @@ void main() {
|
||||
tryToDelete(tempDir);
|
||||
});
|
||||
|
||||
Future<String> createProjectWithPlugin(String plugin) async {
|
||||
final String projectPath = await createProject(tempDir);
|
||||
Future<String> createProjectWithPlugin(String plugin, {List<String> arguments}) async {
|
||||
final String projectPath = await createProject(tempDir, arguments: arguments);
|
||||
final File pubspec = fs.file(fs.path.join(projectPath, 'pubspec.yaml'));
|
||||
String content = await pubspec.readAsString();
|
||||
content = content.replaceFirst(
|
||||
@@ -114,7 +114,7 @@ void main() {
|
||||
'android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java',
|
||||
];
|
||||
|
||||
const List<String> applicationPluginRegistrants = <String>[
|
||||
const List<String> modulePluginRegistrants = <String>[
|
||||
'.ios/Flutter/FlutterPluginRegistrant/Classes/GeneratedPluginRegistrant.h',
|
||||
'.ios/Flutter/FlutterPluginRegistrant/Classes/GeneratedPluginRegistrant.m',
|
||||
'.android/Flutter/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java',
|
||||
@@ -125,7 +125,7 @@ void main() {
|
||||
'ios/Podfile',
|
||||
];
|
||||
|
||||
const List<String> applicationPluginWitnesses = <String>[
|
||||
const List<String> modulePluginWitnesses = <String>[
|
||||
'.flutter-plugins',
|
||||
'.ios/Podfile',
|
||||
];
|
||||
@@ -135,7 +135,7 @@ void main() {
|
||||
'ios/Flutter/Release.xcconfig': '#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"',
|
||||
};
|
||||
|
||||
const Map<String, String> applicationPluginContentWitnesses = <String, String>{
|
||||
const Map<String, String> modulePluginContentWitnesses = <String, String>{
|
||||
'.ios/Config/Debug.xcconfig': '#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"',
|
||||
'.ios/Config/Release.xcconfig': '#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"',
|
||||
};
|
||||
@@ -147,13 +147,13 @@ void main() {
|
||||
}
|
||||
|
||||
void expectZeroPluginsInjected(String projectPath) {
|
||||
for (final String registrant in applicationPluginRegistrants) {
|
||||
for (final String registrant in modulePluginRegistrants) {
|
||||
expectExists(projectPath, registrant);
|
||||
}
|
||||
for (final String witness in pluginWitnesses) {
|
||||
expectNotExists(projectPath, witness);
|
||||
}
|
||||
applicationPluginContentWitnesses.forEach((String witness, String content) {
|
||||
modulePluginContentWitnesses.forEach((String witness, String content) {
|
||||
expectNotContains(projectPath, witness, content);
|
||||
});
|
||||
}
|
||||
@@ -170,14 +170,14 @@ void main() {
|
||||
});
|
||||
}
|
||||
|
||||
void expectApplicationPluginInjected(String projectPath) {
|
||||
for (final String registrant in applicationPluginRegistrants) {
|
||||
void expectModulePluginInjected(String projectPath) {
|
||||
for (final String registrant in modulePluginRegistrants) {
|
||||
expectExists(projectPath, registrant);
|
||||
}
|
||||
for (final String witness in applicationPluginWitnesses) {
|
||||
for (final String witness in modulePluginWitnesses) {
|
||||
expectExists(projectPath, witness);
|
||||
}
|
||||
applicationPluginContentWitnesses.forEach((String witness, String content) {
|
||||
modulePluginContentWitnesses.forEach((String witness, String content) {
|
||||
expectContains(projectPath, witness, content);
|
||||
});
|
||||
}
|
||||
@@ -185,7 +185,7 @@ void main() {
|
||||
void removeGeneratedFiles(String projectPath) {
|
||||
final Iterable<String> allFiles = <List<String>>[
|
||||
pubOutput,
|
||||
applicationPluginRegistrants,
|
||||
modulePluginRegistrants,
|
||||
pluginWitnesses,
|
||||
].expand<String>((List<String> list) => list);
|
||||
for (String path in allFiles) {
|
||||
@@ -196,7 +196,8 @@ void main() {
|
||||
}
|
||||
|
||||
testUsingContext('get fetches packages', () async {
|
||||
final String projectPath = await createProject(tempDir);
|
||||
final String projectPath = await createProject(tempDir,
|
||||
arguments: <String>['--no-pub', '--template=module']);
|
||||
removeGeneratedFiles(projectPath);
|
||||
|
||||
await runCommandIn(projectPath, 'get');
|
||||
@@ -206,7 +207,8 @@ void main() {
|
||||
}, timeout: allowForRemotePubInvocation);
|
||||
|
||||
testUsingContext('get --offline fetches packages', () async {
|
||||
final String projectPath = await createProject(tempDir);
|
||||
final String projectPath = await createProject(tempDir,
|
||||
arguments: <String>['--no-pub', '--template=module']);
|
||||
removeGeneratedFiles(projectPath);
|
||||
|
||||
await runCommandIn(projectPath, 'get', args: <String>['--offline']);
|
||||
@@ -216,7 +218,8 @@ void main() {
|
||||
}, timeout: allowForCreateFlutterProject);
|
||||
|
||||
testUsingContext('upgrade fetches packages', () async {
|
||||
final String projectPath = await createProject(tempDir);
|
||||
final String projectPath = await createProject(tempDir,
|
||||
arguments: <String>['--no-pub', '--template=module']);
|
||||
removeGeneratedFiles(projectPath);
|
||||
|
||||
await runCommandIn(projectPath, 'upgrade');
|
||||
@@ -226,13 +229,14 @@ void main() {
|
||||
}, timeout: allowForRemotePubInvocation);
|
||||
|
||||
testUsingContext('get fetches packages and injects plugin', () async {
|
||||
final String projectPath = await createProjectWithPlugin('path_provider');
|
||||
final String projectPath = await createProjectWithPlugin('path_provider',
|
||||
arguments: <String>['--no-pub', '--template=module']);
|
||||
removeGeneratedFiles(projectPath);
|
||||
|
||||
await runCommandIn(projectPath, 'get');
|
||||
|
||||
expectDependenciesResolved(projectPath);
|
||||
expectApplicationPluginInjected(projectPath);
|
||||
expectModulePluginInjected(projectPath);
|
||||
}, timeout: allowForRemotePubInvocation);
|
||||
|
||||
testUsingContext('get fetches packages and injects plugin in plugin project', () async {
|
||||
|
||||
@@ -355,20 +355,20 @@ flutter:
|
||||
''';
|
||||
final FlutterManifest flutterManifest = await FlutterManifest.createFromString(manifest);
|
||||
expect(flutterManifest.isEmpty, false);
|
||||
expect(flutterManifest.isApplication, false);
|
||||
expect(flutterManifest.isModule, false);
|
||||
expect(flutterManifest.isPlugin, false);
|
||||
expect(flutterManifest.androidPackage, null);
|
||||
});
|
||||
|
||||
test('allows an application declaration', () async {
|
||||
test('allows a module declaration', () async {
|
||||
const String manifest = '''
|
||||
name: test
|
||||
flutter:
|
||||
application:
|
||||
module:
|
||||
androidPackage: com.example
|
||||
''';
|
||||
final FlutterManifest flutterManifest = await FlutterManifest.createFromString(manifest);
|
||||
expect(flutterManifest.isApplication, true);
|
||||
expect(flutterManifest.isModule, true);
|
||||
expect(flutterManifest.androidPackage, 'com.example');
|
||||
});
|
||||
|
||||
|
||||
@@ -90,20 +90,20 @@ void main() {
|
||||
});
|
||||
|
||||
group('editable Android host app', () {
|
||||
testInMemory('fails on non-application', () async {
|
||||
testInMemory('fails on non-module', () async {
|
||||
final FlutterProject project = await someProject();
|
||||
await expectLater(
|
||||
project.android.makeHostAppEditable(),
|
||||
throwsA(isInstanceOf<AssertionError>()),
|
||||
);
|
||||
});
|
||||
testInMemory('exits on already editable application', () async {
|
||||
final FlutterProject project = await anApplicationProject();
|
||||
testInMemory('exits on already editable module', () async {
|
||||
final FlutterProject project = await aModuleProject();
|
||||
await project.android.makeHostAppEditable();
|
||||
return expectToolExitLater(project.android.makeHostAppEditable(), contains('already editable'));
|
||||
});
|
||||
testInMemory('creates android/app folder in place of .android/app', () async {
|
||||
final FlutterProject project = await anApplicationProject();
|
||||
final FlutterProject project = await aModuleProject();
|
||||
await project.android.makeHostAppEditable();
|
||||
expectNotExists(project.directory.childDirectory('.android').childDirectory('app'));
|
||||
expect(
|
||||
@@ -118,7 +118,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
testInMemory('retains .android/Flutter folder and references it', () async {
|
||||
final FlutterProject project = await anApplicationProject();
|
||||
final FlutterProject project = await aModuleProject();
|
||||
await project.android.makeHostAppEditable();
|
||||
expectExists(project.directory.childDirectory('.android').childDirectory('Flutter'));
|
||||
expect(
|
||||
@@ -127,7 +127,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
testInMemory('can be redone after deletion', () async {
|
||||
final FlutterProject project = await anApplicationProject();
|
||||
final FlutterProject project = await aModuleProject();
|
||||
await project.android.makeHostAppEditable();
|
||||
project.directory.childDirectory('android').deleteSync(recursive: true);
|
||||
await project.android.makeHostAppEditable();
|
||||
@@ -173,15 +173,15 @@ void main() {
|
||||
await project.ensureReadyForPlatformSpecificTooling();
|
||||
expectExists(project.android.hostAppGradleRoot.childFile('local.properties'));
|
||||
});
|
||||
testInMemory('creates Android library in application', () async {
|
||||
final FlutterProject project = await anApplicationProject();
|
||||
testInMemory('creates Android library in module', () async {
|
||||
final FlutterProject project = await aModuleProject();
|
||||
await project.ensureReadyForPlatformSpecificTooling();
|
||||
expectExists(project.android.hostAppGradleRoot.childFile('settings.gradle'));
|
||||
expectExists(project.android.hostAppGradleRoot.childFile('local.properties'));
|
||||
expectExists(androidPluginRegistrant(project.android.hostAppGradleRoot.childDirectory('Flutter')));
|
||||
});
|
||||
testInMemory('creates iOS pod in application', () async {
|
||||
final FlutterProject project = await anApplicationProject();
|
||||
testInMemory('creates iOS pod in module', () async {
|
||||
final FlutterProject project = await aModuleProject();
|
||||
await project.ensureReadyForPlatformSpecificTooling();
|
||||
final Directory flutter = project.ios.hostAppRoot.childDirectory('Flutter');
|
||||
expectExists(flutter.childFile('podhelper.rb'));
|
||||
@@ -194,20 +194,20 @@ void main() {
|
||||
});
|
||||
});
|
||||
|
||||
group('application status', () {
|
||||
testInMemory('is known for application', () async {
|
||||
final FlutterProject project = await anApplicationProject();
|
||||
expect(project.isApplication, isTrue);
|
||||
expect(project.android.isApplication, isTrue);
|
||||
expect(project.ios.isApplication, isTrue);
|
||||
group('module status', () {
|
||||
testInMemory('is known for module', () async {
|
||||
final FlutterProject project = await aModuleProject();
|
||||
expect(project.isModule, isTrue);
|
||||
expect(project.android.isModule, isTrue);
|
||||
expect(project.ios.isModule, isTrue);
|
||||
expect(project.android.hostAppGradleRoot.basename, '.android');
|
||||
expect(project.ios.hostAppRoot.basename, '.ios');
|
||||
});
|
||||
testInMemory('is known for non-application', () async {
|
||||
testInMemory('is known for non-module', () async {
|
||||
final FlutterProject project = await someProject();
|
||||
expect(project.isApplication, isFalse);
|
||||
expect(project.android.isApplication, isFalse);
|
||||
expect(project.ios.isApplication, isFalse);
|
||||
expect(project.isModule, isFalse);
|
||||
expect(project.android.isModule, isFalse);
|
||||
expect(project.ios.isModule, isFalse);
|
||||
expect(project.android.hostAppGradleRoot.basename, 'android');
|
||||
expect(project.ios.hostAppRoot.basename, 'ios');
|
||||
});
|
||||
@@ -351,13 +351,13 @@ flutter:
|
||||
return FlutterProject.fromDirectory(directory);
|
||||
}
|
||||
|
||||
Future<FlutterProject> anApplicationProject() async {
|
||||
final Directory directory = fs.directory('application_project');
|
||||
Future<FlutterProject> aModuleProject() async {
|
||||
final Directory directory = fs.directory('module_project');
|
||||
directory.childFile('.packages').createSync(recursive: true);
|
||||
directory.childFile('pubspec.yaml').writeAsStringSync('''
|
||||
name: my_application
|
||||
name: my_module
|
||||
flutter:
|
||||
application:
|
||||
module:
|
||||
androidPackage: com.example
|
||||
''');
|
||||
return FlutterProject.fromDirectory(directory);
|
||||
|
||||
Reference in New Issue
Block a user