From a440899880829bafddbfa61dacaad66c33e288d4 Mon Sep 17 00:00:00 2001 From: Harry Terkelsen Date: Fri, 18 Oct 2019 13:53:32 -0700 Subject: [PATCH 01/10] [url_launcher] Add overridable platform --- .../url_launcher/url_launcher/CHANGELOG.md | 5 ++ .../lib/method_channel_url_launcher.dart | 47 +++++++++++++ .../url_launcher/lib/url_launcher.dart | 49 +++++++++----- .../lib/url_launcher_platform_interface.dart | 29 ++++++++ .../url_launcher/url_launcher/pubspec.yaml | 2 +- .../test/url_launcher_platform_test.dart | 67 +++++++++++++++++++ 6 files changed, 181 insertions(+), 18 deletions(-) create mode 100644 packages/url_launcher/url_launcher/lib/method_channel_url_launcher.dart create mode 100644 packages/url_launcher/url_launcher/lib/url_launcher_platform_interface.dart create mode 100644 packages/url_launcher/url_launcher/test/url_launcher_platform_test.dart diff --git a/packages/url_launcher/url_launcher/CHANGELOG.md b/packages/url_launcher/url_launcher/CHANGELOG.md index 9893c4f8931d..f4f48ae0feb6 100644 --- a/packages/url_launcher/url_launcher/CHANGELOG.md +++ b/packages/url_launcher/url_launcher/CHANGELOG.md @@ -1,3 +1,8 @@ +## 5.2.3 + +* Adds `urlLauncherPlatform` which can be overridden to implement `url_launcher` + on other platforms (which may not want to use MethodChannels). + ## 5.2.2 * Re-land embedder v2 support with correct Flutter SDK constraints. diff --git a/packages/url_launcher/url_launcher/lib/method_channel_url_launcher.dart b/packages/url_launcher/url_launcher/lib/method_channel_url_launcher.dart new file mode 100644 index 000000000000..4beb4098bde9 --- /dev/null +++ b/packages/url_launcher/url_launcher/lib/method_channel_url_launcher.dart @@ -0,0 +1,47 @@ +import 'dart:async'; + +import 'package:flutter/services.dart'; + +import 'url_launcher_platform_interface.dart'; + +const MethodChannel _channel = MethodChannel('plugins.flutter.io/url_launcher'); + +/// An implementation of [UrlLauncherPlatform] that uses method channels. +class MethodChannelUrlLauncher extends UrlLauncherPlatform { + @override + Future canLaunch(String url) { + return _channel.invokeMethod( + 'canLaunch', + {'url': url}, + ); + } + + @override + Future closeWebView() { + return _channel.invokeMethod('closeWebView'); + } + + @override + Future launch( + String url, + bool useSafariVC, + bool useWebView, + bool enableJavaScript, + bool enableDomStorage, + bool universalLinksOnly, + Map headers, + ) { + _channel.invokeMethod( + 'launch', + { + 'url': url, + 'useSafariVC': useSafariVC, + 'useWebView': useWebView, + 'enableJavaScript': enableJavaScript, + 'enableDomStorage': enableDomStorage, + 'universalLinksOnly': universalLinksOnly, + 'headers': headers, + }, + ); + } +} diff --git a/packages/url_launcher/url_launcher/lib/url_launcher.dart b/packages/url_launcher/url_launcher/lib/url_launcher.dart index 045448fbde97..51bcc5875c2b 100644 --- a/packages/url_launcher/url_launcher/lib/url_launcher.dart +++ b/packages/url_launcher/url_launcher/lib/url_launcher.dart @@ -8,7 +8,8 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/services.dart'; import 'package:flutter/widgets.dart'; -const MethodChannel _channel = MethodChannel('plugins.flutter.io/url_launcher'); +import 'url_launcher_platform_interface.dart'; +import 'method_channel_url_launcher.dart'; /// Parses the specified URL string and delegates handling of it to the /// underlying platform. @@ -84,17 +85,14 @@ Future launch( ? SystemUiOverlayStyle.dark : SystemUiOverlayStyle.light); } - final bool result = await _channel.invokeMethod( - 'launch', - { - 'url': urlString, - 'useSafariVC': forceSafariVC ?? isWebURL, - 'useWebView': forceWebView ?? false, - 'enableJavaScript': enableJavaScript ?? false, - 'enableDomStorage': enableDomStorage ?? false, - 'universalLinksOnly': universalLinksOnly ?? false, - 'headers': headers ?? {}, - }, + final bool result = await urlLauncherPlatform.launch( + urlString, + forceSafariVC ?? isWebURL, + forceWebView ?? false, + enableJavaScript ?? false, + enableDomStorage ?? false, + universalLinksOnly ?? false, + headers ?? {}, ); if (statusBarBrightness != null) { WidgetsBinding.instance.renderView.automaticSystemUiAdjustment = @@ -109,10 +107,7 @@ Future canLaunch(String urlString) async { if (urlString == null) { return false; } - return await _channel.invokeMethod( - 'canLaunch', - {'url': urlString}, - ); + return await urlLauncherPlatform.canLaunch(urlString); } /// Closes the current WebView, if one was previously opened via a call to [launch]. @@ -127,5 +122,25 @@ Future canLaunch(String urlString) async { /// SafariViewController is only available on IOS version >= 9.0, this method does not do anything /// on IOS version below 9.0 Future closeWebView() async { - return await _channel.invokeMethod('closeWebView'); + return await urlLauncherPlatform.closeWebView(); +} + +UrlLauncherPlatform _platform; + +/// The [UrlLauncherPlatform] that will do the platform-specific work. +/// +/// Defaults to [MethodChannelUrlLauncher]. +UrlLauncherPlatform get urlLauncherPlatform { + if (_platform == null) { + _platform = MethodChannelUrlLauncher(); + } + return _platform; +} + +/// Sets the [UrlLauncherPlatform] to use. +/// +/// Set the platform if you have a platform-specific implementation of +/// [UrlLauncherPlatform] that you would like to use. +set urlLauncherPlatform(UrlLauncherPlatform newPlatform) { + _platform = newPlatform; } diff --git a/packages/url_launcher/url_launcher/lib/url_launcher_platform_interface.dart b/packages/url_launcher/url_launcher/lib/url_launcher_platform_interface.dart new file mode 100644 index 000000000000..ffe8e883a6c3 --- /dev/null +++ b/packages/url_launcher/url_launcher/lib/url_launcher_platform_interface.dart @@ -0,0 +1,29 @@ +// Copyright 2017 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:async'; + +/// The interface that implementations of url_launcher must implement. +abstract class UrlLauncherPlatform { + /// Returns `true` if this platform is able to launch [url]. + Future canLaunch(String url); + + /// Returns `true` if the given [url] was successfully launched. + /// + /// For documentation on the other arguments, see the `launch` documentation + /// in `package:url_launcher/url_launcher.dart`. + Future launch( + String url, + bool useSafariVC, + bool useWebView, + bool enableJavaScript, + bool enableDomStorage, + bool universalLinksOnly, + Map headers, + ); + + + /// Closes the WebView, if one was opened earlier by `launch`. + Future closeWebView(); +} diff --git a/packages/url_launcher/url_launcher/pubspec.yaml b/packages/url_launcher/url_launcher/pubspec.yaml index 6f882fbc740a..4763469d558d 100644 --- a/packages/url_launcher/url_launcher/pubspec.yaml +++ b/packages/url_launcher/url_launcher/pubspec.yaml @@ -3,7 +3,7 @@ description: Flutter plugin for launching a URL on Android and iOS. Supports web, phone, SMS, and email schemes. author: Flutter Team homepage: https://github.com/flutter/plugins/tree/master/packages/url_launcher/url_launcher -version: 5.2.2 +version: 5.2.3 flutter: plugin: diff --git a/packages/url_launcher/url_launcher/test/url_launcher_platform_test.dart b/packages/url_launcher/url_launcher/test/url_launcher_platform_test.dart new file mode 100644 index 000000000000..2a5466e59bf2 --- /dev/null +++ b/packages/url_launcher/url_launcher/test/url_launcher_platform_test.dart @@ -0,0 +1,67 @@ +// Copyright 2017 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter_test/flutter_test.dart'; +import 'package:url_launcher/url_launcher.dart'; +import 'package:url_launcher/url_launcher_platform_interface.dart'; + +void main() { + TestWidgetsFlutterBinding.ensureInitialized(); + + group('UrlLauncher with mock platform', () { + final MockUrlLauncherPlatform platform = MockUrlLauncherPlatform(); + urlLauncherPlatform = platform; + + test('can mock "canLaunch"', () async { + expect(canLaunch('http://www.google.com'), completion(isFalse)); + + platform.launchableUrls.add('http://www.google.com'); + + expect(canLaunch('http://www.google.com'), completion(isTrue)); + + platform.launchableUrls.clear(); + }); + + test('can mock "launch"', () async { + expect(launch('http://www.google.com'), completion(isFalse)); + + platform.launchableUrls.add('http://www.google.com'); + + expect(launch('http://www.google.com'), completion(isTrue)); + + platform.launchableUrls.clear(); + }); + + test('can mock "closeWebView"', () async { + expect(closeWebView(), completes); + }); + }); +} + +class MockUrlLauncherPlatform extends UrlLauncherPlatform { + Set launchableUrls = Set(); + + @override + Future canLaunch(String url) { + return Future.value(launchableUrls.contains(url)); + } + + @override + Future closeWebView() { + return Future.value(); + } + + @override + Future launch( + String url, + bool useSafariVC, + bool useWebView, + bool enableJavaScript, + bool enableDomStorage, + bool universalLinksOnly, + Map headers, + ) { + return Future.value(launchableUrls.contains(url)); + } +} From d1f0ca2cd893a4c5d6dabd931ee3ef5f840187c3 Mon Sep 17 00:00:00 2001 From: Harry Terkelsen Date: Fri, 18 Oct 2019 13:59:46 -0700 Subject: [PATCH 02/10] Fix analyzer lints --- .../url_launcher/lib/method_channel_url_launcher.dart | 2 +- packages/url_launcher/url_launcher/lib/url_launcher.dart | 2 +- .../url_launcher/test/url_launcher_platform_test.dart | 9 +++++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/url_launcher/url_launcher/lib/method_channel_url_launcher.dart b/packages/url_launcher/url_launcher/lib/method_channel_url_launcher.dart index 4beb4098bde9..74da123a90ad 100644 --- a/packages/url_launcher/url_launcher/lib/method_channel_url_launcher.dart +++ b/packages/url_launcher/url_launcher/lib/method_channel_url_launcher.dart @@ -31,7 +31,7 @@ class MethodChannelUrlLauncher extends UrlLauncherPlatform { bool universalLinksOnly, Map headers, ) { - _channel.invokeMethod( + return _channel.invokeMethod( 'launch', { 'url': url, diff --git a/packages/url_launcher/url_launcher/lib/url_launcher.dart b/packages/url_launcher/url_launcher/lib/url_launcher.dart index 51bcc5875c2b..7173d86d59ec 100644 --- a/packages/url_launcher/url_launcher/lib/url_launcher.dart +++ b/packages/url_launcher/url_launcher/lib/url_launcher.dart @@ -8,8 +8,8 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/services.dart'; import 'package:flutter/widgets.dart'; -import 'url_launcher_platform_interface.dart'; import 'method_channel_url_launcher.dart'; +import 'url_launcher_platform_interface.dart'; /// Parses the specified URL string and delegates handling of it to the /// underlying platform. diff --git a/packages/url_launcher/url_launcher/test/url_launcher_platform_test.dart b/packages/url_launcher/url_launcher/test/url_launcher_platform_test.dart index 2a5466e59bf2..05de983e41ba 100644 --- a/packages/url_launcher/url_launcher/test/url_launcher_platform_test.dart +++ b/packages/url_launcher/url_launcher/test/url_launcher_platform_test.dart @@ -40,11 +40,16 @@ void main() { } class MockUrlLauncherPlatform extends UrlLauncherPlatform { + // Ignoring the `prefer_collection_literals` warning here because if we use + // a set literal, it will give another warning saying this code is required + // to run on versions of Dart that are older than 2.2 (when set literals were + // added. + // ignore: prefer_collection_literals Set launchableUrls = Set(); @override Future canLaunch(String url) { - return Future.value(launchableUrls.contains(url)); + return Future.value(launchableUrls.contains(url)); } @override @@ -62,6 +67,6 @@ class MockUrlLauncherPlatform extends UrlLauncherPlatform { bool universalLinksOnly, Map headers, ) { - return Future.value(launchableUrls.contains(url)); + return Future.value(launchableUrls.contains(url)); } } From d58d524ca54cd5dae3f800b217e8bf71745689ea Mon Sep 17 00:00:00 2001 From: Harry Terkelsen Date: Fri, 18 Oct 2019 14:52:24 -0700 Subject: [PATCH 03/10] Run dartfmt --- .../lib/url_launcher_platform_interface.dart | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/packages/url_launcher/url_launcher/lib/url_launcher_platform_interface.dart b/packages/url_launcher/url_launcher/lib/url_launcher_platform_interface.dart index ffe8e883a6c3..865df02ad2d7 100644 --- a/packages/url_launcher/url_launcher/lib/url_launcher_platform_interface.dart +++ b/packages/url_launcher/url_launcher/lib/url_launcher_platform_interface.dart @@ -14,16 +14,15 @@ abstract class UrlLauncherPlatform { /// For documentation on the other arguments, see the `launch` documentation /// in `package:url_launcher/url_launcher.dart`. Future launch( - String url, - bool useSafariVC, - bool useWebView, - bool enableJavaScript, - bool enableDomStorage, - bool universalLinksOnly, - Map headers, + String url, + bool useSafariVC, + bool useWebView, + bool enableJavaScript, + bool enableDomStorage, + bool universalLinksOnly, + Map headers, ); - /// Closes the WebView, if one was opened earlier by `launch`. Future closeWebView(); } From bada3feca40764d34b0b652f502eb70f05e7bc81 Mon Sep 17 00:00:00 2001 From: Harry Terkelsen Date: Tue, 22 Oct 2019 10:39:50 -0700 Subject: [PATCH 04/10] Add a url_launcher_platform_interface package --- .../url_launcher/url_launcher/CHANGELOG.md | 5 -- .../url_launcher/lib/url_launcher.dart | 49 +++++++------------ .../url_launcher/url_launcher/pubspec.yaml | 2 +- .../url_launcher_platform_interface/README.md | 19 +++++++ .../lib/method_channel_url_launcher.dart | 0 .../lib/url_launcher_platform_interface.dart | 0 .../pubspec.yaml | 19 +++++++ .../test/url_launcher_platform_test.dart | 2 +- 8 files changed, 57 insertions(+), 39 deletions(-) create mode 100644 packages/url_launcher/url_launcher_platform_interface/README.md rename packages/url_launcher/{url_launcher => url_launcher_platform_interface}/lib/method_channel_url_launcher.dart (100%) rename packages/url_launcher/{url_launcher => url_launcher_platform_interface}/lib/url_launcher_platform_interface.dart (100%) create mode 100644 packages/url_launcher/url_launcher_platform_interface/pubspec.yaml rename packages/url_launcher/{url_launcher => url_launcher_platform_interface}/test/url_launcher_platform_test.dart (95%) diff --git a/packages/url_launcher/url_launcher/CHANGELOG.md b/packages/url_launcher/url_launcher/CHANGELOG.md index f4f48ae0feb6..9893c4f8931d 100644 --- a/packages/url_launcher/url_launcher/CHANGELOG.md +++ b/packages/url_launcher/url_launcher/CHANGELOG.md @@ -1,8 +1,3 @@ -## 5.2.3 - -* Adds `urlLauncherPlatform` which can be overridden to implement `url_launcher` - on other platforms (which may not want to use MethodChannels). - ## 5.2.2 * Re-land embedder v2 support with correct Flutter SDK constraints. diff --git a/packages/url_launcher/url_launcher/lib/url_launcher.dart b/packages/url_launcher/url_launcher/lib/url_launcher.dart index 7173d86d59ec..045448fbde97 100644 --- a/packages/url_launcher/url_launcher/lib/url_launcher.dart +++ b/packages/url_launcher/url_launcher/lib/url_launcher.dart @@ -8,8 +8,7 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/services.dart'; import 'package:flutter/widgets.dart'; -import 'method_channel_url_launcher.dart'; -import 'url_launcher_platform_interface.dart'; +const MethodChannel _channel = MethodChannel('plugins.flutter.io/url_launcher'); /// Parses the specified URL string and delegates handling of it to the /// underlying platform. @@ -85,14 +84,17 @@ Future launch( ? SystemUiOverlayStyle.dark : SystemUiOverlayStyle.light); } - final bool result = await urlLauncherPlatform.launch( - urlString, - forceSafariVC ?? isWebURL, - forceWebView ?? false, - enableJavaScript ?? false, - enableDomStorage ?? false, - universalLinksOnly ?? false, - headers ?? {}, + final bool result = await _channel.invokeMethod( + 'launch', + { + 'url': urlString, + 'useSafariVC': forceSafariVC ?? isWebURL, + 'useWebView': forceWebView ?? false, + 'enableJavaScript': enableJavaScript ?? false, + 'enableDomStorage': enableDomStorage ?? false, + 'universalLinksOnly': universalLinksOnly ?? false, + 'headers': headers ?? {}, + }, ); if (statusBarBrightness != null) { WidgetsBinding.instance.renderView.automaticSystemUiAdjustment = @@ -107,7 +109,10 @@ Future canLaunch(String urlString) async { if (urlString == null) { return false; } - return await urlLauncherPlatform.canLaunch(urlString); + return await _channel.invokeMethod( + 'canLaunch', + {'url': urlString}, + ); } /// Closes the current WebView, if one was previously opened via a call to [launch]. @@ -122,25 +127,5 @@ Future canLaunch(String urlString) async { /// SafariViewController is only available on IOS version >= 9.0, this method does not do anything /// on IOS version below 9.0 Future closeWebView() async { - return await urlLauncherPlatform.closeWebView(); -} - -UrlLauncherPlatform _platform; - -/// The [UrlLauncherPlatform] that will do the platform-specific work. -/// -/// Defaults to [MethodChannelUrlLauncher]. -UrlLauncherPlatform get urlLauncherPlatform { - if (_platform == null) { - _platform = MethodChannelUrlLauncher(); - } - return _platform; -} - -/// Sets the [UrlLauncherPlatform] to use. -/// -/// Set the platform if you have a platform-specific implementation of -/// [UrlLauncherPlatform] that you would like to use. -set urlLauncherPlatform(UrlLauncherPlatform newPlatform) { - _platform = newPlatform; + return await _channel.invokeMethod('closeWebView'); } diff --git a/packages/url_launcher/url_launcher/pubspec.yaml b/packages/url_launcher/url_launcher/pubspec.yaml index 4763469d558d..6f882fbc740a 100644 --- a/packages/url_launcher/url_launcher/pubspec.yaml +++ b/packages/url_launcher/url_launcher/pubspec.yaml @@ -3,7 +3,7 @@ description: Flutter plugin for launching a URL on Android and iOS. Supports web, phone, SMS, and email schemes. author: Flutter Team homepage: https://github.com/flutter/plugins/tree/master/packages/url_launcher/url_launcher -version: 5.2.3 +version: 5.2.2 flutter: plugin: diff --git a/packages/url_launcher/url_launcher_platform_interface/README.md b/packages/url_launcher/url_launcher_platform_interface/README.md new file mode 100644 index 000000000000..d7d3ac0cded2 --- /dev/null +++ b/packages/url_launcher/url_launcher_platform_interface/README.md @@ -0,0 +1,19 @@ +# url_launcher_platform_interface + +A common platform interface for the [`url_launcher`][1] plugin. + +This interface allows platform-specific implementations of the `url_launcher` +plugin, as well as the plugin itself, to ensure they are supporting the +same interface. + +# Usage + +To implement a new platform-specific implementation of `url_launcher`, you can +either implement the method channel calls (specified in +[`method_channel_url_launcher.dart`][2]) or you can implement your own instance +of [`UrlLauncherPlatform`][3] and register it with `package:url_launcher` by +setting `urlLauncherPlatform`. + +[1]: ../url_launcher +[2]: lib/method_channel_url_launcher.dart +[3]: lib/url_launcher_platform_interface.dart diff --git a/packages/url_launcher/url_launcher/lib/method_channel_url_launcher.dart b/packages/url_launcher/url_launcher_platform_interface/lib/method_channel_url_launcher.dart similarity index 100% rename from packages/url_launcher/url_launcher/lib/method_channel_url_launcher.dart rename to packages/url_launcher/url_launcher_platform_interface/lib/method_channel_url_launcher.dart diff --git a/packages/url_launcher/url_launcher/lib/url_launcher_platform_interface.dart b/packages/url_launcher/url_launcher_platform_interface/lib/url_launcher_platform_interface.dart similarity index 100% rename from packages/url_launcher/url_launcher/lib/url_launcher_platform_interface.dart rename to packages/url_launcher/url_launcher_platform_interface/lib/url_launcher_platform_interface.dart diff --git a/packages/url_launcher/url_launcher_platform_interface/pubspec.yaml b/packages/url_launcher/url_launcher_platform_interface/pubspec.yaml new file mode 100644 index 000000000000..1fb34e400c06 --- /dev/null +++ b/packages/url_launcher/url_launcher_platform_interface/pubspec.yaml @@ -0,0 +1,19 @@ +name: url_launcher_platform_interface +description: A common platform interface for the url_launcher plugin. +author: Flutter Team +homepage: https://github.com/flutter/plugins/tree/master/packages/url_launcher/url_launcher_platform_interface +version: 0.1.0 + +dependencies: + flutter: + sdk: flutter + +dev_dependencies: + flutter_test: + sdk: flutter + url_launcher: + path: ../url_launcher + +environment: + sdk: ">=2.0.0-dev.28.0 <3.0.0" + flutter: ">=1.9.1+hotfix.4 <2.0.0" diff --git a/packages/url_launcher/url_launcher/test/url_launcher_platform_test.dart b/packages/url_launcher/url_launcher_platform_interface/test/url_launcher_platform_test.dart similarity index 95% rename from packages/url_launcher/url_launcher/test/url_launcher_platform_test.dart rename to packages/url_launcher/url_launcher_platform_interface/test/url_launcher_platform_test.dart index 05de983e41ba..9d4c768e7ccb 100644 --- a/packages/url_launcher/url_launcher/test/url_launcher_platform_test.dart +++ b/packages/url_launcher/url_launcher_platform_interface/test/url_launcher_platform_test.dart @@ -4,7 +4,7 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:url_launcher/url_launcher.dart'; -import 'package:url_launcher/url_launcher_platform_interface.dart'; +import 'package:url_launcher_platform_interface/url_launcher_platform_interface.dart'; void main() { TestWidgetsFlutterBinding.ensureInitialized(); From 7cba5065bc01afe0796b03c77f1e9fd533be87a7 Mon Sep 17 00:00:00 2001 From: Harry Terkelsen Date: Tue, 22 Oct 2019 10:46:54 -0700 Subject: [PATCH 05/10] Disable tests temporarily --- .../test/url_launcher_platform_test.dart | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/url_launcher/url_launcher_platform_interface/test/url_launcher_platform_test.dart b/packages/url_launcher/url_launcher_platform_interface/test/url_launcher_platform_test.dart index 9d4c768e7ccb..e90014188048 100644 --- a/packages/url_launcher/url_launcher_platform_interface/test/url_launcher_platform_test.dart +++ b/packages/url_launcher/url_launcher_platform_interface/test/url_launcher_platform_test.dart @@ -9,9 +9,12 @@ import 'package:url_launcher_platform_interface/url_launcher_platform_interface. void main() { TestWidgetsFlutterBinding.ensureInitialized(); + // TODO(hterkelsen): Re-enable this test once we land the corresponding + // change in package:url_launcher group('UrlLauncher with mock platform', () { final MockUrlLauncherPlatform platform = MockUrlLauncherPlatform(); - urlLauncherPlatform = platform; + // Skip until we add this to package:url_launcher + //urlLauncherPlatform = platform; test('can mock "canLaunch"', () async { expect(canLaunch('http://www.google.com'), completion(isFalse)); @@ -36,7 +39,7 @@ void main() { test('can mock "closeWebView"', () async { expect(closeWebView(), completes); }); - }); + }, skip: true); } class MockUrlLauncherPlatform extends UrlLauncherPlatform { From 3607ed6096cc6006deef0d46100a9a1234a83e1b Mon Sep 17 00:00:00 2001 From: Harry Terkelsen Date: Tue, 22 Oct 2019 10:48:11 -0700 Subject: [PATCH 06/10] Add license header --- .../lib/method_channel_url_launcher.dart | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/url_launcher/url_launcher_platform_interface/lib/method_channel_url_launcher.dart b/packages/url_launcher/url_launcher_platform_interface/lib/method_channel_url_launcher.dart index 74da123a90ad..6e0ac187e91b 100644 --- a/packages/url_launcher/url_launcher_platform_interface/lib/method_channel_url_launcher.dart +++ b/packages/url_launcher/url_launcher_platform_interface/lib/method_channel_url_launcher.dart @@ -1,3 +1,7 @@ +// Copyright 2017 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + import 'dart:async'; import 'package:flutter/services.dart'; From 9c33b610a2c6d6212aee1ba255ce551cfda64150 Mon Sep 17 00:00:00 2001 From: Harry Terkelsen Date: Tue, 22 Oct 2019 10:48:50 -0700 Subject: [PATCH 07/10] Fix typo in test --- .../test/url_launcher_platform_test.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/url_launcher/url_launcher_platform_interface/test/url_launcher_platform_test.dart b/packages/url_launcher/url_launcher_platform_interface/test/url_launcher_platform_test.dart index e90014188048..289dcc14352f 100644 --- a/packages/url_launcher/url_launcher_platform_interface/test/url_launcher_platform_test.dart +++ b/packages/url_launcher/url_launcher_platform_interface/test/url_launcher_platform_test.dart @@ -46,7 +46,7 @@ class MockUrlLauncherPlatform extends UrlLauncherPlatform { // Ignoring the `prefer_collection_literals` warning here because if we use // a set literal, it will give another warning saying this code is required // to run on versions of Dart that are older than 2.2 (when set literals were - // added. + // added.) // ignore: prefer_collection_literals Set launchableUrls = Set(); From e6119eed25df899f479a49356aca5e74888ee21e Mon Sep 17 00:00:00 2001 From: Harry Terkelsen Date: Tue, 22 Oct 2019 10:54:54 -0700 Subject: [PATCH 08/10] Add LICENSE file --- .../url_launcher_platform_interface/LICENSE | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 packages/url_launcher/url_launcher_platform_interface/LICENSE diff --git a/packages/url_launcher/url_launcher_platform_interface/LICENSE b/packages/url_launcher/url_launcher_platform_interface/LICENSE new file mode 100644 index 000000000000..c89293372cf3 --- /dev/null +++ b/packages/url_launcher/url_launcher_platform_interface/LICENSE @@ -0,0 +1,27 @@ +// Copyright 2017 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. From 732afcd49fb13d366e3e5a62bc4564e46395f6ea Mon Sep 17 00:00:00 2001 From: Harry Terkelsen Date: Tue, 22 Oct 2019 14:23:46 -0700 Subject: [PATCH 09/10] Respond to review comments --- .../url_launcher_platform_interface/README.md | 21 +- .../lib/url_launcher_platform_interface.dart | 32 ++- .../pubspec.yaml | 4 +- .../method_channel_url_launcher_test.dart | 260 ++++++++++++++++++ .../test/url_launcher_platform_test.dart | 75 ----- 5 files changed, 303 insertions(+), 89 deletions(-) create mode 100644 packages/url_launcher/url_launcher_platform_interface/test/method_channel_url_launcher_test.dart delete mode 100644 packages/url_launcher/url_launcher_platform_interface/test/url_launcher_platform_test.dart diff --git a/packages/url_launcher/url_launcher_platform_interface/README.md b/packages/url_launcher/url_launcher_platform_interface/README.md index d7d3ac0cded2..3fd6b02cfdf5 100644 --- a/packages/url_launcher/url_launcher_platform_interface/README.md +++ b/packages/url_launcher/url_launcher_platform_interface/README.md @@ -8,12 +8,19 @@ same interface. # Usage -To implement a new platform-specific implementation of `url_launcher`, you can -either implement the method channel calls (specified in -[`method_channel_url_launcher.dart`][2]) or you can implement your own instance -of [`UrlLauncherPlatform`][3] and register it with `package:url_launcher` by -setting `urlLauncherPlatform`. +To implement a new platform-specific implementation of `url_launcher`, extend +[`UrlLauncherPlatform`][2] with an implementation that performs the +platform-specific behavior, and when you register your plugin, set the default +`UrlLauncherPlatform` by calling +`UrlLauncherPlatform.instance = MyPlatformUrlLauncher()`. + +# Note on breaking changes + +Strongly prefer non-breaking changes (such as adding a method to the interface) +over breaking changes for this package. + +See https://flutter.dev/go/platform-interface-breaking-changes for a discussion +on why a less-clean interface is preferable to a breaking change. [1]: ../url_launcher -[2]: lib/method_channel_url_launcher.dart -[3]: lib/url_launcher_platform_interface.dart +[2]: lib/url_launcher_platform_interface.dart diff --git a/packages/url_launcher/url_launcher_platform_interface/lib/url_launcher_platform_interface.dart b/packages/url_launcher/url_launcher_platform_interface/lib/url_launcher_platform_interface.dart index 865df02ad2d7..651a866e7403 100644 --- a/packages/url_launcher/url_launcher_platform_interface/lib/url_launcher_platform_interface.dart +++ b/packages/url_launcher/url_launcher_platform_interface/lib/url_launcher_platform_interface.dart @@ -4,10 +4,30 @@ import 'dart:async'; +import 'method_channel_url_launcher.dart'; + /// The interface that implementations of url_launcher must implement. +/// +/// Platform implementations that live in a separate package should extend this +/// class rather than implement it as `url_launcher` does not consider newly +/// added methods to be breaking changes. Extending this class (using `extends`) +/// ensures that the subclass will get the default implementation, while +/// platform implementations that `implements` this interface will be broken by +/// newly added [UrlLauncherPlatform] methods. abstract class UrlLauncherPlatform { + /// The default instance of [UrlLauncherPlatform] to use. + /// + /// Platform-specific plugins should override this with their own + /// platform-specific class that extends [UrlLauncherPlatform] when they + /// register themselves. + /// + /// Defaults to [MethodChannelUrlLauncher]. + static UrlLauncherPlatform instance = MethodChannelUrlLauncher(); + /// Returns `true` if this platform is able to launch [url]. - Future canLaunch(String url); + Future canLaunch(String url) { + throw new UnimplementedError('canLaunch() has not been implemented.'); + } /// Returns `true` if the given [url] was successfully launched. /// @@ -21,8 +41,12 @@ abstract class UrlLauncherPlatform { bool enableDomStorage, bool universalLinksOnly, Map headers, - ); + ) { + throw new UnimplementedError('launch() has not been implemented.'); + } - /// Closes the WebView, if one was opened earlier by `launch`. - Future closeWebView(); + /// Closes the WebView, if one was opened earlier by [launch]. + Future closeWebView() { + throw new UnimplementedError('closeWebView() has not been implemented.'); + } } diff --git a/packages/url_launcher/url_launcher_platform_interface/pubspec.yaml b/packages/url_launcher/url_launcher_platform_interface/pubspec.yaml index 1fb34e400c06..ef59b68fbf44 100644 --- a/packages/url_launcher/url_launcher_platform_interface/pubspec.yaml +++ b/packages/url_launcher/url_launcher_platform_interface/pubspec.yaml @@ -2,7 +2,7 @@ name: url_launcher_platform_interface description: A common platform interface for the url_launcher plugin. author: Flutter Team homepage: https://github.com/flutter/plugins/tree/master/packages/url_launcher/url_launcher_platform_interface -version: 0.1.0 +version: 1.0.0 dependencies: flutter: @@ -11,8 +11,6 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - url_launcher: - path: ../url_launcher environment: sdk: ">=2.0.0-dev.28.0 <3.0.0" diff --git a/packages/url_launcher/url_launcher_platform_interface/test/method_channel_url_launcher_test.dart b/packages/url_launcher/url_launcher_platform_interface/test/method_channel_url_launcher_test.dart new file mode 100644 index 000000000000..6f7651b496cd --- /dev/null +++ b/packages/url_launcher/url_launcher_platform_interface/test/method_channel_url_launcher_test.dart @@ -0,0 +1,260 @@ +// Copyright 2017 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/services.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:url_launcher_platform_interface/method_channel_url_launcher.dart'; +import 'package:url_launcher_platform_interface/url_launcher_platform_interface.dart'; + +void main() { + group('$MethodChannelUrlLauncher', () { + TestWidgetsFlutterBinding.ensureInitialized(); + + const MethodChannel channel = + MethodChannel('plugins.flutter.io/url_launcher'); + final List log = []; + channel.setMockMethodCallHandler((MethodCall methodCall) async { + log.add(methodCall); + }); + + final MethodChannelUrlLauncher launcher = MethodChannelUrlLauncher(); + + tearDown(() { + log.clear(); + }); + + test('is the default $UrlLauncherPlatform instance', () { + expect(UrlLauncherPlatform.instance, + isInstanceOf()); + }); + + test('canLaunch', () async { + await launcher.canLaunch('http://example.com/'); + expect( + log, + [ + isMethodCall('canLaunch', arguments: { + 'url': 'http://example.com/', + }) + ], + ); + }); + + test('launch', () async { + await launcher.launch( + 'http://example.com/', + true, + false, + false, + false, + false, + const {}, + ); + expect( + log, + [ + isMethodCall('launch', arguments: { + 'url': 'http://example.com/', + 'useSafariVC': true, + 'useWebView': false, + 'enableJavaScript': false, + 'enableDomStorage': false, + 'universalLinksOnly': false, + 'headers': {}, + }) + ], + ); + }); + + test('launch with headers', () async { + await launcher.launch( + 'http://example.com/', + true, + false, + false, + false, + false, + const {'key': 'value'}, + ); + expect( + log, + [ + isMethodCall('launch', arguments: { + 'url': 'http://example.com/', + 'useSafariVC': true, + 'useWebView': false, + 'enableJavaScript': false, + 'enableDomStorage': false, + 'universalLinksOnly': false, + 'headers': {'key': 'value'}, + }) + ], + ); + }); + + test('launch force SafariVC', () async { + await launcher.launch( + 'http://example.com/', + true, + false, + false, + false, + false, + const {}, + ); + expect( + log, + [ + isMethodCall('launch', arguments: { + 'url': 'http://example.com/', + 'useSafariVC': true, + 'useWebView': false, + 'enableJavaScript': false, + 'enableDomStorage': false, + 'universalLinksOnly': false, + 'headers': {}, + }) + ], + ); + }); + + test('launch universal links only', () async { + await launcher.launch( + 'http://example.com/', + false, + false, + false, + false, + true, + const {}, + ); + expect( + log, + [ + isMethodCall('launch', arguments: { + 'url': 'http://example.com/', + 'useSafariVC': false, + 'useWebView': false, + 'enableJavaScript': false, + 'enableDomStorage': false, + 'universalLinksOnly': true, + 'headers': {}, + }) + ], + ); + }); + + test('launch force WebView', () async { + await launcher.launch( + 'http://example.com/', + true, + true, + false, + false, + false, + const {}, + ); + expect( + log, + [ + isMethodCall('launch', arguments: { + 'url': 'http://example.com/', + 'useSafariVC': true, + 'useWebView': true, + 'enableJavaScript': false, + 'enableDomStorage': false, + 'universalLinksOnly': false, + 'headers': {}, + }) + ], + ); + }); + + test('launch force WebView enable javascript', () async { + await launcher.launch( + 'http://example.com/', + true, + true, + true, + false, + false, + const {}, + ); + expect( + log, + [ + isMethodCall('launch', arguments: { + 'url': 'http://example.com/', + 'useSafariVC': true, + 'useWebView': true, + 'enableJavaScript': true, + 'enableDomStorage': false, + 'universalLinksOnly': false, + 'headers': {}, + }) + ], + ); + }); + + test('launch force WebView enable DOM storage', () async { + await launcher.launch( + 'http://example.com/', + true, + true, + false, + true, + false, + const {}, + ); + expect( + log, + [ + isMethodCall('launch', arguments: { + 'url': 'http://example.com/', + 'useSafariVC': true, + 'useWebView': true, + 'enableJavaScript': false, + 'enableDomStorage': true, + 'universalLinksOnly': false, + 'headers': {}, + }) + ], + ); + }); + + test('launch force SafariVC to false', () async { + await launcher.launch( + 'http://example.com/', + false, + false, + false, + false, + false, + const {}, + ); + expect( + log, + [ + isMethodCall('launch', arguments: { + 'url': 'http://example.com/', + 'useSafariVC': false, + 'useWebView': false, + 'enableJavaScript': false, + 'enableDomStorage': false, + 'universalLinksOnly': false, + 'headers': {}, + }) + ], + ); + }); + + test('closeWebView default behavior', () async { + await launcher.closeWebView(); + expect( + log, + [isMethodCall('closeWebView', arguments: null)], + ); + }); + }); +} diff --git a/packages/url_launcher/url_launcher_platform_interface/test/url_launcher_platform_test.dart b/packages/url_launcher/url_launcher_platform_interface/test/url_launcher_platform_test.dart deleted file mode 100644 index 289dcc14352f..000000000000 --- a/packages/url_launcher/url_launcher_platform_interface/test/url_launcher_platform_test.dart +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright 2017 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'package:flutter_test/flutter_test.dart'; -import 'package:url_launcher/url_launcher.dart'; -import 'package:url_launcher_platform_interface/url_launcher_platform_interface.dart'; - -void main() { - TestWidgetsFlutterBinding.ensureInitialized(); - - // TODO(hterkelsen): Re-enable this test once we land the corresponding - // change in package:url_launcher - group('UrlLauncher with mock platform', () { - final MockUrlLauncherPlatform platform = MockUrlLauncherPlatform(); - // Skip until we add this to package:url_launcher - //urlLauncherPlatform = platform; - - test('can mock "canLaunch"', () async { - expect(canLaunch('http://www.google.com'), completion(isFalse)); - - platform.launchableUrls.add('http://www.google.com'); - - expect(canLaunch('http://www.google.com'), completion(isTrue)); - - platform.launchableUrls.clear(); - }); - - test('can mock "launch"', () async { - expect(launch('http://www.google.com'), completion(isFalse)); - - platform.launchableUrls.add('http://www.google.com'); - - expect(launch('http://www.google.com'), completion(isTrue)); - - platform.launchableUrls.clear(); - }); - - test('can mock "closeWebView"', () async { - expect(closeWebView(), completes); - }); - }, skip: true); -} - -class MockUrlLauncherPlatform extends UrlLauncherPlatform { - // Ignoring the `prefer_collection_literals` warning here because if we use - // a set literal, it will give another warning saying this code is required - // to run on versions of Dart that are older than 2.2 (when set literals were - // added.) - // ignore: prefer_collection_literals - Set launchableUrls = Set(); - - @override - Future canLaunch(String url) { - return Future.value(launchableUrls.contains(url)); - } - - @override - Future closeWebView() { - return Future.value(); - } - - @override - Future launch( - String url, - bool useSafariVC, - bool useWebView, - bool enableJavaScript, - bool enableDomStorage, - bool universalLinksOnly, - Map headers, - ) { - return Future.value(launchableUrls.contains(url)); - } -} From 36d14550b8a370b56eef22aa3aa9f35e433f8db3 Mon Sep 17 00:00:00 2001 From: Harry Terkelsen Date: Tue, 22 Oct 2019 15:12:49 -0700 Subject: [PATCH 10/10] Respond to review comments --- .../lib/method_channel_url_launcher.dart | 17 ++-- .../lib/url_launcher_platform_interface.dart | 24 ++--- .../pubspec.yaml | 3 + .../method_channel_url_launcher_test.dart | 96 +++++++++---------- 4 files changed, 73 insertions(+), 67 deletions(-) diff --git a/packages/url_launcher/url_launcher_platform_interface/lib/method_channel_url_launcher.dart b/packages/url_launcher/url_launcher_platform_interface/lib/method_channel_url_launcher.dart index 6e0ac187e91b..3fbd2ee01843 100644 --- a/packages/url_launcher/url_launcher_platform_interface/lib/method_channel_url_launcher.dart +++ b/packages/url_launcher/url_launcher_platform_interface/lib/method_channel_url_launcher.dart @@ -5,6 +5,7 @@ import 'dart:async'; import 'package:flutter/services.dart'; +import 'package:meta/meta.dart' show required; import 'url_launcher_platform_interface.dart'; @@ -27,14 +28,14 @@ class MethodChannelUrlLauncher extends UrlLauncherPlatform { @override Future launch( - String url, - bool useSafariVC, - bool useWebView, - bool enableJavaScript, - bool enableDomStorage, - bool universalLinksOnly, - Map headers, - ) { + String url, { + @required bool useSafariVC, + @required bool useWebView, + @required bool enableJavaScript, + @required bool enableDomStorage, + @required bool universalLinksOnly, + @required Map headers, + }) { return _channel.invokeMethod( 'launch', { diff --git a/packages/url_launcher/url_launcher_platform_interface/lib/url_launcher_platform_interface.dart b/packages/url_launcher/url_launcher_platform_interface/lib/url_launcher_platform_interface.dart index 651a866e7403..8e1d090eef2b 100644 --- a/packages/url_launcher/url_launcher_platform_interface/lib/url_launcher_platform_interface.dart +++ b/packages/url_launcher/url_launcher_platform_interface/lib/url_launcher_platform_interface.dart @@ -4,6 +4,8 @@ import 'dart:async'; +import 'package:meta/meta.dart' show required; + import 'method_channel_url_launcher.dart'; /// The interface that implementations of url_launcher must implement. @@ -26,7 +28,7 @@ abstract class UrlLauncherPlatform { /// Returns `true` if this platform is able to launch [url]. Future canLaunch(String url) { - throw new UnimplementedError('canLaunch() has not been implemented.'); + throw UnimplementedError('canLaunch() has not been implemented.'); } /// Returns `true` if the given [url] was successfully launched. @@ -34,19 +36,19 @@ abstract class UrlLauncherPlatform { /// For documentation on the other arguments, see the `launch` documentation /// in `package:url_launcher/url_launcher.dart`. Future launch( - String url, - bool useSafariVC, - bool useWebView, - bool enableJavaScript, - bool enableDomStorage, - bool universalLinksOnly, - Map headers, - ) { - throw new UnimplementedError('launch() has not been implemented.'); + String url, { + @required bool useSafariVC, + @required bool useWebView, + @required bool enableJavaScript, + @required bool enableDomStorage, + @required bool universalLinksOnly, + @required Map headers, + }) { + throw UnimplementedError('launch() has not been implemented.'); } /// Closes the WebView, if one was opened earlier by [launch]. Future closeWebView() { - throw new UnimplementedError('closeWebView() has not been implemented.'); + throw UnimplementedError('closeWebView() has not been implemented.'); } } diff --git a/packages/url_launcher/url_launcher_platform_interface/pubspec.yaml b/packages/url_launcher/url_launcher_platform_interface/pubspec.yaml index ef59b68fbf44..99b260efe943 100644 --- a/packages/url_launcher/url_launcher_platform_interface/pubspec.yaml +++ b/packages/url_launcher/url_launcher_platform_interface/pubspec.yaml @@ -2,11 +2,14 @@ name: url_launcher_platform_interface description: A common platform interface for the url_launcher plugin. author: Flutter Team homepage: https://github.com/flutter/plugins/tree/master/packages/url_launcher/url_launcher_platform_interface +# NOTE: We strongly prefer non-breaking changes, even at the expense of a +# less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes version: 1.0.0 dependencies: flutter: sdk: flutter + meta: ^1.0.5 dev_dependencies: flutter_test: diff --git a/packages/url_launcher/url_launcher_platform_interface/test/method_channel_url_launcher_test.dart b/packages/url_launcher/url_launcher_platform_interface/test/method_channel_url_launcher_test.dart index 6f7651b496cd..f409441903f3 100644 --- a/packages/url_launcher/url_launcher_platform_interface/test/method_channel_url_launcher_test.dart +++ b/packages/url_launcher/url_launcher_platform_interface/test/method_channel_url_launcher_test.dart @@ -44,12 +44,12 @@ void main() { test('launch', () async { await launcher.launch( 'http://example.com/', - true, - false, - false, - false, - false, - const {}, + useSafariVC: true, + useWebView: false, + enableJavaScript: false, + enableDomStorage: false, + universalLinksOnly: false, + headers: const {}, ); expect( log, @@ -70,12 +70,12 @@ void main() { test('launch with headers', () async { await launcher.launch( 'http://example.com/', - true, - false, - false, - false, - false, - const {'key': 'value'}, + useSafariVC: true, + useWebView: false, + enableJavaScript: false, + enableDomStorage: false, + universalLinksOnly: false, + headers: const {'key': 'value'}, ); expect( log, @@ -96,12 +96,12 @@ void main() { test('launch force SafariVC', () async { await launcher.launch( 'http://example.com/', - true, - false, - false, - false, - false, - const {}, + useSafariVC: true, + useWebView: false, + enableJavaScript: false, + enableDomStorage: false, + universalLinksOnly: false, + headers: const {}, ); expect( log, @@ -122,12 +122,12 @@ void main() { test('launch universal links only', () async { await launcher.launch( 'http://example.com/', - false, - false, - false, - false, - true, - const {}, + useSafariVC: false, + useWebView: false, + enableJavaScript: false, + enableDomStorage: false, + universalLinksOnly: true, + headers: const {}, ); expect( log, @@ -148,12 +148,12 @@ void main() { test('launch force WebView', () async { await launcher.launch( 'http://example.com/', - true, - true, - false, - false, - false, - const {}, + useSafariVC: true, + useWebView: true, + enableJavaScript: false, + enableDomStorage: false, + universalLinksOnly: false, + headers: const {}, ); expect( log, @@ -174,12 +174,12 @@ void main() { test('launch force WebView enable javascript', () async { await launcher.launch( 'http://example.com/', - true, - true, - true, - false, - false, - const {}, + useSafariVC: true, + useWebView: true, + enableJavaScript: true, + enableDomStorage: false, + universalLinksOnly: false, + headers: const {}, ); expect( log, @@ -200,12 +200,12 @@ void main() { test('launch force WebView enable DOM storage', () async { await launcher.launch( 'http://example.com/', - true, - true, - false, - true, - false, - const {}, + useSafariVC: true, + useWebView: true, + enableJavaScript: false, + enableDomStorage: true, + universalLinksOnly: false, + headers: const {}, ); expect( log, @@ -226,12 +226,12 @@ void main() { test('launch force SafariVC to false', () async { await launcher.launch( 'http://example.com/', - false, - false, - false, - false, - false, - const {}, + useSafariVC: false, + useWebView: false, + enableJavaScript: false, + enableDomStorage: false, + universalLinksOnly: false, + headers: const {}, ); expect( log,