Unverified Commit 9eb9ea0f authored by xster's avatar xster Committed by GitHub

Let the tool warn about all old API plugins (#48282)

parent e1812c82
...@@ -497,7 +497,6 @@ Future<void> _writeAndroidPluginRegistrant(FlutterProject project, List<Plugin> ...@@ -497,7 +497,6 @@ Future<void> _writeAndroidPluginRegistrant(FlutterProject project, List<Plugin>
'following https://flutter.dev/go/android-plugin-migration.' 'following https://flutter.dev/go/android-plugin-migration.'
); );
} }
break;
} }
} }
templateContent = _androidPluginRegistryTemplateNewEmbedding; templateContent = _androidPluginRegistryTemplateNewEmbedding;
......
...@@ -129,7 +129,7 @@ flutter: ...@@ -129,7 +129,7 @@ flutter:
); );
} }
void createOldJavaPlugin3() { void createOldJavaPlugin(String pluginName) {
final Directory pluginUsingOldEmbeddingDir = final Directory pluginUsingOldEmbeddingDir =
fs.systemTempDirectory.createTempSync('flutter_plugin_using_old_embedding_dir.'); fs.systemTempDirectory.createTempSync('flutter_plugin_using_old_embedding_dir.');
pluginUsingOldEmbeddingDir pluginUsingOldEmbeddingDir
...@@ -137,7 +137,7 @@ flutter: ...@@ -137,7 +137,7 @@ flutter:
.writeAsStringSync(''' .writeAsStringSync('''
flutter: flutter:
plugin: plugin:
androidPackage: plugin3 androidPackage: $pluginName
pluginClass: UseOldEmbedding pluginClass: UseOldEmbedding
'''); ''');
pluginUsingOldEmbeddingDir pluginUsingOldEmbeddingDir
...@@ -145,14 +145,14 @@ flutter: ...@@ -145,14 +145,14 @@ flutter:
.childDirectory('src') .childDirectory('src')
.childDirectory('main') .childDirectory('main')
.childDirectory('java') .childDirectory('java')
.childDirectory('plugin3') .childDirectory(pluginName)
.childFile('UseOldEmbedding.java') .childFile('UseOldEmbedding.java')
..createSync(recursive: true); ..createSync(recursive: true);
flutterProject.directory flutterProject.directory
.childFile('.packages') .childFile('.packages')
.writeAsStringSync( .writeAsStringSync(
'plugin3:${pluginUsingOldEmbeddingDir.childDirectory('lib').uri.toString()}\n', '$pluginName:${pluginUsingOldEmbeddingDir.childDirectory('lib').uri.toString()}\n',
mode: FileMode.append, mode: FileMode.append,
); );
} }
...@@ -379,7 +379,7 @@ dependencies: ...@@ -379,7 +379,7 @@ dependencies:
createNewJavaPlugin1(); createNewJavaPlugin1();
createNewKotlinPlugin2(); createNewKotlinPlugin2();
createOldJavaPlugin3(); createOldJavaPlugin('plugin3');
await injectPlugins(flutterProject); await injectPlugins(flutterProject);
...@@ -497,7 +497,7 @@ dependencies: ...@@ -497,7 +497,7 @@ dependencies:
when(flutterProject.isModule).thenReturn(true); when(flutterProject.isModule).thenReturn(true);
when(androidProject.getEmbeddingVersion()).thenReturn(AndroidEmbeddingVersion.v2); when(androidProject.getEmbeddingVersion()).thenReturn(AndroidEmbeddingVersion.v2);
createOldJavaPlugin3(); createOldJavaPlugin('plugin3');
await injectPlugins(flutterProject); await injectPlugins(flutterProject);
...@@ -558,6 +558,31 @@ dependencies: ...@@ -558,6 +558,31 @@ dependencies:
XcodeProjectInterpreter: () => xcodeProjectInterpreter, XcodeProjectInterpreter: () => xcodeProjectInterpreter,
}); });
testUsingContext('Module using multiple old plugins all show warnings', () async {
when(flutterProject.isModule).thenReturn(true);
when(androidProject.getEmbeddingVersion()).thenReturn(AndroidEmbeddingVersion.v2);
createOldJavaPlugin('plugin3');
createOldJavaPlugin('plugin4');
await injectPlugins(flutterProject);
final File registrant = flutterProject.directory
.childDirectory(fs.path.join('android', 'app', 'src', 'main', 'java', 'io', 'flutter', 'plugins'))
.childFile('GeneratedPluginRegistrant.java');
expect(registrant.readAsStringSync(),
contains('plugin3.UseOldEmbedding.registerWith(shimPluginRegistry.registrarFor("plugin3.UseOldEmbedding"));'));
expect(registrant.readAsStringSync(),
contains('plugin4.UseOldEmbedding.registerWith(shimPluginRegistry.registrarFor("plugin4.UseOldEmbedding"));'));
expect(testLogger.statusText, contains('The plugin `plugin3` is built using an older version of the Android plugin API'));
expect(testLogger.statusText, contains('The plugin `plugin4` is built using an older version of the Android plugin API'));
}, overrides: <Type, Generator>{
FileSystem: () => fs,
ProcessManager: () => FakeProcessManager.any(),
FeatureFlags: () => featureFlags,
XcodeProjectInterpreter: () => xcodeProjectInterpreter,
});
testUsingContext('Does not throw when AndroidManifest.xml is not found', () async { testUsingContext('Does not throw when AndroidManifest.xml is not found', () async {
when(flutterProject.isModule).thenReturn(false); when(flutterProject.isModule).thenReturn(false);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment