Move v1 embedding migration warning from plugin consumers to all apps (#64181)
This commit is contained in:
@@ -654,6 +654,31 @@ void main() {
|
||||
expect(actualContents.contains('useAndroidX'), true);
|
||||
});
|
||||
|
||||
testUsingContext('creating a new project should create v2 embedding and never show an Android v1 deprecation warning', () async {
|
||||
Cache.flutterRoot = '../..';
|
||||
when(mockFlutterVersion.frameworkRevision).thenReturn(frameworkRevision);
|
||||
when(mockFlutterVersion.channel).thenReturn(frameworkChannel);
|
||||
|
||||
final CreateCommand command = CreateCommand();
|
||||
final CommandRunner<void> runner = createTestCommandRunner(command);
|
||||
|
||||
await runner.run(<String>['create', '--no-pub', '--platforms', 'android', projectDir.path]);
|
||||
|
||||
final String androidManifest = await globals.fs.file(
|
||||
projectDir.path + '/android/app/src/main/AndroidManifest.xml'
|
||||
).readAsString();
|
||||
expect(androidManifest.contains('android:name="flutterEmbedding"'), true);
|
||||
expect(androidManifest.contains('android:value="2"'), true);
|
||||
|
||||
final String mainActivity = await globals.fs.file(
|
||||
projectDir.path + '/android/app/src/main/kotlin/com/example/flutter_project/MainActivity.kt'
|
||||
).readAsString();
|
||||
// Import for the new embedding class.
|
||||
expect(mainActivity.contains('import io.flutter.embedding.android.FlutterActivity'), true);
|
||||
|
||||
expect(testLogger.statusText, isNot(contains('https://flutter.dev/go/android-project-migration')));
|
||||
});
|
||||
|
||||
testUsingContext('app supports Linux if requested', () async {
|
||||
Cache.flutterRoot = '../..';
|
||||
when(mockFlutterVersion.frameworkRevision).thenReturn(frameworkRevision);
|
||||
|
||||
@@ -638,7 +638,7 @@ dependencies:
|
||||
XcodeProjectInterpreter: () => xcodeProjectInterpreter,
|
||||
});
|
||||
|
||||
testUsingContext('old embedding app uses a plugin that supports v1 and v2 embedding works but shows a deprecation warning', () async {
|
||||
testUsingContext('old embedding app uses a plugin that supports v1 and v2 embedding works', () async {
|
||||
when(flutterProject.isModule).thenReturn(false);
|
||||
when(androidProject.getEmbeddingVersion()).thenReturn(AndroidEmbeddingVersion.v1);
|
||||
|
||||
@@ -655,7 +655,6 @@ dependencies:
|
||||
expect(registrant.readAsStringSync(), contains('class GeneratedPluginRegistrant'));
|
||||
expect(registrant.readAsStringSync(),
|
||||
contains('UseBothEmbedding.registerWith(registry.registrarFor("plugin4.UseBothEmbedding"));'));
|
||||
expect(testLogger.statusText, contains('Follow the steps on https://flutter.dev/go/android-project-migration'));
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => fs,
|
||||
ProcessManager: () => FakeProcessManager.any(),
|
||||
|
||||
@@ -148,6 +148,20 @@ void main() {
|
||||
await project.ensureReadyForPlatformSpecificTooling();
|
||||
expectExists(project.android.hostAppGradleRoot.childFile('local.properties'));
|
||||
});
|
||||
_testInMemory('Android project not on v2 embedding shows a warning', () async {
|
||||
final FlutterProject project = await someProject();
|
||||
// The default someProject with an empty <manifest> already indicates
|
||||
// v1 embedding, as opposed to having <meta-data
|
||||
// android:name="flutterEmbedding" android:value="2" />.
|
||||
|
||||
await project.ensureReadyForPlatformSpecificTooling();
|
||||
expect(testLogger.statusText, contains('https://flutter.dev/go/android-project-migration'));
|
||||
});
|
||||
_testInMemory('updates local properties for Android', () async {
|
||||
final FlutterProject project = await someProject();
|
||||
await project.ensureReadyForPlatformSpecificTooling();
|
||||
expectExists(project.android.hostAppGradleRoot.childFile('local.properties'));
|
||||
});
|
||||
testUsingContext('injects plugins for macOS', () async {
|
||||
final FlutterProject project = await someProject();
|
||||
project.macos.managedDirectory.createSync(recursive: true);
|
||||
|
||||
Reference in New Issue
Block a user