Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
e41ea0e
add android show title customization functionality
Alex-Usmanov Oct 17, 2023
fb67692
Pass the parameter
Alex-Usmanov Oct 17, 2023
21cd06f
Dependency overrides
Alex-Usmanov Oct 17, 2023
276c08b
Add tests for native side
Alex-Usmanov Oct 17, 2023
1897451
Cover dart side with tests
Alex-Usmanov Oct 17, 2023
5cd1709
Format
Alex-Usmanov Oct 17, 2023
bc943c5
Reduce code repetition
Alex-Usmanov Oct 17, 2023
d6306ba
Revert todo change
Alex-Usmanov Oct 18, 2023
f59475b
Wrap browser customization values in another configuration object
Alex-Usmanov Oct 20, 2023
157343b
Remove deps overrides
Alex-Usmanov Oct 20, 2023
ae20b08
Revert more deps overrides
Alex-Usmanov Oct 20, 2023
214b0a9
Revert web as well
Alex-Usmanov Oct 20, 2023
cd7dfc9
Revert go_router
Alex-Usmanov Oct 20, 2023
d205c7c
Merge branch 'main' into main
Alex-Usmanov Oct 20, 2023
5eef662
Merge remote-tracking branch 'upstream/main'
Alex-Usmanov Oct 27, 2023
c86ff6e
Format files
Alex-Usmanov Oct 27, 2023
92b2197
Fix tests
Alex-Usmanov Oct 27, 2023
425617e
Add browseroptions to launchUrlString & add more tests
Alex-Usmanov Oct 30, 2023
ece2b78
Fix docstrings
Alex-Usmanov Dec 7, 2023
3ddd644
Revert test format change
Alex-Usmanov Dec 7, 2023
cd361d0
Fix tests
Alex-Usmanov Dec 8, 2023
f0017b7
Version bumps and changelogs
Alex-Usmanov Dec 8, 2023
6105671
Merge remote-tracking branch 'upstream/main'
Alex-Usmanov Dec 8, 2023
a50be0f
Return path-based dependencies
Alex-Usmanov Dec 8, 2023
ef9c154
Add licences
Alex-Usmanov Dec 11, 2023
f4b08cb
Merge remote-tracking branch 'upstream/main'
Alex-Usmanov Dec 11, 2023
80d439b
Fix documentation & changelog
Alex-Usmanov Dec 26, 2023
992d38e
Merge remote-tracking branch 'upstream/main'
Alex-Usmanov Dec 26, 2023
193c076
Add backticks to SFSafariViewController in platform interface changelog
Alex-Usmanov Jan 4, 2024
b399c9b
Merge remote-tracking branch 'upstream/main'
Alex-Usmanov Jan 4, 2024
1ad83a2
More merging
Alex-Usmanov Jan 4, 2024
298a705
Merge remote-tracking branch 'upstream/main' into show-title
Alex-Usmanov Feb 12, 2024
70f5eb0
Merge remote-tracking branch 'upstream/main' into show-title
Alex-Usmanov Mar 31, 2024
8f67ab9
Remove dependency overrides
Alex-Usmanov Mar 31, 2024
c203ae0
Revert changelog
Alex-Usmanov Apr 1, 2024
5ae7bc9
Merge branch 'main' into show-title
Alex-Usmanov Apr 7, 2024
e646958
Merge remote-tracking branch 'upstream/main' into show-title
Alex-Usmanov May 10, 2024
7d92695
Merge remote-tracking branch 'upstream/main' into show-title
Alex-Usmanov May 21, 2024
90360b0
Fix missing classname in type_conversion.dart
Alex-Usmanov Jun 3, 2024
647a8ce
Merge remote-tracking branch 'upstream/main' into show-title
Alex-Usmanov Jun 3, 2024
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
Prev Previous commit
Next Next commit
Add browseroptions to launchUrlString & add more tests
  • Loading branch information
Alex-Usmanov committed Oct 30, 2023
commit 425617e04830f47642db7ab964ceef6d93c7a29c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Future<bool> launchUrlString(
String urlString, {
LaunchMode mode = LaunchMode.platformDefault,
WebViewConfiguration webViewConfiguration = const WebViewConfiguration(),
BrowserConfiguration browserConfiguration = const BrowserConfiguration(),
String? webOnlyWindowName,
}) async {
if ((mode == LaunchMode.inAppWebView ||
Expand All @@ -36,6 +37,7 @@ Future<bool> launchUrlString(
LaunchOptions(
mode: convertLaunchMode(mode),
webViewConfiguration: convertWebViewConfiguration(webViewConfiguration),
browserConfiguration: convertBrowserConfiguration(browserConfiguration),
webOnlyWindowName: webOnlyWindowName,
),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,50 @@ void main() {
isTrue);
});

test('in-app browser', () async {
const String urlString = 'https://flutter.dev';
mock
..setLaunchExpectations(
url: urlString,
launchMode: PreferredLaunchMode.inAppBrowserView,
enableJavaScript: true,
enableDomStorage: true,
universalLinksOnly: false,
headers: <String, String>{},
webOnlyWindowName: null,
showTitle: false,
)
..setResponse(true);
expect(
await launchUrlString(urlString, mode: LaunchMode.inAppBrowserView),
isTrue,
);
});

test('in-app browser with title', () async {
const String urlString = 'https://flutter.dev';
mock
..setLaunchExpectations(
url: urlString,
launchMode: PreferredLaunchMode.inAppBrowserView,
enableJavaScript: true,
enableDomStorage: true,
universalLinksOnly: false,
headers: <String, String>{},
webOnlyWindowName: null,
showTitle: true,
)
..setResponse(true);
expect(
await launchUrlString(
urlString,
mode: LaunchMode.inAppBrowserView,
browserConfiguration: const BrowserConfiguration(showTitle: true),
),
isTrue,
);
});

test('external non-browser only', () async {
const String urlString = 'https://flutter.dev';
mock
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,12 @@ void main() {
isTrue);
});

test('in-app webview with show title', () async {
test('in-app browser view with show title', () async {
final Uri url = Uri.parse('https://flutter.dev');
mock
..setLaunchExpectations(
url: url.toString(),
launchMode: PreferredLaunchMode.inAppWebView,
launchMode: PreferredLaunchMode.inAppBrowserView,
enableJavaScript: true,
enableDomStorage: true,
universalLinksOnly: false,
Expand All @@ -204,7 +204,7 @@ void main() {
expect(
await launchUrl(
url,
mode: LaunchMode.inAppWebView,
mode: LaunchMode.inAppBrowserView,
browserConfiguration: const BrowserConfiguration(showTitle: true),
),
isTrue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ public void openWebView_opensUrlInWebViewIfRequested() {
.setEnableJavaScript(false)
.setEnableDomStorage(false)
.setHeaders(new HashMap<>())
.build(), new Messages.BrowserOptions.Builder().setShowTitle(true).build());
.build(),
new Messages.BrowserOptions.Builder().setShowTitle(true).build());

final ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class);
verify(activity).startActivity(intentCaptor.capture());
Expand All @@ -204,16 +205,13 @@ public void openWebView_opensUrlInCustomTabs() {
.setEnableDomStorage(false)
.setHeaders(new HashMap<>())
.build(),
new Messages.BrowserOptions.Builder().setShowTitle(true).build());
new Messages.BrowserOptions.Builder().setShowTitle(false).build());

final ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class);
verify(activity).startActivity(intentCaptor.capture(), isNull());
assertTrue(result);
assertEquals(Intent.ACTION_VIEW, intentCaptor.getValue().getAction());
assertNull(intentCaptor.getValue().getComponent());
assertEquals(
intentCaptor.getValue().getExtras().getInt(CustomTabsIntent.EXTRA_TITLE_VISIBILITY_STATE),
CustomTabsIntent.SHOW_PAGE_TITLE);
}

@Test
Expand Down Expand Up @@ -247,6 +245,68 @@ public void openWebView_opensUrlInCustomTabsWithCORSAllowedHeader() {
assertEquals(headers.get(headerKey), passedHeaders.getString(headerKey));
}

@Test
public void openWebView_opensUrlInCustomTabsWithShowTitle() {
Activity activity = mock(Activity.class);
UrlLauncher api = new UrlLauncher(ApplicationProvider.getApplicationContext());
api.setActivity(activity);
String url = "https://flutter.dev";
HashMap<String, String> headers = new HashMap<>();
String headerKey = "Content-Type";
headers.put(headerKey, "text/plain");

boolean result =
api.openUrlInApp(
url,
true,
new Messages.WebViewOptions.Builder()
.setEnableJavaScript(false)
.setEnableDomStorage(false)
.setHeaders(headers)
.build(),
new Messages.BrowserOptions.Builder().setShowTitle(true).build());

final ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class);
verify(activity).startActivity(intentCaptor.capture(), isNull());
assertTrue(result);
assertEquals(Intent.ACTION_VIEW, intentCaptor.getValue().getAction());
assertNull(intentCaptor.getValue().getComponent());
assertEquals(
intentCaptor.getValue().getExtras().getInt(CustomTabsIntent.EXTRA_TITLE_VISIBILITY_STATE),
CustomTabsIntent.SHOW_PAGE_TITLE);
}

@Test
public void openWebView_opensUrlInCustomTabsWithoutShowTitle() {
Activity activity = mock(Activity.class);
UrlLauncher api = new UrlLauncher(ApplicationProvider.getApplicationContext());
api.setActivity(activity);
String url = "https://flutter.dev";
HashMap<String, String> headers = new HashMap<>();
String headerKey = "Content-Type";
headers.put(headerKey, "text/plain");

boolean result =
api.openUrlInApp(
url,
true,
new Messages.WebViewOptions.Builder()
.setEnableJavaScript(false)
.setEnableDomStorage(false)
.setHeaders(headers)
.build(),
new Messages.BrowserOptions.Builder().setShowTitle(false).build());

final ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class);
verify(activity).startActivity(intentCaptor.capture(), isNull());
assertTrue(result);
assertEquals(Intent.ACTION_VIEW, intentCaptor.getValue().getAction());
assertNull(intentCaptor.getValue().getComponent());
assertEquals(
intentCaptor.getValue().getExtras().getInt(CustomTabsIntent.EXTRA_TITLE_VISIBILITY_STATE),
CustomTabsIntent.NO_TITLE);
}

@Test
public void openWebView_fallsBackToWebViewIfCustomTabFails() {
Activity activity = mock(Activity.class);
Expand Down