Skip to content

Commit 67b082d

Browse files
authored
[path_provider] Skip verifying sample file on macOS (flutter#6874)
[Sandboxing was recently disabled for macOS CI tests](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#149713.
1 parent 3885ac2 commit 67b082d

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

packages/path_provider/path_provider/example/integration_test/path_provider_test.dart

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,15 @@ void main() {
1717

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

2331
testWidgets('getApplicationSupportDirectory', (WidgetTester tester) async {

packages/path_provider/path_provider_foundation/example/integration_test/path_provider_test.dart

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,15 @@ void main() {
2020
testWidgets('getApplicationDocumentsDirectory', (WidgetTester tester) async {
2121
final PathProviderPlatform provider = PathProviderPlatform.instance;
2222
final String? result = await provider.getApplicationDocumentsPath();
23-
_verifySampleFile(result, 'applicationDocuments');
23+
if (Platform.isMacOS) {
24+
// _verifySampleFile causes hangs in driver when sandboxing is disabled
25+
// because the path changes from an app specific directory to
26+
// ~/Documents, which requires additional permissions to access on macOS.
27+
// Instead, validate that a non-empty path was returned.
28+
expect(result, isNotEmpty);
29+
} else {
30+
_verifySampleFile(result, 'applicationDocuments');
31+
}
2432
});
2533

2634
testWidgets('getApplicationSupportDirectory', (WidgetTester tester) async {

0 commit comments

Comments
 (0)