Skip to content

Commit

Permalink
[path_provider] Fix integration tests (flutter#5075)
Browse files Browse the repository at this point in the history
- Fix the `throwsA` test to properly await.
- Updates the `getDownloadsDirectory` test to not assume that Android will throw, since that is no longer true.
  • Loading branch information
stuartmorgan authored Oct 4, 2023
1 parent dccde60 commit 5badf97
Showing 1 changed file with 10 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ void main() {
_verifySampleFile(result, 'library');
} else if (Platform.isAndroid) {
final Future<Directory?> result = getLibraryDirectory();
expect(result, throwsA(isInstanceOf<UnsupportedError>()));
await expectLater(result, throwsA(isInstanceOf<UnsupportedError>()));
}
});

testWidgets('getExternalStorageDirectory', (WidgetTester tester) async {
if (Platform.isIOS) {
final Future<Directory?> result = getExternalStorageDirectory();
expect(result, throwsA(isInstanceOf<UnsupportedError>()));
await expectLater(result, throwsA(isInstanceOf<UnsupportedError>()));
} else if (Platform.isAndroid) {
final Directory? result = await getExternalStorageDirectory();
_verifySampleFile(result, 'externalStorage');
Expand All @@ -53,7 +53,7 @@ void main() {
testWidgets('getExternalCacheDirectories', (WidgetTester tester) async {
if (Platform.isIOS) {
final Future<List<Directory>?> result = getExternalCacheDirectories();
expect(result, throwsA(isInstanceOf<UnsupportedError>()));
await expectLater(result, throwsA(isInstanceOf<UnsupportedError>()));
} else if (Platform.isAndroid) {
final List<Directory>? directories = await getExternalCacheDirectories();
expect(directories, isNotNull);
Expand All @@ -79,7 +79,7 @@ void main() {
(WidgetTester tester) async {
if (Platform.isIOS) {
final Future<List<Directory>?> result = getExternalStorageDirectories();
expect(result, throwsA(isInstanceOf<UnsupportedError>()));
await expectLater(result, throwsA(isInstanceOf<UnsupportedError>()));
} else if (Platform.isAndroid) {
final List<Directory>? directories =
await getExternalStorageDirectories(type: type);
Expand All @@ -92,17 +92,12 @@ void main() {
}

testWidgets('getDownloadsDirectory', (WidgetTester tester) async {
if (Platform.isAndroid) {
final Future<Directory?> result = getDownloadsDirectory();
expect(result, throwsA(isInstanceOf<UnsupportedError>()));
} 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);
});
}

Expand Down

0 comments on commit 5badf97

Please sign in to comment.