-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[file_selector] Add file group to save return value #4222
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
auto-submit
merged 21 commits into
flutter:main
from
stuartmorgan-g:file-selector-save-extension-group
Jun 23, 2023
Merged
Changes from 11 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
fe1b7be
WIP
stuartmorgan-g 7566d9f
Split and comment
stuartmorgan-g 9c8e359
Pathify deps
stuartmorgan-g 3535dc2
Deprecate old version
stuartmorgan-g 31edcc4
Add initial passthrough implementations of the new method
stuartmorgan-g 4f7da27
Test the interface fallback
stuartmorgan-g af2e10e
Add unit tests for higher levels
stuartmorgan-g 9ad7d01
Merge branch 'main' into file-selector-save-extension-group
stuartmorgan-g cee261f
Implement for Windows
stuartmorgan-g 8d9a32f
Bump versions
stuartmorgan-g f315e22
Linux TODO
stuartmorgan-g 7854c63
Review feedback
stuartmorgan-g 411be21
Add missed file
stuartmorgan-g 2ea2d71
Merge branch 'main' into file-selector-save-extension-group
stuartmorgan-g 2af5085
Update dependencies
stuartmorgan-g c1c42be
Restore changes accidentally lost in the merge
stuartmorgan-g 0e4a2e0
Update readme excerpt
stuartmorgan-g 04fc894
Update dependency
stuartmorgan-g df77e54
Merge branch 'main' into file-selector-save-extension-group
stuartmorgan-g 8615f42
Revert iOS
stuartmorgan-g 22353ab
Update implementation versions
stuartmorgan-g File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -144,7 +144,80 @@ void main() { | |
| }); | ||
| }); | ||
|
|
||
| group('getSavePath', () { | ||
| group('getSaveLocation', () { | ||
| const String expectedSavePath = '/example/path'; | ||
|
|
||
| test('works', () async { | ||
| const int expectedActiveFilter = 1; | ||
| fakePlatformImplementation | ||
| ..setExpectations( | ||
| initialDirectory: initialDirectory, | ||
| confirmButtonText: confirmButtonText, | ||
| acceptedTypeGroups: acceptedTypeGroups, | ||
| suggestedName: suggestedName) | ||
| ..setPathsResponse(<String>[expectedSavePath], | ||
| activeFilter: expectedActiveFilter); | ||
|
|
||
| final FileSaveLocationResult? location = await getSaveLocation( | ||
| initialDirectory: initialDirectory, | ||
| confirmButtonText: confirmButtonText, | ||
| acceptedTypeGroups: acceptedTypeGroups, | ||
| suggestedName: suggestedName, | ||
| ); | ||
|
|
||
| expect(location?.path, expectedSavePath); | ||
| expect(location?.activeFilter, acceptedTypeGroups[expectedActiveFilter]); | ||
| }); | ||
|
|
||
| test('works with no arguments', () async { | ||
| fakePlatformImplementation.setPathsResponse(<String>[expectedSavePath]); | ||
|
|
||
| final FileSaveLocationResult? location = await getSaveLocation(); | ||
| expect(location?.path, expectedSavePath); | ||
| }); | ||
|
|
||
| test('sets the initial directory', () async { | ||
| fakePlatformImplementation | ||
| ..setExpectations(initialDirectory: initialDirectory) | ||
| ..setPathsResponse(<String>[expectedSavePath]); | ||
|
|
||
| final FileSaveLocationResult? location = | ||
| await getSaveLocation(initialDirectory: initialDirectory); | ||
| expect(location?.path, expectedSavePath); | ||
| }); | ||
|
|
||
| test('sets the button confirmation label', () async { | ||
| fakePlatformImplementation | ||
| ..setExpectations(confirmButtonText: confirmButtonText) | ||
| ..setPathsResponse(<String>[expectedSavePath]); | ||
|
|
||
| final FileSaveLocationResult? location = | ||
| await getSaveLocation(confirmButtonText: confirmButtonText); | ||
| expect(location?.path, expectedSavePath); | ||
| }); | ||
|
|
||
| test('sets the accepted type groups', () async { | ||
| fakePlatformImplementation | ||
| ..setExpectations(acceptedTypeGroups: acceptedTypeGroups) | ||
| ..setPathsResponse(<String>[expectedSavePath]); | ||
|
|
||
| final FileSaveLocationResult? location = | ||
| await getSaveLocation(acceptedTypeGroups: acceptedTypeGroups); | ||
| expect(location?.path, expectedSavePath); | ||
| }); | ||
|
|
||
| test('sets the suggested name', () async { | ||
| fakePlatformImplementation | ||
| ..setExpectations(suggestedName: suggestedName) | ||
| ..setPathsResponse(<String>[expectedSavePath]); | ||
|
|
||
| final FileSaveLocationResult? location = | ||
| await getSaveLocation(suggestedName: suggestedName); | ||
| expect(location?.path, expectedSavePath); | ||
| }); | ||
| }); | ||
|
|
||
| group('getSavePath (deprecated)', () { | ||
| const String expectedSavePath = '/example/path'; | ||
|
|
||
| test('works', () async { | ||
|
|
@@ -321,6 +394,7 @@ class FakeFileSelector extends Fake | |
| // Return values. | ||
| List<XFile>? files; | ||
| List<String>? paths; | ||
| int? activeFilter; | ||
|
|
||
| void setExpectations({ | ||
| List<XTypeGroup> acceptedTypeGroups = const <XTypeGroup>[], | ||
|
|
@@ -339,9 +413,9 @@ class FakeFileSelector extends Fake | |
| this.files = files; | ||
| } | ||
|
|
||
| // ignore: use_setters_to_change_properties | ||
| void setPathsResponse(List<String> paths) { | ||
| void setPathsResponse(List<String> paths, {int? activeFilter}) { | ||
| this.paths = paths; | ||
| this.activeFilter = activeFilter; | ||
| } | ||
|
|
||
| @override | ||
|
|
@@ -374,12 +448,35 @@ class FakeFileSelector extends Fake | |
| String? initialDirectory, | ||
| String? suggestedName, | ||
| String? confirmButtonText, | ||
| }) async { | ||
| return (await getSaveLocation( | ||
| acceptedTypeGroups: acceptedTypeGroups, | ||
| options: SaveDialogOptions( | ||
| initialDirectory: initialDirectory, | ||
| suggestedName: suggestedName, | ||
| confirmButtonText: confirmButtonText, | ||
| ), | ||
| )) | ||
| ?.path; | ||
|
||
| } | ||
|
|
||
| @override | ||
| Future<FileSaveLocationResult?> getSaveLocation({ | ||
| List<XTypeGroup>? acceptedTypeGroups, | ||
| SaveDialogOptions options = const SaveDialogOptions(), | ||
| }) async { | ||
| expect(acceptedTypeGroups, this.acceptedTypeGroups); | ||
| expect(initialDirectory, this.initialDirectory); | ||
| expect(suggestedName, this.suggestedName); | ||
| expect(confirmButtonText, this.confirmButtonText); | ||
| return paths?[0]; | ||
| expect(options.initialDirectory, initialDirectory); | ||
| expect(options.suggestedName, suggestedName); | ||
| expect(options.confirmButtonText, confirmButtonText); | ||
| final String? path = paths?[0]; | ||
| final int? activeFilterIndex = activeFilter; | ||
| return path == null | ||
| ? null | ||
| : FileSaveLocationResult(path, | ||
| activeFilter: activeFilterIndex == null | ||
| ? null | ||
| : acceptedTypeGroups?[activeFilterIndex]); | ||
| } | ||
|
|
||
| @override | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.