Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/url_launcher/url_launcher/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## NEXT
## 6.3.3

Copy link
Copy Markdown
Collaborator

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.

* Updates minimum supported SDK version to Flutter 3.41/Dart 3.11.
* Updates README to reflect currently supported OS versions for the latest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,5 +104,5 @@ Future<bool> supportsLaunchMode(LaunchMode mode) {
/// If this returns false, [closeInAppWebView] will not work when launching
/// URLs with [mode].
Future<bool> supportsCloseForLaunchMode(LaunchMode mode) {
return UrlLauncherPlatform.instance.supportsMode(convertLaunchMode(mode));
return UrlLauncherPlatform.instance.supportsCloseForMode(convertLaunchMode(mode));
}
2 changes: 1 addition & 1 deletion packages/url_launcher/url_launcher/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: Flutter plugin for launching a URL. Supports
web, phone, SMS, and email schemes.
repository: https://github.com/flutter/packages/tree/main/packages/url_launcher/url_launcher
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+url_launcher%22
version: 6.3.2
version: 6.3.3

environment:
sdk: ^3.11.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class MockUrlLauncher extends Fake with MockPlatformInterfaceMixin implements Ur
String? webOnlyWindowName;

bool? response;
bool? closeForModeResponse;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can just be called closeResponse. Also, the existing member should be renamed to launchResponse to make its role clear now that there are multiple responses (and the setter renamed to setLaunchResponse accordingly).


bool closeWebViewCalled = false;
bool canLaunchCalled = false;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand Up @@ -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();
Expand Down Expand Up @@ -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);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The 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 true/false instead of false/true.


expect(await supportsLaunchMode(LaunchMode.inAppBrowserView), false);
expect(await supportsCloseForLaunchMode(LaunchMode.inAppBrowserView), true);
});
});
}
Loading