From 1513b9719ac51c1732c67c79e065fb181feed22e Mon Sep 17 00:00:00 2001 From: Jenn Magder Date: Mon, 3 Aug 2020 10:24:04 -0700 Subject: [PATCH] Add integration test for plugins without ios directories (#62630) --- .../bin/tasks/plugin_dependencies_test.dart | 90 ++++++++++++++++++- 1 file changed, 86 insertions(+), 4 deletions(-) diff --git a/dev/devicelab/bin/tasks/plugin_dependencies_test.dart b/dev/devicelab/bin/tasks/plugin_dependencies_test.dart index 79de9f68a3..b5df8ba6fd 100644 --- a/dev/devicelab/bin/tasks/plugin_dependencies_test.dart +++ b/dev/devicelab/bin/tasks/plugin_dependencies_test.dart @@ -78,6 +78,11 @@ Future main() async { ); }); + checkDirectoryNotExists(path.join( + pluginCDirectory.path, + 'android', + )); + final File pluginCpubspec = File(path.join(pluginCDirectory.path, 'pubspec.yaml')); await pluginCpubspec.writeAsString(''' name: plugin_c @@ -98,6 +103,27 @@ environment: flutter: ">=1.5.0 <2.0.0" ''', flush: true); + section('Create plugin D without ios/ directory'); + + final Directory pluginDDirectory = Directory(path.join(tempDir.path, 'plugin_d')); + await inDirectory(tempDir, () async { + await flutter( + 'create', + options: [ + '--org', + 'io.flutter.devicelab.plugin_d', + '--template=plugin', + '--platforms=android', + pluginDDirectory.path, + ], + ); + }); + + checkDirectoryNotExists(path.join( + pluginDDirectory.path, + 'ios', + )); + section('Write dummy Kotlin code in plugin B'); final File pluginBKotlinClass = File(path.join( @@ -120,7 +146,7 @@ public class DummyPluginBClass { } ''', flush: true); - section('Make plugin A depend on plugin B and plugin C'); + section('Make plugin A depend on plugin B, C, and D'); final File pluginApubspec = File(path.join(pluginADirectory.path, 'pubspec.yaml')); String pluginApubspecContent = await pluginApubspec.readAsString(); @@ -130,7 +156,9 @@ public class DummyPluginBClass { ' plugin_b:\n' ' path: ${pluginBDirectory.path}\n' ' plugin_c:\n' - ' path: ${pluginCDirectory.path}\n', + ' path: ${pluginCDirectory.path}\n' + ' plugin_d:\n' + ' path: ${pluginDDirectory.path}\n', ); await pluginApubspec.writeAsString(pluginApubspecContent, flush: true); @@ -187,7 +215,7 @@ public class DummyPluginAClass { '[' '{' '"name":"plugin_a",' - '"dependencies":["plugin_b","plugin_c"]' + '"dependencies":["plugin_b","plugin_c","plugin_d"]' '},' '{' '"name":"plugin_b",' @@ -196,6 +224,10 @@ public class DummyPluginAClass { '{' '"name":"plugin_c",' '"dependencies":[]' + '},' + '{' + '"name":"plugin_d",' + '"dependencies":[]' '}' ']'; final String graphString = json.encode(dependencyGraph); @@ -206,7 +238,7 @@ public class DummyPluginAClass { ); } - section('Build plugin A example app'); + section('Build plugin A example Android app'); final StringBuffer stderr = StringBuffer(); await inDirectory(exampleApp, () async { @@ -237,6 +269,56 @@ public class DummyPluginAClass { return TaskResult.failure('Failed to build plugin A example APK'); } + if (Platform.isMacOS) { + section('Build plugin A example iOS app'); + + await inDirectory(exampleApp, () async { + await evalFlutter( + 'build', + options: [ + 'ios', + '--no-codesign', + ], + ); + }); + + final Directory appBundle = Directory(path.join( + pluginADirectory.path, + 'example', + 'build', + 'ios', + 'iphoneos', + 'Runner.app', + )); + + if (!exists(appBundle)) { + return TaskResult.failure('Failed to build plugin A example iOS app'); + } + + checkDirectoryExists(path.join( + appBundle.path, + 'Frameworks', + 'plugin_a.framework', + )); + checkDirectoryExists(path.join( + appBundle.path, + 'Frameworks', + 'plugin_b.framework', + )); + checkDirectoryExists(path.join( + appBundle.path, + 'Frameworks', + 'plugin_c.framework', + )); + + // Plugin D is Android only and should not be embedded. + checkDirectoryNotExists(path.join( + appBundle.path, + 'Frameworks', + 'plugin_d.framework', + )); + } + return TaskResult.success(null); } on TaskResult catch (taskResult) { return taskResult;