From 5badf97998fd02f1c380f1dddb2ecf322b9b15f9 Mon Sep 17 00:00:00 2001 From: stuartmorgan Date: Wed, 4 Oct 2023 13:42:06 -0700 Subject: [PATCH] [path_provider] Fix integration tests (#5075) - Fix the `throwsA` test to properly await. - Updates the `getDownloadsDirectory` test to not assume that Android will throw, since that is no longer true. --- .../integration_test/path_provider_test.dart | 25 ++++++++----------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/packages/path_provider/path_provider/example/integration_test/path_provider_test.dart b/packages/path_provider/path_provider/example/integration_test/path_provider_test.dart index 1a70c573e54b..f26f88b46528 100644 --- a/packages/path_provider/path_provider/example/integration_test/path_provider_test.dart +++ b/packages/path_provider/path_provider/example/integration_test/path_provider_test.dart @@ -36,14 +36,14 @@ void main() { _verifySampleFile(result, 'library'); } else if (Platform.isAndroid) { final Future result = getLibraryDirectory(); - expect(result, throwsA(isInstanceOf())); + await expectLater(result, throwsA(isInstanceOf())); } }); testWidgets('getExternalStorageDirectory', (WidgetTester tester) async { if (Platform.isIOS) { final Future result = getExternalStorageDirectory(); - expect(result, throwsA(isInstanceOf())); + await expectLater(result, throwsA(isInstanceOf())); } else if (Platform.isAndroid) { final Directory? result = await getExternalStorageDirectory(); _verifySampleFile(result, 'externalStorage'); @@ -53,7 +53,7 @@ void main() { testWidgets('getExternalCacheDirectories', (WidgetTester tester) async { if (Platform.isIOS) { final Future?> result = getExternalCacheDirectories(); - expect(result, throwsA(isInstanceOf())); + await expectLater(result, throwsA(isInstanceOf())); } else if (Platform.isAndroid) { final List? directories = await getExternalCacheDirectories(); expect(directories, isNotNull); @@ -79,7 +79,7 @@ void main() { (WidgetTester tester) async { if (Platform.isIOS) { final Future?> result = getExternalStorageDirectories(); - expect(result, throwsA(isInstanceOf())); + await expectLater(result, throwsA(isInstanceOf())); } else if (Platform.isAndroid) { final List? directories = await getExternalStorageDirectories(type: type); @@ -92,17 +92,12 @@ void main() { } testWidgets('getDownloadsDirectory', (WidgetTester tester) async { - if (Platform.isAndroid) { - final Future result = getDownloadsDirectory(); - expect(result, throwsA(isInstanceOf())); - } else { - final Directory? result = await getDownloadsDirectory(); - // On recent versions of macOS, actually using the downloads directory - // requires a user prompt (so will fail on CI), and on some platforms the - // directory may not exist. Instead of verifying that it exists, just - // check that it returned a path. - expect(result?.path, isNotEmpty); - } + final Directory? result = await getDownloadsDirectory(); + // On recent versions of macOS, actually using the downloads directory + // requires a user prompt (so will fail on CI), and on some platforms the + // directory may not exist. Instead of verifying that it exists, just + // check that it returned a path. + expect(result?.path, isNotEmpty); }); }