Skip to content

Commit

Permalink
[path_provider] Skip verifying sample file on macOS (#6874)
Browse files Browse the repository at this point in the history
[Sandboxing was recently disabled for macOS CI tests](flutter/flutter#149618). This caused `getApplicationDocumentsDirectory` tests in path_provider to fail because it changes the path.

With sandboxing enabled, the path is `~/Library/Containers/dev.flutter.plugins.pathProviderExample/Data/Documents`. With sandboxing disabled, the path is `~/Documents`, which requires additional permissions to access. 

To workaround, skip verifying a file can be created/deleted and simply validate a path is returned.

Fixes flutter/flutter#149713.
  • Loading branch information
vashworth committed Jun 5, 2024
1 parent 3885ac2 commit 67b082d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,15 @@ void main() {

testWidgets('getApplicationDocumentsDirectory', (WidgetTester tester) async {
final Directory result = await getApplicationDocumentsDirectory();
_verifySampleFile(result, 'applicationDocuments');
if (Platform.isMacOS) {
// _verifySampleFile causes hangs in driver when sandboxing is disabled
// because the path changes from an app specific directory to
// ~/Documents, which requires additional permissions to access on macOS.
// Instead, validate that a non-empty path was returned.
expect(result.path, isNotEmpty);
} else {
_verifySampleFile(result, 'applicationDocuments');
}
});

testWidgets('getApplicationSupportDirectory', (WidgetTester tester) async {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,15 @@ void main() {
testWidgets('getApplicationDocumentsDirectory', (WidgetTester tester) async {
final PathProviderPlatform provider = PathProviderPlatform.instance;
final String? result = await provider.getApplicationDocumentsPath();
_verifySampleFile(result, 'applicationDocuments');
if (Platform.isMacOS) {
// _verifySampleFile causes hangs in driver when sandboxing is disabled
// because the path changes from an app specific directory to
// ~/Documents, which requires additional permissions to access on macOS.
// Instead, validate that a non-empty path was returned.
expect(result, isNotEmpty);
} else {
_verifySampleFile(result, 'applicationDocuments');
}
});

testWidgets('getApplicationSupportDirectory', (WidgetTester tester) async {
Expand Down

0 comments on commit 67b082d

Please sign in to comment.