diff --git a/example/integration_test/in_app_webview/apple_pay_api.dart b/example/integration_test/in_app_webview/apple_pay_api.dart index eab58079..4734a7b4 100644 --- a/example/integration_test/in_app_webview/apple_pay_api.dart +++ b/example/integration_test/in_app_webview/apple_pay_api.dart @@ -6,11 +6,12 @@ import 'package:flutter_inappwebview/flutter_inappwebview.dart'; import 'package:flutter_test/flutter_test.dart'; void applePayAPI() { - final shouldSkip = kIsWeb || - ![ - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); + final shouldSkip = kIsWeb + ? true + : ![ + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); testWidgets('Apple Pay API enabled', (WidgetTester tester) async { final Completer pageLoaded = Completer(); diff --git a/example/integration_test/in_app_webview/audio_playback_policy.dart b/example/integration_test/in_app_webview/audio_playback_policy.dart index 0112c8da..6d4d2d5b 100644 --- a/example/integration_test/in_app_webview/audio_playback_policy.dart +++ b/example/integration_test/in_app_webview/audio_playback_policy.dart @@ -8,22 +8,22 @@ import 'package:flutter/widgets.dart'; import 'package:flutter_inappwebview/flutter_inappwebview.dart'; import 'package:flutter_test/flutter_test.dart'; -import '../constants.dart'; - void audioPlaybackPolicy() { - final shouldSkip = kIsWeb || ![ - TargetPlatform.android, - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); + final shouldSkip = kIsWeb + ? true + : ![ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); group('Audio playback policy', () { String audioTestBase64 = ""; setUpAll(() async { final ByteData audioData = - await rootBundle.load('test_assets/sample_audio.ogg'); + await rootBundle.load('test_assets/sample_audio.ogg'); final String base64AudioData = - base64Encode(Uint8List.view(audioData.buffer)); + base64Encode(Uint8List.view(audioData.buffer)); final String audioTest = ''' Audio auto play @@ -50,7 +50,7 @@ void audioPlaybackPolicy() { testWidgets('Auto media playback', (WidgetTester tester) async { Completer controllerCompleter = - Completer(); + Completer(); Completer pageStarted = Completer(); Completer pageLoaded = Completer(); @@ -66,8 +66,8 @@ void audioPlaybackPolicy() { controllerCompleter.complete(controller); }, initialSettings: InAppWebViewSettings( - javaScriptEnabled: true, - mediaPlaybackRequiresUserGesture: false), + javaScriptEnabled: true, + mediaPlaybackRequiresUserGesture: false), onLoadStart: (controller, url) { pageStarted.complete(); }, @@ -82,7 +82,7 @@ void audioPlaybackPolicy() { await pageLoaded.future; bool isPaused = - await controller.evaluateJavascript(source: 'isPaused();'); + await controller.evaluateJavascript(source: 'isPaused();'); expect(isPaused, false); controllerCompleter = Completer(); @@ -122,4 +122,4 @@ void audioPlaybackPolicy() { expect(isPaused, true); }); }, skip: shouldSkip); -} \ No newline at end of file +} diff --git a/example/integration_test/in_app_webview/clear_cache.dart b/example/integration_test/in_app_webview/clear_cache.dart index 0f66a508..b0686bc7 100644 --- a/example/integration_test/in_app_webview/clear_cache.dart +++ b/example/integration_test/in_app_webview/clear_cache.dart @@ -8,12 +8,13 @@ import 'package:flutter_test/flutter_test.dart'; import '../constants.dart'; void clearCache() { - final shouldSkip = kIsWeb || - ![ - TargetPlatform.android, - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); + final shouldSkip = kIsWeb + ? true + : ![ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); testWidgets('clearCache', (WidgetTester tester) async { final Completer controllerCompleter = Completer(); @@ -24,8 +25,7 @@ void clearCache() { 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 clearCache() { ), ); - final InAppWebViewController controller = - await controllerCompleter.future; + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; await expectLater(controller.clearCache(), completes); }, skip: shouldSkip); diff --git a/example/integration_test/in_app_webview/clear_client_cert_preferences.dart b/example/integration_test/in_app_webview/clear_client_cert_preferences.dart index ba730321..6cdf8144 100644 --- a/example/integration_test/in_app_webview/clear_client_cert_preferences.dart +++ b/example/integration_test/in_app_webview/clear_client_cert_preferences.dart @@ -1,17 +1,16 @@ import 'package:flutter/foundation.dart'; -import 'package:flutter/widgets.dart'; import 'package:flutter_inappwebview/flutter_inappwebview.dart'; import 'package:flutter_test/flutter_test.dart'; void clearClientCertPreferences() { - final shouldSkip = kIsWeb || - ![ - TargetPlatform.android, - ].contains(defaultTargetPlatform); + final shouldSkip = kIsWeb + ? true + : ![ + TargetPlatform.android, + ].contains(defaultTargetPlatform); test('clearClientCertPreferences', () async { await expectLater( - InAppWebViewController.clearClientCertPreferences(), - completes); + InAppWebViewController.clearClientCertPreferences(), completes); }, skip: shouldSkip); } diff --git a/example/integration_test/in_app_webview/clear_focus.dart b/example/integration_test/in_app_webview/clear_focus.dart index 28c5b2f0..b511de72 100644 --- a/example/integration_test/in_app_webview/clear_focus.dart +++ b/example/integration_test/in_app_webview/clear_focus.dart @@ -8,12 +8,13 @@ import 'package:flutter_test/flutter_test.dart'; import '../constants.dart'; void clearFocus() { - final shouldSkip = kIsWeb || - ![ - TargetPlatform.android, - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); + final shouldSkip = kIsWeb + ? true + : ![ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); testWidgets('clearFocus', (WidgetTester tester) async { final Completer controllerCompleter = Completer(); @@ -24,8 +25,7 @@ void clearFocus() { 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 clearFocus() { ), ); - final InAppWebViewController controller = - await controllerCompleter.future; + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; await expectLater(controller.clearFocus(), completes); diff --git a/example/integration_test/in_app_webview/clear_ssl_preferences.dart b/example/integration_test/in_app_webview/clear_ssl_preferences.dart index 601a0acb..c72efc2a 100644 --- a/example/integration_test/in_app_webview/clear_ssl_preferences.dart +++ b/example/integration_test/in_app_webview/clear_ssl_preferences.dart @@ -8,14 +8,14 @@ import 'package:flutter_test/flutter_test.dart'; import '../constants.dart'; void clearSslPreferences() { - final shouldSkip = kIsWeb || - ![ - TargetPlatform.android, - ].contains(defaultTargetPlatform); + final shouldSkip = kIsWeb + ? true + : ![ + TargetPlatform.android, + ].contains(defaultTargetPlatform); testWidgets('clearSslPreferences', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = Completer(); final Completer pageLoaded = Completer(); await tester.pumpWidget( @@ -23,8 +23,7 @@ void clearSslPreferences() { 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); }, @@ -35,8 +34,7 @@ void clearSslPreferences() { ), ); - final InAppWebViewController controller = - await controllerCompleter.future; + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; await expectLater(controller.clearSslPreferences(), completes); }, skip: shouldSkip); diff --git a/example/integration_test/in_app_webview/content_blocker.dart b/example/integration_test/in_app_webview/content_blocker.dart index 688ba964..827765d0 100644 --- a/example/integration_test/in_app_webview/content_blocker.dart +++ b/example/integration_test/in_app_webview/content_blocker.dart @@ -8,11 +8,13 @@ import 'package:flutter_test/flutter_test.dart'; import '../constants.dart'; void contentBlocker() { - final shouldSkip = kIsWeb || ![ - TargetPlatform.android, - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); + final shouldSkip = kIsWeb + ? true + : ![ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); testWidgets('Content Blocker', (WidgetTester tester) async { final Completer controllerCompleter = Completer(); @@ -22,23 +24,22 @@ void contentBlocker() { 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); }, - initialSettings: InAppWebViewSettings(clearCache: true, contentBlockers: [ - ContentBlocker( - trigger: - ContentBlockerTrigger(urlFilter: ".*", resourceType: [ - ContentBlockerTriggerResourceType.IMAGE, - ContentBlockerTriggerResourceType.STYLE_SHEET - ], ifTopUrl: [ - TEST_CROSS_PLATFORM_URL_1.toString() - ]), - action: ContentBlockerAction( - type: ContentBlockerActionType.BLOCK)) - ]), + initialSettings: + InAppWebViewSettings(clearCache: true, contentBlockers: [ + ContentBlocker( + trigger: ContentBlockerTrigger(urlFilter: ".*", resourceType: [ + ContentBlockerTriggerResourceType.IMAGE, + ContentBlockerTriggerResourceType.STYLE_SHEET + ], ifTopUrl: [ + TEST_CROSS_PLATFORM_URL_1.toString() + ]), + action: + ContentBlockerAction(type: ContentBlockerActionType.BLOCK)) + ]), onLoadStop: (controller, url) { pageLoaded.complete(); }, @@ -47,4 +48,4 @@ void contentBlocker() { ); await expectLater(pageLoaded.future, completes); }, skip: shouldSkip); -} \ No newline at end of file +} diff --git a/example/integration_test/in_app_webview/create_pdf.dart b/example/integration_test/in_app_webview/create_pdf.dart index f90cf0b8..37fc06b6 100644 --- a/example/integration_test/in_app_webview/create_pdf.dart +++ b/example/integration_test/in_app_webview/create_pdf.dart @@ -8,15 +8,15 @@ import 'package:flutter_test/flutter_test.dart'; import '../constants.dart'; void createPdf() { - final shouldSkip = kIsWeb || - ![ - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); + final shouldSkip = kIsWeb + ? true + : ![ + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); testWidgets('createPdf', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = Completer(); final Completer pageLoaded = Completer(); await tester.pumpWidget( @@ -24,8 +24,7 @@ void createPdf() { 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 +35,7 @@ void createPdf() { ), ); - final InAppWebViewController controller = - await controllerCompleter.future; + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; var pdfConfiguration = PDFConfiguration( diff --git a/example/integration_test/in_app_webview/get_certificate.dart b/example/integration_test/in_app_webview/get_certificate.dart index 1b64e580..e256a85a 100644 --- a/example/integration_test/in_app_webview/get_certificate.dart +++ b/example/integration_test/in_app_webview/get_certificate.dart @@ -8,12 +8,13 @@ import 'package:flutter_test/flutter_test.dart'; import '../constants.dart'; void getCertificate() { - final shouldSkip = kIsWeb || - ![ - TargetPlatform.android, - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); + final shouldSkip = kIsWeb + ? true + : ![ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); testWidgets('getCertificate', (WidgetTester tester) async { final Completer controllerCompleter = Completer(); @@ -24,8 +25,7 @@ void getCertificate() { 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 getCertificate() { ), ); - final InAppWebViewController controller = - await controllerCompleter.future; + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; var sslCertificate = await controller.getCertificate(); diff --git a/example/integration_test/in_app_webview/get_content_height.dart b/example/integration_test/in_app_webview/get_content_height.dart index 991ef373..d1cfb0b0 100644 --- a/example/integration_test/in_app_webview/get_content_height.dart +++ b/example/integration_test/in_app_webview/get_content_height.dart @@ -8,12 +8,13 @@ import 'package:flutter_test/flutter_test.dart'; import '../constants.dart'; void getContentHeight() { - final shouldSkip = !kIsWeb || - ![ - TargetPlatform.android, - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); + final shouldSkip = kIsWeb + ? false + : ![ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); var url = !kIsWeb ? TEST_CROSS_PLATFORM_URL_1 : TEST_WEB_PLATFORM_URL_1; @@ -26,8 +27,7 @@ void getContentHeight() { textDirection: TextDirection.ltr, child: InAppWebView( key: GlobalKey(), - initialUrlRequest: - URLRequest(url: url), + initialUrlRequest: URLRequest(url: url), onWebViewCreated: (controller) { controllerCompleter.complete(controller); }, @@ -38,8 +38,7 @@ void getContentHeight() { ), ); - final InAppWebViewController controller = - await controllerCompleter.future; + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; final contentHeight = await controller.getContentHeight(); diff --git a/example/integration_test/in_app_webview/get_current_web_view_package.dart b/example/integration_test/in_app_webview/get_current_web_view_package.dart index d58532e4..0f99cf30 100644 --- a/example/integration_test/in_app_webview/get_current_web_view_package.dart +++ b/example/integration_test/in_app_webview/get_current_web_view_package.dart @@ -1,13 +1,13 @@ import 'package:flutter/foundation.dart'; -import 'package:flutter/widgets.dart'; import 'package:flutter_inappwebview/flutter_inappwebview.dart'; import 'package:flutter_test/flutter_test.dart'; void getCurrentWebViewPackage() { - final shouldSkip = kIsWeb || - ![ - TargetPlatform.android, - ].contains(defaultTargetPlatform); + final shouldSkip = kIsWeb + ? true + : ![ + TargetPlatform.android, + ].contains(defaultTargetPlatform); test('getCurrentWebViewPackage', () async { expect(await InAppWebViewController.getCurrentWebViewPackage(), isNotNull); diff --git a/example/integration_test/in_app_webview/get_default_user_agent.dart b/example/integration_test/in_app_webview/get_default_user_agent.dart index 30d9256d..b0b90724 100644 --- a/example/integration_test/in_app_webview/get_default_user_agent.dart +++ b/example/integration_test/in_app_webview/get_default_user_agent.dart @@ -4,12 +4,13 @@ import 'package:flutter_inappwebview/flutter_inappwebview.dart'; import 'package:flutter_test/flutter_test.dart'; void getDefaultUserAgent() { - final shouldSkip = kIsWeb || - ![ - TargetPlatform.android, - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); + final shouldSkip = kIsWeb + ? true + : ![ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); test('getDefaultUserAgent', () async { expect(await InAppWebViewController.getDefaultUserAgent(), isNotNull); diff --git a/example/integration_test/in_app_webview/get_favicons.dart b/example/integration_test/in_app_webview/get_favicons.dart index df018340..e8626730 100644 --- a/example/integration_test/in_app_webview/get_favicons.dart +++ b/example/integration_test/in_app_webview/get_favicons.dart @@ -8,12 +8,13 @@ import 'package:flutter_test/flutter_test.dart'; import '../constants.dart'; void getFavicons() { - final shouldSkip = !kIsWeb || - ![ - TargetPlatform.android, - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); + final shouldSkip = kIsWeb + ? false + : ![ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); var url = !kIsWeb ? TEST_CROSS_PLATFORM_URL_1 : TEST_WEB_PLATFORM_URL_1; @@ -26,8 +27,7 @@ void getFavicons() { textDirection: TextDirection.ltr, child: InAppWebView( key: GlobalKey(), - initialUrlRequest: - URLRequest(url: url), + initialUrlRequest: URLRequest(url: url), onWebViewCreated: (controller) { controllerCompleter.complete(controller); }, @@ -38,8 +38,7 @@ void getFavicons() { ), ); - final InAppWebViewController controller = - await controllerCompleter.future; + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; final List? favicons = await controller.getFavicons(); diff --git a/example/integration_test/in_app_webview/get_html.dart b/example/integration_test/in_app_webview/get_html.dart index 192176cf..c69f6a70 100644 --- a/example/integration_test/in_app_webview/get_html.dart +++ b/example/integration_test/in_app_webview/get_html.dart @@ -8,12 +8,13 @@ import 'package:flutter_test/flutter_test.dart'; import '../constants.dart'; void getHtml() { - final shouldSkip = !kIsWeb || - ![ - TargetPlatform.android, - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); + final shouldSkip = kIsWeb + ? false + : ![ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); var url = !kIsWeb ? TEST_CROSS_PLATFORM_URL_1 : TEST_WEB_PLATFORM_URL_1; @@ -26,8 +27,7 @@ void getHtml() { textDirection: TextDirection.ltr, child: InAppWebView( key: GlobalKey(), - initialUrlRequest: - URLRequest(url: url), + initialUrlRequest: URLRequest(url: url), onWebViewCreated: (controller) { controllerCompleter.complete(controller); }, @@ -38,8 +38,7 @@ void getHtml() { ), ); - final InAppWebViewController controller = - await controllerCompleter.future; + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; final String? html = await controller.getHtml(); diff --git a/example/integration_test/in_app_webview/get_meta_tags.dart b/example/integration_test/in_app_webview/get_meta_tags.dart index a89fed38..a13bd1d2 100644 --- a/example/integration_test/in_app_webview/get_meta_tags.dart +++ b/example/integration_test/in_app_webview/get_meta_tags.dart @@ -8,12 +8,13 @@ import 'package:flutter_test/flutter_test.dart'; import '../constants.dart'; void getMetaTags() { - final shouldSkip = !kIsWeb || - ![ - TargetPlatform.android, - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); + final shouldSkip = kIsWeb + ? false + : ![ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); var url = !kIsWeb ? TEST_CROSS_PLATFORM_URL_1 : TEST_WEB_PLATFORM_URL_1; @@ -26,8 +27,7 @@ void getMetaTags() { textDirection: TextDirection.ltr, child: InAppWebView( key: GlobalKey(), - initialUrlRequest: - URLRequest(url: url), + initialUrlRequest: URLRequest(url: url), onWebViewCreated: (controller) { controllerCompleter.complete(controller); }, @@ -38,8 +38,7 @@ void getMetaTags() { ), ); - final InAppWebViewController controller = - await controllerCompleter.future; + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; List metaTags = await controller.getMetaTags(); diff --git a/example/integration_test/in_app_webview/get_meta_theme_color.dart b/example/integration_test/in_app_webview/get_meta_theme_color.dart index e9105d33..71f5fa99 100644 --- a/example/integration_test/in_app_webview/get_meta_theme_color.dart +++ b/example/integration_test/in_app_webview/get_meta_theme_color.dart @@ -8,12 +8,13 @@ import 'package:flutter_test/flutter_test.dart'; import '../constants.dart'; void getMetaThemeColor() { - final shouldSkip = !kIsWeb || - ![ - TargetPlatform.android, - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); + final shouldSkip = kIsWeb + ? false + : ![ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); var url = !kIsWeb ? TEST_URL_1 : TEST_WEB_PLATFORM_URL_1; @@ -37,8 +38,7 @@ void getMetaThemeColor() { ), ); - final InAppWebViewController controller = - await controllerCompleter.future; + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; expect(await controller.getMetaThemeColor(), isNotNull); diff --git a/example/integration_test/in_app_webview/get_original_url.dart b/example/integration_test/in_app_webview/get_original_url.dart index 35b1d19e..5a1ef667 100644 --- a/example/integration_test/in_app_webview/get_original_url.dart +++ b/example/integration_test/in_app_webview/get_original_url.dart @@ -8,18 +8,18 @@ import 'package:flutter_test/flutter_test.dart'; import '../constants.dart'; void getOriginalUrl() { - final shouldSkip = !kIsWeb || - ![ - TargetPlatform.android, - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); + final shouldSkip = kIsWeb + ? false + : ![ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); var url = !kIsWeb ? TEST_URL_1 : TEST_WEB_PLATFORM_URL_1; testWidgets('getOriginalUrl', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = Completer(); final Completer pageLoaded = Completer(); await tester.pumpWidget( @@ -27,8 +27,7 @@ void getOriginalUrl() { textDirection: TextDirection.ltr, child: InAppWebView( key: GlobalKey(), - initialUrlRequest: - URLRequest(url: url), + initialUrlRequest: URLRequest(url: url), onWebViewCreated: (controller) { controllerCompleter.complete(controller); }, @@ -39,8 +38,7 @@ void getOriginalUrl() { ), ); - final InAppWebViewController controller = - await controllerCompleter.future; + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; var originUrl = (await controller.getOriginalUrl())?.toString(); expect(originUrl, url.toString()); diff --git a/example/integration_test/in_app_webview/get_progress.dart b/example/integration_test/in_app_webview/get_progress.dart index e0072bd8..9ebd33cb 100644 --- a/example/integration_test/in_app_webview/get_progress.dart +++ b/example/integration_test/in_app_webview/get_progress.dart @@ -8,12 +8,13 @@ import 'package:flutter_test/flutter_test.dart'; import '../constants.dart'; void getProgress() { - final shouldSkip = kIsWeb || - ![ - TargetPlatform.android, - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); + final shouldSkip = kIsWeb + ? true + : ![ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); testWidgets('getProgress', (WidgetTester tester) async { final Completer controllerCompleter = Completer(); @@ -24,8 +25,7 @@ void getProgress() { 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 getProgress() { ), ); - final InAppWebViewController controller = - await controllerCompleter.future; + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; final int? progress = await controller.getProgress(); diff --git a/example/integration_test/in_app_webview/get_title.dart b/example/integration_test/in_app_webview/get_title.dart index da3e03ca..427c5ab0 100644 --- a/example/integration_test/in_app_webview/get_title.dart +++ b/example/integration_test/in_app_webview/get_title.dart @@ -9,11 +9,13 @@ import 'package:flutter_test/flutter_test.dart'; import '../constants.dart'; void getTitle() { - final shouldSkip = !kIsWeb || ![ - TargetPlatform.android, - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); + final shouldSkip = kIsWeb + ? false + : ![ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); final String getTitleTest = ''' @@ -24,15 +26,14 @@ void getTitle() { '''; final String getTitleTestBase64 = - base64Encode(const Utf8Encoder().convert(getTitleTest)); + base64Encode(const Utf8Encoder().convert(getTitleTest)); - var url = !kIsWeb ? Uri.parse( - 'data:text/html;charset=utf-8;base64,$getTitleTestBase64') : - TEST_WEB_PLATFORM_URL_1; + var url = !kIsWeb + ? Uri.parse('data:text/html;charset=utf-8;base64,$getTitleTestBase64') + : TEST_WEB_PLATFORM_URL_1; var expectedValue = !kIsWeb ? 'Some title' : 'page'; testWidgets('getTitle', (WidgetTester tester) async { - final Completer pageStarted = Completer(); final Completer pageLoaded = Completer(); final Completer controllerCompleter = Completer(); @@ -41,8 +42,7 @@ void getTitle() { Directionality( textDirection: TextDirection.ltr, child: InAppWebView( - initialUrlRequest: URLRequest( - url: url), + initialUrlRequest: URLRequest(url: url), onWebViewCreated: (controller) { controllerCompleter.complete(controller); }, @@ -56,12 +56,11 @@ void getTitle() { ), ); - final InAppWebViewController controller = - await controllerCompleter.future; + final InAppWebViewController controller = await controllerCompleter.future; await pageStarted.future; await pageLoaded.future; final String? title = await controller.getTitle(); expect(title, expectedValue); }, skip: shouldSkip); -} \ No newline at end of file +} diff --git a/example/integration_test/in_app_webview/handles_url_scheme.dart b/example/integration_test/in_app_webview/handles_url_scheme.dart index 5cf0ada9..e501856a 100644 --- a/example/integration_test/in_app_webview/handles_url_scheme.dart +++ b/example/integration_test/in_app_webview/handles_url_scheme.dart @@ -3,11 +3,12 @@ import 'package:flutter_inappwebview/flutter_inappwebview.dart'; import 'package:flutter_test/flutter_test.dart'; void handlesURLScheme() { - final shouldSkip = kIsWeb || - ![ - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); + final shouldSkip = kIsWeb + ? true + : ![ + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); test('handlesURLScheme', () async { expect(await InAppWebViewController.handlesURLScheme("http"), true); diff --git a/example/integration_test/in_app_webview/http_auth_credential_database.dart b/example/integration_test/in_app_webview/http_auth_credential_database.dart index 2a1e9bcd..d2d65bab 100644 --- a/example/integration_test/in_app_webview/http_auth_credential_database.dart +++ b/example/integration_test/in_app_webview/http_auth_credential_database.dart @@ -8,12 +8,13 @@ import 'package:flutter_test/flutter_test.dart'; import '../.env.dart'; void httpAuthCredentialDatabase() { - final shouldSkip = kIsWeb || - ![ - TargetPlatform.android, - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); + final shouldSkip = kIsWeb + ? true + : ![ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); group('Http Auth Credential Database', () { testWidgets('use saved credentials', (WidgetTester tester) async { diff --git a/example/integration_test/in_app_webview/initial_url_request.dart b/example/integration_test/in_app_webview/initial_url_request.dart index ec0fbcb7..1668cfe4 100644 --- a/example/integration_test/in_app_webview/initial_url_request.dart +++ b/example/integration_test/in_app_webview/initial_url_request.dart @@ -8,21 +8,23 @@ import 'package:flutter_test/flutter_test.dart'; import '../constants.dart'; void initialUrlRequest() { - final shouldSkip = !kIsWeb || - ![ - TargetPlatform.android, - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); - - group('initial url request', () { - final shouldSkipTest1 = !kIsWeb || - ![ + final shouldSkip = kIsWeb + ? false + : ![ TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS, ].contains(defaultTargetPlatform); + group('initial url request', () { + final shouldSkipTest1 = kIsWeb + ? false + : ![ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); + testWidgets('basic', (WidgetTester tester) async { final Completer controllerCompleter = Completer(); await tester.pumpWidget( @@ -45,11 +47,12 @@ void initialUrlRequest() { expect(currentUrl, TEST_CROSS_PLATFORM_URL_1.toString()); }, skip: shouldSkipTest1); - final shouldSkipTest2 = kIsWeb || - ![ - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); + final shouldSkipTest2 = kIsWeb + ? true + : ![ + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); testWidgets('launches with allowsBackForwardNavigationGestures true', (WidgetTester tester) async { @@ -62,8 +65,7 @@ void initialUrlRequest() { height: 300, child: InAppWebView( key: GlobalKey(), - initialUrlRequest: - URLRequest(url: TEST_URL_1), + initialUrlRequest: URLRequest(url: TEST_URL_1), initialSettings: InAppWebViewSettings( allowsBackForwardNavigationGestures: true), onWebViewCreated: (controller) { diff --git a/example/integration_test/in_app_webview/inject_css.dart b/example/integration_test/in_app_webview/inject_css.dart index e436de2e..e2831919 100644 --- a/example/integration_test/in_app_webview/inject_css.dart +++ b/example/integration_test/in_app_webview/inject_css.dart @@ -8,12 +8,13 @@ import 'package:flutter_test/flutter_test.dart'; import '../constants.dart'; void injectCSS() { - final shouldSkip = !kIsWeb || - ![ - TargetPlatform.android, - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); + final shouldSkip = kIsWeb + ? false + : ![ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); var url = !kIsWeb ? TEST_URL_ABOUT_BLANK : TEST_WEB_PLATFORM_URL_1; @@ -39,7 +40,7 @@ void injectCSS() { ); final InAppWebViewController controller = - await controllerCompleter.future; + await controllerCompleter.future; await pageLoaded.future; await controller.injectCSSCode(source: """ @@ -77,7 +78,7 @@ void injectCSS() { ); final InAppWebViewController controller = - await controllerCompleter.future; + await controllerCompleter.future; await pageLoaded.future; await controller.injectCSSFileFromUrl( @@ -112,7 +113,7 @@ void injectCSS() { ); final InAppWebViewController controller = - await controllerCompleter.future; + await controllerCompleter.future; await pageLoaded.future; await controller.injectCSSFileFromAsset( diff --git a/example/integration_test/in_app_webview/inject_javascript_file.dart b/example/integration_test/in_app_webview/inject_javascript_file.dart index 8edf6974..a94a25ba 100644 --- a/example/integration_test/in_app_webview/inject_javascript_file.dart +++ b/example/integration_test/in_app_webview/inject_javascript_file.dart @@ -8,12 +8,13 @@ import 'package:flutter_test/flutter_test.dart'; import '../constants.dart'; void injectJavascriptFile() { - final shouldSkip = !kIsWeb || - ![ - TargetPlatform.android, - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); + final shouldSkip = kIsWeb + ? false + : ![ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); var url = !kIsWeb ? TEST_URL_ABOUT_BLANK : TEST_WEB_PLATFORM_URL_1; @@ -41,12 +42,12 @@ void injectJavascriptFile() { ); final InAppWebViewController controller = - await controllerCompleter.future; + await controllerCompleter.future; await pageLoaded.future; await controller.injectJavascriptFileFromUrl( urlFile: - Uri.parse('https://www.notawebsite..com/jquery-3.3.1.min.js'), + Uri.parse('https://www.notawebsite..com/jquery-3.3.1.min.js'), scriptHtmlTagAttributes: ScriptHtmlTagAttributes( id: 'jquery-error', onError: () { @@ -101,7 +102,7 @@ void injectJavascriptFile() { ); final InAppWebViewController controller = - await controllerCompleter.future; + await controllerCompleter.future; await pageLoaded.future; await controller.injectJavascriptFileFromAsset( diff --git a/example/integration_test/in_app_webview/intercept_ajax_request.dart b/example/integration_test/in_app_webview/intercept_ajax_request.dart index 6dae7320..f891dbe9 100644 --- a/example/integration_test/in_app_webview/intercept_ajax_request.dart +++ b/example/integration_test/in_app_webview/intercept_ajax_request.dart @@ -9,12 +9,13 @@ import 'package:flutter_test/flutter_test.dart'; import '../.env.dart'; void interceptAjaxRequest() { - final shouldSkip = kIsWeb || - ![ - TargetPlatform.android, - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); + final shouldSkip = kIsWeb + ? true + : ![ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); group('intercept ajax request', () { testWidgets('send string data', (WidgetTester tester) async { diff --git a/example/integration_test/in_app_webview/intercept_fetch_request.dart b/example/integration_test/in_app_webview/intercept_fetch_request.dart index bb7b1a87..a580ecf1 100644 --- a/example/integration_test/in_app_webview/intercept_fetch_request.dart +++ b/example/integration_test/in_app_webview/intercept_fetch_request.dart @@ -9,12 +9,13 @@ import 'package:flutter_test/flutter_test.dart'; import '../.env.dart'; void interceptFetchRequest() { - final shouldSkip = kIsWeb || - ![ - TargetPlatform.android, - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); + final shouldSkip = kIsWeb + ? true + : ![ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); group('intercept fetch request', () { testWidgets('send string data', (WidgetTester tester) async { diff --git a/example/integration_test/in_app_webview/is_loading.dart b/example/integration_test/in_app_webview/is_loading.dart index b0630bf4..2dbe9cf9 100644 --- a/example/integration_test/in_app_webview/is_loading.dart +++ b/example/integration_test/in_app_webview/is_loading.dart @@ -8,12 +8,13 @@ import 'package:flutter_test/flutter_test.dart'; import '../constants.dart'; void isLoading() { - final shouldSkip = kIsWeb || - ![ - TargetPlatform.android, - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); + final shouldSkip = kIsWeb + ? true + : ![ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); testWidgets('isLoading', (WidgetTester tester) async { final Completer controllerCompleter = Completer(); @@ -25,8 +26,7 @@ void isLoading() { textDirection: TextDirection.ltr, child: InAppWebView( key: GlobalKey(), - initialUrlRequest: - URLRequest(url: TEST_CROSS_PLATFORM_URL_1), + initialUrlRequest: URLRequest(url: TEST_CROSS_PLATFORM_URL_1), initialSettings: InAppWebViewSettings(clearCache: true), onWebViewCreated: (controller) { controllerCompleter.complete(controller); @@ -41,8 +41,7 @@ void isLoading() { ), ); - final InAppWebViewController controller = - await controllerCompleter.future; + final InAppWebViewController controller = await controllerCompleter.future; await pageStarted.future; expect(await controller.isLoading(), true); diff --git a/example/integration_test/in_app_webview/is_secure_context.dart b/example/integration_test/in_app_webview/is_secure_context.dart index b0b26b50..7a3464c3 100644 --- a/example/integration_test/in_app_webview/is_secure_context.dart +++ b/example/integration_test/in_app_webview/is_secure_context.dart @@ -8,27 +8,27 @@ import 'package:flutter_test/flutter_test.dart'; import '../constants.dart'; void isSecureContext() { - final shouldSkip = !kIsWeb || - ![ - TargetPlatform.android, - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); + final shouldSkip = kIsWeb + ? false + : ![ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); var url = !kIsWeb ? TEST_CROSS_PLATFORM_URL_1 : TEST_WEB_PLATFORM_URL_1; testWidgets('isSecureContext', (WidgetTester tester) async { final Completer controllerCompleter = Completer(); final StreamController pageLoads = - StreamController.broadcast(); + StreamController.broadcast(); await tester.pumpWidget( Directionality( textDirection: TextDirection.ltr, child: InAppWebView( key: GlobalKey(), - initialUrlRequest: - URLRequest(url: url), + initialUrlRequest: URLRequest(url: url), onWebViewCreated: (controller) { controllerCompleter.complete(controller); }, @@ -39,8 +39,7 @@ void isSecureContext() { ), ); - final InAppWebViewController controller = - await controllerCompleter.future; + final InAppWebViewController controller = await controllerCompleter.future; await pageLoads.stream.first; expect(await controller.isSecureContext(), true); diff --git a/example/integration_test/in_app_webview/javascript_code_evaluation.dart b/example/integration_test/in_app_webview/javascript_code_evaluation.dart index e2efc808..b05f48d5 100644 --- a/example/integration_test/in_app_webview/javascript_code_evaluation.dart +++ b/example/integration_test/in_app_webview/javascript_code_evaluation.dart @@ -8,21 +8,23 @@ import 'package:flutter_test/flutter_test.dart'; import '../constants.dart'; void javascriptCodeEvaluation() { - final shouldSkip = !kIsWeb || - ![ - TargetPlatform.android, - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); - - group('javascript code evaluation', () { - final shouldSkipTest1 = !kIsWeb || - ![ + final shouldSkip = kIsWeb + ? false + : ![ TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS, ].contains(defaultTargetPlatform); + group('javascript code evaluation', () { + final shouldSkipTest1 = kIsWeb + ? false + : ![ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); + testWidgets('evaluateJavascript', (WidgetTester tester) async { final Completer controllerCompleter = Completer(); final Completer pageLoaded = Completer(); @@ -57,12 +59,13 @@ void javascriptCodeEvaluation() { mapEquals(result[3]?.cast(), {"foo": "baz"}), true); }, skip: shouldSkipTest1); - final shouldSkipTest2 = kIsWeb || - ![ - TargetPlatform.android, - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); + final shouldSkipTest2 = kIsWeb + ? true + : ![ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); testWidgets('evaluateJavascript with content world', (WidgetTester tester) async { @@ -100,12 +103,13 @@ void javascriptCodeEvaluation() { expect(result, 49); }, skip: shouldSkipTest2); - final shouldSkipTest3 = kIsWeb || - ![ - TargetPlatform.android, - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); + final shouldSkipTest3 = kIsWeb + ? true + : ![ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); testWidgets('callAsyncJavaScript', (WidgetTester tester) async { final Completer controllerCompleter = Completer(); @@ -159,12 +163,13 @@ void javascriptCodeEvaluation() { expect(result.error, 'error message'); }, skip: shouldSkipTest3); - final shouldSkipTest4 = kIsWeb || - ![ - TargetPlatform.android, - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); + final shouldSkipTest4 = kIsWeb + ? true + : ![ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); testWidgets('callAsyncJavaScript with content world', (WidgetTester tester) async { diff --git a/example/integration_test/in_app_webview/javascript_dialogs.dart b/example/integration_test/in_app_webview/javascript_dialogs.dart index 8d026c39..5c7ba4eb 100644 --- a/example/integration_test/in_app_webview/javascript_dialogs.dart +++ b/example/integration_test/in_app_webview/javascript_dialogs.dart @@ -5,15 +5,14 @@ import 'package:flutter/widgets.dart'; import 'package:flutter_inappwebview/flutter_inappwebview.dart'; import 'package:flutter_test/flutter_test.dart'; -import '../constants.dart'; - void javascriptDialogs() { - final shouldSkip = kIsWeb || - ![ - TargetPlatform.android, - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); + final shouldSkip = kIsWeb + ? true + : ![ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); testWidgets('javascript dialogs', (WidgetTester tester) async { final Completer controllerCompleter = Completer(); diff --git a/example/integration_test/in_app_webview/javascript_handler.dart b/example/integration_test/in_app_webview/javascript_handler.dart index 0380701f..d73476eb 100644 --- a/example/integration_test/in_app_webview/javascript_handler.dart +++ b/example/integration_test/in_app_webview/javascript_handler.dart @@ -8,11 +8,13 @@ import 'package:flutter_test/flutter_test.dart'; import '../util.dart'; void javascriptHandler() { - final shouldSkip = kIsWeb || ![ - TargetPlatform.android, - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); + final shouldSkip = kIsWeb + ? true + : ![ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); testWidgets('JavaScript Handler', (WidgetTester tester) async { final Completer controllerCompleter = Completer(); @@ -27,7 +29,7 @@ void javascriptHandler() { child: InAppWebView( key: GlobalKey(), initialFile: - "test_assets/in_app_webview_javascript_handler_test.html", + "test_assets/in_app_webview_javascript_handler_test.html", onWebViewCreated: (controller) { controllerCompleter.complete(controller); @@ -44,10 +46,10 @@ void javascriptHandler() { messagesReceived.add(args[0] as int); messagesReceived.add(args[1] as bool); messagesReceived.add(args[2] as List?); - messagesReceived.add(args[3]?.cast() - as Map?); - messagesReceived.add(args[4]?.cast() - as Map?); + messagesReceived.add( + args[3]?.cast() as Map?); + messagesReceived.add( + args[4]?.cast() as Map?); handlerFooWithArgs.complete(); }); }, @@ -69,12 +71,11 @@ void javascriptHandler() { expect(messagesReceived[0], 1); expect(messagesReceived[1], true); - expect( - listEquals(messagesReceived[2] as List?, ["bar", 5]), true); + expect(listEquals(messagesReceived[2] as List?, ["bar", 5]), true); expect(mapEquals(messagesReceived[3], {"foo": "baz"}), true); expect( mapEquals( messagesReceived[4], {"bar": "bar_value", "baz": "baz_value"}), true); }, skip: shouldSkip); -} \ No newline at end of file +} diff --git a/example/integration_test/in_app_webview/load_data.dart b/example/integration_test/in_app_webview/load_data.dart index e05e40e3..d8e11013 100644 --- a/example/integration_test/in_app_webview/load_data.dart +++ b/example/integration_test/in_app_webview/load_data.dart @@ -8,17 +8,18 @@ import 'package:flutter_test/flutter_test.dart'; import '../constants.dart'; void loadData() { - final shouldSkip = !kIsWeb || - ![ - TargetPlatform.android, - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); + final shouldSkip = kIsWeb + ? false + : ![ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); testWidgets('loadData', (WidgetTester tester) async { final Completer controllerCompleter = Completer(); final StreamController pageLoads = - StreamController.broadcast(); + StreamController.broadcast(); await tester.pumpWidget( Directionality( @@ -36,8 +37,7 @@ void loadData() { ), ); - final InAppWebViewController controller = - await controllerCompleter.future; + final InAppWebViewController controller = await controllerCompleter.future; await pageLoads.stream.first; final data = """ @@ -70,7 +70,7 @@ void loadData() { if (!kIsWeb) { expect(currentUrl, TEST_CROSS_PLATFORM_URL_1.toString()); } else { - expect(currentUrl, 'data:$mimeType,' + Uri.encodeFull(data)) ; + expect(currentUrl, 'data:$mimeType,' + Uri.encodeFull(data)); } pageLoads.close(); diff --git a/example/integration_test/in_app_webview/load_file.dart b/example/integration_test/in_app_webview/load_file.dart index f9f46801..e42141ad 100644 --- a/example/integration_test/in_app_webview/load_file.dart +++ b/example/integration_test/in_app_webview/load_file.dart @@ -8,17 +8,18 @@ import 'package:flutter_test/flutter_test.dart'; import '../constants.dart'; void loadFile() { - final shouldSkip = !kIsWeb || - ![ - TargetPlatform.android, - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); + final shouldSkip = kIsWeb + ? false + : ![ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); testWidgets('loadFile', (WidgetTester tester) async { final Completer controllerCompleter = Completer(); final StreamController pageLoads = - StreamController.broadcast(); + StreamController.broadcast(); await tester.pumpWidget( Directionality( @@ -36,8 +37,7 @@ void loadFile() { ), ); - final InAppWebViewController controller = - await controllerCompleter.future; + final InAppWebViewController controller = await controllerCompleter.future; await pageLoads.stream.first; await controller.loadFile( diff --git a/example/integration_test/in_app_webview/load_file_url.dart b/example/integration_test/in_app_webview/load_file_url.dart index aadf088f..85c6f794 100644 --- a/example/integration_test/in_app_webview/load_file_url.dart +++ b/example/integration_test/in_app_webview/load_file_url.dart @@ -8,7 +8,7 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:path_provider/path_provider.dart'; void loadFileUrl() { - final shouldSkip = kIsWeb || + final shouldSkip = kIsWeb ? true : ![ TargetPlatform.iOS, TargetPlatform.macOS, diff --git a/example/integration_test/in_app_webview/load_url.dart b/example/integration_test/in_app_webview/load_url.dart index 09eca075..7a8c97f4 100644 --- a/example/integration_test/in_app_webview/load_url.dart +++ b/example/integration_test/in_app_webview/load_url.dart @@ -8,14 +8,14 @@ import 'package:flutter_test/flutter_test.dart'; import '../constants.dart'; void loadUrl() { - final shouldSkip = !kIsWeb || + final shouldSkip = kIsWeb ? false : ![ TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS, ].contains(defaultTargetPlatform); - testWidgets('reload', (WidgetTester tester) async { + testWidgets('loadUrl', (WidgetTester tester) async { final Completer controllerCompleter = Completer(); final StreamController pageLoads = StreamController.broadcast(); @@ -26,7 +26,7 @@ void loadUrl() { child: InAppWebView( key: GlobalKey(), initialUrlRequest: - URLRequest(url: Uri.parse('https://github.com/flutter')), + URLRequest(url: TEST_CROSS_PLATFORM_URL_1), onWebViewCreated: (controller) { controllerCompleter.complete(controller); }, @@ -38,13 +38,14 @@ void loadUrl() { ); final InAppWebViewController controller = await controllerCompleter.future; - String? url = await pageLoads.stream.first; - expect(url, 'https://github.com/flutter'); + var url = await pageLoads.stream.first; + expect(url, TEST_CROSS_PLATFORM_URL_1.toString()); - await controller.reload(); + await controller.loadUrl( + urlRequest: URLRequest(url: TEST_CROSS_PLATFORM_URL_2)); url = await pageLoads.stream.first; - expect(url, 'https://github.com/flutter'); + expect(url, TEST_CROSS_PLATFORM_URL_2.toString()); pageLoads.close(); - }); + }, skip: shouldSkip); } diff --git a/example/integration_test/in_app_webview/on_console_message.dart b/example/integration_test/in_app_webview/on_console_message.dart index 3275d683..b9a71605 100644 --- a/example/integration_test/in_app_webview/on_console_message.dart +++ b/example/integration_test/in_app_webview/on_console_message.dart @@ -8,12 +8,13 @@ import 'package:flutter_test/flutter_test.dart'; import '../constants.dart'; void onConsoleMessage() { - final shouldSkip = !kIsWeb || - ![ - TargetPlatform.android, - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); + final shouldSkip = kIsWeb + ? false + : ![ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); testWidgets('onConsoleMessage', (WidgetTester tester) async { final Completer controllerCompleter = Completer(); diff --git a/example/integration_test/in_app_webview/on_download_start_request.dart b/example/integration_test/in_app_webview/on_download_start_request.dart index 85a9b080..cd7eb3e9 100644 --- a/example/integration_test/in_app_webview/on_download_start_request.dart +++ b/example/integration_test/in_app_webview/on_download_start_request.dart @@ -8,12 +8,13 @@ import 'package:flutter_test/flutter_test.dart'; import '../.env.dart'; void onDownloadStartRequest() { - final shouldSkip = kIsWeb || - ![ - TargetPlatform.android, - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); + final shouldSkip = kIsWeb + ? true + : ![ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); testWidgets('onDownloadStartRequest', (WidgetTester tester) async { final Completer controllerCompleter = Completer(); diff --git a/example/integration_test/in_app_webview/on_find_result_received.dart b/example/integration_test/in_app_webview/on_find_result_received.dart index 00bfd2b6..09fd6838 100644 --- a/example/integration_test/in_app_webview/on_find_result_received.dart +++ b/example/integration_test/in_app_webview/on_find_result_received.dart @@ -8,12 +8,13 @@ import 'package:flutter_test/flutter_test.dart'; import '../constants.dart'; void onFindResultReceived() { - final shouldSkip = kIsWeb || - ![ - TargetPlatform.android, - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); + final shouldSkip = kIsWeb + ? true + : ![ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); testWidgets('onFindResultReceived', (WidgetTester tester) async { final Completer controllerCompleter = Completer(); diff --git a/example/integration_test/in_app_webview/on_js_before_unload.dart b/example/integration_test/in_app_webview/on_js_before_unload.dart index e0da3d38..70529db0 100644 --- a/example/integration_test/in_app_webview/on_js_before_unload.dart +++ b/example/integration_test/in_app_webview/on_js_before_unload.dart @@ -8,10 +8,11 @@ import 'package:flutter_test/flutter_test.dart'; import '../constants.dart'; void onJsBeforeUnload() { - final shouldSkip = kIsWeb || - ![ - TargetPlatform.android, - ].contains(defaultTargetPlatform); + final shouldSkip = kIsWeb + ? true + : ![ + TargetPlatform.android, + ].contains(defaultTargetPlatform); testWidgets('onJsBeforeUnload', (WidgetTester tester) async { final Completer controllerCompleter = Completer(); @@ -23,8 +24,7 @@ void onJsBeforeUnload() { textDirection: TextDirection.ltr, child: InAppWebView( key: GlobalKey(), - initialUrlRequest: - URLRequest(url: TEST_URL_1), + initialUrlRequest: URLRequest(url: TEST_URL_1), onWebViewCreated: (controller) { controllerCompleter.complete(controller); }, @@ -48,8 +48,7 @@ void onJsBeforeUnload() { ), ); - final InAppWebViewController controller = - await controllerCompleter.future; + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; await controller.evaluateJavascript( source: "window.location.href = '$TEST_URL_1';"); diff --git a/example/integration_test/in_app_webview/on_load_error.dart b/example/integration_test/in_app_webview/on_load_error.dart index 5c83c419..0667adaf 100644 --- a/example/integration_test/in_app_webview/on_load_error.dart +++ b/example/integration_test/in_app_webview/on_load_error.dart @@ -8,12 +8,13 @@ import 'package:flutter_test/flutter_test.dart'; import '../constants.dart'; void onLoadError() { - final shouldSkip = kIsWeb || - ![ - TargetPlatform.android, - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); + final shouldSkip = kIsWeb + ? true + : ![ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); group('onLoadError', () { testWidgets('invalid url', (WidgetTester tester) async { diff --git a/example/integration_test/in_app_webview/on_load_http_error.dart b/example/integration_test/in_app_webview/on_load_http_error.dart index e423bd94..e6795d96 100644 --- a/example/integration_test/in_app_webview/on_load_http_error.dart +++ b/example/integration_test/in_app_webview/on_load_http_error.dart @@ -8,11 +8,13 @@ import 'package:flutter_test/flutter_test.dart'; import '../constants.dart'; void onLoadHttpError() { - final shouldSkip = kIsWeb || ![ - TargetPlatform.android, - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); + final shouldSkip = kIsWeb + ? true + : ![ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); testWidgets('onLoadHttpError', (WidgetTester tester) async { final Completer errorUrlCompleter = Completer(); @@ -23,8 +25,7 @@ void onLoadHttpError() { textDirection: TextDirection.ltr, child: InAppWebView( key: GlobalKey(), - initialUrlRequest: - URLRequest(url: TEST_URL_404), + initialUrlRequest: URLRequest(url: TEST_URL_404), onLoadHttpError: (controller, url, statusCode, description) async { errorUrlCompleter.complete(url.toString()); statusCodeCompleter.complete(statusCode); @@ -39,4 +40,4 @@ void onLoadHttpError() { expect(url, TEST_URL_404.toString()); expect(code, 404); }, skip: shouldSkip); -} \ No newline at end of file +} diff --git a/example/integration_test/in_app_webview/on_load_resource.dart b/example/integration_test/in_app_webview/on_load_resource.dart index 2578c57f..8e744bc3 100644 --- a/example/integration_test/in_app_webview/on_load_resource.dart +++ b/example/integration_test/in_app_webview/on_load_resource.dart @@ -5,15 +5,14 @@ import 'package:flutter/widgets.dart'; import 'package:flutter_inappwebview/flutter_inappwebview.dart'; import 'package:flutter_test/flutter_test.dart'; -import '../constants.dart'; - void onLoadResource() { - final shouldSkip = kIsWeb || - ![ - TargetPlatform.android, - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); + final shouldSkip = kIsWeb + ? true + : ![ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); testWidgets('onLoadResource', (WidgetTester tester) async { List resourceList = [ diff --git a/example/integration_test/in_app_webview/on_load_resource_custom_scheme.dart b/example/integration_test/in_app_webview/on_load_resource_custom_scheme.dart index 76196ad6..b961105c 100644 --- a/example/integration_test/in_app_webview/on_load_resource_custom_scheme.dart +++ b/example/integration_test/in_app_webview/on_load_resource_custom_scheme.dart @@ -7,12 +7,13 @@ import 'package:flutter_inappwebview/flutter_inappwebview.dart'; import 'package:flutter_test/flutter_test.dart'; void onLoadResourceCustomScheme() { - final shouldSkip = kIsWeb || - ![ - TargetPlatform.android, - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); + final shouldSkip = kIsWeb + ? true + : ![ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); testWidgets('onLoadResourceCustomScheme', (WidgetTester tester) async { final Completer controllerCompleter = Completer(); diff --git a/example/integration_test/in_app_webview/on_navigation_response.dart b/example/integration_test/in_app_webview/on_navigation_response.dart index 99a09497..47db1b53 100644 --- a/example/integration_test/in_app_webview/on_navigation_response.dart +++ b/example/integration_test/in_app_webview/on_navigation_response.dart @@ -8,11 +8,12 @@ import 'package:flutter_test/flutter_test.dart'; import '../constants.dart'; void onNavigationResponse() { - final shouldSkip = kIsWeb || - ![ - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); + final shouldSkip = kIsWeb + ? true + : ![ + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); group("onNavigationResponse", () { testWidgets('allow navigation', (WidgetTester tester) async { @@ -26,8 +27,7 @@ void onNavigationResponse() { textDirection: TextDirection.ltr, child: InAppWebView( key: GlobalKey(), - initialUrlRequest: - URLRequest(url: TEST_URL_1), + initialUrlRequest: URLRequest(url: TEST_URL_1), initialSettings: InAppWebViewSettings(useOnNavigationResponse: true), onWebViewCreated: (controller) { @@ -61,8 +61,7 @@ void onNavigationResponse() { textDirection: TextDirection.ltr, child: InAppWebView( key: GlobalKey(), - initialUrlRequest: - URLRequest(url: TEST_URL_1), + initialUrlRequest: URLRequest(url: TEST_URL_1), initialSettings: InAppWebViewSettings(useOnNavigationResponse: true), onWebViewCreated: (controller) { diff --git a/example/integration_test/in_app_webview/on_page_commit_visible.dart b/example/integration_test/in_app_webview/on_page_commit_visible.dart index f3b1ae10..716cb183 100644 --- a/example/integration_test/in_app_webview/on_page_commit_visible.dart +++ b/example/integration_test/in_app_webview/on_page_commit_visible.dart @@ -8,25 +8,24 @@ import 'package:flutter_test/flutter_test.dart'; import '../constants.dart'; void onPageCommitVisible() { - final shouldSkip = kIsWeb || - ![ - TargetPlatform.android, - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); + final shouldSkip = kIsWeb + ? true + : ![ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); testWidgets('onPageCommitVisible', (WidgetTester tester) async { final Completer controllerCompleter = Completer(); - final Completer onPageCommitVisibleCompleter = - Completer(); + final Completer onPageCommitVisibleCompleter = Completer(); await tester.pumpWidget( Directionality( textDirection: TextDirection.ltr, child: InAppWebView( key: GlobalKey(), - initialUrlRequest: - URLRequest(url: TEST_URL_1), + initialUrlRequest: URLRequest(url: TEST_URL_1), onWebViewCreated: (controller) { controllerCompleter.complete(controller); }, diff --git a/example/integration_test/in_app_webview/on_permission_request.dart b/example/integration_test/in_app_webview/on_permission_request.dart index 5fe1c7f0..11b9d84b 100644 --- a/example/integration_test/in_app_webview/on_permission_request.dart +++ b/example/integration_test/in_app_webview/on_permission_request.dart @@ -8,12 +8,13 @@ import 'package:flutter_test/flutter_test.dart'; import '../constants.dart'; void onPermissionRequest() { - final shouldSkip = kIsWeb || - ![ - TargetPlatform.android, - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); + final shouldSkip = kIsWeb + ? true + : ![ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); var expectedValue = []; if (defaultTargetPlatform == TargetPlatform.android) { @@ -27,7 +28,7 @@ void onPermissionRequest() { final Completer controllerCompleter = Completer(); final Completer pageLoaded = Completer(); final Completer> onPermissionRequestCompleter = - Completer>(); + Completer>(); await tester.pumpWidget( Directionality( @@ -44,7 +45,8 @@ void onPermissionRequest() { onPermissionRequest: (controller, PermissionRequest permissionRequest) async { onPermissionRequestCompleter.complete(permissionRequest.resources); - return PermissionResponse(resources: permissionRequest.resources, + return PermissionResponse( + resources: permissionRequest.resources, action: PermissionResponseAction.GRANT); }, ), @@ -57,7 +59,7 @@ void onPermissionRequest() { source: "document.querySelector('#camera').click();"); await tester.pump(); final List resources = - await onPermissionRequestCompleter.future; + await onPermissionRequestCompleter.future; expect(listEquals(resources, expectedValue), true); }, skip: shouldSkip); diff --git a/example/integration_test/in_app_webview/on_print.dart b/example/integration_test/in_app_webview/on_print.dart index 71bf71ed..0134a549 100644 --- a/example/integration_test/in_app_webview/on_print.dart +++ b/example/integration_test/in_app_webview/on_print.dart @@ -8,11 +8,13 @@ import 'package:flutter_test/flutter_test.dart'; import '../constants.dart'; void onPrint() { - final shouldSkip = !kIsWeb || ![ - TargetPlatform.android, - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); + final shouldSkip = kIsWeb + ? false + : ![ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); var url = !kIsWeb ? TEST_URL_1 : TEST_WEB_PLATFORM_URL_1; @@ -23,8 +25,7 @@ void onPrint() { textDirection: TextDirection.ltr, child: InAppWebView( key: GlobalKey(), - initialUrlRequest: - URLRequest(url: url), + initialUrlRequest: URLRequest(url: url), onLoadStop: (controller, url) async { await controller.evaluateJavascript(source: "window.print();"); }, @@ -38,4 +39,4 @@ void onPrint() { final String printUrl = await onPrintCompleter.future; expect(printUrl, url.toString()); }, skip: shouldSkip); -} \ No newline at end of file +} diff --git a/example/integration_test/in_app_webview/on_progress_changed.dart b/example/integration_test/in_app_webview/on_progress_changed.dart index 61709200..29552ca4 100644 --- a/example/integration_test/in_app_webview/on_progress_changed.dart +++ b/example/integration_test/in_app_webview/on_progress_changed.dart @@ -8,12 +8,13 @@ import 'package:flutter_test/flutter_test.dart'; import '../constants.dart'; void onProgressChanged() { - final shouldSkip = kIsWeb || - ![ - TargetPlatform.android, - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); + final shouldSkip = kIsWeb + ? true + : ![ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); testWidgets('onProgressChanged', (WidgetTester tester) async { final Completer onProgressChangedCompleter = Completer(); @@ -22,8 +23,7 @@ void onProgressChanged() { textDirection: TextDirection.ltr, child: InAppWebView( key: GlobalKey(), - initialUrlRequest: - URLRequest(url: TEST_URL_1), + initialUrlRequest: URLRequest(url: TEST_URL_1), initialSettings: InAppWebViewSettings( clearCache: true, ), diff --git a/example/integration_test/in_app_webview/on_received_icon.dart b/example/integration_test/in_app_webview/on_received_icon.dart index b92f0926..7c304158 100644 --- a/example/integration_test/in_app_webview/on_received_icon.dart +++ b/example/integration_test/in_app_webview/on_received_icon.dart @@ -9,24 +9,23 @@ import 'package:flutter_test/flutter_test.dart'; import '../constants.dart'; void onReceivedIcon() { - final shouldSkip = kIsWeb || - ![ - TargetPlatform.android, - ].contains(defaultTargetPlatform); + final shouldSkip = kIsWeb + ? true + : ![ + TargetPlatform.android, + ].contains(defaultTargetPlatform); testWidgets('onReceivedIcon', (WidgetTester tester) async { final Completer controllerCompleter = Completer(); final Completer pageLoaded = Completer(); - final Completer onReceivedIconCompleter = - Completer(); + final Completer onReceivedIconCompleter = Completer(); await tester.pumpWidget( Directionality( textDirection: TextDirection.ltr, child: InAppWebView( key: GlobalKey(), - initialUrlRequest: - URLRequest(url: TEST_URL_1), + initialUrlRequest: URLRequest(url: TEST_URL_1), onWebViewCreated: (controller) { controllerCompleter.complete(controller); }, diff --git a/example/integration_test/in_app_webview/on_received_touch_icon_url.dart b/example/integration_test/in_app_webview/on_received_touch_icon_url.dart index 80978ea5..e146c674 100644 --- a/example/integration_test/in_app_webview/on_received_touch_icon_url.dart +++ b/example/integration_test/in_app_webview/on_received_touch_icon_url.dart @@ -5,13 +5,12 @@ import 'package:flutter/widgets.dart'; import 'package:flutter_inappwebview/flutter_inappwebview.dart'; import 'package:flutter_test/flutter_test.dart'; -import '../constants.dart'; - void onReceivedTouchIconUrl() { - final shouldSkip = kIsWeb || - ![ - TargetPlatform.android, - ].contains(defaultTargetPlatform); + final shouldSkip = kIsWeb + ? true + : ![ + TargetPlatform.android, + ].contains(defaultTargetPlatform); testWidgets('onReceivedTouchIconUrl', (WidgetTester tester) async { final Completer controllerCompleter = Completer(); diff --git a/example/integration_test/in_app_webview/on_scroll_changed.dart b/example/integration_test/in_app_webview/on_scroll_changed.dart index 261809bc..eec009e1 100644 --- a/example/integration_test/in_app_webview/on_scroll_changed.dart +++ b/example/integration_test/in_app_webview/on_scroll_changed.dart @@ -8,11 +8,13 @@ import 'package:flutter_test/flutter_test.dart'; import '../constants.dart'; void onScrollChanged() { - final shouldSkip = !kIsWeb || ![ - TargetPlatform.android, - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); + final shouldSkip = kIsWeb + ? false + : ![ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); var url = !kIsWeb ? TEST_URL_1 : TEST_WEB_PLATFORM_URL_1; @@ -25,8 +27,7 @@ void onScrollChanged() { textDirection: TextDirection.ltr, child: InAppWebView( key: GlobalKey(), - initialUrlRequest: - URLRequest(url: url), + initialUrlRequest: URLRequest(url: url), onWebViewCreated: (controller) { controllerCompleter.complete(controller); }, @@ -42,8 +43,7 @@ void onScrollChanged() { ), ); - final InAppWebViewController controller = - await controllerCompleter.future; + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; controller.scrollTo(x: 0, y: 500); @@ -51,4 +51,4 @@ void onScrollChanged() { await expectLater(onScrollChangedCompleter.future, completes); }, skip: shouldSkip); -} \ No newline at end of file +} diff --git a/example/integration_test/in_app_webview/on_title_changed.dart b/example/integration_test/in_app_webview/on_title_changed.dart index b3ae6235..85222342 100644 --- a/example/integration_test/in_app_webview/on_title_changed.dart +++ b/example/integration_test/in_app_webview/on_title_changed.dart @@ -8,12 +8,13 @@ import 'package:flutter_test/flutter_test.dart'; import '../constants.dart'; void onTitleChanged() { - final shouldSkip = !kIsWeb || - ![ - TargetPlatform.android, - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); + final shouldSkip = kIsWeb + ? false + : ![ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); var url = !kIsWeb ? TEST_URL_1 : TEST_WEB_PLATFORM_URL_1; @@ -27,8 +28,7 @@ void onTitleChanged() { textDirection: TextDirection.ltr, child: InAppWebView( key: GlobalKey(), - initialUrlRequest: - URLRequest(url: url), + initialUrlRequest: URLRequest(url: url), onWebViewCreated: (controller) { controllerCompleter.complete(controller); }, @@ -44,8 +44,7 @@ void onTitleChanged() { ), ); - final InAppWebViewController controller = - await controllerCompleter.future; + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; await controller.evaluateJavascript( source: "document.title = 'title test';"); diff --git a/example/integration_test/in_app_webview/on_update_visited_history.dart b/example/integration_test/in_app_webview/on_update_visited_history.dart index d2d09b39..ea6e0e1d 100644 --- a/example/integration_test/in_app_webview/on_update_visited_history.dart +++ b/example/integration_test/in_app_webview/on_update_visited_history.dart @@ -8,12 +8,13 @@ import 'package:flutter_test/flutter_test.dart'; import '../constants.dart'; void onUpdateVisitedHistory() { - final shouldSkip = !kIsWeb || - ![ - TargetPlatform.android, - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); + final shouldSkip = kIsWeb + ? false + : ![ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); var url = !kIsWeb ? TEST_CROSS_PLATFORM_URL_1 : TEST_WEB_PLATFORM_URL_1; diff --git a/example/integration_test/in_app_webview/on_window_blur.dart b/example/integration_test/in_app_webview/on_window_blur.dart index f8f145ed..98fb99da 100644 --- a/example/integration_test/in_app_webview/on_window_blur.dart +++ b/example/integration_test/in_app_webview/on_window_blur.dart @@ -8,12 +8,13 @@ import 'package:flutter_test/flutter_test.dart'; import '../constants.dart'; void onWindowBlur() { - final shouldSkip = !kIsWeb || - ![ - TargetPlatform.android, - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); + final shouldSkip = kIsWeb + ? false + : ![ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); var url = !kIsWeb ? TEST_URL_1 : TEST_WEB_PLATFORM_URL_1; diff --git a/example/integration_test/in_app_webview/on_window_focus.dart b/example/integration_test/in_app_webview/on_window_focus.dart index f0e1bb1d..6a4bc0bc 100644 --- a/example/integration_test/in_app_webview/on_window_focus.dart +++ b/example/integration_test/in_app_webview/on_window_focus.dart @@ -8,12 +8,13 @@ import 'package:flutter_test/flutter_test.dart'; import '../constants.dart'; void onWindowFocus() { - final shouldSkip = !kIsWeb || - ![ - TargetPlatform.android, - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); + final shouldSkip = kIsWeb + ? false + : ![ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); var url = !kIsWeb ? TEST_URL_1 : TEST_WEB_PLATFORM_URL_1; diff --git a/example/integration_test/in_app_webview/page_down_up.dart b/example/integration_test/in_app_webview/page_down_up.dart index 3d286acc..21a8343f 100644 --- a/example/integration_test/in_app_webview/page_down_up.dart +++ b/example/integration_test/in_app_webview/page_down_up.dart @@ -8,14 +8,14 @@ import 'package:flutter_test/flutter_test.dart'; import '../constants.dart'; void pageDownUp() { - final shouldSkip = kIsWeb || - ![ - TargetPlatform.android, - ].contains(defaultTargetPlatform); + final shouldSkip = kIsWeb + ? true + : ![ + TargetPlatform.android, + ].contains(defaultTargetPlatform); testWidgets('pageDown/pageUp', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = Completer(); final Completer pageLoaded = Completer(); await tester.pumpWidget( @@ -23,8 +23,7 @@ void pageDownUp() { 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); }, @@ -35,8 +34,7 @@ void pageDownUp() { ), ); - final InAppWebViewController controller = - await controllerCompleter.future; + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; expect(await controller.pageDown(bottom: false), true); await Future.delayed(Duration(seconds: 1)); diff --git a/example/integration_test/in_app_webview/pause_resume.dart b/example/integration_test/in_app_webview/pause_resume.dart index aed90e54..b008fdc7 100644 --- a/example/integration_test/in_app_webview/pause_resume.dart +++ b/example/integration_test/in_app_webview/pause_resume.dart @@ -8,14 +8,14 @@ import 'package:flutter_test/flutter_test.dart'; import '../constants.dart'; void pauseResume() { - final shouldSkip = kIsWeb || - ![ - TargetPlatform.android, - ].contains(defaultTargetPlatform); + final shouldSkip = kIsWeb + ? true + : ![ + TargetPlatform.android, + ].contains(defaultTargetPlatform); testWidgets('pause/resume', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = Completer(); final Completer pageLoaded = Completer(); await tester.pumpWidget( @@ -23,8 +23,7 @@ void pauseResume() { 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); }, @@ -35,8 +34,7 @@ void pauseResume() { ), ); - final InAppWebViewController controller = - await controllerCompleter.future; + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; await expectLater(controller.pause(), completes); await Future.delayed(Duration(seconds: 1)); diff --git a/example/integration_test/in_app_webview/pause_resume_timers.dart b/example/integration_test/in_app_webview/pause_resume_timers.dart index 64eb080d..d18792cb 100644 --- a/example/integration_test/in_app_webview/pause_resume_timers.dart +++ b/example/integration_test/in_app_webview/pause_resume_timers.dart @@ -8,12 +8,13 @@ import 'package:flutter_test/flutter_test.dart'; import '../constants.dart'; void pauseResumeTimers() { - final shouldSkip = kIsWeb || - ![ - TargetPlatform.android, - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); + final shouldSkip = kIsWeb + ? true + : ![ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); testWidgets('pause/resume timers', (WidgetTester tester) async { final Completer controllerCompleter = Completer(); @@ -35,8 +36,7 @@ void pauseResumeTimers() { ), ); - final InAppWebViewController controller = - await controllerCompleter.future; + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; await controller.evaluateJavascript(source: """ @@ -49,10 +49,9 @@ void pauseResumeTimers() { await controller.pauseTimers(); await Future.delayed(Duration(seconds: 2)); await controller.resumeTimers(); - expect( - await controller.evaluateJavascript(source: "count;"), lessThan(50)); + expect(await controller.evaluateJavascript(source: "count;"), lessThan(50)); await Future.delayed(Duration(seconds: 4)); - expect(await controller.evaluateJavascript(source: "count;"), - greaterThan(50)); + expect( + await controller.evaluateJavascript(source: "count;"), greaterThan(50)); }, skip: shouldSkip); } diff --git a/example/integration_test/in_app_webview/post_requests.dart b/example/integration_test/in_app_webview/post_requests.dart index 7bb59076..c604b897 100644 --- a/example/integration_test/in_app_webview/post_requests.dart +++ b/example/integration_test/in_app_webview/post_requests.dart @@ -10,17 +10,17 @@ import 'package:flutter_test/flutter_test.dart'; import '../.env.dart'; void postRequests() { - final shouldSkip = kIsWeb || - ![ - TargetPlatform.android, - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); + final shouldSkip = kIsWeb + ? true + : ![ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); group('POST requests', () { testWidgets('initialUrlRequest', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = Completer(); final Completer postPageLoaded = Completer(); await tester.pumpWidget( @@ -33,9 +33,7 @@ void postRequests() { "http://${environment["NODE_SERVER_IP"]}:8082/test-post"), method: 'POST', body: Uint8List.fromList(utf8.encode("name=FooBar")), - headers: { - 'Content-Type': 'application/x-www-form-urlencoded' - }), + headers: {'Content-Type': 'application/x-www-form-urlencoded'}), onWebViewCreated: (controller) { controllerCompleter.complete(controller); }, @@ -47,12 +45,12 @@ void postRequests() { ); final InAppWebViewController controller = - await controllerCompleter.future; + await controllerCompleter.future; await postPageLoaded.future; final String? currentUrl = (await controller.getUrl())?.toString(); - expect(currentUrl, - 'http://${environment["NODE_SERVER_IP"]}:8082/test-post'); + expect( + currentUrl, 'http://${environment["NODE_SERVER_IP"]}:8082/test-post'); final String? pContent = await controller.evaluateJavascript( source: "document.querySelector('p').innerHTML;"); @@ -60,8 +58,7 @@ void postRequests() { }); testWidgets('loadUrl', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = Completer(); final Completer postPageLoaded = Completer(); await tester.pumpWidget( @@ -83,7 +80,7 @@ void postRequests() { ); final InAppWebViewController controller = - await controllerCompleter.future; + await controllerCompleter.future; var postData = Uint8List.fromList(utf8.encode("name=FooBar")); await controller.loadUrl( @@ -92,15 +89,13 @@ void postRequests() { "http://${environment["NODE_SERVER_IP"]}:8082/test-post"), method: 'POST', body: postData, - headers: { - 'Content-Type': 'application/x-www-form-urlencoded' - })); + headers: {'Content-Type': 'application/x-www-form-urlencoded'})); await postPageLoaded.future; final String? currentUrl = (await controller.getUrl())?.toString(); - expect(currentUrl, - 'http://${environment["NODE_SERVER_IP"]}:8082/test-post'); + expect( + currentUrl, 'http://${environment["NODE_SERVER_IP"]}:8082/test-post'); final String? pContent = await controller.evaluateJavascript( source: "document.querySelector('p').innerHTML;"); @@ -108,8 +103,7 @@ void postRequests() { }); testWidgets('postUrl', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = Completer(); final Completer postPageLoaded = Completer(); await tester.pumpWidget( @@ -131,7 +125,7 @@ void postRequests() { ); final InAppWebViewController controller = - await controllerCompleter.future; + await controllerCompleter.future; var postData = Uint8List.fromList(utf8.encode("name=FooBar")); await controller.postUrl( @@ -142,8 +136,8 @@ void postRequests() { await postPageLoaded.future; final String? currentUrl = (await controller.getUrl())?.toString(); - expect(currentUrl, - 'http://${environment["NODE_SERVER_IP"]}:8082/test-post'); + expect( + currentUrl, 'http://${environment["NODE_SERVER_IP"]}:8082/test-post'); final String? pContent = await controller.evaluateJavascript( source: "document.querySelector('p').innerHTML;"); diff --git a/example/integration_test/in_app_webview/print_current_page.dart b/example/integration_test/in_app_webview/print_current_page.dart index 8f88e20f..b0162a11 100644 --- a/example/integration_test/in_app_webview/print_current_page.dart +++ b/example/integration_test/in_app_webview/print_current_page.dart @@ -8,12 +8,13 @@ import 'package:flutter_test/flutter_test.dart'; import '../constants.dart'; void printCurrentPage() { - final shouldSkip = !kIsWeb || - ![ - TargetPlatform.android, - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); + final shouldSkip = kIsWeb + ? false + : ![ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); var url = !kIsWeb ? TEST_CROSS_PLATFORM_URL_1 : TEST_WEB_PLATFORM_URL_1; @@ -26,8 +27,7 @@ void printCurrentPage() { textDirection: TextDirection.ltr, child: InAppWebView( key: GlobalKey(), - initialUrlRequest: - URLRequest(url: url), + initialUrlRequest: URLRequest(url: url), onWebViewCreated: (controller) { controllerCompleter.complete(controller); }, @@ -38,8 +38,7 @@ void printCurrentPage() { ), ); - final InAppWebViewController controller = - await controllerCompleter.future; + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; await tester.pump(); await expectLater(controller.printCurrentPage(), completes); diff --git a/example/integration_test/in_app_webview/programmatic_scroll.dart b/example/integration_test/in_app_webview/programmatic_scroll.dart index 92cdb5ec..b5bc87a0 100644 --- a/example/integration_test/in_app_webview/programmatic_scroll.dart +++ b/example/integration_test/in_app_webview/programmatic_scroll.dart @@ -9,18 +9,22 @@ import 'package:flutter_test/flutter_test.dart'; import '../constants.dart'; void programmaticScroll() { - final shouldSkip = !kIsWeb || ![ - TargetPlatform.android, - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); + final shouldSkip = kIsWeb + ? false + : ![ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); group('Programmatic Scroll', () { - final shouldSkipTest1 = !kIsWeb || ![ - TargetPlatform.android, - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); + final shouldSkipTest1 = kIsWeb + ? false + : ![ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); testWidgets('set and get scroll position', (WidgetTester tester) async { final String scrollTestPage = ''' @@ -45,22 +49,21 @@ void programmaticScroll() { '''; final String scrollTestPageBase64 = - base64Encode(const Utf8Encoder().convert(scrollTestPage)); + base64Encode(const Utf8Encoder().convert(scrollTestPage)); - var url = !kIsWeb ? Uri.parse( - 'data:text/html;charset=utf-8;base64,$scrollTestPageBase64') : - TEST_WEB_PLATFORM_URL_1; + var url = !kIsWeb + ? Uri.parse( + 'data:text/html;charset=utf-8;base64,$scrollTestPageBase64') + : TEST_WEB_PLATFORM_URL_1; final Completer pageLoaded = Completer(); - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = Completer(); await tester.pumpWidget( Directionality( textDirection: TextDirection.ltr, child: InAppWebView( - initialUrlRequest: URLRequest( - url: url), + initialUrlRequest: URLRequest(url: url), onWebViewCreated: (controller) { controllerCompleter.complete(controller); }, @@ -72,7 +75,7 @@ void programmaticScroll() { ); final InAppWebViewController controller = - await controllerCompleter.future; + await controllerCompleter.future; await pageLoaded.future; await controller.scrollTo(x: 0, y: 0); @@ -98,7 +101,15 @@ void programmaticScroll() { expect(scrollPosY, Y_SCROLL * 2); }, skip: shouldSkipTest1); - testWidgets('set and get scroll position on Android without Hybrid Composition', (WidgetTester tester) async { + final shouldSkipTest2 = kIsWeb + ? true + : ![ + TargetPlatform.android, + ].contains(defaultTargetPlatform); + + testWidgets( + 'set and get scroll position on Android without Hybrid Composition', + (WidgetTester tester) async { final String scrollTestPage = ''' @@ -121,11 +132,10 @@ void programmaticScroll() { '''; final String scrollTestPageBase64 = - base64Encode(const Utf8Encoder().convert(scrollTestPage)); + base64Encode(const Utf8Encoder().convert(scrollTestPage)); final Completer pageLoaded = Completer(); - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = Completer(); await tester.pumpWidget( Directionality( @@ -137,8 +147,7 @@ void programmaticScroll() { onWebViewCreated: (controller) { controllerCompleter.complete(controller); }, - initialSettings: InAppWebViewSettings( - useHybridComposition: false), + initialSettings: InAppWebViewSettings(useHybridComposition: false), onLoadStop: (controller, url) { pageLoaded.complete(); }, @@ -147,7 +156,7 @@ void programmaticScroll() { ); final InAppWebViewController controller = - await controllerCompleter.future; + await controllerCompleter.future; await pageLoaded.future; await controller.scrollTo(x: 0, y: 0); @@ -171,6 +180,6 @@ void programmaticScroll() { scrollPosY = await controller.getScrollY(); expect(scrollPosX, X_SCROLL * 2); expect(scrollPosY, Y_SCROLL * 2); - }, skip: defaultTargetPlatform != TargetPlatform.android); + }, skip: shouldSkipTest2); }, skip: shouldSkip); -} \ No newline at end of file +} diff --git a/example/integration_test/in_app_webview/programmatic_zoom_scale.dart b/example/integration_test/in_app_webview/programmatic_zoom_scale.dart index 429b2589..422601f8 100644 --- a/example/integration_test/in_app_webview/programmatic_zoom_scale.dart +++ b/example/integration_test/in_app_webview/programmatic_zoom_scale.dart @@ -8,22 +8,23 @@ import 'package:flutter_test/flutter_test.dart'; import '../constants.dart'; void programmaticZoomScale() { - final shouldSkip = kIsWeb || - ![ - TargetPlatform.android, - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); - - group('programmatic zoom scale', () { - final shouldSkipTest1 = kIsWeb || - ![ + final shouldSkip = kIsWeb + ? true + : ![ TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, ].contains(defaultTargetPlatform); + group('programmatic zoom scale', () { + final shouldSkipTest1 = kIsWeb + ? true + : ![ + TargetPlatform.android, + ].contains(defaultTargetPlatform); + testWidgets('zoomIn/zoomOut', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = Completer(); final Completer pageLoaded = Completer(); await tester.pumpWidget( @@ -31,8 +32,7 @@ void programmaticZoomScale() { 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); }, @@ -44,7 +44,7 @@ void programmaticZoomScale() { ); final InAppWebViewController controller = - await controllerCompleter.future; + await controllerCompleter.future; await pageLoaded.future; expect(await controller.zoomIn(), true); await Future.delayed(Duration(seconds: 1)); @@ -63,8 +63,7 @@ void programmaticZoomScale() { textDirection: TextDirection.ltr, child: InAppWebView( key: GlobalKey(), - initialUrlRequest: - URLRequest(url: TEST_URL_1), + initialUrlRequest: URLRequest(url: TEST_URL_1), onWebViewCreated: (controller) { controllerCompleter.complete(controller); }, @@ -81,7 +80,7 @@ void programmaticZoomScale() { ); final InAppWebViewController controller = - await controllerCompleter.future; + await controllerCompleter.future; await pageLoaded.future; listenForScaleChange = true; @@ -100,7 +99,7 @@ void programmaticZoomScale() { child: InAppWebView( key: GlobalKey(), initialUrlRequest: - URLRequest(url: Uri.parse('https://flutter.dev')), + URLRequest(url: Uri.parse('https://flutter.dev')), onWebViewCreated: (controller) { controllerCompleter.complete(controller); }, @@ -112,7 +111,7 @@ void programmaticZoomScale() { ); final InAppWebViewController controller = - await controllerCompleter.future; + await controllerCompleter.future; await pageLoaded.future; await expectLater( @@ -129,7 +128,7 @@ void programmaticZoomScale() { child: InAppWebView( key: GlobalKey(), initialUrlRequest: - URLRequest(url: Uri.parse('https://flutter.dev')), + URLRequest(url: Uri.parse('https://flutter.dev')), onWebViewCreated: (controller) { controllerCompleter.complete(controller); }, @@ -141,7 +140,7 @@ void programmaticZoomScale() { ); final InAppWebViewController controller = - await controllerCompleter.future; + await controllerCompleter.future; await pageLoaded.future; final scale = await controller.getZoomScale(); diff --git a/example/integration_test/in_app_webview/pull_to_refresh.dart b/example/integration_test/in_app_webview/pull_to_refresh.dart index af6d7ccf..a12b1537 100644 --- a/example/integration_test/in_app_webview/pull_to_refresh.dart +++ b/example/integration_test/in_app_webview/pull_to_refresh.dart @@ -9,12 +9,13 @@ import 'package:flutter_test/flutter_test.dart'; import '../constants.dart'; void pullToRefresh() { - final shouldSkip = kIsWeb || - ![ - TargetPlatform.android, - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); + final shouldSkip = kIsWeb + ? true + : ![ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); testWidgets('launches with pull-to-refresh feature', (WidgetTester tester) async { @@ -36,8 +37,7 @@ void pullToRefresh() { textDirection: TextDirection.ltr, child: InAppWebView( key: GlobalKey(), - initialUrlRequest: - URLRequest(url: TEST_URL_1), + initialUrlRequest: URLRequest(url: TEST_URL_1), pullToRefreshController: pullToRefreshController, onWebViewCreated: (controller) { controllerCompleter.complete(controller); diff --git a/example/integration_test/in_app_webview/reload.dart b/example/integration_test/in_app_webview/reload.dart index 3063091b..7c622554 100644 --- a/example/integration_test/in_app_webview/reload.dart +++ b/example/integration_test/in_app_webview/reload.dart @@ -8,21 +8,23 @@ import 'package:flutter_test/flutter_test.dart'; import '../constants.dart'; void reload() { - final shouldSkip = !kIsWeb || - ![ - TargetPlatform.android, - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); + final shouldSkip = kIsWeb + ? false + : ![ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); var url = !kIsWeb ? TEST_URL_1 : TEST_WEB_PLATFORM_URL_1; group('reload', () { - final shouldSkipTest1 = kIsWeb || - ![ - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); + final shouldSkipTest1 = kIsWeb + ? true + : ![ + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); testWidgets('reload from origin', (WidgetTester tester) async { final Completer controllerCompleter = Completer(); diff --git a/example/integration_test/in_app_webview/request_focus_node_href.dart b/example/integration_test/in_app_webview/request_focus_node_href.dart index c26f2e8a..72ab7b00 100644 --- a/example/integration_test/in_app_webview/request_focus_node_href.dart +++ b/example/integration_test/in_app_webview/request_focus_node_href.dart @@ -8,12 +8,13 @@ import 'package:flutter_test/flutter_test.dart'; import '../constants.dart'; void requestFocusNodeHref() { - final shouldSkip = kIsWeb || - ![ - TargetPlatform.android, - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); + final shouldSkip = kIsWeb + ? true + : ![ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); testWidgets('requestFocusNodeHref', (WidgetTester tester) async { final Completer controllerCompleter = Completer(); @@ -24,8 +25,7 @@ void requestFocusNodeHref() { 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 requestFocusNodeHref() { ), ); - final InAppWebViewController controller = - await controllerCompleter.future; + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; await expectLater(controller.requestFocusNodeHref(), completes); diff --git a/example/integration_test/in_app_webview/request_image_ref.dart b/example/integration_test/in_app_webview/request_image_ref.dart index 35eca2e8..93f29c40 100644 --- a/example/integration_test/in_app_webview/request_image_ref.dart +++ b/example/integration_test/in_app_webview/request_image_ref.dart @@ -8,12 +8,13 @@ import 'package:flutter_test/flutter_test.dart'; import '../constants.dart'; void requestImageRef() { - final shouldSkip = kIsWeb || - ![ - TargetPlatform.android, - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); + final shouldSkip = kIsWeb + ? true + : ![ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); testWidgets('requestImageRef', (WidgetTester tester) async { final Completer controllerCompleter = Completer(); @@ -24,8 +25,7 @@ void requestImageRef() { 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 requestImageRef() { ), ); - final InAppWebViewController controller = - await controllerCompleter.future; + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; await expectLater(controller.requestImageRef(), completes); diff --git a/example/integration_test/in_app_webview/resize_webview.dart b/example/integration_test/in_app_webview/resize_webview.dart index 43ff9084..5cc45513 100644 --- a/example/integration_test/in_app_webview/resize_webview.dart +++ b/example/integration_test/in_app_webview/resize_webview.dart @@ -6,14 +6,14 @@ import 'package:flutter/widgets.dart'; import 'package:flutter_inappwebview/flutter_inappwebview.dart'; import 'package:flutter_test/flutter_test.dart'; -import '../constants.dart'; - void resizeWebView() { - final shouldSkip = kIsWeb || ![ - TargetPlatform.android, - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); + final shouldSkip = kIsWeb + ? true + : ![ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); testWidgets('resize webview', (WidgetTester tester) async { final String resizeTest = ''' @@ -33,7 +33,7 @@ void resizeWebView() { '''; final String resizeTestBase64 = - base64Encode(const Utf8Encoder().convert(resizeTest)); + base64Encode(const Utf8Encoder().convert(resizeTest)); final Completer resizeCompleter = Completer(); final Completer pageStarted = Completer(); final Completer pageLoaded = Completer(); @@ -101,4 +101,4 @@ void resizeWebView() { await resizeCompleter.future; }, skip: shouldSkip); -} \ No newline at end of file +} diff --git a/example/integration_test/in_app_webview/safe_browsing.dart b/example/integration_test/in_app_webview/safe_browsing.dart index 48ee97dd..2ddfafd8 100644 --- a/example/integration_test/in_app_webview/safe_browsing.dart +++ b/example/integration_test/in_app_webview/safe_browsing.dart @@ -8,10 +8,11 @@ import 'package:flutter_test/flutter_test.dart'; import '../constants.dart'; void safeBrowsing() { - final shouldSkip = kIsWeb || - ![ - TargetPlatform.android, - ].contains(defaultTargetPlatform); + final shouldSkip = kIsWeb + ? true + : ![ + TargetPlatform.android, + ].contains(defaultTargetPlatform); group('safe browsing', () { testWidgets('onSafeBrowsingHit', (WidgetTester tester) async { diff --git a/example/integration_test/in_app_webview/set_custom_useragent.dart b/example/integration_test/in_app_webview/set_custom_useragent.dart index cdf9d2b6..aec98ada 100644 --- a/example/integration_test/in_app_webview/set_custom_useragent.dart +++ b/example/integration_test/in_app_webview/set_custom_useragent.dart @@ -8,12 +8,13 @@ import 'package:flutter_test/flutter_test.dart'; import '../constants.dart'; void setCustomUserAgent() { - 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 custom userAgent', (WidgetTester tester) async { final Completer controllerCompleter1 = Completer(); diff --git a/example/integration_test/in_app_webview/set_get_settings.dart b/example/integration_test/in_app_webview/set_get_settings.dart index 1001089f..1b10f575 100644 --- a/example/integration_test/in_app_webview/set_get_settings.dart +++ b/example/integration_test/in_app_webview/set_get_settings.dart @@ -8,11 +8,13 @@ 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); final url = !kIsWeb ? TEST_CROSS_PLATFORM_URL_1 : TEST_WEB_PLATFORM_URL_1; @@ -25,11 +27,8 @@ void setGetSettings() { textDirection: TextDirection.ltr, child: InAppWebView( key: GlobalKey(), - initialUrlRequest: - URLRequest(url: url), - initialSettings: InAppWebViewSettings( - javaScriptEnabled: false - ), + initialUrlRequest: URLRequest(url: url), + initialSettings: InAppWebViewSettings(javaScriptEnabled: false), onWebViewCreated: (controller) { controllerCompleter.complete(controller); }, @@ -39,8 +38,7 @@ void setGetSettings() { ), ), ); - final InAppWebViewController controller = - await controllerCompleter.future; + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; InAppWebViewSettings? settings = await controller.getSettings(); @@ -52,8 +50,8 @@ void setGetSettings() { expect(settings.iframeSandbox!.contains(Sandbox.ALLOW_SCRIPTS), false); } - await controller.setSettings(settings: InAppWebViewSettings( - javaScriptEnabled: true)); + await controller.setSettings( + settings: InAppWebViewSettings(javaScriptEnabled: true)); settings = await controller.getSettings(); expect(settings, isNotNull); @@ -64,4 +62,4 @@ void setGetSettings() { expect(settings.iframeSandbox!.contains(Sandbox.ALLOW_SCRIPTS), true); } }, skip: shouldSkip); -} \ No newline at end of file +} diff --git a/example/integration_test/in_app_webview/set_web_contents_debugging_enabled.dart b/example/integration_test/in_app_webview/set_web_contents_debugging_enabled.dart index 5c1fa637..88056775 100644 --- a/example/integration_test/in_app_webview/set_web_contents_debugging_enabled.dart +++ b/example/integration_test/in_app_webview/set_web_contents_debugging_enabled.dart @@ -1,13 +1,13 @@ import 'package:flutter/foundation.dart'; -import 'package:flutter/widgets.dart'; import 'package:flutter_inappwebview/flutter_inappwebview.dart'; import 'package:flutter_test/flutter_test.dart'; void setWebContentsDebuggingEnabled() { - final shouldSkip = kIsWeb || - ![ - TargetPlatform.android, - ].contains(defaultTargetPlatform); + final shouldSkip = kIsWeb + ? true + : ![ + TargetPlatform.android, + ].contains(defaultTargetPlatform); test('setWebContentsDebuggingEnabled', () async { expect( diff --git a/example/integration_test/in_app_webview/should_intercept_request.dart b/example/integration_test/in_app_webview/should_intercept_request.dart index 9acaede8..e46cd156 100644 --- a/example/integration_test/in_app_webview/should_intercept_request.dart +++ b/example/integration_test/in_app_webview/should_intercept_request.dart @@ -6,10 +6,11 @@ import 'package:flutter_inappwebview/flutter_inappwebview.dart'; import 'package:flutter_test/flutter_test.dart'; void shouldInterceptRequest() { - final shouldSkip = kIsWeb || - ![ - TargetPlatform.android, - ].contains(defaultTargetPlatform); + final shouldSkip = kIsWeb + ? true + : ![ + TargetPlatform.android, + ].contains(defaultTargetPlatform); testWidgets('shouldInterceptRequest', (WidgetTester tester) async { List resourceList = [ diff --git a/example/integration_test/in_app_webview/should_override_url_loading.dart b/example/integration_test/in_app_webview/should_override_url_loading.dart index bf776a86..d0372b73 100644 --- a/example/integration_test/in_app_webview/should_override_url_loading.dart +++ b/example/integration_test/in_app_webview/should_override_url_loading.dart @@ -9,12 +9,13 @@ import 'package:flutter_test/flutter_test.dart'; import '../constants.dart'; void shouldOverrideUrlLoading() { - final shouldSkip = kIsWeb || - ![ - TargetPlatform.android, - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); + final shouldSkip = kIsWeb + ? true + : ![ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); group('shouldOverrideUrlLoading', () { final String page = @@ -22,13 +23,6 @@ void shouldOverrideUrlLoading() { final String pageEncoded = 'data:text/html;charset=utf-8;base64,' + base64Encode(const Utf8Encoder().convert(page)); - final shouldSkipTest1 = kIsWeb || - ![ - TargetPlatform.android, - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); - testWidgets('can allow requests', (WidgetTester tester) async { final Completer controllerCompleter = Completer(); final StreamController pageLoads = @@ -70,13 +64,14 @@ void shouldOverrideUrlLoading() { expect(currentUrl, TEST_URL_2.toString()); pageLoads.close(); - }, skip: shouldSkipTest1); + }); - final shouldSkipTest2 = kIsWeb || - ![ - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); + final shouldSkipTest2 = kIsWeb + ? true + : ![ + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); testWidgets( 'allow requests on iOS only if navigationType == NavigationType.LINK_ACTIVATED', @@ -138,13 +133,6 @@ void shouldOverrideUrlLoading() { pageLoads.close(); }, skip: shouldSkipTest2); - final shouldSkipTest3 = kIsWeb || - ![ - TargetPlatform.android, - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); - testWidgets('can block requests', (WidgetTester tester) async { final Completer controllerCompleter = Completer(); final StreamController pageLoads = @@ -194,14 +182,7 @@ void shouldOverrideUrlLoading() { currentUrl, isNot(contains(TEST_URL_4.host.replaceAll("www.", "")))); pageLoads.close(); - }, skip: shouldSkipTest3); - - final shouldSkipTest4 = kIsWeb || - ![ - TargetPlatform.android, - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); + }); testWidgets('supports asynchronous decisions', (WidgetTester tester) async { final Completer controllerCompleter = Completer(); @@ -245,6 +226,6 @@ void shouldOverrideUrlLoading() { expect(currentUrl, TEST_URL_2.toString()); pageLoads.close(); - }, skip: shouldSkipTest4); + }); }, skip: shouldSkip); } diff --git a/example/integration_test/in_app_webview/ssl_request.dart b/example/integration_test/in_app_webview/ssl_request.dart index 122bbdeb..5c495683 100644 --- a/example/integration_test/in_app_webview/ssl_request.dart +++ b/example/integration_test/in_app_webview/ssl_request.dart @@ -8,11 +8,13 @@ import 'package:flutter_test/flutter_test.dart'; import '../.env.dart'; void sslRequest() { - final shouldSkip = kIsWeb || ![ - TargetPlatform.android, - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); + final shouldSkip = kIsWeb + ? true + : ![ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); testWidgets('SSL request', (WidgetTester tester) async { final Completer controllerCompleter = Completer(); @@ -23,8 +25,7 @@ void sslRequest() { child: InAppWebView( key: GlobalKey(), initialUrlRequest: URLRequest( - url: Uri.parse( - "https://${environment["NODE_SERVER_IP"]}:4433/")), + url: Uri.parse("https://${environment["NODE_SERVER_IP"]}:4433/")), onWebViewCreated: (controller) { controllerCompleter.complete(controller); }, @@ -45,12 +46,11 @@ void sslRequest() { ), ), ); - final InAppWebViewController controller = - await controllerCompleter.future; + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; final String h1Content = await controller.evaluateJavascript( source: "document.body.querySelector('h1').textContent"); expect(h1Content, "Authorized"); }, skip: shouldSkip); -} \ No newline at end of file +} diff --git a/example/integration_test/in_app_webview/stop_loading.dart b/example/integration_test/in_app_webview/stop_loading.dart index 101c2f76..0e9fbcbb 100644 --- a/example/integration_test/in_app_webview/stop_loading.dart +++ b/example/integration_test/in_app_webview/stop_loading.dart @@ -9,12 +9,13 @@ import '../constants.dart'; import '../util.dart'; void stopLoading() { - final shouldSkip = kIsWeb || - ![ - TargetPlatform.android, - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); + final shouldSkip = kIsWeb + ? true + : ![ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); testWidgets('stopLoading', (WidgetTester tester) async { final Completer controllerCompleter = Completer(); diff --git a/example/integration_test/in_app_webview/t_rex_runner_game.dart b/example/integration_test/in_app_webview/t_rex_runner_game.dart index 3aa280aa..fabdd663 100644 --- a/example/integration_test/in_app_webview/t_rex_runner_game.dart +++ b/example/integration_test/in_app_webview/t_rex_runner_game.dart @@ -8,12 +8,13 @@ import 'package:flutter_test/flutter_test.dart'; import '../constants.dart'; void tRexRunnerGame() { - final shouldSkip = kIsWeb || - ![ - TargetPlatform.android, - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); + final shouldSkip = kIsWeb + ? true + : ![ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); testWidgets('T-Rex Runner game', (WidgetTester tester) async { final Completer controllerCompleter = Completer(); @@ -35,12 +36,11 @@ void tRexRunnerGame() { ), ); - final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; - var html = await controller.getTRexRunnerHtml(); - var css = await controller.getTRexRunnerCss(); + var html = await InAppWebViewController.tRexRunnerHtml; + var css = await InAppWebViewController.tRexRunnerCss; expect(html, isNotNull); expect(css, isNotNull); diff --git a/example/integration_test/in_app_webview/user_scripts.dart b/example/integration_test/in_app_webview/user_scripts.dart index a39f8848..fa943970 100644 --- a/example/integration_test/in_app_webview/user_scripts.dart +++ b/example/integration_test/in_app_webview/user_scripts.dart @@ -9,12 +9,13 @@ import 'package:flutter_test/flutter_test.dart'; import '../constants.dart'; void userScripts() { - final shouldSkip = kIsWeb || - ![ - TargetPlatform.android, - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); + final shouldSkip = kIsWeb + ? true + : ![ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); group('user scripts', () { testWidgets('initialUserScripts', (WidgetTester tester) async { diff --git a/example/integration_test/in_app_webview/video_playback_policy.dart b/example/integration_test/in_app_webview/video_playback_policy.dart index 4cb7f98c..f995738e 100644 --- a/example/integration_test/in_app_webview/video_playback_policy.dart +++ b/example/integration_test/in_app_webview/video_playback_policy.dart @@ -9,7 +9,7 @@ import 'package:flutter_inappwebview/flutter_inappwebview.dart'; import 'package:flutter_test/flutter_test.dart'; void videoPlaybackPolicy() { - final shouldSkip = kIsWeb || + final shouldSkip = kIsWeb ? true : ![ TargetPlatform.android, TargetPlatform.iOS, diff --git a/example/integration_test/in_app_webview/web_archive.dart b/example/integration_test/in_app_webview/web_archive.dart index 951a06a8..d4a83c46 100644 --- a/example/integration_test/in_app_webview/web_archive.dart +++ b/example/integration_test/in_app_webview/web_archive.dart @@ -10,24 +10,24 @@ import 'package:path_provider/path_provider.dart'; import '../constants.dart'; void webArchive() { - final shouldSkip = kIsWeb || - ![ - TargetPlatform.android, - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); - - group('web archive', () { - - final shouldSkipTest1 = kIsWeb || - ![ + final shouldSkip = kIsWeb + ? true + : ![ + TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS, ].contains(defaultTargetPlatform); + group('web archive', () { + final shouldSkipTest1 = kIsWeb + ? true + : ![ + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); + testWidgets('create data', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = Completer(); final Completer pageLoaded = Completer(); await tester.pumpWidget( @@ -35,8 +35,7 @@ void webArchive() { 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); }, @@ -48,7 +47,7 @@ void webArchive() { ); final InAppWebViewController controller = - await controllerCompleter.future; + await controllerCompleter.future; await pageLoaded.future; expect(await controller.createWebArchiveData(), isNotNull); @@ -63,8 +62,7 @@ void webArchive() { textDirection: TextDirection.ltr, child: InAppWebView( key: GlobalKey(), - initialUrlRequest: - URLRequest(url: TEST_URL_1), + initialUrlRequest: URLRequest(url: TEST_URL_1), onWebViewCreated: (controller) { controllerCompleter.complete(controller); }, @@ -76,7 +74,7 @@ void webArchive() { ); final InAppWebViewController controller = - await controllerCompleter.future; + await controllerCompleter.future; await pageLoaded.future; // wait a little bit after page load otherwise Android will not save the web archive diff --git a/example/integration_test/in_app_webview/web_history.dart b/example/integration_test/in_app_webview/web_history.dart index b4283631..43226a76 100644 --- a/example/integration_test/in_app_webview/web_history.dart +++ b/example/integration_test/in_app_webview/web_history.dart @@ -8,22 +8,25 @@ import 'package:flutter_test/flutter_test.dart'; import '../constants.dart'; void webHistory() { - final shouldSkip = !kIsWeb || - ![ - TargetPlatform.android, - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); - - group('web history', () { - final shouldSkipTest1 = kIsWeb || - ![ + final shouldSkip = kIsWeb + ? false + : ![ TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS, ].contains(defaultTargetPlatform); - testWidgets('get history list and go back/forward', (WidgetTester tester) async { + group('web history', () { + final shouldSkipTest1 = kIsWeb + ? true + : ![ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); + + testWidgets('get history list and go back/forward', + (WidgetTester tester) async { final Completer controllerCompleter = Completer(); await tester.pumpWidget( @@ -42,7 +45,8 @@ void webHistory() { ), ); - final InAppWebViewController controller = await controllerCompleter.future; + final InAppWebViewController controller = + await controllerCompleter.future; await Future.delayed(Duration(seconds: 1)); var url = (await controller.getUrl()).toString(); @@ -50,10 +54,10 @@ void webHistory() { expect(url, TEST_CROSS_PLATFORM_URL_1.toString()); expect(webHistory!.currentIndex, 0); expect(webHistory.list!.length, 1); - expect(webHistory.list![0].url.toString(), TEST_CROSS_PLATFORM_URL_1.toString()); + expect(webHistory.list![0].url.toString(), + TEST_CROSS_PLATFORM_URL_1.toString()); - await controller.loadUrl( - urlRequest: URLRequest(url: TEST_URL_1)); + await controller.loadUrl(urlRequest: URLRequest(url: TEST_URL_1)); await Future.delayed(Duration(seconds: 1)); url = (await controller.getUrl()).toString(); webHistory = await controller.getCopyBackForwardList(); @@ -64,7 +68,8 @@ void webHistory() { expect(await controller.canGoBackOrForward(steps: 1), false); expect(webHistory!.currentIndex, 1); expect(webHistory.list!.length, 2); - expect(webHistory.list![0].url.toString(), TEST_CROSS_PLATFORM_URL_1.toString()); + expect(webHistory.list![0].url.toString(), + TEST_CROSS_PLATFORM_URL_1.toString()); expect(webHistory.list![1].url.toString(), TEST_URL_1.toString()); await Future.delayed(Duration(seconds: 1)); @@ -79,7 +84,8 @@ void webHistory() { expect(await controller.canGoBackOrForward(steps: 1), true); expect(webHistory!.currentIndex, 0); expect(webHistory.list!.length, 2); - expect(webHistory.list![0].url.toString(), TEST_CROSS_PLATFORM_URL_1.toString()); + expect(webHistory.list![0].url.toString(), + TEST_CROSS_PLATFORM_URL_1.toString()); expect(webHistory.list![1].url.toString(), TEST_URL_1.toString()); await Future.delayed(Duration(seconds: 1)); @@ -94,7 +100,8 @@ void webHistory() { expect(await controller.canGoBackOrForward(steps: 1), false); expect(webHistory!.currentIndex, 1); expect(webHistory.list!.length, 2); - expect(webHistory.list![0].url.toString(), TEST_CROSS_PLATFORM_URL_1.toString()); + expect(webHistory.list![0].url.toString(), + TEST_CROSS_PLATFORM_URL_1.toString()); expect(webHistory.list![1].url.toString(), TEST_URL_1.toString()); await Future.delayed(Duration(seconds: 1)); @@ -109,7 +116,8 @@ void webHistory() { expect(await controller.canGoBackOrForward(steps: 1), true); expect(webHistory!.currentIndex, 0); expect(webHistory.list!.length, 2); - expect(webHistory.list![0].url.toString(), TEST_CROSS_PLATFORM_URL_1.toString()); + expect(webHistory.list![0].url.toString(), + TEST_CROSS_PLATFORM_URL_1.toString()); expect(webHistory.list![1].url.toString(), TEST_URL_1.toString()); }, skip: shouldSkipTest1); @@ -118,7 +126,7 @@ void webHistory() { testWidgets('go back/forward on web platform', (WidgetTester tester) async { final Completer controllerCompleter = Completer(); final StreamController pageLoads = - StreamController.broadcast(); + StreamController.broadcast(); await tester.pumpWidget( Directionality( @@ -136,7 +144,8 @@ void webHistory() { ), ); - final InAppWebViewController controller = await controllerCompleter.future; + final InAppWebViewController controller = + await controllerCompleter.future; var url = await pageLoads.stream.first; expect(url, TEST_WEB_PLATFORM_URL_1.toString()); @@ -164,24 +173,23 @@ void webHistory() { pageLoads.close(); }, skip: shouldSkipTest2); - final shouldSkipTest3 = kIsWeb || - ![ - TargetPlatform.android, - ].contains(defaultTargetPlatform); + final shouldSkipTest3 = kIsWeb + ? true + : ![ + TargetPlatform.android, + ].contains(defaultTargetPlatform); testWidgets('clearHistory', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = Completer(); final StreamController pageLoads = - StreamController.broadcast(); + StreamController.broadcast(); await tester.pumpWidget( Directionality( 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); }, @@ -193,11 +201,9 @@ void webHistory() { ); final InAppWebViewController controller = - await controllerCompleter.future; + await controllerCompleter.future; await pageLoads.stream.first; - await controller.loadUrl( - urlRequest: - URLRequest(url: TEST_URL_1)); + await controller.loadUrl(urlRequest: URLRequest(url: TEST_URL_1)); await pageLoads.stream.first; var webHistory = await controller.getCopyBackForwardList(); diff --git a/example/integration_test/in_app_webview/web_message.dart b/example/integration_test/in_app_webview/web_message.dart index 3cd54e30..0cd7a02a 100644 --- a/example/integration_test/in_app_webview/web_message.dart +++ b/example/integration_test/in_app_webview/web_message.dart @@ -8,12 +8,13 @@ import 'package:flutter_test/flutter_test.dart'; import '../constants.dart'; void webMessage() { - final shouldSkip = kIsWeb || - ![ - TargetPlatform.android, - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); + final shouldSkip = kIsWeb + ? true + : ![ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); group('WebMessage', () { testWidgets('WebMessageChannel', (WidgetTester tester) async { diff --git a/example/integration_test/in_app_webview/webview_windows.dart b/example/integration_test/in_app_webview/webview_windows.dart index 9c267117..f2dc40d1 100644 --- a/example/integration_test/in_app_webview/webview_windows.dart +++ b/example/integration_test/in_app_webview/webview_windows.dart @@ -9,21 +9,23 @@ import 'package:flutter_test/flutter_test.dart'; import '../constants.dart'; void webViewWindows() { - final shouldSkip = !kIsWeb || - ![ - TargetPlatform.android, - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); - - group("WebView Windows", () { - final shouldSkipTest1 = kIsWeb || - ![ + final shouldSkip = kIsWeb + ? false + : ![ TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS, ].contains(defaultTargetPlatform); + group("WebView Windows", () { + final shouldSkipTest1 = kIsWeb + ? true + : ![ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); + testWidgets('onCreateWindow return false', (WidgetTester tester) async { final Completer controllerCompleter = Completer(); final Completer pageLoaded = Completer(); @@ -57,12 +59,13 @@ void webViewWindows() { await expectLater(pageLoaded.future, completes); }, skip: shouldSkipTest1); - final shouldSkipTest2 = kIsWeb || - ![ - TargetPlatform.android, - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); + final shouldSkipTest2 = kIsWeb + ? true + : ![ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); testWidgets('onCreateWindow return true', (WidgetTester tester) async { final Completer controllerCompleter = Completer(); @@ -127,12 +130,13 @@ void webViewWindows() { await expectLater(onCloseWindowCompleter.future, completes); }, skip: shouldSkipTest2); - final shouldSkipTest3 = kIsWeb || - ![ - TargetPlatform.android, - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); + final shouldSkipTest3 = kIsWeb + ? true + : ![ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); testWidgets('window.open() with target _blank opens in same window', (WidgetTester tester) async { @@ -170,70 +174,68 @@ void webViewWindows() { pageLoads.close(); }, skip: shouldSkipTest3); - final shouldSkipTest4 = kIsWeb || - ![ - TargetPlatform.android, - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); + final shouldSkipTest4 = kIsWeb + ? true + : ![ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); - testWidgets( - 'can open new window and go back', - (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); - final StreamController pageLoads = - StreamController.broadcast(); - await tester.pumpWidget( - Directionality( - textDirection: TextDirection.ltr, - child: InAppWebView( - key: GlobalKey(), - initialUrlRequest: URLRequest(url: TEST_CROSS_PLATFORM_URL_1), - onWebViewCreated: (controller) { - controllerCompleter.complete(controller); - }, - initialSettings: InAppWebViewSettings( - javaScriptEnabled: true, - javaScriptCanOpenWindowsAutomatically: true, - ), - onLoadStop: (controller, url) { - pageLoads.add(url!.toString()); - }, + testWidgets('can open new window and go back', (WidgetTester tester) async { + final Completer controllerCompleter = Completer(); + final StreamController pageLoads = + StreamController.broadcast(); + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: InAppWebView( + key: GlobalKey(), + initialUrlRequest: URLRequest(url: TEST_CROSS_PLATFORM_URL_1), + onWebViewCreated: (controller) { + controllerCompleter.complete(controller); + }, + initialSettings: InAppWebViewSettings( + javaScriptEnabled: true, + javaScriptCanOpenWindowsAutomatically: true, ), + onLoadStop: (controller, url) { + pageLoads.add(url!.toString()); + }, ), - ); - await pageLoads.stream.first; - final InAppWebViewController controller = - await controllerCompleter.future; + ), + ); + await pageLoads.stream.first; + final InAppWebViewController controller = + await controllerCompleter.future; - await tester.pump(); + await tester.pump(); - await controller.evaluateJavascript( - source: 'window.open("$TEST_URL_1");'); - await pageLoads.stream.first; - expect( - (await controller.getUrl())?.toString(), contains(TEST_URL_1.host)); + await controller.evaluateJavascript( + source: 'window.open("$TEST_URL_1");'); + await pageLoads.stream.first; + expect( + (await controller.getUrl())?.toString(), contains(TEST_URL_1.host)); - await controller.goBack(); - await pageLoads.stream.first; - expect((await controller.getUrl())?.toString(), - contains(TEST_CROSS_PLATFORM_URL_1.host)); + await controller.goBack(); + await pageLoads.stream.first; + expect((await controller.getUrl())?.toString(), + contains(TEST_CROSS_PLATFORM_URL_1.host)); - pageLoads.close(); - }, skip: shouldSkipTest4); + pageLoads.close(); + }, skip: shouldSkipTest4); - final shouldSkipTest5 = kIsWeb || - ![ - TargetPlatform.android, - TargetPlatform.iOS, - TargetPlatform.macOS, - ].contains(defaultTargetPlatform); + final shouldSkipTest5 = kIsWeb + ? true + : ![ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + ].contains(defaultTargetPlatform); - testWidgets( - 'javascript does not run in parent window', - (WidgetTester tester) async { - final String iframe = ''' + testWidgets('javascript does not run in parent window', + (WidgetTester tester) async { + final String iframe = ''' '''; - final String iframeTestBase64 = - base64Encode(const Utf8Encoder().convert(iframe)); + final String iframeTestBase64 = + base64Encode(const Utf8Encoder().convert(iframe)); - final String openWindowTest = ''' + final String openWindowTest = ''' @@ -261,47 +263,46 @@ void webViewWindows() { '''; - final String openWindowTestBase64 = - base64Encode(const Utf8Encoder().convert(openWindowTest)); - final Completer controllerCompleter = - Completer(); - final Completer pageLoadCompleter = Completer(); + final String openWindowTestBase64 = + base64Encode(const Utf8Encoder().convert(openWindowTest)); + final Completer controllerCompleter = Completer(); + final Completer pageLoadCompleter = Completer(); - await tester.pumpWidget( - Directionality( - textDirection: TextDirection.ltr, - child: InAppWebView( - key: GlobalKey(), - initialUrlRequest: URLRequest( - url: Uri.parse( - 'data:text/html;charset=utf-8;base64,$openWindowTestBase64')), - onWebViewCreated: (controller) { - controllerCompleter.complete(controller); - }, - initialSettings: InAppWebViewSettings( - javaScriptEnabled: true, - javaScriptCanOpenWindowsAutomatically: true, - ), - onLoadStop: (controller, url) { - pageLoadCompleter.complete(); - }, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: InAppWebView( + key: GlobalKey(), + initialUrlRequest: URLRequest( + url: Uri.parse( + 'data:text/html;charset=utf-8;base64,$openWindowTestBase64')), + onWebViewCreated: (controller) { + controllerCompleter.complete(controller); + }, + initialSettings: InAppWebViewSettings( + javaScriptEnabled: true, + javaScriptCanOpenWindowsAutomatically: true, ), + onLoadStop: (controller, url) { + pageLoadCompleter.complete(); + }, ), - ); + ), + ); - final InAppWebViewController controller = - await controllerCompleter.future; - await pageLoadCompleter.future; + final InAppWebViewController controller = + await controllerCompleter.future; + await pageLoadCompleter.future; - expect(controller.evaluateJavascript(source: 'iframeLoaded'), - completion(true)); - expect( - controller.evaluateJavascript( - source: - 'document.querySelector("p") && document.querySelector("p").textContent'), - completion(null), - ); - }, skip: shouldSkipTest5); + expect(controller.evaluateJavascript(source: 'iframeLoaded'), + completion(true)); + expect( + controller.evaluateJavascript( + source: + 'document.querySelector("p") && document.querySelector("p").textContent'), + completion(null), + ); + }, skip: shouldSkipTest5); final shouldSkipTest6 = !kIsWeb; @@ -322,15 +323,18 @@ void webViewWindows() { controllerCompleter.complete(controller); }, onCreateWindow: (controller, createNavigationAction) async { - onCreateWindowCalled.complete(createNavigationAction.request.url.toString()); + onCreateWindowCalled + .complete(createNavigationAction.request.url.toString()); return false; }, ), ), ); - final InAppWebViewController controller = await controllerCompleter.future; - await controller.evaluateJavascript(source: "window.open('$TEST_CROSS_PLATFORM_URL_1')"); + final InAppWebViewController controller = + await controllerCompleter.future; + await controller.evaluateJavascript( + source: "window.open('$TEST_CROSS_PLATFORM_URL_1')"); var url = await onCreateWindowCalled.future; expect(url, TEST_CROSS_PLATFORM_URL_1.toString()); diff --git a/example/ios/Flutter/flutter_export_environment.sh b/example/ios/Flutter/flutter_export_environment.sh index 9e98dd5e..03bce7c9 100755 --- a/example/ios/Flutter/flutter_export_environment.sh +++ b/example/ios/Flutter/flutter_export_environment.sh @@ -3,11 +3,11 @@ export "FLUTTER_ROOT=/Users/lorenzopichilli/fvm/versions/2.10.4" export "FLUTTER_APPLICATION_PATH=/Users/lorenzopichilli/Desktop/flutter_inappwebview/example" export "COCOAPODS_PARALLEL_CODE_SIGN=true" -export "FLUTTER_TARGET=/Users/lorenzopichilli/Desktop/flutter_inappwebview/example/lib/main.dart" +export "FLUTTER_TARGET=integration_test/webview_flutter_test.dart" export "FLUTTER_BUILD_DIR=build" export "FLUTTER_BUILD_NAME=1.0.0" export "FLUTTER_BUILD_NUMBER=1" -export "DART_DEFINES=Zmx1dHRlci5pbnNwZWN0b3Iuc3RydWN0dXJlZEVycm9ycz10cnVl,RkxVVFRFUl9XRUJfQVVUT19ERVRFQ1Q9dHJ1ZQ==" +export "DART_DEFINES=RkxVVFRFUl9XRUJfQVVUT19ERVRFQ1Q9dHJ1ZQ==" export "DART_OBFUSCATION=false" export "TRACK_WIDGET_CREATION=true" export "TREE_SHAKE_ICONS=false" diff --git a/lib/src/android/service_worker_controller.dart b/lib/src/android/service_worker_controller.dart index cb58e9ea..b31d15ab 100644 --- a/lib/src/android/service_worker_controller.dart +++ b/lib/src/android/service_worker_controller.dart @@ -23,8 +23,11 @@ class ServiceWorkerController { ServiceWorkerClient? get serviceWorkerClient => _serviceWorkerClient; - ///Sets the service worker client - setServiceWorkerClient(ServiceWorkerClient? value) async { + ///Sets the service worker client. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - ServiceWorkerControllerCompat.setServiceWorkerClient](https://developer.android.com/reference/androidx/webkit/ServiceWorkerControllerCompat#setServiceWorkerClient(androidx.webkit.ServiceWorkerClientCompat))) + Future setServiceWorkerClient(ServiceWorkerClient? value) async { Map args = {}; args.putIfAbsent('isNull', () => value == null); await _channel.invokeMethod("setServiceWorkerClient", args); diff --git a/lib/src/in_app_webview/in_app_webview_controller.dart b/lib/src/in_app_webview/in_app_webview_controller.dart index 50dfd24d..f9b3f32f 100644 --- a/lib/src/in_app_webview/in_app_webview_controller.dart +++ b/lib/src/in_app_webview/in_app_webview_controller.dart @@ -2090,24 +2090,16 @@ class InAppWebViewController await _channel.invokeMethod('clearMatches', args); } - ///Gets the html (with javascript) of the Chromium's t-rex runner game. Used in combination with [getTRexRunnerCss]. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS + ///Use [tRexRunnerHtml] instead. + @Deprecated("Use tRexRunnerHtml instead") Future getTRexRunnerHtml() async { - return await rootBundle.loadString( - "packages/flutter_inappwebview/assets/t_rex_runner/t-rex.html"); + return await InAppWebViewController.tRexRunnerHtml; } - ///Gets the css of the Chromium's t-rex runner game. Used in combination with [getTRexRunnerHtml]. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS + ///Use [tRexRunnerCss] instead. + @Deprecated("Use tRexRunnerCss instead") Future getTRexRunnerCss() async { - return await rootBundle.loadString( - "packages/flutter_inappwebview/assets/t_rex_runner/t-rex.css"); + return await InAppWebViewController.tRexRunnerCss; } ///Scrolls the WebView to the position. @@ -3116,6 +3108,22 @@ class InAppWebViewController return await _staticChannel.invokeMethod('handlesURLScheme', args); } + ///Gets the html (with javascript) of the Chromium's t-rex runner game. Used in combination with [getTRexRunnerCss]. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + static Future get tRexRunnerHtml async => await rootBundle.loadString( + 'packages/flutter_inappwebview/assets/t_rex_runner/t-rex.html'); + + ///Gets the css of the Chromium's t-rex runner game. Used in combination with [getTRexRunnerHtml]. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + static Future get tRexRunnerCss async => await rootBundle.loadString( + 'packages/flutter_inappwebview/assets/t_rex_runner/t-rex.css'); + ///Used internally. MethodChannel getChannel() { return _channel; diff --git a/lib/src/in_app_webview/webview.dart b/lib/src/in_app_webview/webview.dart index f882c246..32bafebb 100644 --- a/lib/src/in_app_webview/webview.dart +++ b/lib/src/in_app_webview/webview.dart @@ -2,7 +2,6 @@ import 'dart:collection'; import 'dart:typed_data'; import 'package:flutter/foundation.dart'; -import 'package:flutter_inappwebview/flutter_inappwebview_web.dart'; import '../pull_to_refresh/pull_to_refresh_controller.dart';