diff --git a/packages/webview_flutter/webview_flutter_android/CHANGELOG.md b/packages/webview_flutter/webview_flutter_android/CHANGELOG.md index 4fb48de10e32..12f7ba007d26 100644 --- a/packages/webview_flutter/webview_flutter_android/CHANGELOG.md +++ b/packages/webview_flutter/webview_flutter_android/CHANGELOG.md @@ -1,3 +1,7 @@ +## 3.12.0 + +* Adds support for `PlatformWebViewController.getUserAgent`. + ## 3.11.0 * Adds support to register a callback to receive JavaScript console messages. See `AndroidWebViewController.onConsoleMessage`. @@ -27,7 +31,7 @@ ## 3.9.2 * Fixes bug where `PlatformWebViewWidget` doesn't rebuild when the controller or PlatformView - implementation flag changes. + implementation flag changes. ## 3.9.1 diff --git a/packages/webview_flutter/webview_flutter_android/android/src/main/java/io/flutter/plugins/webviewflutter/GeneratedAndroidWebView.java b/packages/webview_flutter/webview_flutter_android/android/src/main/java/io/flutter/plugins/webviewflutter/GeneratedAndroidWebView.java index d4cfc698f030..8e8a12cbd305 100644 --- a/packages/webview_flutter/webview_flutter_android/android/src/main/java/io/flutter/plugins/webviewflutter/GeneratedAndroidWebView.java +++ b/packages/webview_flutter/webview_flutter_android/android/src/main/java/io/flutter/plugins/webviewflutter/GeneratedAndroidWebView.java @@ -1790,6 +1790,9 @@ public interface WebSettingsHostApi { void setTextZoom(@NonNull Long instanceId, @NonNull Long textZoom); + @NonNull + String getUserAgentString(@NonNull Long instanceId); + /** The codec used by WebSettingsHostApi. */ static @NonNull MessageCodec getCodec() { return new StandardMessageCodec(); @@ -2179,6 +2182,33 @@ static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable WebSetting channel.setMessageHandler(null); } } + { + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, + "dev.flutter.pigeon.webview_flutter_android.WebSettingsHostApi.getUserAgentString", + getCodec()); + if (api != null) { + channel.setMessageHandler( + (message, reply) -> { + ArrayList wrapped = new ArrayList(); + ArrayList args = (ArrayList) message; + Number instanceIdArg = (Number) args.get(0); + try { + String output = + api.getUserAgentString( + (instanceIdArg == null) ? null : instanceIdArg.longValue()); + wrapped.add(0, output); + } catch (Throwable exception) { + ArrayList wrappedError = wrapError(exception); + wrapped = wrappedError; + } + reply.reply(wrapped); + }); + } else { + channel.setMessageHandler(null); + } + } } } /** Generated interface from Pigeon that represents a handler of messages from Flutter. */ diff --git a/packages/webview_flutter/webview_flutter_android/android/src/main/java/io/flutter/plugins/webviewflutter/WebSettingsHostApiImpl.java b/packages/webview_flutter/webview_flutter_android/android/src/main/java/io/flutter/plugins/webviewflutter/WebSettingsHostApiImpl.java index 3a6b151fa711..8eac2ed6a0c5 100644 --- a/packages/webview_flutter/webview_flutter_android/android/src/main/java/io/flutter/plugins/webviewflutter/WebSettingsHostApiImpl.java +++ b/packages/webview_flutter/webview_flutter_android/android/src/main/java/io/flutter/plugins/webviewflutter/WebSettingsHostApiImpl.java @@ -132,4 +132,11 @@ public void setTextZoom(@NonNull Long instanceId, @NonNull Long textZoom) { final WebSettings webSettings = Objects.requireNonNull(instanceManager.getInstance(instanceId)); webSettings.setTextZoom(textZoom.intValue()); } + + @NonNull + @Override + public String getUserAgentString(@NonNull Long instanceId) { + final WebSettings webSettings = Objects.requireNonNull(instanceManager.getInstance(instanceId)); + return webSettings.getUserAgentString(); + } } diff --git a/packages/webview_flutter/webview_flutter_android/android/src/test/java/io/flutter/plugins/webviewflutter/WebSettingsTest.java b/packages/webview_flutter/webview_flutter_android/android/src/test/java/io/flutter/plugins/webviewflutter/WebSettingsTest.java index 4a2997669885..47d98ecce4f0 100644 --- a/packages/webview_flutter/webview_flutter_android/android/src/test/java/io/flutter/plugins/webviewflutter/WebSettingsTest.java +++ b/packages/webview_flutter/webview_flutter_android/android/src/test/java/io/flutter/plugins/webviewflutter/WebSettingsTest.java @@ -4,6 +4,7 @@ package io.flutter.plugins.webviewflutter; +import static org.junit.Assert.assertEquals; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; @@ -117,4 +118,11 @@ public void setTextZoom() { testHostApiImpl.setTextZoom(0L, 100L); verify(mockWebSettings).setTextZoom(100); } + + @Test + public void getUserAgentString() { + final String userAgent = "str"; + when(mockWebSettings.getUserAgentString()).thenReturn(userAgent); + assertEquals(testHostApiImpl.getUserAgentString(0L), userAgent); + } } diff --git a/packages/webview_flutter/webview_flutter_android/example/integration_test/webview_flutter_test.dart b/packages/webview_flutter/webview_flutter_android/example/integration_test/webview_flutter_test.dart index 017e6961e60f..19fd1a44758a 100644 --- a/packages/webview_flutter/webview_flutter_android/example/integration_test/webview_flutter_test.dart +++ b/packages/webview_flutter/webview_flutter_android/example/integration_test/webview_flutter_test.dart @@ -342,7 +342,7 @@ Future main() async { await pageFinished.future; - final String customUserAgent = await _getUserAgent(controller); + final String? customUserAgent = await controller.getUserAgent(); expect(customUserAgent, 'Custom_User_Agent1'); }); @@ -1353,19 +1353,6 @@ Future main() async { }); } -/// Returns the value used for the HTTP User-Agent: request header in subsequent HTTP requests. -Future _getUserAgent(PlatformWebViewController controller) async { - return _runJavaScriptReturningResult(controller, 'navigator.userAgent;'); -} - -Future _runJavaScriptReturningResult( - PlatformWebViewController controller, - String js, -) async { - return jsonDecode(await controller.runJavaScriptReturningResult(js) as String) - as String; -} - class ResizableWebView extends StatefulWidget { const ResizableWebView({ super.key, diff --git a/packages/webview_flutter/webview_flutter_android/lib/src/android_webview.dart b/packages/webview_flutter/webview_flutter_android/lib/src/android_webview.dart index d63f2c75cb5f..c0778ed07224 100644 --- a/packages/webview_flutter/webview_flutter_android/lib/src/android_webview.dart +++ b/packages/webview_flutter/webview_flutter_android/lib/src/android_webview.dart @@ -695,6 +695,11 @@ class WebSettings extends JavaObject { return api.setSetTextZoomFromInstance(this, textZoom); } + /// Gets the WebView's user-agent string. + Future getUserAgentString() { + return api.getUserAgentStringFromInstance(this); + } + @override WebSettings copy() { return WebSettings.detached( diff --git a/packages/webview_flutter/webview_flutter_android/lib/src/android_webview.g.dart b/packages/webview_flutter/webview_flutter_android/lib/src/android_webview.g.dart index 87f75f19cd37..8435f7302fa0 100644 --- a/packages/webview_flutter/webview_flutter_android/lib/src/android_webview.g.dart +++ b/packages/webview_flutter/webview_flutter_android/lib/src/android_webview.g.dart @@ -1499,6 +1499,34 @@ class WebSettingsHostApi { return; } } + + Future getUserAgentString(int arg_instanceId) async { + final BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.webview_flutter_android.WebSettingsHostApi.getUserAgentString', + codec, + binaryMessenger: _binaryMessenger); + final List? replyList = + await channel.send([arg_instanceId]) as List?; + if (replyList == null) { + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel.', + ); + } else if (replyList.length > 1) { + throw PlatformException( + code: replyList[0]! as String, + message: replyList[1] as String?, + details: replyList[2], + ); + } else if (replyList[0] == null) { + throw PlatformException( + code: 'null-error', + message: 'Host platform returned null value for non-null return value.', + ); + } else { + return (replyList[0] as String?)!; + } + } } class JavaScriptChannelHostApi { diff --git a/packages/webview_flutter/webview_flutter_android/lib/src/android_webview_api_impls.dart b/packages/webview_flutter/webview_flutter_android/lib/src/android_webview_api_impls.dart index c9191e06f0c0..4ecb06b05790 100644 --- a/packages/webview_flutter/webview_flutter_android/lib/src/android_webview_api_impls.dart +++ b/packages/webview_flutter/webview_flutter_android/lib/src/android_webview_api_impls.dart @@ -553,6 +553,11 @@ class WebSettingsHostApiImpl extends WebSettingsHostApi { enabled, ); } + + /// Helper method to convert instances ids to objects. + Future getUserAgentStringFromInstance(WebSettings instance) { + return getUserAgentString(instanceManager.getIdentifier(instance)!); + } } /// Host api implementation for [JavaScriptChannel]. diff --git a/packages/webview_flutter/webview_flutter_android/lib/src/android_webview_controller.dart b/packages/webview_flutter/webview_flutter_android/lib/src/android_webview_controller.dart index d0559b4a6e5a..ccfe14391e8f 100644 --- a/packages/webview_flutter/webview_flutter_android/lib/src/android_webview_controller.dart +++ b/packages/webview_flutter/webview_flutter_android/lib/src/android_webview_controller.dart @@ -617,6 +617,9 @@ class AndroidWebViewController extends PlatformWebViewController { return _webChromeClient.setSynchronousReturnValueForOnConsoleMessage( _onConsoleLogCallback != null); } + + @override + Future getUserAgent() => _webView.settings.getUserAgentString(); } /// Android implementation of [PlatformWebViewPermissionRequest]. diff --git a/packages/webview_flutter/webview_flutter_android/pigeons/android_webview.dart b/packages/webview_flutter/webview_flutter_android/pigeons/android_webview.dart index 367605395613..6cce34382a19 100644 --- a/packages/webview_flutter/webview_flutter_android/pigeons/android_webview.dart +++ b/packages/webview_flutter/webview_flutter_android/pigeons/android_webview.dart @@ -299,6 +299,8 @@ abstract class WebSettingsHostApi { void setAllowFileAccess(int instanceId, bool enabled); void setTextZoom(int instanceId, int textZoom); + + String getUserAgentString(int instanceId); } @HostApi(dartHostTestHandler: 'TestJavaScriptChannelHostApi') diff --git a/packages/webview_flutter/webview_flutter_android/pubspec.yaml b/packages/webview_flutter/webview_flutter_android/pubspec.yaml index 8242abd17f05..8087d7957489 100644 --- a/packages/webview_flutter/webview_flutter_android/pubspec.yaml +++ b/packages/webview_flutter/webview_flutter_android/pubspec.yaml @@ -2,7 +2,7 @@ name: webview_flutter_android description: A Flutter plugin that provides a WebView widget on Android. repository: https://github.com/flutter/packages/tree/main/packages/webview_flutter/webview_flutter_android issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+webview%22 -version: 3.11.0 +version: 3.12.0 environment: sdk: ">=2.19.0 <4.0.0" diff --git a/packages/webview_flutter/webview_flutter_android/test/android_webview_controller_test.dart b/packages/webview_flutter/webview_flutter_android/test/android_webview_controller_test.dart index 3f3bf73b33cf..6a7bf30e6145 100644 --- a/packages/webview_flutter/webview_flutter_android/test/android_webview_controller_test.dart +++ b/packages/webview_flutter/webview_flutter_android/test/android_webview_controller_test.dart @@ -1259,6 +1259,20 @@ void main() { verify(mockWebView.settings).called(1); verify(mockSettings.setUserAgentString('Test Framework')).called(1); }); + + test('getUserAgent', () async { + final MockWebSettings mockSettings = MockWebSettings(); + final AndroidWebViewController controller = createControllerWithMocks( + mockSettings: mockSettings, + ); + + const String userAgent = 'str'; + + when(mockSettings.getUserAgentString()) + .thenAnswer((_) => Future.value(userAgent)); + + expect(await controller.getUserAgent(), userAgent); + }); }); test('setMediaPlaybackRequiresUserGesture', () async { diff --git a/packages/webview_flutter/webview_flutter_android/test/android_webview_controller_test.mocks.dart b/packages/webview_flutter/webview_flutter_android/test/android_webview_controller_test.mocks.dart index 98d78795f3c3..ebb01cf8f11c 100644 --- a/packages/webview_flutter/webview_flutter_android/test/android_webview_controller_test.mocks.dart +++ b/packages/webview_flutter/webview_flutter_android/test/android_webview_controller_test.mocks.dart @@ -255,6 +255,7 @@ class MockAndroidNavigationDelegate extends _i1.Mock Invocation.getter(#androidWebChromeClient), ), ) as _i2.WebChromeClient); + @override _i2.WebViewClient get androidWebViewClient => (super.noSuchMethod( Invocation.getter(#androidWebViewClient), @@ -267,6 +268,7 @@ class MockAndroidNavigationDelegate extends _i1.Mock Invocation.getter(#androidWebViewClient), ), ) as _i2.WebViewClient); + @override _i2.DownloadListener get androidDownloadListener => (super.noSuchMethod( Invocation.getter(#androidDownloadListener), @@ -279,6 +281,7 @@ class MockAndroidNavigationDelegate extends _i1.Mock Invocation.getter(#androidDownloadListener), ), ) as _i2.DownloadListener); + @override _i3.PlatformNavigationDelegateCreationParams get params => (super.noSuchMethod( @@ -293,6 +296,7 @@ class MockAndroidNavigationDelegate extends _i1.Mock Invocation.getter(#params), ), ) as _i3.PlatformNavigationDelegateCreationParams); + @override _i9.Future setOnLoadRequest(_i8.LoadRequestCallback? onLoadRequest) => (super.noSuchMethod( @@ -303,6 +307,7 @@ class MockAndroidNavigationDelegate extends _i1.Mock returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future setOnNavigationRequest( _i3.NavigationRequestCallback? onNavigationRequest) => @@ -314,6 +319,7 @@ class MockAndroidNavigationDelegate extends _i1.Mock returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future setOnPageStarted(_i3.PageEventCallback? onPageStarted) => (super.noSuchMethod( @@ -324,6 +330,7 @@ class MockAndroidNavigationDelegate extends _i1.Mock returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future setOnPageFinished(_i3.PageEventCallback? onPageFinished) => (super.noSuchMethod( @@ -334,6 +341,7 @@ class MockAndroidNavigationDelegate extends _i1.Mock returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future setOnProgress(_i3.ProgressCallback? onProgress) => (super.noSuchMethod( @@ -344,6 +352,7 @@ class MockAndroidNavigationDelegate extends _i1.Mock returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future setOnWebResourceError( _i3.WebResourceErrorCallback? onWebResourceError) => @@ -355,6 +364,7 @@ class MockAndroidNavigationDelegate extends _i1.Mock returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future setOnUrlChange(_i3.UrlChangeCallback? onUrlChange) => (super.noSuchMethod( @@ -365,6 +375,7 @@ class MockAndroidNavigationDelegate extends _i1.Mock returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future setOnHttpError(_i3.HttpResponseErrorCallback? onHttpError) => (super.noSuchMethod( @@ -388,6 +399,7 @@ class MockAndroidWebViewController extends _i1.Mock returnValue: 0, returnValueForMissingStub: 0, ) as int); + @override _i3.PlatformWebViewControllerCreationParams get params => (super.noSuchMethod( Invocation.getter(#params), @@ -401,6 +413,7 @@ class MockAndroidWebViewController extends _i1.Mock Invocation.getter(#params), ), ) as _i3.PlatformWebViewControllerCreationParams); + @override _i9.Future loadFile(String? absoluteFilePath) => (super.noSuchMethod( Invocation.method( @@ -410,6 +423,7 @@ class MockAndroidWebViewController extends _i1.Mock returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future loadFlutterAsset(String? key) => (super.noSuchMethod( Invocation.method( @@ -419,6 +433,7 @@ class MockAndroidWebViewController extends _i1.Mock returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future loadHtmlString( String? html, { @@ -433,6 +448,7 @@ class MockAndroidWebViewController extends _i1.Mock returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future loadRequest(_i3.LoadRequestParams? params) => (super.noSuchMethod( @@ -443,6 +459,7 @@ class MockAndroidWebViewController extends _i1.Mock returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future currentUrl() => (super.noSuchMethod( Invocation.method( @@ -452,6 +469,7 @@ class MockAndroidWebViewController extends _i1.Mock returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future canGoBack() => (super.noSuchMethod( Invocation.method( @@ -461,6 +479,7 @@ class MockAndroidWebViewController extends _i1.Mock returnValue: _i9.Future.value(false), returnValueForMissingStub: _i9.Future.value(false), ) as _i9.Future); + @override _i9.Future canGoForward() => (super.noSuchMethod( Invocation.method( @@ -470,6 +489,7 @@ class MockAndroidWebViewController extends _i1.Mock returnValue: _i9.Future.value(false), returnValueForMissingStub: _i9.Future.value(false), ) as _i9.Future); + @override _i9.Future goBack() => (super.noSuchMethod( Invocation.method( @@ -479,6 +499,7 @@ class MockAndroidWebViewController extends _i1.Mock returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future goForward() => (super.noSuchMethod( Invocation.method( @@ -488,6 +509,7 @@ class MockAndroidWebViewController extends _i1.Mock returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future reload() => (super.noSuchMethod( Invocation.method( @@ -497,6 +519,7 @@ class MockAndroidWebViewController extends _i1.Mock returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future clearCache() => (super.noSuchMethod( Invocation.method( @@ -506,6 +529,7 @@ class MockAndroidWebViewController extends _i1.Mock returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future clearLocalStorage() => (super.noSuchMethod( Invocation.method( @@ -515,6 +539,7 @@ class MockAndroidWebViewController extends _i1.Mock returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future setPlatformNavigationDelegate( _i3.PlatformNavigationDelegate? handler) => @@ -526,6 +551,7 @@ class MockAndroidWebViewController extends _i1.Mock returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future runJavaScript(String? javaScript) => (super.noSuchMethod( Invocation.method( @@ -535,6 +561,7 @@ class MockAndroidWebViewController extends _i1.Mock returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future runJavaScriptReturningResult(String? javaScript) => (super.noSuchMethod( @@ -557,6 +584,7 @@ class MockAndroidWebViewController extends _i1.Mock ), )), ) as _i9.Future); + @override _i9.Future addJavaScriptChannel( _i3.JavaScriptChannelParams? javaScriptChannelParams) => @@ -568,6 +596,7 @@ class MockAndroidWebViewController extends _i1.Mock returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future removeJavaScriptChannel(String? javaScriptChannelName) => (super.noSuchMethod( @@ -578,6 +607,7 @@ class MockAndroidWebViewController extends _i1.Mock returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future getTitle() => (super.noSuchMethod( Invocation.method( @@ -587,6 +617,7 @@ class MockAndroidWebViewController extends _i1.Mock returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future scrollTo( int? x, @@ -603,6 +634,7 @@ class MockAndroidWebViewController extends _i1.Mock returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future scrollBy( int? x, @@ -619,6 +651,7 @@ class MockAndroidWebViewController extends _i1.Mock returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future<_i4.Offset> getScrollPosition() => (super.noSuchMethod( Invocation.method( @@ -640,6 +673,7 @@ class MockAndroidWebViewController extends _i1.Mock ), )), ) as _i9.Future<_i4.Offset>); + @override _i9.Future enableZoom(bool? enabled) => (super.noSuchMethod( Invocation.method( @@ -649,6 +683,7 @@ class MockAndroidWebViewController extends _i1.Mock returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future setBackgroundColor(_i4.Color? color) => (super.noSuchMethod( Invocation.method( @@ -658,6 +693,7 @@ class MockAndroidWebViewController extends _i1.Mock returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future setJavaScriptMode(_i3.JavaScriptMode? javaScriptMode) => (super.noSuchMethod( @@ -668,6 +704,7 @@ class MockAndroidWebViewController extends _i1.Mock returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future setUserAgent(String? userAgent) => (super.noSuchMethod( Invocation.method( @@ -677,6 +714,7 @@ class MockAndroidWebViewController extends _i1.Mock returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future setMediaPlaybackRequiresUserGesture(bool? require) => (super.noSuchMethod( @@ -687,6 +725,7 @@ class MockAndroidWebViewController extends _i1.Mock returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future setTextZoom(int? textZoom) => (super.noSuchMethod( Invocation.method( @@ -696,6 +735,7 @@ class MockAndroidWebViewController extends _i1.Mock returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future setOnShowFileSelector( _i9.Future> Function(_i8.FileSelectorParams)? @@ -708,6 +748,7 @@ class MockAndroidWebViewController extends _i1.Mock returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future setOnPlatformPermissionRequest( void Function(_i3.PlatformWebViewPermissionRequest)? @@ -720,6 +761,7 @@ class MockAndroidWebViewController extends _i1.Mock returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future setGeolocationPermissionsPromptCallbacks({ _i8.OnGeolocationPermissionsShowPrompt? onShowPrompt, @@ -737,6 +779,7 @@ class MockAndroidWebViewController extends _i1.Mock returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future setCustomWidgetCallbacks({ required _i8.OnShowCustomWidgetCallback? onShowCustomWidget, @@ -754,6 +797,7 @@ class MockAndroidWebViewController extends _i1.Mock returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future setOnConsoleMessage( void Function(_i3.JavaScriptConsoleMessage)? onConsoleMessage) => @@ -765,6 +809,7 @@ class MockAndroidWebViewController extends _i1.Mock returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future getUserAgent() => (super.noSuchMethod( Invocation.method( @@ -793,6 +838,7 @@ class MockAndroidWebViewProxy extends _i1.Mock Invocation.getter(#createAndroidWebView), ), ) as _i2.WebView Function()); + @override _i2.WebChromeClient Function({ void Function( @@ -921,6 +967,7 @@ class MockAndroidWebViewProxy extends _i1.Mock _i2.FileChooserParams, )? onShowFileChooser, })); + @override _i2.WebViewClient Function({ void Function( @@ -1067,6 +1114,7 @@ class MockAndroidWebViewProxy extends _i1.Mock String, )? urlLoading, })); + @override _i2.FlutterAssetManager Function() get createFlutterAssetManager => (super.noSuchMethod( @@ -1080,6 +1128,7 @@ class MockAndroidWebViewProxy extends _i1.Mock Invocation.getter(#createFlutterAssetManager), ), ) as _i2.FlutterAssetManager Function()); + @override _i2.JavaScriptChannel Function( String, { @@ -1106,6 +1155,7 @@ class MockAndroidWebViewProxy extends _i1.Mock String, { required void Function(String) postMessage, })); + @override _i2.DownloadListener Function( {required void Function( @@ -1148,6 +1198,7 @@ class MockAndroidWebViewProxy extends _i1.Mock String, int, ) onDownloadStart})); + @override _i9.Future setWebContentsDebuggingEnabled(bool? enabled) => (super.noSuchMethod( @@ -1178,6 +1229,7 @@ class MockAndroidWebViewWidgetCreationParams extends _i1.Mock Invocation.getter(#instanceManager), ), ) as _i5.InstanceManager); + @override _i6.PlatformViewsServiceProxy get platformViewsServiceProxy => (super.noSuchMethod( @@ -1191,12 +1243,14 @@ class MockAndroidWebViewWidgetCreationParams extends _i1.Mock Invocation.getter(#platformViewsServiceProxy), ), ) as _i6.PlatformViewsServiceProxy); + @override bool get displayWithHybridComposition => (super.noSuchMethod( Invocation.getter(#displayWithHybridComposition), returnValue: false, returnValueForMissingStub: false, ) as bool); + @override _i3.PlatformWebViewController get controller => (super.noSuchMethod( Invocation.getter(#controller), @@ -1209,12 +1263,14 @@ class MockAndroidWebViewWidgetCreationParams extends _i1.Mock Invocation.getter(#controller), ), ) as _i3.PlatformWebViewController); + @override _i4.TextDirection get layoutDirection => (super.noSuchMethod( Invocation.getter(#layoutDirection), returnValue: _i4.TextDirection.rtl, returnValueForMissingStub: _i4.TextDirection.rtl, ) as _i4.TextDirection); + @override Set<_i11.Factory<_i12.OneSequenceGestureRecognizer>> get gestureRecognizers => (super.noSuchMethod( @@ -1236,18 +1292,21 @@ class MockExpensiveAndroidViewController extends _i1.Mock returnValue: false, returnValueForMissingStub: false, ) as bool); + @override int get viewId => (super.noSuchMethod( Invocation.getter(#viewId), returnValue: 0, returnValueForMissingStub: 0, ) as int); + @override bool get awaitingCreation => (super.noSuchMethod( Invocation.getter(#awaitingCreation), returnValue: false, returnValueForMissingStub: false, ) as bool); + @override _i7.PointTransformer get pointTransformer => (super.noSuchMethod( Invocation.getter(#pointTransformer), @@ -1260,6 +1319,7 @@ class MockExpensiveAndroidViewController extends _i1.Mock Invocation.getter(#pointTransformer), ), ) as _i7.PointTransformer); + @override set pointTransformer(_i7.PointTransformer? transformer) => super.noSuchMethod( Invocation.setter( @@ -1268,12 +1328,14 @@ class MockExpensiveAndroidViewController extends _i1.Mock ), returnValueForMissingStub: null, ); + @override bool get isCreated => (super.noSuchMethod( Invocation.getter(#isCreated), returnValue: false, returnValueForMissingStub: false, ) as bool); + @override List<_i7.PlatformViewCreatedCallback> get createdCallbacks => (super.noSuchMethod( @@ -1281,6 +1343,7 @@ class MockExpensiveAndroidViewController extends _i1.Mock returnValue: <_i7.PlatformViewCreatedCallback>[], returnValueForMissingStub: <_i7.PlatformViewCreatedCallback>[], ) as List<_i7.PlatformViewCreatedCallback>); + @override _i9.Future setOffset(_i4.Offset? off) => (super.noSuchMethod( Invocation.method( @@ -1290,6 +1353,7 @@ class MockExpensiveAndroidViewController extends _i1.Mock returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future create({ _i4.Size? size, @@ -1307,6 +1371,7 @@ class MockExpensiveAndroidViewController extends _i1.Mock returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future<_i4.Size> setSize(_i4.Size? size) => (super.noSuchMethod( Invocation.method( @@ -1328,6 +1393,7 @@ class MockExpensiveAndroidViewController extends _i1.Mock ), )), ) as _i9.Future<_i4.Size>); + @override _i9.Future sendMotionEvent(_i7.AndroidMotionEvent? event) => (super.noSuchMethod( @@ -1338,6 +1404,7 @@ class MockExpensiveAndroidViewController extends _i1.Mock returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override void addOnPlatformViewCreatedListener( _i7.PlatformViewCreatedCallback? listener) => @@ -1348,6 +1415,7 @@ class MockExpensiveAndroidViewController extends _i1.Mock ), returnValueForMissingStub: null, ); + @override void removeOnPlatformViewCreatedListener( _i7.PlatformViewCreatedCallback? listener) => @@ -1358,6 +1426,7 @@ class MockExpensiveAndroidViewController extends _i1.Mock ), returnValueForMissingStub: null, ); + @override _i9.Future setLayoutDirection(_i4.TextDirection? layoutDirection) => (super.noSuchMethod( @@ -1368,6 +1437,7 @@ class MockExpensiveAndroidViewController extends _i1.Mock returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future dispatchPointerEvent(_i12.PointerEvent? event) => (super.noSuchMethod( @@ -1378,6 +1448,7 @@ class MockExpensiveAndroidViewController extends _i1.Mock returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future clearFocus() => (super.noSuchMethod( Invocation.method( @@ -1387,6 +1458,7 @@ class MockExpensiveAndroidViewController extends _i1.Mock returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future dispose() => (super.noSuchMethod( Invocation.method( @@ -1412,6 +1484,7 @@ class MockFlutterAssetManager extends _i1.Mock returnValue: _i9.Future>.value([]), returnValueForMissingStub: _i9.Future>.value([]), ) as _i9.Future>); + @override _i9.Future getAssetFilePathByName(String? name) => (super.noSuchMethod( @@ -1434,12 +1507,14 @@ class MockJavaScriptChannel extends _i1.Mock implements _i2.JavaScriptChannel { returnValue: '', returnValueForMissingStub: '', ) as String); + @override void Function(String) get postMessage => (super.noSuchMethod( Invocation.getter(#postMessage), returnValue: (String message) {}, returnValueForMissingStub: (String message) {}, ) as void Function(String)); + @override _i2.JavaScriptChannel copy() => (super.noSuchMethod( Invocation.method( @@ -1473,6 +1548,7 @@ class MockPermissionRequest extends _i1.Mock implements _i2.PermissionRequest { returnValue: [], returnValueForMissingStub: [], ) as List); + @override _i9.Future grant(List? resources) => (super.noSuchMethod( Invocation.method( @@ -1482,6 +1558,7 @@ class MockPermissionRequest extends _i1.Mock implements _i2.PermissionRequest { returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future deny() => (super.noSuchMethod( Invocation.method( @@ -1491,6 +1568,7 @@ class MockPermissionRequest extends _i1.Mock implements _i2.PermissionRequest { returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i2.PermissionRequest copy() => (super.noSuchMethod( Invocation.method( @@ -1573,6 +1651,7 @@ class MockPlatformViewsServiceProxy extends _i1.Mock ), ), ) as _i7.ExpensiveAndroidViewController); + @override _i7.SurfaceAndroidViewController initSurfaceAndroidView({ required int? id, @@ -1639,18 +1718,21 @@ class MockSurfaceAndroidViewController extends _i1.Mock returnValue: false, returnValueForMissingStub: false, ) as bool); + @override int get viewId => (super.noSuchMethod( Invocation.getter(#viewId), returnValue: 0, returnValueForMissingStub: 0, ) as int); + @override bool get awaitingCreation => (super.noSuchMethod( Invocation.getter(#awaitingCreation), returnValue: false, returnValueForMissingStub: false, ) as bool); + @override _i7.PointTransformer get pointTransformer => (super.noSuchMethod( Invocation.getter(#pointTransformer), @@ -1663,6 +1745,7 @@ class MockSurfaceAndroidViewController extends _i1.Mock Invocation.getter(#pointTransformer), ), ) as _i7.PointTransformer); + @override set pointTransformer(_i7.PointTransformer? transformer) => super.noSuchMethod( Invocation.setter( @@ -1671,12 +1754,14 @@ class MockSurfaceAndroidViewController extends _i1.Mock ), returnValueForMissingStub: null, ); + @override bool get isCreated => (super.noSuchMethod( Invocation.getter(#isCreated), returnValue: false, returnValueForMissingStub: false, ) as bool); + @override List<_i7.PlatformViewCreatedCallback> get createdCallbacks => (super.noSuchMethod( @@ -1684,6 +1769,7 @@ class MockSurfaceAndroidViewController extends _i1.Mock returnValue: <_i7.PlatformViewCreatedCallback>[], returnValueForMissingStub: <_i7.PlatformViewCreatedCallback>[], ) as List<_i7.PlatformViewCreatedCallback>); + @override _i9.Future setOffset(_i4.Offset? off) => (super.noSuchMethod( Invocation.method( @@ -1693,6 +1779,7 @@ class MockSurfaceAndroidViewController extends _i1.Mock returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future create({ _i4.Size? size, @@ -1710,6 +1797,7 @@ class MockSurfaceAndroidViewController extends _i1.Mock returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future<_i4.Size> setSize(_i4.Size? size) => (super.noSuchMethod( Invocation.method( @@ -1731,6 +1819,7 @@ class MockSurfaceAndroidViewController extends _i1.Mock ), )), ) as _i9.Future<_i4.Size>); + @override _i9.Future sendMotionEvent(_i7.AndroidMotionEvent? event) => (super.noSuchMethod( @@ -1741,6 +1830,7 @@ class MockSurfaceAndroidViewController extends _i1.Mock returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override void addOnPlatformViewCreatedListener( _i7.PlatformViewCreatedCallback? listener) => @@ -1751,6 +1841,7 @@ class MockSurfaceAndroidViewController extends _i1.Mock ), returnValueForMissingStub: null, ); + @override void removeOnPlatformViewCreatedListener( _i7.PlatformViewCreatedCallback? listener) => @@ -1761,6 +1852,7 @@ class MockSurfaceAndroidViewController extends _i1.Mock ), returnValueForMissingStub: null, ); + @override _i9.Future setLayoutDirection(_i4.TextDirection? layoutDirection) => (super.noSuchMethod( @@ -1771,6 +1863,7 @@ class MockSurfaceAndroidViewController extends _i1.Mock returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future dispatchPointerEvent(_i12.PointerEvent? event) => (super.noSuchMethod( @@ -1781,6 +1874,7 @@ class MockSurfaceAndroidViewController extends _i1.Mock returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future clearFocus() => (super.noSuchMethod( Invocation.method( @@ -1790,6 +1884,7 @@ class MockSurfaceAndroidViewController extends _i1.Mock returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future dispose() => (super.noSuchMethod( Invocation.method( @@ -1815,6 +1910,7 @@ class MockWebChromeClient extends _i1.Mock implements _i2.WebChromeClient { returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future setSynchronousReturnValueForOnConsoleMessage(bool? value) => (super.noSuchMethod( @@ -1825,6 +1921,7 @@ class MockWebChromeClient extends _i1.Mock implements _i2.WebChromeClient { returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i2.WebChromeClient copy() => (super.noSuchMethod( Invocation.method( @@ -1861,6 +1958,7 @@ class MockWebSettings extends _i1.Mock implements _i2.WebSettings { returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future setJavaScriptCanOpenWindowsAutomatically(bool? flag) => (super.noSuchMethod( @@ -1871,6 +1969,7 @@ class MockWebSettings extends _i1.Mock implements _i2.WebSettings { returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future setSupportMultipleWindows(bool? support) => (super.noSuchMethod( @@ -1881,6 +1980,7 @@ class MockWebSettings extends _i1.Mock implements _i2.WebSettings { returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future setJavaScriptEnabled(bool? flag) => (super.noSuchMethod( Invocation.method( @@ -1890,6 +1990,7 @@ class MockWebSettings extends _i1.Mock implements _i2.WebSettings { returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future setUserAgentString(String? userAgentString) => (super.noSuchMethod( @@ -1900,6 +2001,7 @@ class MockWebSettings extends _i1.Mock implements _i2.WebSettings { returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future setMediaPlaybackRequiresUserGesture(bool? require) => (super.noSuchMethod( @@ -1910,6 +2012,7 @@ class MockWebSettings extends _i1.Mock implements _i2.WebSettings { returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future setSupportZoom(bool? support) => (super.noSuchMethod( Invocation.method( @@ -1919,6 +2022,7 @@ class MockWebSettings extends _i1.Mock implements _i2.WebSettings { returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future setLoadWithOverviewMode(bool? overview) => (super.noSuchMethod( @@ -1929,6 +2033,7 @@ class MockWebSettings extends _i1.Mock implements _i2.WebSettings { returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future setUseWideViewPort(bool? use) => (super.noSuchMethod( Invocation.method( @@ -1938,6 +2043,7 @@ class MockWebSettings extends _i1.Mock implements _i2.WebSettings { returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future setDisplayZoomControls(bool? enabled) => (super.noSuchMethod( Invocation.method( @@ -1947,6 +2053,7 @@ class MockWebSettings extends _i1.Mock implements _i2.WebSettings { returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future setBuiltInZoomControls(bool? enabled) => (super.noSuchMethod( Invocation.method( @@ -1956,6 +2063,7 @@ class MockWebSettings extends _i1.Mock implements _i2.WebSettings { returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future setAllowFileAccess(bool? enabled) => (super.noSuchMethod( Invocation.method( @@ -1965,6 +2073,7 @@ class MockWebSettings extends _i1.Mock implements _i2.WebSettings { returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future setTextZoom(int? textZoom) => (super.noSuchMethod( Invocation.method( @@ -1974,6 +2083,17 @@ class MockWebSettings extends _i1.Mock implements _i2.WebSettings { returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + + @override + _i9.Future getUserAgentString() => (super.noSuchMethod( + Invocation.method( + #getUserAgentString, + [], + ), + returnValue: _i9.Future.value(''), + returnValueForMissingStub: _i9.Future.value(''), + ) as _i9.Future); + @override _i2.WebSettings copy() => (super.noSuchMethod( Invocation.method( @@ -2013,6 +2133,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { Invocation.getter(#settings), ), ) as _i2.WebSettings); + @override _i9.Future loadData({ required String? data, @@ -2032,6 +2153,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future loadDataWithBaseUrl({ String? baseUrl, @@ -2055,6 +2177,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future loadUrl( String? url, @@ -2071,6 +2194,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future postUrl( String? url, @@ -2087,6 +2211,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future getUrl() => (super.noSuchMethod( Invocation.method( @@ -2096,6 +2221,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future canGoBack() => (super.noSuchMethod( Invocation.method( @@ -2105,6 +2231,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { returnValue: _i9.Future.value(false), returnValueForMissingStub: _i9.Future.value(false), ) as _i9.Future); + @override _i9.Future canGoForward() => (super.noSuchMethod( Invocation.method( @@ -2114,6 +2241,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { returnValue: _i9.Future.value(false), returnValueForMissingStub: _i9.Future.value(false), ) as _i9.Future); + @override _i9.Future goBack() => (super.noSuchMethod( Invocation.method( @@ -2123,6 +2251,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future goForward() => (super.noSuchMethod( Invocation.method( @@ -2132,6 +2261,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future reload() => (super.noSuchMethod( Invocation.method( @@ -2141,6 +2271,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future clearCache(bool? includeDiskFiles) => (super.noSuchMethod( Invocation.method( @@ -2150,6 +2281,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future evaluateJavascript(String? javascriptString) => (super.noSuchMethod( @@ -2160,6 +2292,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future getTitle() => (super.noSuchMethod( Invocation.method( @@ -2169,6 +2302,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future scrollTo( int? x, @@ -2185,6 +2319,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future scrollBy( int? x, @@ -2201,6 +2336,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future getScrollX() => (super.noSuchMethod( Invocation.method( @@ -2210,6 +2346,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { returnValue: _i9.Future.value(0), returnValueForMissingStub: _i9.Future.value(0), ) as _i9.Future); + @override _i9.Future getScrollY() => (super.noSuchMethod( Invocation.method( @@ -2219,6 +2356,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { returnValue: _i9.Future.value(0), returnValueForMissingStub: _i9.Future.value(0), ) as _i9.Future); + @override _i9.Future<_i4.Offset> getScrollPosition() => (super.noSuchMethod( Invocation.method( @@ -2240,6 +2378,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { ), )), ) as _i9.Future<_i4.Offset>); + @override _i9.Future setWebViewClient(_i2.WebViewClient? webViewClient) => (super.noSuchMethod( @@ -2250,6 +2389,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future addJavaScriptChannel( _i2.JavaScriptChannel? javaScriptChannel) => @@ -2261,6 +2401,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future removeJavaScriptChannel( _i2.JavaScriptChannel? javaScriptChannel) => @@ -2272,6 +2413,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future setDownloadListener(_i2.DownloadListener? listener) => (super.noSuchMethod( @@ -2282,6 +2424,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future setWebChromeClient(_i2.WebChromeClient? client) => (super.noSuchMethod( @@ -2292,6 +2435,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future setBackgroundColor(_i4.Color? color) => (super.noSuchMethod( Invocation.method( @@ -2301,6 +2445,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i2.WebView copy() => (super.noSuchMethod( Invocation.method( @@ -2339,6 +2484,7 @@ class MockWebViewClient extends _i1.Mock implements _i2.WebViewClient { returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i2.WebViewClient copy() => (super.noSuchMethod( Invocation.method( @@ -2375,6 +2521,7 @@ class MockWebStorage extends _i1.Mock implements _i2.WebStorage { returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i2.WebStorage copy() => (super.noSuchMethod( Invocation.method( @@ -2408,6 +2555,7 @@ class MockInstanceManager extends _i1.Mock implements _i5.InstanceManager { returnValue: (int __p0) {}, returnValueForMissingStub: (int __p0) {}, ) as void Function(int)); + @override set onWeakReferenceRemoved(void Function(int)? _onWeakReferenceRemoved) => super.noSuchMethod( @@ -2417,6 +2565,7 @@ class MockInstanceManager extends _i1.Mock implements _i5.InstanceManager { ), returnValueForMissingStub: null, ); + @override int addDartCreatedInstance(_i5.Copyable? instance) => (super.noSuchMethod( Invocation.method( @@ -2426,6 +2575,7 @@ class MockInstanceManager extends _i1.Mock implements _i5.InstanceManager { returnValue: 0, returnValueForMissingStub: 0, ) as int); + @override int? removeWeakReference(_i5.Copyable? instance) => (super.noSuchMethod( Invocation.method( @@ -2434,6 +2584,7 @@ class MockInstanceManager extends _i1.Mock implements _i5.InstanceManager { ), returnValueForMissingStub: null, ) as int?); + @override T? remove(int? identifier) => (super.noSuchMethod( Invocation.method( @@ -2442,6 +2593,7 @@ class MockInstanceManager extends _i1.Mock implements _i5.InstanceManager { ), returnValueForMissingStub: null, ) as T?); + @override T? getInstanceWithWeakReference(int? identifier) => (super.noSuchMethod( @@ -2451,6 +2603,7 @@ class MockInstanceManager extends _i1.Mock implements _i5.InstanceManager { ), returnValueForMissingStub: null, ) as T?); + @override int? getIdentifier(_i5.Copyable? instance) => (super.noSuchMethod( Invocation.method( @@ -2459,6 +2612,7 @@ class MockInstanceManager extends _i1.Mock implements _i5.InstanceManager { ), returnValueForMissingStub: null, ) as int?); + @override void addHostCreatedInstance( _i5.Copyable? instance, @@ -2474,6 +2628,7 @@ class MockInstanceManager extends _i1.Mock implements _i5.InstanceManager { ), returnValueForMissingStub: null, ); + @override bool containsIdentifier(int? identifier) => (super.noSuchMethod( Invocation.method( diff --git a/packages/webview_flutter/webview_flutter_android/test/android_webview_cookie_manager_test.mocks.dart b/packages/webview_flutter/webview_flutter_android/test/android_webview_cookie_manager_test.mocks.dart index 5213793ee9e9..cc9fbfae2a33 100644 --- a/packages/webview_flutter/webview_flutter_android/test/android_webview_cookie_manager_test.mocks.dart +++ b/packages/webview_flutter/webview_flutter_android/test/android_webview_cookie_manager_test.mocks.dart @@ -93,6 +93,7 @@ class MockCookieManager extends _i1.Mock implements _i2.CookieManager { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future removeAllCookies() => (super.noSuchMethod( Invocation.method( @@ -101,6 +102,7 @@ class MockCookieManager extends _i1.Mock implements _i2.CookieManager { ), returnValue: _i5.Future.value(false), ) as _i5.Future); + @override _i5.Future setAcceptThirdPartyCookies( _i2.WebView? webView, @@ -117,6 +119,7 @@ class MockCookieManager extends _i1.Mock implements _i2.CookieManager { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i2.CookieManager copy() => (super.noSuchMethod( Invocation.method( @@ -147,6 +150,7 @@ class MockAndroidWebViewController extends _i1.Mock Invocation.getter(#webViewIdentifier), returnValue: 0, ) as int); + @override _i3.PlatformWebViewControllerCreationParams get params => (super.noSuchMethod( Invocation.getter(#params), @@ -155,6 +159,7 @@ class MockAndroidWebViewController extends _i1.Mock Invocation.getter(#params), ), ) as _i3.PlatformWebViewControllerCreationParams); + @override _i5.Future loadFile(String? absoluteFilePath) => (super.noSuchMethod( Invocation.method( @@ -164,6 +169,7 @@ class MockAndroidWebViewController extends _i1.Mock returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future loadFlutterAsset(String? key) => (super.noSuchMethod( Invocation.method( @@ -173,6 +179,7 @@ class MockAndroidWebViewController extends _i1.Mock returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future loadHtmlString( String? html, { @@ -187,6 +194,7 @@ class MockAndroidWebViewController extends _i1.Mock returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future loadRequest(_i3.LoadRequestParams? params) => (super.noSuchMethod( @@ -197,6 +205,7 @@ class MockAndroidWebViewController extends _i1.Mock returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future currentUrl() => (super.noSuchMethod( Invocation.method( @@ -205,6 +214,7 @@ class MockAndroidWebViewController extends _i1.Mock ), returnValue: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future canGoBack() => (super.noSuchMethod( Invocation.method( @@ -213,6 +223,7 @@ class MockAndroidWebViewController extends _i1.Mock ), returnValue: _i5.Future.value(false), ) as _i5.Future); + @override _i5.Future canGoForward() => (super.noSuchMethod( Invocation.method( @@ -221,6 +232,7 @@ class MockAndroidWebViewController extends _i1.Mock ), returnValue: _i5.Future.value(false), ) as _i5.Future); + @override _i5.Future goBack() => (super.noSuchMethod( Invocation.method( @@ -230,6 +242,7 @@ class MockAndroidWebViewController extends _i1.Mock returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future goForward() => (super.noSuchMethod( Invocation.method( @@ -239,6 +252,7 @@ class MockAndroidWebViewController extends _i1.Mock returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future reload() => (super.noSuchMethod( Invocation.method( @@ -248,6 +262,7 @@ class MockAndroidWebViewController extends _i1.Mock returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future clearCache() => (super.noSuchMethod( Invocation.method( @@ -257,6 +272,7 @@ class MockAndroidWebViewController extends _i1.Mock returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future clearLocalStorage() => (super.noSuchMethod( Invocation.method( @@ -266,6 +282,7 @@ class MockAndroidWebViewController extends _i1.Mock returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future setPlatformNavigationDelegate( _i3.PlatformNavigationDelegate? handler) => @@ -277,6 +294,7 @@ class MockAndroidWebViewController extends _i1.Mock returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future runJavaScript(String? javaScript) => (super.noSuchMethod( Invocation.method( @@ -286,6 +304,7 @@ class MockAndroidWebViewController extends _i1.Mock returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future runJavaScriptReturningResult(String? javaScript) => (super.noSuchMethod( @@ -301,6 +320,7 @@ class MockAndroidWebViewController extends _i1.Mock ), )), ) as _i5.Future); + @override _i5.Future addJavaScriptChannel( _i3.JavaScriptChannelParams? javaScriptChannelParams) => @@ -312,6 +332,7 @@ class MockAndroidWebViewController extends _i1.Mock returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future removeJavaScriptChannel(String? javaScriptChannelName) => (super.noSuchMethod( @@ -322,6 +343,7 @@ class MockAndroidWebViewController extends _i1.Mock returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future getTitle() => (super.noSuchMethod( Invocation.method( @@ -330,6 +352,7 @@ class MockAndroidWebViewController extends _i1.Mock ), returnValue: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future scrollTo( int? x, @@ -346,6 +369,7 @@ class MockAndroidWebViewController extends _i1.Mock returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future scrollBy( int? x, @@ -362,6 +386,7 @@ class MockAndroidWebViewController extends _i1.Mock returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future<_i4.Offset> getScrollPosition() => (super.noSuchMethod( Invocation.method( @@ -376,6 +401,7 @@ class MockAndroidWebViewController extends _i1.Mock ), )), ) as _i5.Future<_i4.Offset>); + @override _i5.Future enableZoom(bool? enabled) => (super.noSuchMethod( Invocation.method( @@ -385,6 +411,7 @@ class MockAndroidWebViewController extends _i1.Mock returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future setBackgroundColor(_i4.Color? color) => (super.noSuchMethod( Invocation.method( @@ -394,6 +421,7 @@ class MockAndroidWebViewController extends _i1.Mock returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future setJavaScriptMode(_i3.JavaScriptMode? javaScriptMode) => (super.noSuchMethod( @@ -404,6 +432,7 @@ class MockAndroidWebViewController extends _i1.Mock returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future setUserAgent(String? userAgent) => (super.noSuchMethod( Invocation.method( @@ -413,6 +442,7 @@ class MockAndroidWebViewController extends _i1.Mock returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future setMediaPlaybackRequiresUserGesture(bool? require) => (super.noSuchMethod( @@ -423,6 +453,7 @@ class MockAndroidWebViewController extends _i1.Mock returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future setTextZoom(int? textZoom) => (super.noSuchMethod( Invocation.method( @@ -432,6 +463,7 @@ class MockAndroidWebViewController extends _i1.Mock returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future setOnShowFileSelector( _i5.Future> Function(_i6.FileSelectorParams)? @@ -444,6 +476,7 @@ class MockAndroidWebViewController extends _i1.Mock returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future setOnPlatformPermissionRequest( void Function(_i3.PlatformWebViewPermissionRequest)? @@ -456,6 +489,7 @@ class MockAndroidWebViewController extends _i1.Mock returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future setGeolocationPermissionsPromptCallbacks({ _i6.OnGeolocationPermissionsShowPrompt? onShowPrompt, @@ -473,6 +507,7 @@ class MockAndroidWebViewController extends _i1.Mock returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future setCustomWidgetCallbacks({ required _i6.OnShowCustomWidgetCallback? onShowCustomWidget, @@ -490,6 +525,7 @@ class MockAndroidWebViewController extends _i1.Mock returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future setOnConsoleMessage( void Function(_i3.JavaScriptConsoleMessage)? onConsoleMessage) => @@ -501,6 +537,7 @@ class MockAndroidWebViewController extends _i1.Mock returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future getUserAgent() => (super.noSuchMethod( Invocation.method( diff --git a/packages/webview_flutter/webview_flutter_android/test/android_webview_test.dart b/packages/webview_flutter/webview_flutter_android/test/android_webview_test.dart index 2629d5665a2d..d542c498772c 100644 --- a/packages/webview_flutter/webview_flutter_android/test/android_webview_test.dart +++ b/packages/webview_flutter/webview_flutter_android/test/android_webview_test.dart @@ -528,6 +528,13 @@ void main() { 100, )); }); + + test('getUserAgentString', () async { + const String userAgent = 'str'; + when(mockPlatformHostApi.getUserAgentString(webSettingsInstanceId)) + .thenReturn(userAgent); + expect(await webSettings.getUserAgentString(), userAgent); + }); }); group('JavaScriptChannel', () { diff --git a/packages/webview_flutter/webview_flutter_android/test/android_webview_test.mocks.dart b/packages/webview_flutter/webview_flutter_android/test/android_webview_test.mocks.dart index 717cc14b7bd2..0928486956d9 100644 --- a/packages/webview_flutter/webview_flutter_android/test/android_webview_test.mocks.dart +++ b/packages/webview_flutter/webview_flutter_android/test/android_webview_test.mocks.dart @@ -128,6 +128,7 @@ class MockCookieManagerHostApi extends _i1.Mock returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future setCookie( int? arg_identifier, @@ -146,6 +147,7 @@ class MockCookieManagerHostApi extends _i1.Mock returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future removeAllCookies(int? arg_identifier) => (super.noSuchMethod( Invocation.method( @@ -154,6 +156,7 @@ class MockCookieManagerHostApi extends _i1.Mock ), returnValue: _i5.Future.value(false), ) as _i5.Future); + @override _i5.Future setAcceptThirdPartyCookies( int? arg_identifier, @@ -205,6 +208,7 @@ class MockDownloadListener extends _i1.Mock implements _i2.DownloadListener { String, int, )); + @override _i2.DownloadListener copy() => (super.noSuchMethod( Invocation.method( @@ -234,11 +238,13 @@ class MockJavaScriptChannel extends _i1.Mock implements _i2.JavaScriptChannel { Invocation.getter(#channelName), returnValue: '', ) as String); + @override void Function(String) get postMessage => (super.noSuchMethod( Invocation.getter(#postMessage), returnValue: (String message) {}, ) as void Function(String)); + @override _i2.JavaScriptChannel copy() => (super.noSuchMethod( Invocation.method( @@ -272,6 +278,7 @@ class MockTestCookieManagerHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); + @override void setCookie( int? identifier, @@ -289,6 +296,7 @@ class MockTestCookieManagerHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); + @override _i5.Future removeAllCookies(int? identifier) => (super.noSuchMethod( Invocation.method( @@ -297,6 +305,7 @@ class MockTestCookieManagerHostApi extends _i1.Mock ), returnValue: _i5.Future.value(false), ) as _i5.Future); + @override void setAcceptThirdPartyCookies( int? identifier, @@ -465,6 +474,7 @@ class MockTestWebChromeClientHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); + @override void setSynchronousReturnValueForOnShowFileChooser( int? instanceId, @@ -480,6 +490,7 @@ class MockTestWebChromeClientHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); + @override void setSynchronousReturnValueForOnConsoleMessage( int? instanceId, @@ -521,6 +532,7 @@ class MockTestWebSettingsHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); + @override void setDomStorageEnabled( int? instanceId, @@ -536,6 +548,7 @@ class MockTestWebSettingsHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); + @override void setJavaScriptCanOpenWindowsAutomatically( int? instanceId, @@ -551,6 +564,7 @@ class MockTestWebSettingsHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); + @override void setSupportMultipleWindows( int? instanceId, @@ -566,6 +580,7 @@ class MockTestWebSettingsHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); + @override void setJavaScriptEnabled( int? instanceId, @@ -581,6 +596,7 @@ class MockTestWebSettingsHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); + @override void setUserAgentString( int? instanceId, @@ -596,6 +612,7 @@ class MockTestWebSettingsHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); + @override void setMediaPlaybackRequiresUserGesture( int? instanceId, @@ -611,6 +628,7 @@ class MockTestWebSettingsHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); + @override void setSupportZoom( int? instanceId, @@ -626,6 +644,7 @@ class MockTestWebSettingsHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); + @override void setLoadWithOverviewMode( int? instanceId, @@ -641,6 +660,7 @@ class MockTestWebSettingsHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); + @override void setUseWideViewPort( int? instanceId, @@ -656,6 +676,7 @@ class MockTestWebSettingsHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); + @override void setDisplayZoomControls( int? instanceId, @@ -671,6 +692,7 @@ class MockTestWebSettingsHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); + @override void setBuiltInZoomControls( int? instanceId, @@ -686,6 +708,7 @@ class MockTestWebSettingsHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); + @override void setAllowFileAccess( int? instanceId, @@ -701,6 +724,7 @@ class MockTestWebSettingsHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); + @override void setTextZoom( int? instanceId, @@ -716,6 +740,15 @@ class MockTestWebSettingsHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); + + @override + String getUserAgentString(int? instanceId) => (super.noSuchMethod( + Invocation.method( + #getUserAgentString, + [instanceId], + ), + returnValue: '', + ) as String); } /// A class which mocks [TestWebStorageHostApi]. @@ -735,6 +768,7 @@ class MockTestWebStorageHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); + @override void deleteAllData(int? instanceId) => super.noSuchMethod( Invocation.method( @@ -762,6 +796,7 @@ class MockTestWebViewClientHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); + @override void setSynchronousReturnValueForShouldOverrideUrlLoading( int? instanceId, @@ -796,6 +831,7 @@ class MockTestWebViewHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); + @override void loadData( int? instanceId, @@ -815,6 +851,7 @@ class MockTestWebViewHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); + @override void loadDataWithBaseUrl( int? instanceId, @@ -838,6 +875,7 @@ class MockTestWebViewHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); + @override void loadUrl( int? instanceId, @@ -855,6 +893,7 @@ class MockTestWebViewHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); + @override void postUrl( int? instanceId, @@ -872,11 +911,13 @@ class MockTestWebViewHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); + @override String? getUrl(int? instanceId) => (super.noSuchMethod(Invocation.method( #getUrl, [instanceId], )) as String?); + @override bool canGoBack(int? instanceId) => (super.noSuchMethod( Invocation.method( @@ -885,6 +926,7 @@ class MockTestWebViewHostApi extends _i1.Mock ), returnValue: false, ) as bool); + @override bool canGoForward(int? instanceId) => (super.noSuchMethod( Invocation.method( @@ -893,6 +935,7 @@ class MockTestWebViewHostApi extends _i1.Mock ), returnValue: false, ) as bool); + @override void goBack(int? instanceId) => super.noSuchMethod( Invocation.method( @@ -901,6 +944,7 @@ class MockTestWebViewHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); + @override void goForward(int? instanceId) => super.noSuchMethod( Invocation.method( @@ -909,6 +953,7 @@ class MockTestWebViewHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); + @override void reload(int? instanceId) => super.noSuchMethod( Invocation.method( @@ -917,6 +962,7 @@ class MockTestWebViewHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); + @override void clearCache( int? instanceId, @@ -932,6 +978,7 @@ class MockTestWebViewHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); + @override _i5.Future evaluateJavascript( int? instanceId, @@ -947,11 +994,13 @@ class MockTestWebViewHostApi extends _i1.Mock ), returnValue: _i5.Future.value(), ) as _i5.Future); + @override String? getTitle(int? instanceId) => (super.noSuchMethod(Invocation.method( #getTitle, [instanceId], )) as String?); + @override void scrollTo( int? instanceId, @@ -969,6 +1018,7 @@ class MockTestWebViewHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); + @override void scrollBy( int? instanceId, @@ -986,6 +1036,7 @@ class MockTestWebViewHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); + @override int getScrollX(int? instanceId) => (super.noSuchMethod( Invocation.method( @@ -994,6 +1045,7 @@ class MockTestWebViewHostApi extends _i1.Mock ), returnValue: 0, ) as int); + @override int getScrollY(int? instanceId) => (super.noSuchMethod( Invocation.method( @@ -1002,6 +1054,7 @@ class MockTestWebViewHostApi extends _i1.Mock ), returnValue: 0, ) as int); + @override _i3.WebViewPoint getScrollPosition(int? instanceId) => (super.noSuchMethod( Invocation.method( @@ -1016,6 +1069,7 @@ class MockTestWebViewHostApi extends _i1.Mock ), ), ) as _i3.WebViewPoint); + @override void setWebContentsDebuggingEnabled(bool? enabled) => super.noSuchMethod( Invocation.method( @@ -1024,6 +1078,7 @@ class MockTestWebViewHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); + @override void setWebViewClient( int? instanceId, @@ -1039,6 +1094,7 @@ class MockTestWebViewHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); + @override void addJavaScriptChannel( int? instanceId, @@ -1054,6 +1110,7 @@ class MockTestWebViewHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); + @override void removeJavaScriptChannel( int? instanceId, @@ -1069,6 +1126,7 @@ class MockTestWebViewHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); + @override void setDownloadListener( int? instanceId, @@ -1084,6 +1142,7 @@ class MockTestWebViewHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); + @override void setWebChromeClient( int? instanceId, @@ -1099,6 +1158,7 @@ class MockTestWebViewHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); + @override void setBackgroundColor( int? instanceId, @@ -1133,6 +1193,7 @@ class MockTestAssetManagerHostApi extends _i1.Mock ), returnValue: [], ) as List); + @override String getAssetFilePathByName(String? name) => (super.noSuchMethod( Invocation.method( @@ -1167,6 +1228,7 @@ class MockTestPermissionRequestHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); + @override void deny(int? instanceId) => super.noSuchMethod( Invocation.method( @@ -1195,6 +1257,7 @@ class MockWebChromeClient extends _i1.Mock implements _i2.WebChromeClient { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future setSynchronousReturnValueForOnConsoleMessage(bool? value) => (super.noSuchMethod( @@ -1205,6 +1268,7 @@ class MockWebChromeClient extends _i1.Mock implements _i2.WebChromeClient { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i2.WebChromeClient copy() => (super.noSuchMethod( Invocation.method( @@ -1237,6 +1301,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { Invocation.getter(#settings), ), ) as _i2.WebSettings); + @override _i5.Future loadData({ required String? data, @@ -1256,6 +1321,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future loadDataWithBaseUrl({ String? baseUrl, @@ -1279,6 +1345,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future loadUrl( String? url, @@ -1295,6 +1362,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future postUrl( String? url, @@ -1311,6 +1379,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future getUrl() => (super.noSuchMethod( Invocation.method( @@ -1319,6 +1388,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { ), returnValue: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future canGoBack() => (super.noSuchMethod( Invocation.method( @@ -1327,6 +1397,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { ), returnValue: _i5.Future.value(false), ) as _i5.Future); + @override _i5.Future canGoForward() => (super.noSuchMethod( Invocation.method( @@ -1335,6 +1406,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { ), returnValue: _i5.Future.value(false), ) as _i5.Future); + @override _i5.Future goBack() => (super.noSuchMethod( Invocation.method( @@ -1344,6 +1416,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future goForward() => (super.noSuchMethod( Invocation.method( @@ -1353,6 +1426,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future reload() => (super.noSuchMethod( Invocation.method( @@ -1362,6 +1436,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future clearCache(bool? includeDiskFiles) => (super.noSuchMethod( Invocation.method( @@ -1371,6 +1446,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future evaluateJavascript(String? javascriptString) => (super.noSuchMethod( @@ -1380,6 +1456,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { ), returnValue: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future getTitle() => (super.noSuchMethod( Invocation.method( @@ -1388,6 +1465,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { ), returnValue: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future scrollTo( int? x, @@ -1404,6 +1482,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future scrollBy( int? x, @@ -1420,6 +1499,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future getScrollX() => (super.noSuchMethod( Invocation.method( @@ -1428,6 +1508,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { ), returnValue: _i5.Future.value(0), ) as _i5.Future); + @override _i5.Future getScrollY() => (super.noSuchMethod( Invocation.method( @@ -1436,6 +1517,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { ), returnValue: _i5.Future.value(0), ) as _i5.Future); + @override _i5.Future<_i4.Offset> getScrollPosition() => (super.noSuchMethod( Invocation.method( @@ -1450,6 +1532,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { ), )), ) as _i5.Future<_i4.Offset>); + @override _i5.Future setWebViewClient(_i2.WebViewClient? webViewClient) => (super.noSuchMethod( @@ -1460,6 +1543,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future addJavaScriptChannel( _i2.JavaScriptChannel? javaScriptChannel) => @@ -1471,6 +1555,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future removeJavaScriptChannel( _i2.JavaScriptChannel? javaScriptChannel) => @@ -1482,6 +1567,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future setDownloadListener(_i2.DownloadListener? listener) => (super.noSuchMethod( @@ -1492,6 +1578,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future setWebChromeClient(_i2.WebChromeClient? client) => (super.noSuchMethod( @@ -1502,6 +1589,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future setBackgroundColor(_i4.Color? color) => (super.noSuchMethod( Invocation.method( @@ -1511,6 +1599,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i2.WebView copy() => (super.noSuchMethod( Invocation.method( @@ -1546,6 +1635,7 @@ class MockWebViewClient extends _i1.Mock implements _i2.WebViewClient { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i2.WebViewClient copy() => (super.noSuchMethod( Invocation.method( diff --git a/packages/webview_flutter/webview_flutter_android/test/legacy/webview_android_cookie_manager_test.mocks.dart b/packages/webview_flutter/webview_flutter_android/test/legacy/webview_android_cookie_manager_test.mocks.dart index df06f6252274..cb453ddb6b12 100644 --- a/packages/webview_flutter/webview_flutter_android/test/legacy/webview_android_cookie_manager_test.mocks.dart +++ b/packages/webview_flutter/webview_flutter_android/test/legacy/webview_android_cookie_manager_test.mocks.dart @@ -55,6 +55,7 @@ class MockCookieManager extends _i1.Mock implements _i2.CookieManager { returnValue: _i3.Future.value(), returnValueForMissingStub: _i3.Future.value(), ) as _i3.Future); + @override _i3.Future removeAllCookies() => (super.noSuchMethod( Invocation.method( @@ -63,6 +64,7 @@ class MockCookieManager extends _i1.Mock implements _i2.CookieManager { ), returnValue: _i3.Future.value(false), ) as _i3.Future); + @override _i3.Future setAcceptThirdPartyCookies( _i2.WebView? webView, @@ -79,6 +81,7 @@ class MockCookieManager extends _i1.Mock implements _i2.CookieManager { returnValue: _i3.Future.value(), returnValueForMissingStub: _i3.Future.value(), ) as _i3.Future); + @override _i2.CookieManager copy() => (super.noSuchMethod( Invocation.method( diff --git a/packages/webview_flutter/webview_flutter_android/test/legacy/webview_android_widget_test.mocks.dart b/packages/webview_flutter/webview_flutter_android/test/legacy/webview_android_widget_test.mocks.dart index 150ea5a275d5..f83d2eaee747 100644 --- a/packages/webview_flutter/webview_flutter_android/test/legacy/webview_android_widget_test.mocks.dart +++ b/packages/webview_flutter/webview_flutter_android/test/legacy/webview_android_widget_test.mocks.dart @@ -138,6 +138,7 @@ class MockFlutterAssetManager extends _i1.Mock ), returnValue: _i5.Future>.value([]), ) as _i5.Future>); + @override _i5.Future getAssetFilePathByName(String? name) => (super.noSuchMethod( @@ -166,6 +167,7 @@ class MockWebSettings extends _i1.Mock implements _i2.WebSettings { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future setJavaScriptCanOpenWindowsAutomatically(bool? flag) => (super.noSuchMethod( @@ -176,6 +178,7 @@ class MockWebSettings extends _i1.Mock implements _i2.WebSettings { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future setSupportMultipleWindows(bool? support) => (super.noSuchMethod( @@ -186,6 +189,7 @@ class MockWebSettings extends _i1.Mock implements _i2.WebSettings { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future setJavaScriptEnabled(bool? flag) => (super.noSuchMethod( Invocation.method( @@ -195,6 +199,7 @@ class MockWebSettings extends _i1.Mock implements _i2.WebSettings { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future setUserAgentString(String? userAgentString) => (super.noSuchMethod( @@ -205,6 +210,7 @@ class MockWebSettings extends _i1.Mock implements _i2.WebSettings { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future setMediaPlaybackRequiresUserGesture(bool? require) => (super.noSuchMethod( @@ -215,6 +221,7 @@ class MockWebSettings extends _i1.Mock implements _i2.WebSettings { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future setSupportZoom(bool? support) => (super.noSuchMethod( Invocation.method( @@ -224,6 +231,7 @@ class MockWebSettings extends _i1.Mock implements _i2.WebSettings { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future setLoadWithOverviewMode(bool? overview) => (super.noSuchMethod( @@ -234,6 +242,7 @@ class MockWebSettings extends _i1.Mock implements _i2.WebSettings { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future setUseWideViewPort(bool? use) => (super.noSuchMethod( Invocation.method( @@ -243,6 +252,7 @@ class MockWebSettings extends _i1.Mock implements _i2.WebSettings { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future setDisplayZoomControls(bool? enabled) => (super.noSuchMethod( Invocation.method( @@ -252,6 +262,7 @@ class MockWebSettings extends _i1.Mock implements _i2.WebSettings { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future setBuiltInZoomControls(bool? enabled) => (super.noSuchMethod( Invocation.method( @@ -261,6 +272,7 @@ class MockWebSettings extends _i1.Mock implements _i2.WebSettings { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future setAllowFileAccess(bool? enabled) => (super.noSuchMethod( Invocation.method( @@ -270,6 +282,7 @@ class MockWebSettings extends _i1.Mock implements _i2.WebSettings { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future setTextZoom(int? textZoom) => (super.noSuchMethod( Invocation.method( @@ -279,6 +292,16 @@ class MockWebSettings extends _i1.Mock implements _i2.WebSettings { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + + @override + _i5.Future getUserAgentString() => (super.noSuchMethod( + Invocation.method( + #getUserAgentString, + [], + ), + returnValue: _i5.Future.value(''), + ) as _i5.Future); + @override _i2.WebSettings copy() => (super.noSuchMethod( Invocation.method( @@ -312,6 +335,7 @@ class MockWebStorage extends _i1.Mock implements _i2.WebStorage { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i2.WebStorage copy() => (super.noSuchMethod( Invocation.method( @@ -344,6 +368,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { Invocation.getter(#settings), ), ) as _i2.WebSettings); + @override _i5.Future loadData({ required String? data, @@ -363,6 +388,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future loadDataWithBaseUrl({ String? baseUrl, @@ -386,6 +412,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future loadUrl( String? url, @@ -402,6 +429,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future postUrl( String? url, @@ -418,6 +446,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future getUrl() => (super.noSuchMethod( Invocation.method( @@ -426,6 +455,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { ), returnValue: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future canGoBack() => (super.noSuchMethod( Invocation.method( @@ -434,6 +464,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { ), returnValue: _i5.Future.value(false), ) as _i5.Future); + @override _i5.Future canGoForward() => (super.noSuchMethod( Invocation.method( @@ -442,6 +473,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { ), returnValue: _i5.Future.value(false), ) as _i5.Future); + @override _i5.Future goBack() => (super.noSuchMethod( Invocation.method( @@ -451,6 +483,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future goForward() => (super.noSuchMethod( Invocation.method( @@ -460,6 +493,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future reload() => (super.noSuchMethod( Invocation.method( @@ -469,6 +503,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future clearCache(bool? includeDiskFiles) => (super.noSuchMethod( Invocation.method( @@ -478,6 +513,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future evaluateJavascript(String? javascriptString) => (super.noSuchMethod( @@ -487,6 +523,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { ), returnValue: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future getTitle() => (super.noSuchMethod( Invocation.method( @@ -495,6 +532,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { ), returnValue: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future scrollTo( int? x, @@ -511,6 +549,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future scrollBy( int? x, @@ -527,6 +566,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future getScrollX() => (super.noSuchMethod( Invocation.method( @@ -535,6 +575,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { ), returnValue: _i5.Future.value(0), ) as _i5.Future); + @override _i5.Future getScrollY() => (super.noSuchMethod( Invocation.method( @@ -543,6 +584,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { ), returnValue: _i5.Future.value(0), ) as _i5.Future); + @override _i5.Future<_i3.Offset> getScrollPosition() => (super.noSuchMethod( Invocation.method( @@ -557,6 +599,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { ), )), ) as _i5.Future<_i3.Offset>); + @override _i5.Future setWebViewClient(_i2.WebViewClient? webViewClient) => (super.noSuchMethod( @@ -567,6 +610,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future addJavaScriptChannel( _i2.JavaScriptChannel? javaScriptChannel) => @@ -578,6 +622,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future removeJavaScriptChannel( _i2.JavaScriptChannel? javaScriptChannel) => @@ -589,6 +634,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future setDownloadListener(_i2.DownloadListener? listener) => (super.noSuchMethod( @@ -599,6 +645,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future setWebChromeClient(_i2.WebChromeClient? client) => (super.noSuchMethod( @@ -609,6 +656,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future setBackgroundColor(_i3.Color? color) => (super.noSuchMethod( Invocation.method( @@ -618,6 +666,7 @@ class MockWebView extends _i1.Mock implements _i2.WebView { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i2.WebView copy() => (super.noSuchMethod( Invocation.method( @@ -648,21 +697,25 @@ class MockWebResourceRequest extends _i1.Mock Invocation.getter(#url), returnValue: '', ) as String); + @override bool get isForMainFrame => (super.noSuchMethod( Invocation.getter(#isForMainFrame), returnValue: false, ) as bool); + @override bool get hasGesture => (super.noSuchMethod( Invocation.getter(#hasGesture), returnValue: false, ) as bool); + @override String get method => (super.noSuchMethod( Invocation.getter(#method), returnValue: '', ) as String); + @override Map get requestHeaders => (super.noSuchMethod( Invocation.getter(#requestHeaders), @@ -701,6 +754,7 @@ class MockDownloadListener extends _i1.Mock implements _i2.DownloadListener { String, int, )); + @override _i2.DownloadListener copy() => (super.noSuchMethod( Invocation.method( @@ -735,16 +789,19 @@ class MockWebViewAndroidJavaScriptChannel extends _i1.Mock Invocation.getter(#javascriptChannelRegistry), ), ) as _i4.JavascriptChannelRegistry); + @override String get channelName => (super.noSuchMethod( Invocation.getter(#channelName), returnValue: '', ) as String); + @override void Function(String) get postMessage => (super.noSuchMethod( Invocation.getter(#postMessage), returnValue: (String message) {}, ) as void Function(String)); + @override _i2.JavaScriptChannel copy() => (super.noSuchMethod( Invocation.method( @@ -779,6 +836,7 @@ class MockWebChromeClient extends _i1.Mock implements _i2.WebChromeClient { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future setSynchronousReturnValueForOnConsoleMessage(bool? value) => (super.noSuchMethod( @@ -789,6 +847,7 @@ class MockWebChromeClient extends _i1.Mock implements _i2.WebChromeClient { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i2.WebChromeClient copy() => (super.noSuchMethod( Invocation.method( @@ -824,6 +883,7 @@ class MockWebViewClient extends _i1.Mock implements _i2.WebViewClient { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i2.WebViewClient copy() => (super.noSuchMethod( Invocation.method( @@ -854,6 +914,7 @@ class MockJavascriptChannelRegistry extends _i1.Mock Invocation.getter(#channels), returnValue: {}, ) as Map); + @override void onJavascriptChannelMessage( String? channel, @@ -869,6 +930,7 @@ class MockJavascriptChannelRegistry extends _i1.Mock ), returnValueForMissingStub: null, ); + @override void updateJavascriptChannelsFromSet(Set<_i4.JavascriptChannel>? channels) => super.noSuchMethod( @@ -905,6 +967,7 @@ class MockWebViewPlatformCallbacksHandler extends _i1.Mock ), returnValue: _i5.Future.value(false), ) as _i5.FutureOr); + @override void onPageStarted(String? url) => super.noSuchMethod( Invocation.method( @@ -913,6 +976,7 @@ class MockWebViewPlatformCallbacksHandler extends _i1.Mock ), returnValueForMissingStub: null, ); + @override void onPageFinished(String? url) => super.noSuchMethod( Invocation.method( @@ -921,6 +985,7 @@ class MockWebViewPlatformCallbacksHandler extends _i1.Mock ), returnValueForMissingStub: null, ); + @override void onProgress(int? progress) => super.noSuchMethod( Invocation.method( @@ -929,6 +994,7 @@ class MockWebViewPlatformCallbacksHandler extends _i1.Mock ), returnValueForMissingStub: null, ); + @override void onWebResourceError(_i4.WebResourceError? error) => super.noSuchMethod( Invocation.method( @@ -961,6 +1027,7 @@ class MockWebViewProxy extends _i1.Mock implements _i7.WebViewProxy { ), ), ) as _i2.WebView); + @override _i2.WebViewClient createWebViewClient({ void Function( @@ -1020,6 +1087,7 @@ class MockWebViewProxy extends _i1.Mock implements _i7.WebViewProxy { ), ), ) as _i2.WebViewClient); + @override _i5.Future setWebContentsDebuggingEnabled(bool? enabled) => (super.noSuchMethod( diff --git a/packages/webview_flutter/webview_flutter_android/test/test_android_webview.g.dart b/packages/webview_flutter/webview_flutter_android/test/test_android_webview.g.dart index a92c054268b7..9644887711db 100644 --- a/packages/webview_flutter/webview_flutter_android/test/test_android_webview.g.dart +++ b/packages/webview_flutter/webview_flutter_android/test/test_android_webview.g.dart @@ -999,6 +999,8 @@ abstract class TestWebSettingsHostApi { void setTextZoom(int instanceId, int textZoom); + String getUserAgentString(int instanceId); + static void setup(TestWebSettingsHostApi? api, {BinaryMessenger? binaryMessenger}) { { @@ -1365,6 +1367,29 @@ abstract class TestWebSettingsHostApi { }); } } + { + final BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.webview_flutter_android.WebSettingsHostApi.getUserAgentString', + codec, + binaryMessenger: binaryMessenger); + if (api == null) { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); + } else { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.webview_flutter_android.WebSettingsHostApi.getUserAgentString was null.'); + final List args = (message as List?)!; + final int? arg_instanceId = (args[0] as int?); + assert(arg_instanceId != null, + 'Argument for dev.flutter.pigeon.webview_flutter_android.WebSettingsHostApi.getUserAgentString was null, expected non-null int.'); + final String output = api.getUserAgentString(arg_instanceId!); + return [output]; + }); + } + } } } diff --git a/packages/webview_flutter/webview_flutter_wkwebview/CHANGELOG.md b/packages/webview_flutter/webview_flutter_wkwebview/CHANGELOG.md index 5bb9cb3e6d12..0b0101494c28 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/CHANGELOG.md +++ b/packages/webview_flutter/webview_flutter_wkwebview/CHANGELOG.md @@ -1,3 +1,7 @@ +## 3.9.0 + +* Adds support for `PlatformWebViewController.getUserAgent`. + ## 3.8.0 * Adds support to register a callback to receive JavaScript console messages. See `WebKitWebViewController.setOnConsoleMessage`. diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/integration_test/webview_flutter_test.dart b/packages/webview_flutter/webview_flutter_wkwebview/example/integration_test/webview_flutter_test.dart index 24b96d755c44..4c8fd2b30d76 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/integration_test/webview_flutter_test.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/integration_test/webview_flutter_test.dart @@ -292,8 +292,27 @@ Future main() async { }, )); - final String customUserAgent2 = await _getUserAgent(controller); - expect(customUserAgent2, 'Custom_User_Agent1'); + final String? customUserAgent = await controller.getUserAgent(); + expect(customUserAgent, 'Custom_User_Agent1'); + }); + + testWidgets( + 'getUserAgent returns a default value when custom value is not set', + (WidgetTester tester) async { + final PlatformWebViewController controller = PlatformWebViewController( + const PlatformWebViewControllerCreationParams(), + ); + + await tester.pumpWidget(Builder( + builder: (BuildContext context) { + return PlatformWebViewWidget( + PlatformWebViewWidgetCreationParams(controller: controller), + ).build(context); + }, + )); + + final String? userAgent = await controller.getUserAgent(); + expect(userAgent, isNotNull); }); group('Video playback policy', () { @@ -1240,12 +1259,6 @@ Future main() async { }); } -/// Returns the value used for the HTTP User-Agent: request header in subsequent HTTP requests. -Future _getUserAgent(PlatformWebViewController controller) async { - return await controller.runJavaScriptReturningResult('navigator.userAgent;') - as String; -} - class ResizableWebView extends StatefulWidget { const ResizableWebView({ super.key, diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebViewHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebViewHostApiTests.m index 1a4d6635e7cc..617f7309cdb5 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebViewHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebViewHostApiTests.m @@ -95,7 +95,7 @@ - (void)testSetCustomUserAgent { instanceManager:instanceManager]; FlutterError *error; - [hostAPI setUserAgentForWebViewWithIdentifier:@0 userAgent:@"userA" error:&error]; + [hostAPI setCustomUserAgentForWebViewWithIdentifier:@0 userAgent:@"userA" error:&error]; OCMVerify([mockWebView setCustomUserAgent:@"userA"]); XCTAssertNil(error); } @@ -487,4 +487,23 @@ - (void)testSetInspectable API_AVAILABLE(ios(16.4), macos(13.3)) { OCMVerify([mockWebView setInspectable:YES]); XCTAssertNil(error); } + +- (void)testCustomUserAgent { + FWFWebView *mockWebView = OCMClassMock([FWFWebView class]); + + NSString *userAgent = @"str"; + OCMStub([mockWebView customUserAgent]).andReturn(userAgent); + + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; + [instanceManager addDartCreatedInstance:mockWebView withIdentifier:0]; + + FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc] + initWithBinaryMessenger:OCMProtocolMock(@protocol(FlutterBinaryMessenger)) + instanceManager:instanceManager]; + + FlutterError *error; + XCTAssertEqualObjects([hostAPI customUserAgentForWebViewWithIdentifier:@0 error:&error], + userAgent); + XCTAssertNil(error); +} @end diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFGeneratedWebKitApis.h b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFGeneratedWebKitApis.h index 5158dcd9689c..11c49d24b541 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFGeneratedWebKitApis.h +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFGeneratedWebKitApis.h @@ -744,9 +744,9 @@ NSObject *FWFWKWebViewHostApiGetCodec(void); - (void)setAllowsBackForwardForWebViewWithIdentifier:(NSNumber *)identifier isAllowed:(NSNumber *)allow error:(FlutterError *_Nullable *_Nonnull)error; -- (void)setUserAgentForWebViewWithIdentifier:(NSNumber *)identifier - userAgent:(nullable NSString *)userAgent - error:(FlutterError *_Nullable *_Nonnull)error; +- (void)setCustomUserAgentForWebViewWithIdentifier:(NSNumber *)identifier + userAgent:(nullable NSString *)userAgent + error:(FlutterError *_Nullable *_Nonnull)error; - (void)evaluateJavaScriptForWebViewWithIdentifier:(NSNumber *)identifier javaScriptString:(NSString *)javaScriptString completion:(void (^)(id _Nullable, @@ -754,6 +754,9 @@ NSObject *FWFWKWebViewHostApiGetCodec(void); - (void)setInspectableForWebViewWithIdentifier:(NSNumber *)identifier inspectable:(NSNumber *)inspectable error:(FlutterError *_Nullable *_Nonnull)error; +- (nullable NSString *)customUserAgentForWebViewWithIdentifier:(NSNumber *)identifier + error:(FlutterError *_Nullable *_Nonnull) + error; @end extern void FWFWKWebViewHostApiSetup(id binaryMessenger, diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFGeneratedWebKitApis.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFGeneratedWebKitApis.m index d8d4e2972eeb..cc58067418e9 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFGeneratedWebKitApis.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFGeneratedWebKitApis.m @@ -2466,19 +2466,19 @@ void FWFWKWebViewHostApiSetup(id binaryMessenger, binaryMessenger:binaryMessenger codec:FWFWKWebViewHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(setUserAgentForWebViewWithIdentifier: - userAgent:error:)], + NSCAssert([api respondsToSelector:@selector + (setCustomUserAgentForWebViewWithIdentifier:userAgent:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to " - @"@selector(setUserAgentForWebViewWithIdentifier:userAgent:error:)", + @"@selector(setCustomUserAgentForWebViewWithIdentifier:userAgent:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_identifier = GetNullableObjectAtIndex(args, 0); NSString *arg_userAgent = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api setUserAgentForWebViewWithIdentifier:arg_identifier - userAgent:arg_userAgent - error:&error]; + [api setCustomUserAgentForWebViewWithIdentifier:arg_identifier + userAgent:arg_userAgent + error:&error]; callback(wrapResult(nil, error)); }]; } else { @@ -2539,6 +2539,29 @@ void FWFWKWebViewHostApiSetup(id binaryMessenger, [channel setMessageHandler:nil]; } } + { + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName: + @"dev.flutter.pigeon.webview_flutter_wkwebview.WKWebViewHostApi.getCustomUserAgent" + binaryMessenger:binaryMessenger + codec:FWFWKWebViewHostApiGetCodec()]; + if (api) { + NSCAssert([api respondsToSelector:@selector(customUserAgentForWebViewWithIdentifier:error:)], + @"FWFWKWebViewHostApi api (%@) doesn't respond to " + @"@selector(customUserAgentForWebViewWithIdentifier:error:)", + api); + [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { + NSArray *args = message; + NSNumber *arg_identifier = GetNullableObjectAtIndex(args, 0); + FlutterError *error; + NSString *output = [api customUserAgentForWebViewWithIdentifier:arg_identifier + error:&error]; + callback(wrapResult(output, error)); + }]; + } else { + [channel setMessageHandler:nil]; + } + } } NSObject *FWFWKUIDelegateHostApiGetCodec(void) { static FlutterStandardMessageCodec *sSharedObject = nil; diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFWebViewHostApi.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFWebViewHostApi.m index 924b9bba4bca..eb30b773d1f2 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFWebViewHostApi.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFWebViewHostApi.m @@ -134,10 +134,11 @@ - (void)loadRequestForWebViewWithIdentifier:(nonnull NSNumber *)identifier [[self webViewForIdentifier:identifier] loadRequest:urlRequest]; } -- (void)setUserAgentForWebViewWithIdentifier:(nonnull NSNumber *)identifier - userAgent:(nullable NSString *)userAgent - error:(FlutterError *_Nullable __autoreleasing *_Nonnull) - error { +- (void)setCustomUserAgentForWebViewWithIdentifier:(nonnull NSNumber *)identifier + userAgent:(nullable NSString *)userAgent + error: + (FlutterError *_Nullable __autoreleasing *_Nonnull) + error { [[self webViewForIdentifier:identifier] setCustomUserAgent:userAgent]; } @@ -299,4 +300,11 @@ - (void)setUIDelegateForWebViewWithIdentifier:(nonnull NSNumber *)identifier error:(FlutterError *_Nullable __autoreleasing *_Nonnull)error { return [[self webViewForIdentifier:identifier] title]; } + +- (nullable NSString *) + customUserAgentForWebViewWithIdentifier:(nonnull NSNumber *)identifier + error: + (FlutterError *_Nullable __autoreleasing *_Nonnull)error { + return [[self webViewForIdentifier:identifier] customUserAgent]; +} @end diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/web_kit.g.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/web_kit.g.dart index 25649a01099f..b0eaadeb739f 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/web_kit.g.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/web_kit.g.dart @@ -2584,6 +2584,29 @@ class WKWebViewHostApi { return; } } + + Future getCustomUserAgent(int arg_identifier) async { + final BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.webview_flutter_wkwebview.WKWebViewHostApi.getCustomUserAgent', + codec, + binaryMessenger: _binaryMessenger); + final List? replyList = + await channel.send([arg_identifier]) as List?; + if (replyList == null) { + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel.', + ); + } else if (replyList.length > 1) { + throw PlatformException( + code: replyList[0]! as String, + message: replyList[1] as String?, + details: replyList[2], + ); + } else { + return (replyList[0] as String?); + } + } } /// Mirror of WKUIDelegate. diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit.dart index 714739c7a6f5..db9f41c28519 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit.dart @@ -1125,6 +1125,13 @@ class WKWebView extends UIView { ); } + /// The custom user agent string. + /// + /// Represents [WKWebView.customUserAgent](https://developer.apple.com/documentation/webkit/wkwebview/1414950-customuseragent?language=objc). + Future getCustomUserAgent() { + return _webViewApi.getCustomUserAgentForInstances(this); + } + @override WKWebView copy() { return WKWebView.detached( diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit_api_impls.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit_api_impls.dart index ccc87377cb04..ee545d45b718 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit_api_impls.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit_api_impls.dart @@ -1078,6 +1078,11 @@ class WKWebViewHostApiImpl extends WKWebViewHostApi { ); } + /// Calls [getCustomUserAgent] with the ids of the provided object instances. + Future getCustomUserAgentForInstances(WKWebView instance) { + return getCustomUserAgent(instanceManager.getIdentifier(instance)!); + } + /// Calls [setNavigationDelegate] with the ids of the provided object instances. Future setNavigationDelegateForInstances( WKWebView instance, diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/webkit_webview_controller.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/webkit_webview_controller.dart index 5162a064b329..6fad6d8aaecf 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/webkit_webview_controller.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/webkit_webview_controller.dart @@ -662,6 +662,17 @@ window.addEventListener("error", function(e) { Future setInspectable(bool inspectable) { return _webView.setInspectable(inspectable); } + + @override + Future getUserAgent() async { + final String? customUserAgent = await _webView.getCustomUserAgent(); + if (customUserAgent != null) { + return customUserAgent; + } + + return (await _webView.evaluateJavaScript('navigator.userAgent;') + as String?)!; + } } /// An implementation of [JavaScriptChannelParams] with the WebKit api. diff --git a/packages/webview_flutter/webview_flutter_wkwebview/pigeons/web_kit.dart b/packages/webview_flutter/webview_flutter_wkwebview/pigeons/web_kit.dart index dea5080e556a..8e9e16ff425d 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/pigeons/web_kit.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/pigeons/web_kit.dart @@ -688,7 +688,7 @@ abstract class WKWebViewHostApi { @ObjCSelector('setAllowsBackForwardForWebViewWithIdentifier:isAllowed:') void setAllowsBackForwardNavigationGestures(int identifier, bool allow); - @ObjCSelector('setUserAgentForWebViewWithIdentifier:userAgent:') + @ObjCSelector('setCustomUserAgentForWebViewWithIdentifier:userAgent:') void setCustomUserAgent(int identifier, String? userAgent); @ObjCSelector('evaluateJavaScriptForWebViewWithIdentifier:javaScriptString:') @@ -697,6 +697,9 @@ abstract class WKWebViewHostApi { @ObjCSelector('setInspectableForWebViewWithIdentifier:inspectable:') void setInspectable(int identifier, bool inspectable); + + @ObjCSelector('customUserAgentForWebViewWithIdentifier:') + String? getCustomUserAgent(int identifier); } /// Mirror of WKUIDelegate. diff --git a/packages/webview_flutter/webview_flutter_wkwebview/pubspec.yaml b/packages/webview_flutter/webview_flutter_wkwebview/pubspec.yaml index 5f99bc9d25fa..685c96ec6999 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/pubspec.yaml +++ b/packages/webview_flutter/webview_flutter_wkwebview/pubspec.yaml @@ -2,7 +2,7 @@ name: webview_flutter_wkwebview description: A Flutter plugin that provides a WebView widget based on Apple's WKWebView control. repository: https://github.com/flutter/packages/tree/main/packages/webview_flutter/webview_flutter_wkwebview issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+webview%22 -version: 3.8.0 +version: 3.9.0 environment: sdk: ">=2.19.0 <4.0.0" diff --git a/packages/webview_flutter/webview_flutter_wkwebview/test/legacy/web_kit_webview_widget_test.mocks.dart b/packages/webview_flutter/webview_flutter_wkwebview/test/legacy/web_kit_webview_widget_test.mocks.dart index b0112709f2b3..8de47910fef3 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/test/legacy/web_kit_webview_widget_test.mocks.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/test/legacy/web_kit_webview_widget_test.mocks.dart @@ -652,6 +652,14 @@ class MockWKWebView extends _i1.Mock implements _i4.WKWebView { returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); @override + _i5.Future getCustomUserAgent() => (super.noSuchMethod( + Invocation.method( + #getCustomUserAgent, + [], + ), + returnValue: _i5.Future.value(), + ) as _i5.Future); + @override _i4.WKWebView copy() => (super.noSuchMethod( Invocation.method( #copy, diff --git a/packages/webview_flutter/webview_flutter_wkwebview/test/src/common/test_web_kit.g.dart b/packages/webview_flutter/webview_flutter_wkwebview/test/src/common/test_web_kit.g.dart index ee9065ea6689..03e5b6cbca5e 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/test/src/common/test_web_kit.g.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/test/src/common/test_web_kit.g.dart @@ -1160,6 +1160,8 @@ abstract class TestWKWebViewHostApi { void setInspectable(int identifier, bool inspectable); + String? getCustomUserAgent(int identifier); + static void setup(TestWKWebViewHostApi? api, {BinaryMessenger? binaryMessenger}) { { @@ -1633,6 +1635,29 @@ abstract class TestWKWebViewHostApi { }); } } + { + final BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.webview_flutter_wkwebview.WKWebViewHostApi.getCustomUserAgent', + codec, + binaryMessenger: binaryMessenger); + if (api == null) { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); + } else { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKWebViewHostApi.getCustomUserAgent was null.'); + final List args = (message as List?)!; + final int? arg_identifier = (args[0] as int?); + assert(arg_identifier != null, + 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKWebViewHostApi.getCustomUserAgent was null, expected non-null int.'); + final String? output = api.getCustomUserAgent(arg_identifier!); + return [output]; + }); + } + } } } diff --git a/packages/webview_flutter/webview_flutter_wkwebview/test/src/ui_kit/ui_kit_test.mocks.dart b/packages/webview_flutter/webview_flutter_wkwebview/test/src/ui_kit/ui_kit_test.mocks.dart index 515028b1d1e5..81ef6a8ca9d6 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/test/src/ui_kit/ui_kit_test.mocks.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/test/src/ui_kit/ui_kit_test.mocks.dart @@ -338,6 +338,12 @@ class MockTestWKWebViewHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); + @override + String? getCustomUserAgent(int? identifier) => + (super.noSuchMethod(Invocation.method( + #getCustomUserAgent, + [identifier], + )) as String?); } /// A class which mocks [TestUIScrollViewHostApi]. diff --git a/packages/webview_flutter/webview_flutter_wkwebview/test/src/web_kit/web_kit_test.dart b/packages/webview_flutter/webview_flutter_wkwebview/test/src/web_kit/web_kit_test.dart index 055f342ab786..98a70de7b328 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/test/src/web_kit/web_kit_test.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/test/src/web_kit/web_kit_test.dart @@ -833,7 +833,7 @@ void main() { )); }); - test('customUserAgent', () { + test('setCustomUserAgent', () { webView.setCustomUserAgent('hello'); verify(mockPlatformHostApi.setCustomUserAgent( webViewInstanceId, @@ -841,6 +841,14 @@ void main() { )); }); + test('getCustomUserAgent', () { + const String userAgent = 'str'; + when( + mockPlatformHostApi.getCustomUserAgent(webViewInstanceId), + ).thenReturn(userAgent); + expect(webView.getCustomUserAgent(), completion(userAgent)); + }); + test('evaluateJavaScript', () { when(mockPlatformHostApi.evaluateJavaScript(webViewInstanceId, 'gogo')) .thenAnswer((_) => Future.value('stopstop')); diff --git a/packages/webview_flutter/webview_flutter_wkwebview/test/src/web_kit/web_kit_test.mocks.dart b/packages/webview_flutter/webview_flutter_wkwebview/test/src/web_kit/web_kit_test.mocks.dart index e46a4ce989be..2343af2f17ff 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/test/src/web_kit/web_kit_test.mocks.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/test/src/web_kit/web_kit_test.mocks.dart @@ -567,6 +567,12 @@ class MockTestWKWebViewHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); + @override + String? getCustomUserAgent(int? identifier) => + (super.noSuchMethod(Invocation.method( + #getCustomUserAgent, + [identifier], + )) as String?); } /// A class which mocks [TestWKWebsiteDataStoreHostApi]. diff --git a/packages/webview_flutter/webview_flutter_wkwebview/test/webkit_webview_controller_test.dart b/packages/webview_flutter/webview_flutter_wkwebview/test/webkit_webview_controller_test.dart index a22e2f6a3243..d1854df4bce0 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/test/webkit_webview_controller_test.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/test/webkit_webview_controller_test.dart @@ -825,6 +825,21 @@ void main() { ); }); + test('getUserAgent', () { + final MockWKWebView mockWebView = MockWKWebView(); + + final WebKitWebViewController controller = createControllerWithMocks( + createMockWebView: (_, {dynamic observeValue}) => mockWebView, + ); + + const String userAgent = 'str'; + + when(mockWebView.getCustomUserAgent()).thenAnswer( + (_) => Future.value(userAgent), + ); + expect(controller.getUserAgent(), completion(userAgent)); + }); + test('setPlatformNavigationDelegate', () { final MockWKWebView mockWebView = MockWKWebView(); diff --git a/packages/webview_flutter/webview_flutter_wkwebview/test/webkit_webview_controller_test.mocks.dart b/packages/webview_flutter/webview_flutter_wkwebview/test/webkit_webview_controller_test.mocks.dart index 7624a8724d98..08bd48041606 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/test/webkit_webview_controller_test.mocks.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/test/webkit_webview_controller_test.mocks.dart @@ -760,6 +760,14 @@ class MockWKWebView extends _i1.Mock implements _i5.WKWebView { returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); @override + _i6.Future getCustomUserAgent() => (super.noSuchMethod( + Invocation.method( + #getCustomUserAgent, + [], + ), + returnValue: _i6.Future.value(), + ) as _i6.Future); + @override _i5.WKWebView copy() => (super.noSuchMethod( Invocation.method( #copy,