diff --git a/packages/flutter_tools/test/general.shard/application_package_test.dart b/packages/flutter_tools/test/general.shard/application_package_test.dart index 8e159d3181..7e68724f16 100644 --- a/packages/flutter_tools/test/general.shard/application_package_test.dart +++ b/packages/flutter_tools/test/general.shard/application_package_test.dart @@ -206,7 +206,7 @@ void main() { }); group('PrebuiltIOSApp', () { - final MockOperatingSystemUtils os = MockOperatingSystemUtils(); + MockOperatingSystemUtils os; final Map overrides = { FileSystem: () => MemoryFileSystem(), ProcessManager: () => FakeProcessManager.any(), @@ -215,6 +215,10 @@ void main() { OperatingSystemUtils: () => os, }; + setUp(() { + os = MockOperatingSystemUtils(); + }); + testUsingContext('Error on non-existing file', () { final PrebuiltIOSApp iosApp = IOSApp.fromPrebuiltApp(globals.fs.file('not_existing.ipa')) as PrebuiltIOSApp; diff --git a/packages/flutter_tools/test/general.shard/plugins_test.dart b/packages/flutter_tools/test/general.shard/plugins_test.dart index f8426716bd..b4da1f5e32 100644 --- a/packages/flutter_tools/test/general.shard/plugins_test.dart +++ b/packages/flutter_tools/test/general.shard/plugins_test.dart @@ -159,7 +159,7 @@ flutter: ); } - void createPluginWithInvalidAndroidPackage() { + Directory createPluginWithInvalidAndroidPackage() { final Directory pluginUsingJavaAndNewEmbeddingDir = fs.systemTempDirectory.createTempSync('flutter_plugin_invalid_package.'); pluginUsingJavaAndNewEmbeddingDir @@ -187,6 +187,7 @@ flutter: 'plugin1:${pluginUsingJavaAndNewEmbeddingDir.childDirectory('lib').uri.toString()}\n', mode: FileMode.append, ); + return pluginUsingJavaAndNewEmbeddingDir; } void createNewKotlinPlugin2() { @@ -279,7 +280,7 @@ flutter: ); } - void createPluginWithDependencies({ + Directory createPluginWithDependencies({ @required String name, @required List dependencies, }) { @@ -308,6 +309,7 @@ dependencies: '$name:${pluginDirectory.childDirectory('lib').uri.toString()}\n', mode: FileMode.append, ); + return pluginDirectory; } // Creates the files that would indicate that pod install has run for the @@ -389,9 +391,9 @@ EndGlobal'''); }); testUsingContext('Refreshing the plugin list modifies .flutter-plugins and .flutter-plugins-dependencies when there are plugins', () { - createPluginWithDependencies(name: 'plugin-a', dependencies: const ['plugin-b', 'plugin-c', 'random-package']); - createPluginWithDependencies(name: 'plugin-b', dependencies: const ['plugin-c']); - createPluginWithDependencies(name: 'plugin-c', dependencies: const []); + final Directory pluginA = createPluginWithDependencies(name: 'plugin-a', dependencies: const ['plugin-b', 'plugin-c', 'random-package']); + final Directory pluginB = createPluginWithDependencies(name: 'plugin-b', dependencies: const ['plugin-c']); + final Directory pluginC = createPluginWithDependencies(name: 'plugin-c', dependencies: const []); when(iosProject.existsSync()).thenReturn(true); final DateTime dateCreated = DateTime(1970, 1, 1); @@ -410,9 +412,9 @@ EndGlobal'''); expect(flutterProject.flutterPluginsDependenciesFile.existsSync(), true); expect(flutterProject.flutterPluginsFile.readAsStringSync(), '# This is a generated file; do not edit or check into version control.\n' - 'plugin-a=/.tmp_rand0/plugin.rand0/\n' - 'plugin-b=/.tmp_rand0/plugin.rand1/\n' - 'plugin-c=/.tmp_rand0/plugin.rand2/\n' + 'plugin-a=${pluginA.path}/\n' + 'plugin-b=${pluginB.path}/\n' + 'plugin-c=${pluginC.path}/\n' '' ); @@ -424,7 +426,7 @@ EndGlobal'''); final List expectedPlugins = [ { 'name': 'plugin-a', - 'path': '/.tmp_rand0/plugin.rand0/', + 'path': '${pluginA.path}/', 'dependencies': [ 'plugin-b', 'plugin-c' @@ -432,14 +434,14 @@ EndGlobal'''); }, { 'name': 'plugin-b', - 'path': '/.tmp_rand0/plugin.rand1/', + 'path': '${pluginB.path}/', 'dependencies': [ 'plugin-c' ] }, { 'name': 'plugin-c', - 'path': '/.tmp_rand0/plugin.rand2/', + 'path': '${pluginC.path}/', 'dependencies': [] }, ]; @@ -642,7 +644,7 @@ EndGlobal'''); when(flutterProject.isModule).thenReturn(false); when(androidProject.getEmbeddingVersion()).thenReturn(AndroidEmbeddingVersion.v1); - createPluginWithInvalidAndroidPackage(); + final Directory pluginDir = createPluginWithInvalidAndroidPackage(); await expectLater( () async { @@ -650,8 +652,8 @@ EndGlobal'''); }, throwsToolExit( message: "The plugin `plugin1` doesn't have a main class defined in " - '/.tmp_rand2/flutter_plugin_invalid_package.rand2/android/src/main/java/plugin1/invalid/UseNewEmbedding.java or ' - '/.tmp_rand2/flutter_plugin_invalid_package.rand2/android/src/main/kotlin/plugin1/invalid/UseNewEmbedding.kt. ' + '${pluginDir.path}/android/src/main/java/plugin1/invalid/UseNewEmbedding.java or ' + '${pluginDir.path}/android/src/main/kotlin/plugin1/invalid/UseNewEmbedding.kt. ' "This is likely to due to an incorrect `androidPackage: plugin1.invalid` or `mainClass` entry in the plugin's pubspec.yaml.\n" 'If you are the author of this plugin, fix the `androidPackage` entry or move the main class to any of locations used above. ' 'Otherwise, please contact the author of this plugin and consider using a different plugin in the meanwhile.',