updated tests

This commit is contained in:
Lorenzo Pichilli 2022-04-29 13:39:28 +02:00
parent a8593f557e
commit 96259a782e
86 changed files with 967 additions and 964 deletions

View File

@ -6,8 +6,9 @@ import 'package:flutter_inappwebview/flutter_inappwebview.dart';
import 'package:flutter_test/flutter_test.dart';
void applePayAPI() {
final shouldSkip = kIsWeb ||
![
final shouldSkip = kIsWeb
? true
: ![
TargetPlatform.iOS,
TargetPlatform.macOS,
].contains(defaultTargetPlatform);

View File

@ -8,10 +8,10 @@ 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 || ![
final shouldSkip = kIsWeb
? true
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,

View File

@ -8,8 +8,9 @@ import 'package:flutter_test/flutter_test.dart';
import '../constants.dart';
void clearCache() {
final shouldSkip = kIsWeb ||
![
final shouldSkip = kIsWeb
? true
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
@ -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);

View File

@ -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 ||
![
final shouldSkip = kIsWeb
? true
: ![
TargetPlatform.android,
].contains(defaultTargetPlatform);
test('clearClientCertPreferences', () async {
await expectLater(
InAppWebViewController.clearClientCertPreferences(),
completes);
InAppWebViewController.clearClientCertPreferences(), completes);
}, skip: shouldSkip);
}

View File

@ -8,8 +8,9 @@ import 'package:flutter_test/flutter_test.dart';
import '../constants.dart';
void clearFocus() {
final shouldSkip = kIsWeb ||
![
final shouldSkip = kIsWeb
? true
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
@ -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);

View File

@ -8,14 +8,14 @@ import 'package:flutter_test/flutter_test.dart';
import '../constants.dart';
void clearSslPreferences() {
final shouldSkip = kIsWeb ||
![
final shouldSkip = kIsWeb
? true
: ![
TargetPlatform.android,
].contains(defaultTargetPlatform);
testWidgets('clearSslPreferences', (WidgetTester tester) async {
final Completer controllerCompleter =
Completer<InAppWebViewController>();
final Completer controllerCompleter = Completer<InAppWebViewController>();
final Completer<void> pageLoaded = Completer<void>();
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);

View File

@ -8,7 +8,9 @@ import 'package:flutter_test/flutter_test.dart';
import '../constants.dart';
void contentBlocker() {
final shouldSkip = kIsWeb || ![
final shouldSkip = kIsWeb
? true
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
@ -22,22 +24,21 @@ 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: [
initialSettings:
InAppWebViewSettings(clearCache: true, contentBlockers: [
ContentBlocker(
trigger:
ContentBlockerTrigger(urlFilter: ".*", resourceType: [
trigger: ContentBlockerTrigger(urlFilter: ".*", resourceType: [
ContentBlockerTriggerResourceType.IMAGE,
ContentBlockerTriggerResourceType.STYLE_SHEET
], ifTopUrl: [
TEST_CROSS_PLATFORM_URL_1.toString()
]),
action: ContentBlockerAction(
type: ContentBlockerActionType.BLOCK))
action:
ContentBlockerAction(type: ContentBlockerActionType.BLOCK))
]),
onLoadStop: (controller, url) {
pageLoaded.complete();

View File

@ -8,15 +8,15 @@ import 'package:flutter_test/flutter_test.dart';
import '../constants.dart';
void createPdf() {
final shouldSkip = kIsWeb ||
![
final shouldSkip = kIsWeb
? true
: ![
TargetPlatform.iOS,
TargetPlatform.macOS,
].contains(defaultTargetPlatform);
testWidgets('createPdf', (WidgetTester tester) async {
final Completer controllerCompleter =
Completer<InAppWebViewController>();
final Completer controllerCompleter = Completer<InAppWebViewController>();
final Completer<void> pageLoaded = Completer<void>();
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(

View File

@ -8,8 +8,9 @@ import 'package:flutter_test/flutter_test.dart';
import '../constants.dart';
void getCertificate() {
final shouldSkip = kIsWeb ||
![
final shouldSkip = kIsWeb
? true
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
@ -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();

View File

@ -8,8 +8,9 @@ import 'package:flutter_test/flutter_test.dart';
import '../constants.dart';
void getContentHeight() {
final shouldSkip = !kIsWeb ||
![
final shouldSkip = kIsWeb
? false
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
@ -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();

View File

@ -1,11 +1,11 @@
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 ||
![
final shouldSkip = kIsWeb
? true
: ![
TargetPlatform.android,
].contains(defaultTargetPlatform);

View File

@ -4,8 +4,9 @@ import 'package:flutter_inappwebview/flutter_inappwebview.dart';
import 'package:flutter_test/flutter_test.dart';
void getDefaultUserAgent() {
final shouldSkip = kIsWeb ||
![
final shouldSkip = kIsWeb
? true
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,

View File

@ -8,8 +8,9 @@ import 'package:flutter_test/flutter_test.dart';
import '../constants.dart';
void getFavicons() {
final shouldSkip = !kIsWeb ||
![
final shouldSkip = kIsWeb
? false
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
@ -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<Favicon>? favicons = await controller.getFavicons();

View File

@ -8,8 +8,9 @@ import 'package:flutter_test/flutter_test.dart';
import '../constants.dart';
void getHtml() {
final shouldSkip = !kIsWeb ||
![
final shouldSkip = kIsWeb
? false
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
@ -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();

View File

@ -8,8 +8,9 @@ import 'package:flutter_test/flutter_test.dart';
import '../constants.dart';
void getMetaTags() {
final shouldSkip = !kIsWeb ||
![
final shouldSkip = kIsWeb
? false
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
@ -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<MetaTag> metaTags = await controller.getMetaTags();

View File

@ -8,8 +8,9 @@ import 'package:flutter_test/flutter_test.dart';
import '../constants.dart';
void getMetaThemeColor() {
final shouldSkip = !kIsWeb ||
![
final shouldSkip = kIsWeb
? false
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
@ -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);

View File

@ -8,8 +8,9 @@ import 'package:flutter_test/flutter_test.dart';
import '../constants.dart';
void getOriginalUrl() {
final shouldSkip = !kIsWeb ||
![
final shouldSkip = kIsWeb
? false
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
@ -18,8 +19,7 @@ void getOriginalUrl() {
var url = !kIsWeb ? TEST_URL_1 : TEST_WEB_PLATFORM_URL_1;
testWidgets('getOriginalUrl', (WidgetTester tester) async {
final Completer controllerCompleter =
Completer<InAppWebViewController>();
final Completer controllerCompleter = Completer<InAppWebViewController>();
final Completer<void> pageLoaded = Completer<void>();
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());

View File

@ -8,8 +8,9 @@ import 'package:flutter_test/flutter_test.dart';
import '../constants.dart';
void getProgress() {
final shouldSkip = kIsWeb ||
![
final shouldSkip = kIsWeb
? true
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
@ -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();

View File

@ -9,7 +9,9 @@ import 'package:flutter_test/flutter_test.dart';
import '../constants.dart';
void getTitle() {
final shouldSkip = !kIsWeb || ![
final shouldSkip = kIsWeb
? false
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
@ -26,13 +28,12 @@ void getTitle() {
final String getTitleTestBase64 =
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<void> pageStarted = Completer<void>();
final Completer<void> pageLoaded = Completer<void>();
final Completer controllerCompleter = Completer<InAppWebViewController>();
@ -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,8 +56,7 @@ void getTitle() {
),
);
final InAppWebViewController controller =
await controllerCompleter.future;
final InAppWebViewController controller = await controllerCompleter.future;
await pageStarted.future;
await pageLoaded.future;

View File

@ -3,8 +3,9 @@ import 'package:flutter_inappwebview/flutter_inappwebview.dart';
import 'package:flutter_test/flutter_test.dart';
void handlesURLScheme() {
final shouldSkip = kIsWeb ||
![
final shouldSkip = kIsWeb
? true
: ![
TargetPlatform.iOS,
TargetPlatform.macOS,
].contains(defaultTargetPlatform);

View File

@ -8,8 +8,9 @@ import 'package:flutter_test/flutter_test.dart';
import '../.env.dart';
void httpAuthCredentialDatabase() {
final shouldSkip = kIsWeb ||
![
final shouldSkip = kIsWeb
? true
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,

View File

@ -8,16 +8,18 @@ import 'package:flutter_test/flutter_test.dart';
import '../constants.dart';
void initialUrlRequest() {
final shouldSkip = !kIsWeb ||
![
final shouldSkip = kIsWeb
? false
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
].contains(defaultTargetPlatform);
group('initial url request', () {
final shouldSkipTest1 = !kIsWeb ||
![
final shouldSkipTest1 = kIsWeb
? false
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
@ -45,8 +47,9 @@ void initialUrlRequest() {
expect(currentUrl, TEST_CROSS_PLATFORM_URL_1.toString());
}, skip: shouldSkipTest1);
final shouldSkipTest2 = kIsWeb ||
![
final shouldSkipTest2 = kIsWeb
? true
: ![
TargetPlatform.iOS,
TargetPlatform.macOS,
].contains(defaultTargetPlatform);
@ -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) {

View File

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

View File

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

View File

@ -9,8 +9,9 @@ import 'package:flutter_test/flutter_test.dart';
import '../.env.dart';
void interceptAjaxRequest() {
final shouldSkip = kIsWeb ||
![
final shouldSkip = kIsWeb
? true
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,

View File

@ -9,8 +9,9 @@ import 'package:flutter_test/flutter_test.dart';
import '../.env.dart';
void interceptFetchRequest() {
final shouldSkip = kIsWeb ||
![
final shouldSkip = kIsWeb
? true
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,

View File

@ -8,8 +8,9 @@ import 'package:flutter_test/flutter_test.dart';
import '../constants.dart';
void isLoading() {
final shouldSkip = kIsWeb ||
![
final shouldSkip = kIsWeb
? true
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
@ -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);

View File

@ -8,8 +8,9 @@ import 'package:flutter_test/flutter_test.dart';
import '../constants.dart';
void isSecureContext() {
final shouldSkip = !kIsWeb ||
![
final shouldSkip = kIsWeb
? false
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
@ -27,8 +28,7 @@ void isSecureContext() {
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);

View File

@ -8,16 +8,18 @@ import 'package:flutter_test/flutter_test.dart';
import '../constants.dart';
void javascriptCodeEvaluation() {
final shouldSkip = !kIsWeb ||
![
final shouldSkip = kIsWeb
? false
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
].contains(defaultTargetPlatform);
group('javascript code evaluation', () {
final shouldSkipTest1 = !kIsWeb ||
![
final shouldSkipTest1 = kIsWeb
? false
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
@ -57,8 +59,9 @@ void javascriptCodeEvaluation() {
mapEquals(result[3]?.cast<String, String>(), {"foo": "baz"}), true);
}, skip: shouldSkipTest1);
final shouldSkipTest2 = kIsWeb ||
![
final shouldSkipTest2 = kIsWeb
? true
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
@ -100,8 +103,9 @@ void javascriptCodeEvaluation() {
expect(result, 49);
}, skip: shouldSkipTest2);
final shouldSkipTest3 = kIsWeb ||
![
final shouldSkipTest3 = kIsWeb
? true
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
@ -159,8 +163,9 @@ void javascriptCodeEvaluation() {
expect(result.error, 'error message');
}, skip: shouldSkipTest3);
final shouldSkipTest4 = kIsWeb ||
![
final shouldSkipTest4 = kIsWeb
? true
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,

View File

@ -5,11 +5,10 @@ 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 ||
![
final shouldSkip = kIsWeb
? true
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,

View File

@ -8,7 +8,9 @@ import 'package:flutter_test/flutter_test.dart';
import '../util.dart';
void javascriptHandler() {
final shouldSkip = kIsWeb || ![
final shouldSkip = kIsWeb
? true
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
@ -44,10 +46,10 @@ void javascriptHandler() {
messagesReceived.add(args[0] as int);
messagesReceived.add(args[1] as bool);
messagesReceived.add(args[2] as List<dynamic>?);
messagesReceived.add(args[3]?.cast<String, String>()
as Map<String, String>?);
messagesReceived.add(args[4]?.cast<String, String>()
as Map<String, String>?);
messagesReceived.add(
args[3]?.cast<String, String>() as Map<String, String>?);
messagesReceived.add(
args[4]?.cast<String, String>() as Map<String, String>?);
handlerFooWithArgs.complete();
});
},
@ -69,8 +71,7 @@ void javascriptHandler() {
expect(messagesReceived[0], 1);
expect(messagesReceived[1], true);
expect(
listEquals(messagesReceived[2] as List<dynamic>?, ["bar", 5]), true);
expect(listEquals(messagesReceived[2] as List<dynamic>?, ["bar", 5]), true);
expect(mapEquals(messagesReceived[3], {"foo": "baz"}), true);
expect(
mapEquals(

View File

@ -8,8 +8,9 @@ import 'package:flutter_test/flutter_test.dart';
import '../constants.dart';
void loadData() {
final shouldSkip = !kIsWeb ||
![
final shouldSkip = kIsWeb
? false
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
@ -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();

View File

@ -8,8 +8,9 @@ import 'package:flutter_test/flutter_test.dart';
import '../constants.dart';
void loadFile() {
final shouldSkip = !kIsWeb ||
![
final shouldSkip = kIsWeb
? false
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
@ -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(

View File

@ -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,

View File

@ -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<InAppWebViewController>();
final StreamController<String> pageLoads =
StreamController<String>.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);
}

View File

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

View File

@ -8,8 +8,9 @@ import 'package:flutter_test/flutter_test.dart';
import '../.env.dart';
void onDownloadStartRequest() {
final shouldSkip = kIsWeb ||
![
final shouldSkip = kIsWeb
? true
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,

View File

@ -8,8 +8,9 @@ import 'package:flutter_test/flutter_test.dart';
import '../constants.dart';
void onFindResultReceived() {
final shouldSkip = kIsWeb ||
![
final shouldSkip = kIsWeb
? true
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,

View File

@ -8,8 +8,9 @@ import 'package:flutter_test/flutter_test.dart';
import '../constants.dart';
void onJsBeforeUnload() {
final shouldSkip = kIsWeb ||
![
final shouldSkip = kIsWeb
? true
: ![
TargetPlatform.android,
].contains(defaultTargetPlatform);
@ -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';");

View File

@ -8,8 +8,9 @@ import 'package:flutter_test/flutter_test.dart';
import '../constants.dart';
void onLoadError() {
final shouldSkip = kIsWeb ||
![
final shouldSkip = kIsWeb
? true
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,

View File

@ -8,7 +8,9 @@ import 'package:flutter_test/flutter_test.dart';
import '../constants.dart';
void onLoadHttpError() {
final shouldSkip = kIsWeb || ![
final shouldSkip = kIsWeb
? true
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
@ -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);

View File

@ -5,11 +5,10 @@ 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 ||
![
final shouldSkip = kIsWeb
? true
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,

View File

@ -7,8 +7,9 @@ import 'package:flutter_inappwebview/flutter_inappwebview.dart';
import 'package:flutter_test/flutter_test.dart';
void onLoadResourceCustomScheme() {
final shouldSkip = kIsWeb ||
![
final shouldSkip = kIsWeb
? true
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,

View File

@ -8,8 +8,9 @@ import 'package:flutter_test/flutter_test.dart';
import '../constants.dart';
void onNavigationResponse() {
final shouldSkip = kIsWeb ||
![
final shouldSkip = kIsWeb
? true
: ![
TargetPlatform.iOS,
TargetPlatform.macOS,
].contains(defaultTargetPlatform);
@ -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) {

View File

@ -8,8 +8,9 @@ import 'package:flutter_test/flutter_test.dart';
import '../constants.dart';
void onPageCommitVisible() {
final shouldSkip = kIsWeb ||
![
final shouldSkip = kIsWeb
? true
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
@ -17,16 +18,14 @@ void onPageCommitVisible() {
testWidgets('onPageCommitVisible', (WidgetTester tester) async {
final Completer controllerCompleter = Completer<InAppWebViewController>();
final Completer<String> onPageCommitVisibleCompleter =
Completer<String>();
final Completer<String> onPageCommitVisibleCompleter = Completer<String>();
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);
},

View File

@ -8,8 +8,9 @@ import 'package:flutter_test/flutter_test.dart';
import '../constants.dart';
void onPermissionRequest() {
final shouldSkip = kIsWeb ||
![
final shouldSkip = kIsWeb
? true
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
@ -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);
},
),

View File

@ -8,7 +8,9 @@ import 'package:flutter_test/flutter_test.dart';
import '../constants.dart';
void onPrint() {
final shouldSkip = !kIsWeb || ![
final shouldSkip = kIsWeb
? false
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
@ -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();");
},

View File

@ -8,8 +8,9 @@ import 'package:flutter_test/flutter_test.dart';
import '../constants.dart';
void onProgressChanged() {
final shouldSkip = kIsWeb ||
![
final shouldSkip = kIsWeb
? true
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
@ -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,
),

View File

@ -9,24 +9,23 @@ import 'package:flutter_test/flutter_test.dart';
import '../constants.dart';
void onReceivedIcon() {
final shouldSkip = kIsWeb ||
![
final shouldSkip = kIsWeb
? true
: ![
TargetPlatform.android,
].contains(defaultTargetPlatform);
testWidgets('onReceivedIcon', (WidgetTester tester) async {
final Completer controllerCompleter = Completer<InAppWebViewController>();
final Completer<void> pageLoaded = Completer<void>();
final Completer<Uint8List> onReceivedIconCompleter =
Completer<Uint8List>();
final Completer<Uint8List> onReceivedIconCompleter = Completer<Uint8List>();
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);
},

View File

@ -5,11 +5,10 @@ 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 ||
![
final shouldSkip = kIsWeb
? true
: ![
TargetPlatform.android,
].contains(defaultTargetPlatform);

View File

@ -8,7 +8,9 @@ import 'package:flutter_test/flutter_test.dart';
import '../constants.dart';
void onScrollChanged() {
final shouldSkip = !kIsWeb || ![
final shouldSkip = kIsWeb
? false
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
@ -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);

View File

@ -8,8 +8,9 @@ import 'package:flutter_test/flutter_test.dart';
import '../constants.dart';
void onTitleChanged() {
final shouldSkip = !kIsWeb ||
![
final shouldSkip = kIsWeb
? false
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
@ -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';");

View File

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

View File

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

View File

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

View File

@ -8,14 +8,14 @@ import 'package:flutter_test/flutter_test.dart';
import '../constants.dart';
void pageDownUp() {
final shouldSkip = kIsWeb ||
![
final shouldSkip = kIsWeb
? true
: ![
TargetPlatform.android,
].contains(defaultTargetPlatform);
testWidgets('pageDown/pageUp', (WidgetTester tester) async {
final Completer controllerCompleter =
Completer<InAppWebViewController>();
final Completer controllerCompleter = Completer<InAppWebViewController>();
final Completer<void> pageLoaded = Completer<void>();
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));

View File

@ -8,14 +8,14 @@ import 'package:flutter_test/flutter_test.dart';
import '../constants.dart';
void pauseResume() {
final shouldSkip = kIsWeb ||
![
final shouldSkip = kIsWeb
? true
: ![
TargetPlatform.android,
].contains(defaultTargetPlatform);
testWidgets('pause/resume', (WidgetTester tester) async {
final Completer controllerCompleter =
Completer<InAppWebViewController>();
final Completer controllerCompleter = Completer<InAppWebViewController>();
final Completer<void> pageLoaded = Completer<void>();
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));

View File

@ -8,8 +8,9 @@ import 'package:flutter_test/flutter_test.dart';
import '../constants.dart';
void pauseResumeTimers() {
final shouldSkip = kIsWeb ||
![
final shouldSkip = kIsWeb
? true
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
@ -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);
}

View File

@ -10,8 +10,9 @@ import 'package:flutter_test/flutter_test.dart';
import '../.env.dart';
void postRequests() {
final shouldSkip = kIsWeb ||
![
final shouldSkip = kIsWeb
? true
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
@ -19,8 +20,7 @@ void postRequests() {
group('POST requests', () {
testWidgets('initialUrlRequest', (WidgetTester tester) async {
final Completer controllerCompleter =
Completer<InAppWebViewController>();
final Completer controllerCompleter = Completer<InAppWebViewController>();
final Completer<void> postPageLoaded = Completer<void>();
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);
},
@ -51,8 +49,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;");
@ -60,8 +58,7 @@ void postRequests() {
});
testWidgets('loadUrl', (WidgetTester tester) async {
final Completer controllerCompleter =
Completer<InAppWebViewController>();
final Completer controllerCompleter = Completer<InAppWebViewController>();
final Completer<void> postPageLoaded = Completer<void>();
await tester.pumpWidget(
@ -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<InAppWebViewController>();
final Completer controllerCompleter = Completer<InAppWebViewController>();
final Completer<void> postPageLoaded = Completer<void>();
await tester.pumpWidget(
@ -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;");

View File

@ -8,8 +8,9 @@ import 'package:flutter_test/flutter_test.dart';
import '../constants.dart';
void printCurrentPage() {
final shouldSkip = !kIsWeb ||
![
final shouldSkip = kIsWeb
? false
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
@ -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);

View File

@ -9,14 +9,18 @@ import 'package:flutter_test/flutter_test.dart';
import '../constants.dart';
void programmaticScroll() {
final shouldSkip = !kIsWeb || ![
final shouldSkip = kIsWeb
? false
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
].contains(defaultTargetPlatform);
group('Programmatic Scroll', () {
final shouldSkipTest1 = !kIsWeb || ![
final shouldSkipTest1 = kIsWeb
? false
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
@ -47,20 +51,19 @@ void programmaticScroll() {
final String scrollTestPageBase64 =
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<void> pageLoaded = Completer<void>();
final Completer controllerCompleter =
Completer<InAppWebViewController>();
final Completer controllerCompleter = Completer<InAppWebViewController>();
await tester.pumpWidget(
Directionality(
textDirection: TextDirection.ltr,
child: InAppWebView(
initialUrlRequest: URLRequest(
url: url),
initialUrlRequest: URLRequest(url: url),
onWebViewCreated: (controller) {
controllerCompleter.complete(controller);
},
@ -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 = '''
<!DOCTYPE html>
<html>
@ -124,8 +135,7 @@ void programmaticScroll() {
base64Encode(const Utf8Encoder().convert(scrollTestPage));
final Completer<void> pageLoaded = Completer<void>();
final Completer controllerCompleter =
Completer<InAppWebViewController>();
final Completer controllerCompleter = Completer<InAppWebViewController>();
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();
},
@ -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);
}

View File

@ -8,22 +8,23 @@ import 'package:flutter_test/flutter_test.dart';
import '../constants.dart';
void programmaticZoomScale() {
final shouldSkip = kIsWeb ||
![
final shouldSkip = kIsWeb
? true
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
].contains(defaultTargetPlatform);
group('programmatic zoom scale', () {
final shouldSkipTest1 = kIsWeb ||
![
final shouldSkipTest1 = kIsWeb
? true
: ![
TargetPlatform.android,
].contains(defaultTargetPlatform);
testWidgets('zoomIn/zoomOut', (WidgetTester tester) async {
final Completer controllerCompleter =
Completer<InAppWebViewController>();
final Completer controllerCompleter = Completer<InAppWebViewController>();
final Completer<void> pageLoaded = Completer<void>();
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);
},
@ -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);
},

View File

@ -9,8 +9,9 @@ import 'package:flutter_test/flutter_test.dart';
import '../constants.dart';
void pullToRefresh() {
final shouldSkip = kIsWeb ||
![
final shouldSkip = kIsWeb
? true
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
@ -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);

View File

@ -8,8 +8,9 @@ import 'package:flutter_test/flutter_test.dart';
import '../constants.dart';
void reload() {
final shouldSkip = !kIsWeb ||
![
final shouldSkip = kIsWeb
? false
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
@ -18,8 +19,9 @@ void reload() {
var url = !kIsWeb ? TEST_URL_1 : TEST_WEB_PLATFORM_URL_1;
group('reload', () {
final shouldSkipTest1 = kIsWeb ||
![
final shouldSkipTest1 = kIsWeb
? true
: ![
TargetPlatform.iOS,
TargetPlatform.macOS,
].contains(defaultTargetPlatform);

View File

@ -8,8 +8,9 @@ import 'package:flutter_test/flutter_test.dart';
import '../constants.dart';
void requestFocusNodeHref() {
final shouldSkip = kIsWeb ||
![
final shouldSkip = kIsWeb
? true
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
@ -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);

View File

@ -8,8 +8,9 @@ import 'package:flutter_test/flutter_test.dart';
import '../constants.dart';
void requestImageRef() {
final shouldSkip = kIsWeb ||
![
final shouldSkip = kIsWeb
? true
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
@ -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);

View File

@ -6,10 +6,10 @@ 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 || ![
final shouldSkip = kIsWeb
? true
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,

View File

@ -8,8 +8,9 @@ import 'package:flutter_test/flutter_test.dart';
import '../constants.dart';
void safeBrowsing() {
final shouldSkip = kIsWeb ||
![
final shouldSkip = kIsWeb
? true
: ![
TargetPlatform.android,
].contains(defaultTargetPlatform);

View File

@ -8,8 +8,9 @@ import 'package:flutter_test/flutter_test.dart';
import '../constants.dart';
void setCustomUserAgent() {
final shouldSkip = kIsWeb ||
![
final shouldSkip = kIsWeb
? true
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,

View File

@ -8,7 +8,9 @@ import 'package:flutter_test/flutter_test.dart';
import '../constants.dart';
void setGetSettings() {
final shouldSkip = !kIsWeb || ![
final shouldSkip = kIsWeb
? false
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
@ -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);

View File

@ -1,11 +1,11 @@
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 ||
![
final shouldSkip = kIsWeb
? true
: ![
TargetPlatform.android,
].contains(defaultTargetPlatform);

View File

@ -6,8 +6,9 @@ import 'package:flutter_inappwebview/flutter_inappwebview.dart';
import 'package:flutter_test/flutter_test.dart';
void shouldInterceptRequest() {
final shouldSkip = kIsWeb ||
![
final shouldSkip = kIsWeb
? true
: ![
TargetPlatform.android,
].contains(defaultTargetPlatform);

View File

@ -9,8 +9,9 @@ import 'package:flutter_test/flutter_test.dart';
import '../constants.dart';
void shouldOverrideUrlLoading() {
final shouldSkip = kIsWeb ||
![
final shouldSkip = kIsWeb
? true
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
@ -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<InAppWebViewController>();
final StreamController<String> pageLoads =
@ -70,10 +64,11 @@ void shouldOverrideUrlLoading() {
expect(currentUrl, TEST_URL_2.toString());
pageLoads.close();
}, skip: shouldSkipTest1);
});
final shouldSkipTest2 = kIsWeb ||
![
final shouldSkipTest2 = kIsWeb
? true
: ![
TargetPlatform.iOS,
TargetPlatform.macOS,
].contains(defaultTargetPlatform);
@ -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<InAppWebViewController>();
final StreamController<String> 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<InAppWebViewController>();
@ -245,6 +226,6 @@ void shouldOverrideUrlLoading() {
expect(currentUrl, TEST_URL_2.toString());
pageLoads.close();
}, skip: shouldSkipTest4);
});
}, skip: shouldSkip);
}

View File

@ -8,7 +8,9 @@ import 'package:flutter_test/flutter_test.dart';
import '../.env.dart';
void sslRequest() {
final shouldSkip = kIsWeb || ![
final shouldSkip = kIsWeb
? true
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
@ -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,8 +46,7 @@ void sslRequest() {
),
),
);
final InAppWebViewController controller =
await controllerCompleter.future;
final InAppWebViewController controller = await controllerCompleter.future;
await pageLoaded.future;
final String h1Content = await controller.evaluateJavascript(

View File

@ -9,8 +9,9 @@ import '../constants.dart';
import '../util.dart';
void stopLoading() {
final shouldSkip = kIsWeb ||
![
final shouldSkip = kIsWeb
? true
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,

View File

@ -8,8 +8,9 @@ import 'package:flutter_test/flutter_test.dart';
import '../constants.dart';
void tRexRunnerGame() {
final shouldSkip = kIsWeb ||
![
final shouldSkip = kIsWeb
? true
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
@ -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);

View File

@ -9,8 +9,9 @@ import 'package:flutter_test/flutter_test.dart';
import '../constants.dart';
void userScripts() {
final shouldSkip = kIsWeb ||
![
final shouldSkip = kIsWeb
? true
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,

View File

@ -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,

View File

@ -10,24 +10,24 @@ import 'package:path_provider/path_provider.dart';
import '../constants.dart';
void webArchive() {
final shouldSkip = kIsWeb ||
![
final shouldSkip = kIsWeb
? true
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
].contains(defaultTargetPlatform);
group('web archive', () {
final shouldSkipTest1 = kIsWeb ||
![
final shouldSkipTest1 = kIsWeb
? true
: ![
TargetPlatform.iOS,
TargetPlatform.macOS,
].contains(defaultTargetPlatform);
testWidgets('create data', (WidgetTester tester) async {
final Completer controllerCompleter =
Completer<InAppWebViewController>();
final Completer controllerCompleter = Completer<InAppWebViewController>();
final Completer<void> pageLoaded = Completer<void>();
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);
},
@ -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);
},

View File

@ -8,22 +8,25 @@ import 'package:flutter_test/flutter_test.dart';
import '../constants.dart';
void webHistory() {
final shouldSkip = !kIsWeb ||
![
final shouldSkip = kIsWeb
? false
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
].contains(defaultTargetPlatform);
group('web history', () {
final shouldSkipTest1 = kIsWeb ||
![
final shouldSkipTest1 = kIsWeb
? true
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
].contains(defaultTargetPlatform);
testWidgets('get history list and go back/forward', (WidgetTester tester) async {
testWidgets('get history list and go back/forward',
(WidgetTester tester) async {
final Completer controllerCompleter = Completer<InAppWebViewController>();
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);
@ -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,14 +173,14 @@ void webHistory() {
pageLoads.close();
}, skip: shouldSkipTest2);
final shouldSkipTest3 = kIsWeb ||
![
final shouldSkipTest3 = kIsWeb
? true
: ![
TargetPlatform.android,
].contains(defaultTargetPlatform);
testWidgets('clearHistory', (WidgetTester tester) async {
final Completer controllerCompleter =
Completer<InAppWebViewController>();
final Completer controllerCompleter = Completer<InAppWebViewController>();
final StreamController<String> pageLoads =
StreamController<String>.broadcast();
@ -180,8 +189,7 @@ void webHistory() {
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);
},
@ -195,9 +203,7 @@ void webHistory() {
final InAppWebViewController controller =
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();

View File

@ -8,8 +8,9 @@ import 'package:flutter_test/flutter_test.dart';
import '../constants.dart';
void webMessage() {
final shouldSkip = kIsWeb ||
![
final shouldSkip = kIsWeb
? true
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,

View File

@ -9,16 +9,18 @@ import 'package:flutter_test/flutter_test.dart';
import '../constants.dart';
void webViewWindows() {
final shouldSkip = !kIsWeb ||
![
final shouldSkip = kIsWeb
? false
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
].contains(defaultTargetPlatform);
group("WebView Windows", () {
final shouldSkipTest1 = kIsWeb ||
![
final shouldSkipTest1 = kIsWeb
? true
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
@ -57,8 +59,9 @@ void webViewWindows() {
await expectLater(pageLoaded.future, completes);
}, skip: shouldSkipTest1);
final shouldSkipTest2 = kIsWeb ||
![
final shouldSkipTest2 = kIsWeb
? true
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
@ -127,8 +130,9 @@ void webViewWindows() {
await expectLater(onCloseWindowCompleter.future, completes);
}, skip: shouldSkipTest2);
final shouldSkipTest3 = kIsWeb ||
![
final shouldSkipTest3 = kIsWeb
? true
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
@ -170,18 +174,16 @@ void webViewWindows() {
pageLoads.close();
}, skip: shouldSkipTest3);
final shouldSkipTest4 = kIsWeb ||
![
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<InAppWebViewController>();
testWidgets('can open new window and go back', (WidgetTester tester) async {
final Completer controllerCompleter = Completer<InAppWebViewController>();
final StreamController<String> pageLoads =
StreamController<String>.broadcast();
await tester.pumpWidget(
@ -223,15 +225,15 @@ void webViewWindows() {
pageLoads.close();
}, skip: shouldSkipTest4);
final shouldSkipTest5 = kIsWeb ||
![
final shouldSkipTest5 = kIsWeb
? true
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
].contains(defaultTargetPlatform);
testWidgets(
'javascript does not run in parent window',
testWidgets('javascript does not run in parent window',
(WidgetTester tester) async {
final String iframe = '''
<!DOCTYPE html>
@ -263,8 +265,7 @@ void webViewWindows() {
''';
final String openWindowTestBase64 =
base64Encode(const Utf8Encoder().convert(openWindowTest));
final Completer controllerCompleter =
Completer<InAppWebViewController>();
final Completer controllerCompleter = Completer<InAppWebViewController>();
final Completer<void> pageLoadCompleter = Completer<void>();
await tester.pumpWidget(
@ -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());

View File

@ -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"

View File

@ -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<void> setServiceWorkerClient(ServiceWorkerClient? value) async {
Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent('isNull', () => value == null);
await _channel.invokeMethod("setServiceWorkerClient", args);

View File

@ -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<String> 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<String> 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<String> 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<String> get tRexRunnerCss async => await rootBundle.loadString(
'packages/flutter_inappwebview/assets/t_rex_runner/t-rex.css');
///Used internally.
MethodChannel getChannel() {
return _channel;

View File

@ -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';