chore(dependencies): add webview_flutter_platform_interface package to pubspec.yaml and clean up test files by removing unnecessary whitespace

This commit is contained in:
mso7nueh
2025-12-11 14:12:41 +03:00
parent 70e4a42e98
commit 960afbd6ed
91 changed files with 6152 additions and 1209 deletions

View File

@@ -0,0 +1,184 @@
import 'package:flutter/material.dart';
import 'package:webview_flutter_platform_interface/webview_flutter_platform_interface.dart';
/// Helper class to set up WebViewPlatform for testing
class WebViewTestHelper {
static FakeWebViewPlatform? _instance;
/// Sets up a fake WebViewPlatform instance for testing
static void setUpWebViewPlatform() {
_instance = FakeWebViewPlatform();
WebViewPlatform.instance = _instance!;
}
/// Cleans up the WebViewPlatform instance after testing
/// Note: We can't set WebViewPlatform.instance to null, so we just reset our reference
static void tearDownWebViewPlatform() {
_instance = null;
// Don't set WebViewPlatform.instance to null as it's not allowed
}
}
/// A fake implementation of WebViewPlatform for testing
class FakeWebViewPlatform extends WebViewPlatform {
FakeWebViewPlatform() : super();
@override
PlatformWebViewController createPlatformWebViewController(
PlatformWebViewControllerCreationParams params,
) {
return FakePlatformWebViewController._(params);
}
@override
PlatformWebViewWidget createPlatformWebViewWidget(
PlatformWebViewWidgetCreationParams params,
) {
return FakePlatformWebViewWidget._(params);
}
@override
PlatformNavigationDelegate createPlatformNavigationDelegate(
PlatformNavigationDelegateCreationParams params,
) {
return FakePlatformNavigationDelegate._(params);
}
}
/// A fake implementation of PlatformWebViewController for testing
class FakePlatformWebViewController extends PlatformWebViewController {
FakePlatformWebViewController._(super.params)
: super.implementation();
// Implement the methods that are actually called in tests
// Using dynamic to avoid type issues with Params classes
@override
Future<void> setJavaScriptMode(dynamic params) async {
// No-op implementation for testing
}
Future<void> setNavigationDelegate(dynamic params) async {
// No-op implementation for testing
}
@override
Future<void> loadRequest(dynamic params) async {
// No-op implementation for testing
}
@override
Future<void> addJavaScriptChannel(dynamic params) async {
// No-op implementation for testing
}
@override
Future<void> removeJavaScriptChannel(dynamic params) async {
// No-op implementation for testing
}
@override
Future<void> setBackgroundColor(dynamic params) async {
// No-op implementation for testing
}
Future<void> setZoomEnabled(dynamic params) async {
// No-op implementation for testing
}
@override
Future<void> setUserAgent(dynamic params) async {
// No-op implementation for testing
}
@override
Future<String?> currentUrl() async => null;
@override
Future<String> getTitle() async => '';
@override
Future<bool> canGoBack() async => false;
@override
Future<bool> canGoForward() async => false;
@override
Future<void> goBack() async {}
@override
Future<void> goForward() async {}
@override
Future<void> reload() async {}
@override
Future<void> clearCache() async {}
@override
Future<void> clearLocalStorage() async {}
@override
Future<void> runJavaScript(dynamic params) async {}
@override
Future<Object> runJavaScriptReturningResult(dynamic params) async {
return '';
}
@override
Future<void> setOnConsoleMessage(dynamic params) async {}
@override
Future<void> setPlatformNavigationDelegate(dynamic delegate) async {
// No-op implementation for testing
}
}
/// A fake implementation of PlatformWebViewWidget for testing
class FakePlatformWebViewWidget extends PlatformWebViewWidget {
FakePlatformWebViewWidget._(super.params)
: super.implementation();
@override
Widget build(BuildContext context) {
return const SizedBox.shrink();
}
}
/// A fake implementation of PlatformNavigationDelegate for testing
class FakePlatformNavigationDelegate extends PlatformNavigationDelegate {
FakePlatformNavigationDelegate._(super.params)
: super.implementation();
@override
Future<void> setOnNavigationRequest(dynamic params) async {
// No-op implementation for testing
}
@override
Future<void> setOnPageStarted(dynamic params) async {
// No-op implementation for testing
}
@override
Future<void> setOnPageFinished(dynamic params) async {
// No-op implementation for testing
}
@override
Future<void> setOnWebResourceError(dynamic params) async {
// No-op implementation for testing
}
// Implement methods that might be called
@override
dynamic noSuchMethod(Invocation invocation) {
// Return empty futures for async methods
if (invocation.memberName.toString().contains('Future')) {
return Future.value();
}
// Return null for other methods
return null;
}
}