-
Notifications
You must be signed in to change notification settings - Fork 4k
[url_launcher] Fix supportsCloseForLaunchMode to query close support #12926
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
base: main
Are you sure you want to change the base?
Changes from all commits
e1fd0c4
2957c6f
326a25c
3324784
d5217fd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,7 @@ class MockUrlLauncher extends Fake with MockPlatformInterfaceMixin implements Ur | |
| String? webOnlyWindowName; | ||
|
|
||
| bool? response; | ||
| bool? closeForModeResponse; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This can just be called |
||
|
|
||
| bool closeWebViewCalled = false; | ||
| bool canLaunchCalled = false; | ||
|
|
@@ -59,6 +60,11 @@ class MockUrlLauncher extends Fake with MockPlatformInterfaceMixin implements Ur | |
| this.response = response; | ||
| } | ||
|
|
||
| // ignore: use_setters_to_change_properties | ||
| void setCloseForModeResponse(bool response) { | ||
| closeForModeResponse = response; | ||
| } | ||
|
|
||
| @override | ||
| LinkDelegate? get linkDelegate => null; | ||
|
|
||
|
|
@@ -120,6 +126,6 @@ class MockUrlLauncher extends Fake with MockPlatformInterfaceMixin implements Ur | |
| @override | ||
| Future<bool> supportsCloseForMode(PreferredLaunchMode mode) async { | ||
| launchMode = mode; | ||
| return response!; | ||
| return closeForModeResponse!; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,8 +10,12 @@ import 'package:url_launcher_platform_interface/url_launcher_platform_interface. | |
| import '../mocks/mock_url_launcher_platform.dart'; | ||
|
|
||
| void main() { | ||
| final mock = MockUrlLauncher(); | ||
| UrlLauncherPlatform.instance = mock; | ||
| late MockUrlLauncher mock; | ||
|
|
||
| setUp(() { | ||
| mock = MockUrlLauncher(); | ||
| UrlLauncherPlatform.instance = mock; | ||
| }); | ||
|
|
||
| test('closeInAppWebView', () async { | ||
| await closeInAppWebView(); | ||
|
|
@@ -310,17 +314,26 @@ void main() { | |
|
|
||
| group('supportsCloseForLaunchMode', () { | ||
| test('handles returning true', () async { | ||
| mock.setResponse(true); | ||
| mock.setCloseForModeResponse(true); | ||
|
|
||
| expect(await supportsCloseForLaunchMode(LaunchMode.inAppBrowserView), true); | ||
| expect(mock.launchMode, PreferredLaunchMode.inAppBrowserView); | ||
| }); | ||
|
|
||
| test('handles returning false', () async { | ||
| mock.setResponse(false); | ||
| mock.setCloseForModeResponse(false); | ||
|
|
||
| expect(await supportsCloseForLaunchMode(LaunchMode.inAppBrowserView), false); | ||
| expect(mock.launchMode, PreferredLaunchMode.inAppBrowserView); | ||
| }); | ||
|
|
||
| test('reflects close support independently of launch support', () async { | ||
| mock | ||
| ..setResponse(false) | ||
| ..setCloseForModeResponse(true); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While it technically works as a test, this combination is nonsensical which makes the test confusing. Please use the realistic mismatch, which is |
||
|
|
||
| expect(await supportsLaunchMode(LaunchMode.inAppBrowserView), false); | ||
| expect(await supportsCloseForLaunchMode(LaunchMode.inAppBrowserView), true); | ||
| }); | ||
| }); | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your removed the entire changelog entry instead of shortening it as requested.