updated tests

This commit is contained in:
Lorenzo Pichilli 2022-04-29 02:07:01 +02:00
parent f45996e187
commit a8593f557e
28 changed files with 181 additions and 169 deletions

View File

@ -7,15 +7,16 @@ import '../constants.dart';
import '../util.dart';
void customActionButton() {
final shouldSkip = kIsWeb ||
![
TargetPlatform.android,
].contains(defaultTargetPlatform);
final shouldSkip = kIsWeb
? true
: ![
TargetPlatform.android,
].contains(defaultTargetPlatform);
test('add custom action button', () async {
var chromeSafariBrowser = new MyChromeSafariBrowser();
var actionButtonIcon =
await rootBundle.load('test_assets/images/flutter-logo.png');
await rootBundle.load('test_assets/images/flutter-logo.png');
chromeSafariBrowser.setActionButton(ChromeSafariBrowserActionButton(
id: 1,
description: 'Action Button description',
@ -25,16 +26,14 @@ void customActionButton() {
}));
expect(chromeSafariBrowser.isOpened(), false);
await chromeSafariBrowser.open(
url: TEST_URL_1);
await chromeSafariBrowser.open(url: TEST_URL_1);
await chromeSafariBrowser.browserCreated.future;
expect(chromeSafariBrowser.isOpened(), true);
expect(() async {
await chromeSafariBrowser.open(url: TEST_CROSS_PLATFORM_URL_1);
}, throwsA(isInstanceOf<ChromeSafariBrowserAlreadyOpenedException>()));
await expectLater(
chromeSafariBrowser.firstPageLoaded.future, completes);
await expectLater(chromeSafariBrowser.firstPageLoaded.future, completes);
await chromeSafariBrowser.close();
await chromeSafariBrowser.browserClosed.future;
expect(chromeSafariBrowser.isOpened(), false);

View File

@ -6,12 +6,13 @@ import '../constants.dart';
import '../util.dart';
void customMenuItem() {
final shouldSkip = kIsWeb ||
![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
].contains(defaultTargetPlatform);
final shouldSkip = kIsWeb
? true
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
].contains(defaultTargetPlatform);
test('add custom menu item', () async {
var chromeSafariBrowser = new MyChromeSafariBrowser();
@ -23,8 +24,7 @@ void customMenuItem() {
}));
expect(chromeSafariBrowser.isOpened(), false);
await chromeSafariBrowser.open(
url: TEST_URL_1);
await chromeSafariBrowser.open(url: TEST_URL_1);
await chromeSafariBrowser.browserCreated.future;
expect(chromeSafariBrowser.isOpened(), true);
expect(() async {

View File

@ -6,12 +6,13 @@ import '../constants.dart';
import '../util.dart';
void customTabs() {
final shouldSkip = kIsWeb ||
![
TargetPlatform.android,
].contains(defaultTargetPlatform);
final shouldSkip = kIsWeb
? true
: ![
TargetPlatform.android,
].contains(defaultTargetPlatform);
group('Custom Tabs', () async {
group('Custom Tabs', () {
test('single instance', () async {
var chromeSafariBrowser = new MyChromeSafariBrowser();
expect(chromeSafariBrowser.isOpened(), false);

View File

@ -6,19 +6,19 @@ import '../constants.dart';
import '../util.dart';
void openAndClose() {
final shouldSkip = kIsWeb ||
![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
].contains(defaultTargetPlatform);
final shouldSkip = kIsWeb
? true
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
].contains(defaultTargetPlatform);
test('open and close', () async {
var chromeSafariBrowser = new MyChromeSafariBrowser();
expect(chromeSafariBrowser.isOpened(), false);
await chromeSafariBrowser.open(
url: TEST_URL_1);
await chromeSafariBrowser.open(url: TEST_URL_1);
await chromeSafariBrowser.browserCreated.future;
expect(chromeSafariBrowser.isOpened(), true);
expect(() async {

View File

@ -6,12 +6,13 @@ import '../constants.dart';
import '../util.dart';
void trustedWebActivity() {
final shouldSkip = kIsWeb ||
![
TargetPlatform.android,
].contains(defaultTargetPlatform);
final shouldSkip = kIsWeb
? true
: ![
TargetPlatform.android,
].contains(defaultTargetPlatform);
group('Trusted Web Activity', () async {
group('Trusted Web Activity', () {
test('basic', () async {
var chromeSafariBrowser = new MyChromeSafariBrowser();
expect(chromeSafariBrowser.isOpened(), false);

View File

@ -11,7 +11,7 @@ final TEST_WEB_PLATFORM_BASE_URL = Uri.parse(Uri.base.toString().replaceFirst("/
final TEST_WEB_PLATFORM_URL_1 = Uri.parse(TEST_WEB_PLATFORM_BASE_URL.toString() + 'page.html');
final TEST_WEB_PLATFORM_URL_2 = Uri.parse(TEST_WEB_PLATFORM_BASE_URL.toString() + 'page-2.html');
final TEST_WEB_PLATFORM_URL_3 = Uri.parse(TEST_WEB_PLATFORM_BASE_URL.toString() + 'heavy-page.html');
final TEST_NOT_A_WEBSITE_URL = Uri.parse('https://www.notawebsite..com');
final TEST_NOT_A_WEBSITE_URL = Uri.parse('https://www.notawebsite..com/');
final TEST_CHROME_SAFE_BROWSING_MALWARE = Uri.parse('chrome://safe-browsing/match?type=malware');
final TEST_PERMISSION_SITE = Uri.parse('https://permission.site/');
final TEST_SERVICE_WORKER_URL = Uri.parse('https://mdn.github.io/sw-test/');

View File

@ -8,12 +8,13 @@ import 'package:flutter_test/flutter_test.dart';
import '../constants.dart';
void setGetDelete() {
final shouldSkip = kIsWeb ||
![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
].contains(defaultTargetPlatform);
final shouldSkip = kIsWeb
? true
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
].contains(defaultTargetPlatform);
testWidgets('set, get, delete', (WidgetTester tester) async {
CookieManager cookieManager = CookieManager.instance();
@ -24,15 +25,13 @@ void setGetDelete() {
textDirection: TextDirection.ltr,
child: InAppWebView(
key: GlobalKey(),
initialUrlRequest:
URLRequest(url: TEST_CROSS_PLATFORM_URL_1),
initialUrlRequest: URLRequest(url: TEST_CROSS_PLATFORM_URL_1),
onWebViewCreated: (controller) {
controllerCompleter.complete(controller);
},
initialOptions: InAppWebViewGroupOptions(
crossPlatform: InAppWebViewOptions(
clearCache: true,
)),
initialSettings: InAppWebViewSettings(
clearCache: true,
),
onLoadStop: (controller, url) {
pageLoaded.complete(url!.toString());
},
@ -42,13 +41,11 @@ void setGetDelete() {
final url = Uri.parse(await pageLoaded.future);
await cookieManager.setCookie(
url: url, name: "myCookie", value: "myValue");
await cookieManager.setCookie(url: url, name: "myCookie", value: "myValue");
List<Cookie> cookies = await cookieManager.getCookies(url: url);
expect(cookies, isNotEmpty);
Cookie? cookie =
await cookieManager.getCookie(url: url, name: "myCookie");
Cookie? cookie = await cookieManager.getCookie(url: url, name: "myCookie");
expect(cookie?.value.toString(), "myValue");
await cookieManager.deleteCookie(url: url, name: "myCookie");

View File

@ -8,19 +8,19 @@ import 'package:flutter_test/flutter_test.dart';
import '../constants.dart';
void customSize() {
final shouldSkip = !kIsWeb ||
![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
].contains(defaultTargetPlatform);
final shouldSkip = kIsWeb
? false
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
].contains(defaultTargetPlatform);
test('set and get custom size', () async {
final Completer controllerCompleter = Completer<InAppWebViewController>();
var headlessWebView = new HeadlessInAppWebView(
initialUrlRequest:
URLRequest(url: TEST_CROSS_PLATFORM_URL_1),
initialUrlRequest: URLRequest(url: TEST_CROSS_PLATFORM_URL_1),
initialSize: Size(600, 800),
onWebViewCreated: (controller) {
controllerCompleter.complete(controller);

View File

@ -7,7 +7,7 @@ import 'package:flutter_test/flutter_test.dart';
import '../constants.dart';
void runAndDispose() {
final shouldSkip = !kIsWeb ||
final shouldSkip = kIsWeb ? false :
![
TargetPlatform.android,
TargetPlatform.iOS,

View File

@ -7,20 +7,20 @@ import 'package:flutter_test/flutter_test.dart';
import '../constants.dart';
void setGetSettings() {
final shouldSkip = !kIsWeb ||
![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
].contains(defaultTargetPlatform);
final shouldSkip = kIsWeb
? false
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
].contains(defaultTargetPlatform);
test('set/get settings', () async {
final Completer controllerCompleter = Completer<InAppWebViewController>();
final Completer<void> pageLoaded = Completer<void>();
var headlessWebView = new HeadlessInAppWebView(
initialUrlRequest:
URLRequest(url: TEST_CROSS_PLATFORM_URL_1),
initialUrlRequest: URLRequest(url: TEST_CROSS_PLATFORM_URL_1),
initialSettings: InAppWebViewSettings(javaScriptEnabled: false),
onWebViewCreated: (controller) {
controllerCompleter.complete(controller);

View File

@ -7,12 +7,13 @@ import '../constants.dart';
import '../util.dart';
void openDataAndClose() {
final shouldSkip = kIsWeb ||
![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
].contains(defaultTargetPlatform);
final shouldSkip = kIsWeb
? true
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
].contains(defaultTargetPlatform);
test('open data and close', () async {
var inAppBrowser = new MyInAppBrowser();
@ -45,8 +46,7 @@ void openDataAndClose() {
expect(inAppBrowser.isOpened(), true);
expect(() async {
await inAppBrowser.openUrlRequest(
urlRequest:
URLRequest(url: TEST_URL_1));
urlRequest: URLRequest(url: TEST_URL_1));
}, throwsA(isInstanceOf<InAppBrowserAlreadyOpenedException>()));
await inAppBrowser.firstPageLoaded.future;

View File

@ -7,12 +7,13 @@ import '../constants.dart';
import '../util.dart';
void openFileAndClose() {
final shouldSkip = kIsWeb ||
![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
].contains(defaultTargetPlatform);
final shouldSkip = kIsWeb
? true
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
].contains(defaultTargetPlatform);
test('open file and close', () async {
var inAppBrowser = new MyInAppBrowser();
@ -27,8 +28,7 @@ void openFileAndClose() {
expect(inAppBrowser.isOpened(), true);
expect(() async {
await inAppBrowser.openUrlRequest(
urlRequest:
URLRequest(url: TEST_URL_1));
urlRequest: URLRequest(url: TEST_URL_1));
}, throwsA(isInstanceOf<InAppBrowserAlreadyOpenedException>()));
await inAppBrowser.firstPageLoaded.future;

View File

@ -7,12 +7,13 @@ import '../constants.dart';
import '../util.dart';
void openUrlAndClose() {
final shouldSkip = kIsWeb ||
![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
].contains(defaultTargetPlatform);
final shouldSkip = kIsWeb
? true
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
].contains(defaultTargetPlatform);
test('open url and close', () async {
var inAppBrowser = new MyInAppBrowser();
@ -21,8 +22,7 @@ void openUrlAndClose() {
await inAppBrowser.show();
}, throwsA(isInstanceOf<InAppBrowserNotOpenedException>()));
await inAppBrowser.openUrlRequest(
urlRequest: URLRequest(url: TEST_URL_1));
await inAppBrowser.openUrlRequest(urlRequest: URLRequest(url: TEST_URL_1));
await inAppBrowser.browserCreated.future;
expect(inAppBrowser.isOpened(), true);
expect(() async {

View File

@ -6,12 +6,13 @@ import '../constants.dart';
import '../util.dart';
void setGetSettings() {
final shouldSkip = kIsWeb ||
![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
].contains(defaultTargetPlatform);
final shouldSkip = kIsWeb
? true
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
].contains(defaultTargetPlatform);
test('set/get settings', () async {
var inAppBrowser = new MyInAppBrowser();

View File

@ -6,12 +6,13 @@ import 'package:flutter_inappwebview/flutter_inappwebview.dart';
import 'package:flutter_test/flutter_test.dart';
void loadAssetFile(InAppLocalhostServer localhostServer) {
final shouldSkip = kIsWeb ||
![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
].contains(defaultTargetPlatform);
final shouldSkip = kIsWeb
? true
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
].contains(defaultTargetPlatform);
testWidgets('load asset file', (WidgetTester tester) async {
expect(localhostServer.isRunning(), true);
@ -30,8 +31,7 @@ void loadAssetFile(InAppLocalhostServer localhostServer) {
),
),
);
final InAppWebViewController controller =
await controllerCompleter.future;
final InAppWebViewController controller = await controllerCompleter.future;
final String? currentUrl = (await controller.getUrl())?.toString();
expect(currentUrl, 'http://localhost:8080/test_assets/index.html');
}, skip: shouldSkip);

View File

@ -27,7 +27,7 @@ void onPermissionRequest() {
final Completer controllerCompleter = Completer<InAppWebViewController>();
final Completer<void> pageLoaded = Completer<void>();
final Completer<List<PermissionResourceType>> onPermissionRequestCompleter =
Completer<List<PermissionResourceType>>();
Completer<List<PermissionResourceType>>();
await tester.pumpWidget(
Directionality(
@ -44,6 +44,8 @@ void onPermissionRequest() {
onPermissionRequest:
(controller, PermissionRequest permissionRequest) async {
onPermissionRequestCompleter.complete(permissionRequest.resources);
return PermissionResponse(resources: permissionRequest.resources,
action: PermissionResponseAction.GRANT);
},
),
),
@ -53,8 +55,9 @@ void onPermissionRequest() {
await pageLoaded.future;
await controller.evaluateJavascript(
source: "document.querySelector('#camera').click();");
await tester.pump();
final List<PermissionResourceType> resources =
await onPermissionRequestCompleter.future;
await onPermissionRequestCompleter.future;
expect(listEquals(resources, expectedValue), true);
}, skip: shouldSkip);

View File

@ -34,6 +34,7 @@ void onPrint() {
),
),
);
await tester.pump();
final String printUrl = await onPrintCompleter.future;
expect(printUrl, url.toString());
}, skip: shouldSkip);

View File

@ -41,7 +41,7 @@ void printCurrentPage() {
final InAppWebViewController controller =
await controllerCompleter.future;
await pageLoaded.future;
await tester.pump();
await expectLater(controller.printCurrentPage(), completes);
}, skip: shouldSkip);
}

View File

@ -8,12 +8,13 @@ import 'package:flutter_test/flutter_test.dart';
import '../constants.dart';
void takeScreenshot() {
final shouldSkip = kIsWeb ||
![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
].contains(defaultTargetPlatform);
final shouldSkip = kIsWeb
? true
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
].contains(defaultTargetPlatform);
testWidgets('takeScreenshot', (WidgetTester tester) async {
final Completer controllerCompleter = Completer<InAppWebViewController>();
@ -24,8 +25,7 @@ void takeScreenshot() {
textDirection: TextDirection.ltr,
child: InAppWebView(
key: GlobalKey(),
initialUrlRequest:
URLRequest(url: TEST_CROSS_PLATFORM_URL_1),
initialUrlRequest: URLRequest(url: TEST_CROSS_PLATFORM_URL_1),
onWebViewCreated: (controller) {
controllerCompleter.complete(controller);
},
@ -36,8 +36,7 @@ void takeScreenshot() {
),
);
final InAppWebViewController controller =
await controllerCompleter.future;
final InAppWebViewController controller = await controllerCompleter.future;
await pageLoaded.future;
var screenshotConfiguration = ScreenshotConfiguration(

View File

@ -190,6 +190,9 @@ void videoPlaybackPolicy() {
);
await pageLoaded.future;
await tester.pump();
await expectLater(onEnterFullscreenCompleter.future, completes);
});
@ -228,6 +231,7 @@ void videoPlaybackPolicy() {
await pageLoaded.future;
await Future.delayed(Duration(seconds: 2));
await tester.pump();
await controller.evaluateJavascript(source: "exitFullscreen();");
await expectLater(onExitFullscreenCompleter.future, completes);

View File

@ -25,8 +25,6 @@ void webHistory() {
testWidgets('get history list and go back/forward', (WidgetTester tester) async {
final Completer controllerCompleter = Completer<InAppWebViewController>();
final StreamController<String> pageLoads =
StreamController<String>.broadcast();
await tester.pumpWidget(
Directionality(
@ -37,8 +35,8 @@ void webHistory() {
onWebViewCreated: (controller) {
controllerCompleter.complete(controller);
},
onLoadStop: (controller, url) {
pageLoads.add(url!.toString());
onLoadStart: (controller, url) {
// pageLoads.add(url!.toString());
},
),
),
@ -46,7 +44,8 @@ void webHistory() {
final InAppWebViewController controller = await controllerCompleter.future;
var url = await pageLoads.stream.first;
await Future.delayed(Duration(seconds: 1));
var url = (await controller.getUrl()).toString();
var webHistory = await controller.getCopyBackForwardList();
expect(url, TEST_CROSS_PLATFORM_URL_1.toString());
expect(webHistory!.currentIndex, 0);
@ -55,7 +54,8 @@ void webHistory() {
await controller.loadUrl(
urlRequest: URLRequest(url: TEST_URL_1));
url = await pageLoads.stream.first;
await Future.delayed(Duration(seconds: 1));
url = (await controller.getUrl()).toString();
webHistory = await controller.getCopyBackForwardList();
expect(url, TEST_URL_1.toString());
expect(await controller.canGoBack(), true);
@ -69,7 +69,8 @@ void webHistory() {
await Future.delayed(Duration(seconds: 1));
await controller.goBack();
url = await pageLoads.stream.first;
await Future.delayed(Duration(seconds: 1));
url = (await controller.getUrl()).toString();
webHistory = await controller.getCopyBackForwardList();
expect(url, TEST_CROSS_PLATFORM_URL_1.toString());
expect(await controller.canGoBack(), false);
@ -83,7 +84,8 @@ void webHistory() {
await Future.delayed(Duration(seconds: 1));
await controller.goForward();
url = await pageLoads.stream.first;
await Future.delayed(Duration(seconds: 1));
url = (await controller.getUrl()).toString();
webHistory = await controller.getCopyBackForwardList();
expect(url, TEST_URL_1.toString());
expect(await controller.canGoBack(), true);
@ -97,7 +99,8 @@ void webHistory() {
await Future.delayed(Duration(seconds: 1));
await controller.goTo(historyItem: webHistory.list![0]);
url = await pageLoads.stream.first;
await Future.delayed(Duration(seconds: 1));
url = (await controller.getUrl()).toString();
webHistory = await controller.getCopyBackForwardList();
expect(url, TEST_CROSS_PLATFORM_URL_1.toString());
expect(await controller.canGoBack(), false);
@ -108,8 +111,6 @@ void webHistory() {
expect(webHistory.list!.length, 2);
expect(webHistory.list![0].url.toString(), TEST_CROSS_PLATFORM_URL_1.toString());
expect(webHistory.list![1].url.toString(), TEST_URL_1.toString());
pageLoads.close();
}, skip: shouldSkipTest1);
final shouldSkipTest2 = !kIsWeb;

View File

@ -98,19 +98,23 @@ void webMessage() {
allowedOriginRules: Set.from(["https://*.example.com"]),
onPostMessage:
(message, sourceOrigin, isMainFrame, replyProxy) {
assert(
sourceOrigin.toString() == TEST_URL_EXAMPLE.toString());
assert(isMainFrame);
replyProxy.postMessage(message! + " and back");
if (isMainFrame &&
(sourceOrigin.toString() + '/') ==
TEST_URL_EXAMPLE.toString()) {
replyProxy.postMessage(message! + " and back");
} else {
replyProxy.postMessage("Nope");
}
},
));
controllerCompleter.complete(controller);
},
onConsoleMessage: (controller, consoleMessage) {
print(consoleMessage);
webMessageCompleter.complete(consoleMessage.message);
},
onLoadStop: (controller, url) async {
print(url);
if (url.toString() == TEST_URL_EXAMPLE.toString()) {
pageLoaded.complete();
}

View File

@ -207,6 +207,8 @@ void webViewWindows() {
final InAppWebViewController controller =
await controllerCompleter.future;
await tester.pump();
await controller.evaluateJavascript(
source: 'window.open("$TEST_URL_1");');
await pageLoads.stream.first;

View File

@ -8,10 +8,11 @@ import 'package:flutter_test/flutter_test.dart';
import '../constants.dart';
void setServiceWorkerClient() {
final shouldSkip = kIsWeb ||
![
TargetPlatform.android,
].contains(defaultTargetPlatform);
final shouldSkip = kIsWeb
? true
: ![
TargetPlatform.android,
].contains(defaultTargetPlatform);
testWidgets('setServiceWorkerClient to null', (WidgetTester tester) async {
final Completer<String> pageLoaded = Completer<String>();
@ -33,8 +34,7 @@ void setServiceWorkerClient() {
textDirection: TextDirection.ltr,
child: InAppWebView(
key: GlobalKey(),
initialUrlRequest:
URLRequest(url: TEST_SERVICE_WORKER_URL),
initialUrlRequest: URLRequest(url: TEST_SERVICE_WORKER_URL),
onLoadStop: (controller, url) {
pageLoaded.complete(url!.toString());
},

View File

@ -8,10 +8,11 @@ import 'package:flutter_test/flutter_test.dart';
import '../constants.dart';
void shouldInterceptRequest() {
final shouldSkip = kIsWeb ||
![
TargetPlatform.android,
].contains(defaultTargetPlatform);
final shouldSkip = kIsWeb
? true
: ![
TargetPlatform.android,
].contains(defaultTargetPlatform);
testWidgets('shouldInterceptRequest', (WidgetTester tester) async {
final Completer completer = Completer();

View File

@ -56,29 +56,14 @@ flutter:
uses-material-design: true
assets:
- assets/index.html
- assets/page-1.html
- assets/page-2.html
- assets/
- assets/js/
- assets/css/
- assets/images/
- assets/favicon.ico
- assets/sample_audio.ogg
- assets/sample_video.mp4
- test_assets/certificate.pfx
- test_assets/in_app_webview_initial_file_test.html
- test_assets/in_app_webview_on_load_resource_test.html
- test_assets/in_app_webview_javascript_handler_test.html
- test_assets/in_app_webview_on_load_resource_custom_scheme_test.html
- test_assets/in_app_webview_on_console_message_test.html
- test_assets/in_app_webview_on_create_window_test.html
- test_assets/in_app_webview_on_js_dialog_test.html
- test_assets/
- test_assets/js/
- test_assets/css/
- test_assets/images/
- test_assets/favicon.ico
- test_assets/sample_audio.ogg
- test_assets/sample_video.mp4
# To add assets to your application, add an assets section, like this:
# assets:

View File

@ -529,7 +529,7 @@ class InAppWebView extends StatefulWidget implements WebView {
}
class _InAppWebViewState extends State<InAppWebView> {
late InAppWebViewController _controller;
InAppWebViewController? _controller;
@override
Widget build(BuildContext context) {
@ -663,18 +663,19 @@ class _InAppWebViewState extends State<InAppWebView> {
@override
void dispose() {
dynamic viewId = _controller.getViewId();
if (kIsWeb && WebPlatformManager.webViews.containsKey(viewId)) {
dynamic viewId = _controller?.getViewId();
if (viewId != null && kIsWeb && WebPlatformManager.webViews.containsKey(viewId)) {
WebPlatformManager.webViews.remove(viewId);
}
super.dispose();
_controller = null;
}
void _onPlatformViewCreated(int id) {
_controller = InAppWebViewController(id, widget);
widget.pullToRefreshController?.initMethodChannel(id);
if (widget.onWebViewCreated != null) {
widget.onWebViewCreated!(_controller);
widget.onWebViewCreated!(_controller!);
}
}
}

View File

@ -10,10 +10,22 @@ function error() {
# on macOS local IP can be found using something like $(ipconfig getifaddr en0)
# on linux local IP can be found using something like $(ifconfig en0 | grep "inet " | grep -Fv 127.0.0.1 | awk '{print $2}') or $(ip route get 1 | awk '{print $NF;exit}')
export NODE_SERVER_IP=$1
if [ -z "$1" ]; then
export NODE_SERVER_IP=$(ipconfig getifaddr en0)
fi
echo Node Server IP: $NODE_SERVER_IP
if [ -z "$NODE_SERVER_IP" ]; then
echo No Server IP found
jobs -p | xargs kill
exit 1
fi
PLATFORM=$2
FAILED=0
if [ $PLATFORM = "web" ]; then
if [ ! -z "$2" ] && [ $PLATFORM = "web" ]; then
$PROJECT_DIR/tool/chromedriver --port=4444 &
fi
@ -26,7 +38,7 @@ flutter --version
flutter clean
cd $PROJECT_DIR/example
flutter clean
if [ $PLATFORM = "web" ]; then
if [ ! -z "$2" ] && [ $PLATFORM = "web" ]; then
flutter driver --driver=test_driver/integration_test.dart --target=integration_test/webview_flutter_test.dart --device-id=chrome
else
flutter driver --driver=test_driver/integration_test.dart --target=integration_test/webview_flutter_test.dart