@@ -154,7 +154,7 @@ void main() {
154
154
confirmButtonText: confirmButtonText,
155
155
acceptedTypeGroups: acceptedTypeGroups,
156
156
suggestedName: suggestedName)
157
- ..setPathResponse ( expectedSavePath);
157
+ ..setPathsResponse ( < String > [ expectedSavePath] );
158
158
159
159
final String ? savePath = await getSavePath (
160
160
initialDirectory: initialDirectory,
@@ -167,7 +167,7 @@ void main() {
167
167
});
168
168
169
169
test ('works with no arguments' , () async {
170
- fakePlatformImplementation.setPathResponse ( expectedSavePath);
170
+ fakePlatformImplementation.setPathsResponse ( < String > [ expectedSavePath] );
171
171
172
172
final String ? savePath = await getSavePath ();
173
173
expect (savePath, expectedSavePath);
@@ -176,7 +176,7 @@ void main() {
176
176
test ('sets the initial directory' , () async {
177
177
fakePlatformImplementation
178
178
..setExpectations (initialDirectory: initialDirectory)
179
- ..setPathResponse ( expectedSavePath);
179
+ ..setPathsResponse ( < String > [ expectedSavePath] );
180
180
181
181
final String ? savePath =
182
182
await getSavePath (initialDirectory: initialDirectory);
@@ -186,7 +186,7 @@ void main() {
186
186
test ('sets the button confirmation label' , () async {
187
187
fakePlatformImplementation
188
188
..setExpectations (confirmButtonText: confirmButtonText)
189
- ..setPathResponse ( expectedSavePath);
189
+ ..setPathsResponse ( < String > [ expectedSavePath] );
190
190
191
191
final String ? savePath =
192
192
await getSavePath (confirmButtonText: confirmButtonText);
@@ -196,7 +196,7 @@ void main() {
196
196
test ('sets the accepted type groups' , () async {
197
197
fakePlatformImplementation
198
198
..setExpectations (acceptedTypeGroups: acceptedTypeGroups)
199
- ..setPathResponse ( expectedSavePath);
199
+ ..setPathsResponse ( < String > [ expectedSavePath] );
200
200
201
201
final String ? savePath =
202
202
await getSavePath (acceptedTypeGroups: acceptedTypeGroups);
@@ -206,7 +206,7 @@ void main() {
206
206
test ('sets the suggested name' , () async {
207
207
fakePlatformImplementation
208
208
..setExpectations (suggestedName: suggestedName)
209
- ..setPathResponse ( expectedSavePath);
209
+ ..setPathsResponse ( < String > [ expectedSavePath] );
210
210
211
211
final String ? savePath = await getSavePath (suggestedName: suggestedName);
212
212
expect (savePath, expectedSavePath);
@@ -221,7 +221,7 @@ void main() {
221
221
..setExpectations (
222
222
initialDirectory: initialDirectory,
223
223
confirmButtonText: confirmButtonText)
224
- ..setPathResponse ( expectedDirectoryPath);
224
+ ..setPathsResponse ( < String > [ expectedDirectoryPath] );
225
225
226
226
final String ? directoryPath = await getDirectoryPath (
227
227
initialDirectory: initialDirectory,
@@ -232,7 +232,8 @@ void main() {
232
232
});
233
233
234
234
test ('works with no arguments' , () async {
235
- fakePlatformImplementation.setPathResponse (expectedDirectoryPath);
235
+ fakePlatformImplementation
236
+ .setPathsResponse (< String > [expectedDirectoryPath]);
236
237
237
238
final String ? directoryPath = await getDirectoryPath ();
238
239
expect (directoryPath, expectedDirectoryPath);
@@ -241,7 +242,7 @@ void main() {
241
242
test ('sets the initial directory' , () async {
242
243
fakePlatformImplementation
243
244
..setExpectations (initialDirectory: initialDirectory)
244
- ..setPathResponse ( expectedDirectoryPath);
245
+ ..setPathsResponse ( < String > [ expectedDirectoryPath] );
245
246
246
247
final String ? directoryPath =
247
248
await getDirectoryPath (initialDirectory: initialDirectory);
@@ -251,13 +252,62 @@ void main() {
251
252
test ('sets the button confirmation label' , () async {
252
253
fakePlatformImplementation
253
254
..setExpectations (confirmButtonText: confirmButtonText)
254
- ..setPathResponse ( expectedDirectoryPath);
255
+ ..setPathsResponse ( < String > [ expectedDirectoryPath] );
255
256
256
257
final String ? directoryPath =
257
258
await getDirectoryPath (confirmButtonText: confirmButtonText);
258
259
expect (directoryPath, expectedDirectoryPath);
259
260
});
260
261
});
262
+
263
+ group ('getDirectoryPaths' , () {
264
+ const List <String > expectedDirectoryPaths = < String > [
265
+ '/example/path' ,
266
+ '/example/2/path'
267
+ ];
268
+
269
+ test ('works' , () async {
270
+ fakePlatformImplementation
271
+ ..setExpectations (
272
+ initialDirectory: initialDirectory,
273
+ confirmButtonText: confirmButtonText)
274
+ ..setPathsResponse (expectedDirectoryPaths);
275
+
276
+ final List <String ?> directoryPaths = await getDirectoryPaths (
277
+ initialDirectory: initialDirectory,
278
+ confirmButtonText: confirmButtonText,
279
+ );
280
+
281
+ expect (directoryPaths, expectedDirectoryPaths);
282
+ });
283
+
284
+ test ('works with no arguments' , () async {
285
+ fakePlatformImplementation.setPathsResponse (expectedDirectoryPaths);
286
+
287
+ final List <String ?> directoryPaths = await getDirectoryPaths ();
288
+ expect (directoryPaths, expectedDirectoryPaths);
289
+ });
290
+
291
+ test ('sets the initial directory' , () async {
292
+ fakePlatformImplementation
293
+ ..setExpectations (initialDirectory: initialDirectory)
294
+ ..setPathsResponse (expectedDirectoryPaths);
295
+
296
+ final List <String ?> directoryPaths =
297
+ await getDirectoryPaths (initialDirectory: initialDirectory);
298
+ expect (directoryPaths, expectedDirectoryPaths);
299
+ });
300
+
301
+ test ('sets the button confirmation label' , () async {
302
+ fakePlatformImplementation
303
+ ..setExpectations (confirmButtonText: confirmButtonText)
304
+ ..setPathsResponse (expectedDirectoryPaths);
305
+
306
+ final List <String ?> directoryPaths =
307
+ await getDirectoryPaths (confirmButtonText: confirmButtonText);
308
+ expect (directoryPaths, expectedDirectoryPaths);
309
+ });
310
+ });
261
311
}
262
312
263
313
class FakeFileSelector extends Fake
@@ -270,7 +320,7 @@ class FakeFileSelector extends Fake
270
320
String ? suggestedName;
271
321
// Return values.
272
322
List <XFile >? files;
273
- String ? path ;
323
+ List < String > ? paths ;
274
324
275
325
void setExpectations ({
276
326
List <XTypeGroup > acceptedTypeGroups = const < XTypeGroup > [],
@@ -290,8 +340,8 @@ class FakeFileSelector extends Fake
290
340
}
291
341
292
342
// ignore: use_setters_to_change_properties
293
- void setPathResponse ( String path ) {
294
- this .path = path ;
343
+ void setPathsResponse ( List < String > paths ) {
344
+ this .paths = paths ;
295
345
}
296
346
297
347
@override
@@ -329,7 +379,7 @@ class FakeFileSelector extends Fake
329
379
expect (initialDirectory, this .initialDirectory);
330
380
expect (suggestedName, this .suggestedName);
331
381
expect (confirmButtonText, this .confirmButtonText);
332
- return path ;
382
+ return paths ? [ 0 ] ;
333
383
}
334
384
335
385
@override
@@ -339,6 +389,16 @@ class FakeFileSelector extends Fake
339
389
}) async {
340
390
expect (initialDirectory, this .initialDirectory);
341
391
expect (confirmButtonText, this .confirmButtonText);
342
- return path;
392
+ return paths? [0 ];
393
+ }
394
+
395
+ @override
396
+ Future <List <String >> getDirectoryPaths ({
397
+ String ? initialDirectory,
398
+ String ? confirmButtonText,
399
+ }) async {
400
+ expect (initialDirectory, this .initialDirectory);
401
+ expect (confirmButtonText, this .confirmButtonText);
402
+ return paths! ;
343
403
}
344
404
}
0 commit comments