Skip to content

Commit

Permalink
Fix setConsoleLogCallback unit-test
Browse files Browse the repository at this point in the history
  • Loading branch information
mvanbeusekom committed Jul 21, 2023
1 parent ad5a961 commit 18b1053
Show file tree
Hide file tree
Showing 10 changed files with 133 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -520,8 +520,10 @@ class WebKitWebViewController extends PlatformWebViewController {
) {
_onConsoleLogCallback = onConsoleMessage;

final JavaScriptChannelParams channelParams = JavaScriptChannelParams(
final JavaScriptChannelParams channelParams = WebKitJavaScriptChannelParams(
name: 'fltConsoleMessage',
webKitProxy:
(params as WebKitWebViewControllerCreationParams).webKitProxy,
onMessageReceived: (JavaScriptMessage message) {
if (_onConsoleLogCallback == null) {
return;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// Mocks generated by Mockito 5.4.0 from annotations
// Mocks generated by Mockito 5.4.1 from annotations
// in webview_flutter_wkwebview/test/legacy/web_kit_cookie_manager_test.dart.
// Do not manually edit this file.

// @dart=2.19

// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'dart:async' as _i3;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// Mocks generated by Mockito 5.4.0 from annotations
// Mocks generated by Mockito 5.4.1 from annotations
// in webview_flutter_wkwebview/test/legacy/web_kit_webview_widget_test.dart.
// Do not manually edit this file.

// @dart=2.19

// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'dart:async' as _i5;
import 'dart:math' as _i2;
Expand Down Expand Up @@ -760,6 +762,16 @@ class MockWKWebViewConfiguration extends _i1.Mock
returnValueForMissingStub: _i5.Future<void>.value(),
) as _i5.Future<void>);
@override
_i5.Future<void> setLimitsNavigationsToAppBoundDomains(bool? limit) =>
(super.noSuchMethod(
Invocation.method(
#setLimitsNavigationsToAppBoundDomains,
[limit],
),
returnValue: _i5.Future<void>.value(),
returnValueForMissingStub: _i5.Future<void>.value(),
) as _i5.Future<void>);
@override
_i5.Future<void> setMediaTypesRequiringUserActionForPlayback(
Set<_i4.WKAudiovisualMediaType>? types) =>
(super.noSuchMethod(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// Mocks generated by Mockito 5.4.0 from annotations
// Mocks generated by Mockito 5.4.1 from annotations
// in webview_flutter_wkwebview/test/src/foundation/foundation_test.dart.
// Do not manually edit this file.

// @dart=2.19

// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'package:mockito/mockito.dart' as _i1;
import 'package:webview_flutter_wkwebview/src/common/web_kit.g.dart' as _i3;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// Mocks generated by Mockito 5.4.0 from annotations
// Mocks generated by Mockito 5.4.1 from annotations
// in webview_flutter_wkwebview/test/src/ui_kit/ui_kit_test.dart.
// Do not manually edit this file.

// @dart=2.19

// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'dart:async' as _i4;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// Mocks generated by Mockito 5.4.0 from annotations
// Mocks generated by Mockito 5.4.1 from annotations
// in webview_flutter_wkwebview/test/src/web_kit/web_kit_test.dart.
// Do not manually edit this file.

// @dart=2.19

// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'dart:async' as _i3;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import 'webkit_webview_controller_test.mocks.dart';
WKWebsiteDataStore,
WKWebView,
WKWebViewConfiguration,
WKScriptMessageHandler,
])
void main() {
WidgetsFlutterBinding.ensureInitialized();
Expand All @@ -48,12 +49,16 @@ void main() {
)? observeValue,
})? createMockWebView,
MockWKWebViewConfiguration? mockWebViewConfiguration,
MockWKScriptMessageHandler? mockWKScriptMessageHandler,
InstanceManager? instanceManager,
}) {
final MockWKWebViewConfiguration nonNullMockWebViewConfiguration =
mockWebViewConfiguration ?? MockWKWebViewConfiguration();
late final MockWKWebView nonNullMockWebView;

final MockWKScriptMessageHandler nonNullMockWKScriptMessageHandler =
mockWKScriptMessageHandler ?? MockWKScriptMessageHandler();

final PlatformWebViewControllerCreationParams controllerCreationParams =
WebKitWebViewControllerCreationParams(
webKitProxy: WebKitProxy(
Expand Down Expand Up @@ -98,6 +103,14 @@ void main() {
requestMediaCapturePermission: requestMediaCapturePermission,
);
},
createScriptMessageHandler: ({
required void Function(
WKUserContentController userContentController,
WKScriptMessage scriptMessage,
) didReceiveScriptMessage,
}) {
return nonNullMockWKScriptMessageHandler;
},
),
instanceManager: instanceManager,
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// Mocks generated by Mockito 5.4.0 from annotations
// Mocks generated by Mockito 5.4.1 from annotations
// in webview_flutter_wkwebview/test/webkit_webview_controller_test.dart.
// Do not manually edit this file.

// @dart=2.19

// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'dart:async' as _i6;
import 'dart:math' as _i3;
Expand Down Expand Up @@ -119,6 +121,17 @@ class _FakeWKWebView_8 extends _i1.SmartFake implements _i5.WKWebView {
);
}

class _FakeWKScriptMessageHandler_9 extends _i1.SmartFake
implements _i5.WKScriptMessageHandler {
_FakeWKScriptMessageHandler_9(
Object parent,
Invocation parentInvocation,
) : super(
parent,
parentInvocation,
);
}

/// A class which mocks [NSUrl].
///
/// See the documentation for Mockito's code generation for more information.
Expand Down Expand Up @@ -924,3 +937,75 @@ class MockWKWebViewConfiguration extends _i1.Mock
returnValueForMissingStub: _i6.Future<void>.value(),
) as _i6.Future<void>);
}

/// A class which mocks [WKScriptMessageHandler].
///
/// See the documentation for Mockito's code generation for more information.
// ignore: must_be_immutable
class MockWKScriptMessageHandler extends _i1.Mock
implements _i5.WKScriptMessageHandler {
MockWKScriptMessageHandler() {
_i1.throwOnMissingStub(this);
}

@override
void Function(
_i5.WKUserContentController,
_i5.WKScriptMessage,
) get didReceiveScriptMessage => (super.noSuchMethod(
Invocation.getter(#didReceiveScriptMessage),
returnValue: (
_i5.WKUserContentController userContentController,
_i5.WKScriptMessage message,
) {},
) as void Function(
_i5.WKUserContentController,
_i5.WKScriptMessage,
));
@override
_i5.WKScriptMessageHandler copy() => (super.noSuchMethod(
Invocation.method(
#copy,
[],
),
returnValue: _FakeWKScriptMessageHandler_9(
this,
Invocation.method(
#copy,
[],
),
),
) as _i5.WKScriptMessageHandler);
@override
_i6.Future<void> addObserver(
_i2.NSObject? observer, {
required String? keyPath,
required Set<_i2.NSKeyValueObservingOptions>? options,
}) =>
(super.noSuchMethod(
Invocation.method(
#addObserver,
[observer],
{
#keyPath: keyPath,
#options: options,
},
),
returnValue: _i6.Future<void>.value(),
returnValueForMissingStub: _i6.Future<void>.value(),
) as _i6.Future<void>);
@override
_i6.Future<void> removeObserver(
_i2.NSObject? observer, {
required String? keyPath,
}) =>
(super.noSuchMethod(
Invocation.method(
#removeObserver,
[observer],
{#keyPath: keyPath},
),
returnValue: _i6.Future<void>.value(),
returnValueForMissingStub: _i6.Future<void>.value(),
) as _i6.Future<void>);
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// Mocks generated by Mockito 5.4.0 from annotations
// Mocks generated by Mockito 5.4.1 from annotations
// in webview_flutter_wkwebview/test/webkit_webview_cookie_manager_test.dart.
// Do not manually edit this file.

// @dart=2.19

// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'dart:async' as _i3;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// Mocks generated by Mockito 5.4.0 from annotations
// Mocks generated by Mockito 5.4.1 from annotations
// in webview_flutter_wkwebview/test/webkit_webview_widget_test.dart.
// Do not manually edit this file.

// @dart=2.19

// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'dart:async' as _i3;

Expand Down

0 comments on commit 18b1053

Please sign in to comment.