updated tests
This commit is contained in:
parent
f45996e187
commit
a8593f557e
|
@ -7,8 +7,9 @@ import '../constants.dart';
|
||||||
import '../util.dart';
|
import '../util.dart';
|
||||||
|
|
||||||
void customActionButton() {
|
void customActionButton() {
|
||||||
final shouldSkip = kIsWeb ||
|
final shouldSkip = kIsWeb
|
||||||
![
|
? true
|
||||||
|
: ![
|
||||||
TargetPlatform.android,
|
TargetPlatform.android,
|
||||||
].contains(defaultTargetPlatform);
|
].contains(defaultTargetPlatform);
|
||||||
|
|
||||||
|
@ -25,16 +26,14 @@ void customActionButton() {
|
||||||
}));
|
}));
|
||||||
expect(chromeSafariBrowser.isOpened(), false);
|
expect(chromeSafariBrowser.isOpened(), false);
|
||||||
|
|
||||||
await chromeSafariBrowser.open(
|
await chromeSafariBrowser.open(url: TEST_URL_1);
|
||||||
url: TEST_URL_1);
|
|
||||||
await chromeSafariBrowser.browserCreated.future;
|
await chromeSafariBrowser.browserCreated.future;
|
||||||
expect(chromeSafariBrowser.isOpened(), true);
|
expect(chromeSafariBrowser.isOpened(), true);
|
||||||
expect(() async {
|
expect(() async {
|
||||||
await chromeSafariBrowser.open(url: TEST_CROSS_PLATFORM_URL_1);
|
await chromeSafariBrowser.open(url: TEST_CROSS_PLATFORM_URL_1);
|
||||||
}, throwsA(isInstanceOf<ChromeSafariBrowserAlreadyOpenedException>()));
|
}, throwsA(isInstanceOf<ChromeSafariBrowserAlreadyOpenedException>()));
|
||||||
|
|
||||||
await expectLater(
|
await expectLater(chromeSafariBrowser.firstPageLoaded.future, completes);
|
||||||
chromeSafariBrowser.firstPageLoaded.future, completes);
|
|
||||||
await chromeSafariBrowser.close();
|
await chromeSafariBrowser.close();
|
||||||
await chromeSafariBrowser.browserClosed.future;
|
await chromeSafariBrowser.browserClosed.future;
|
||||||
expect(chromeSafariBrowser.isOpened(), false);
|
expect(chromeSafariBrowser.isOpened(), false);
|
||||||
|
|
|
@ -6,8 +6,9 @@ import '../constants.dart';
|
||||||
import '../util.dart';
|
import '../util.dart';
|
||||||
|
|
||||||
void customMenuItem() {
|
void customMenuItem() {
|
||||||
final shouldSkip = kIsWeb ||
|
final shouldSkip = kIsWeb
|
||||||
![
|
? true
|
||||||
|
: ![
|
||||||
TargetPlatform.android,
|
TargetPlatform.android,
|
||||||
TargetPlatform.iOS,
|
TargetPlatform.iOS,
|
||||||
TargetPlatform.macOS,
|
TargetPlatform.macOS,
|
||||||
|
@ -23,8 +24,7 @@ void customMenuItem() {
|
||||||
}));
|
}));
|
||||||
expect(chromeSafariBrowser.isOpened(), false);
|
expect(chromeSafariBrowser.isOpened(), false);
|
||||||
|
|
||||||
await chromeSafariBrowser.open(
|
await chromeSafariBrowser.open(url: TEST_URL_1);
|
||||||
url: TEST_URL_1);
|
|
||||||
await chromeSafariBrowser.browserCreated.future;
|
await chromeSafariBrowser.browserCreated.future;
|
||||||
expect(chromeSafariBrowser.isOpened(), true);
|
expect(chromeSafariBrowser.isOpened(), true);
|
||||||
expect(() async {
|
expect(() async {
|
||||||
|
|
|
@ -6,12 +6,13 @@ import '../constants.dart';
|
||||||
import '../util.dart';
|
import '../util.dart';
|
||||||
|
|
||||||
void customTabs() {
|
void customTabs() {
|
||||||
final shouldSkip = kIsWeb ||
|
final shouldSkip = kIsWeb
|
||||||
![
|
? true
|
||||||
|
: ![
|
||||||
TargetPlatform.android,
|
TargetPlatform.android,
|
||||||
].contains(defaultTargetPlatform);
|
].contains(defaultTargetPlatform);
|
||||||
|
|
||||||
group('Custom Tabs', () async {
|
group('Custom Tabs', () {
|
||||||
test('single instance', () async {
|
test('single instance', () async {
|
||||||
var chromeSafariBrowser = new MyChromeSafariBrowser();
|
var chromeSafariBrowser = new MyChromeSafariBrowser();
|
||||||
expect(chromeSafariBrowser.isOpened(), false);
|
expect(chromeSafariBrowser.isOpened(), false);
|
||||||
|
|
|
@ -6,8 +6,9 @@ import '../constants.dart';
|
||||||
import '../util.dart';
|
import '../util.dart';
|
||||||
|
|
||||||
void openAndClose() {
|
void openAndClose() {
|
||||||
final shouldSkip = kIsWeb ||
|
final shouldSkip = kIsWeb
|
||||||
![
|
? true
|
||||||
|
: ![
|
||||||
TargetPlatform.android,
|
TargetPlatform.android,
|
||||||
TargetPlatform.iOS,
|
TargetPlatform.iOS,
|
||||||
TargetPlatform.macOS,
|
TargetPlatform.macOS,
|
||||||
|
@ -17,8 +18,7 @@ void openAndClose() {
|
||||||
var chromeSafariBrowser = new MyChromeSafariBrowser();
|
var chromeSafariBrowser = new MyChromeSafariBrowser();
|
||||||
expect(chromeSafariBrowser.isOpened(), false);
|
expect(chromeSafariBrowser.isOpened(), false);
|
||||||
|
|
||||||
await chromeSafariBrowser.open(
|
await chromeSafariBrowser.open(url: TEST_URL_1);
|
||||||
url: TEST_URL_1);
|
|
||||||
await chromeSafariBrowser.browserCreated.future;
|
await chromeSafariBrowser.browserCreated.future;
|
||||||
expect(chromeSafariBrowser.isOpened(), true);
|
expect(chromeSafariBrowser.isOpened(), true);
|
||||||
expect(() async {
|
expect(() async {
|
||||||
|
|
|
@ -6,12 +6,13 @@ import '../constants.dart';
|
||||||
import '../util.dart';
|
import '../util.dart';
|
||||||
|
|
||||||
void trustedWebActivity() {
|
void trustedWebActivity() {
|
||||||
final shouldSkip = kIsWeb ||
|
final shouldSkip = kIsWeb
|
||||||
![
|
? true
|
||||||
|
: ![
|
||||||
TargetPlatform.android,
|
TargetPlatform.android,
|
||||||
].contains(defaultTargetPlatform);
|
].contains(defaultTargetPlatform);
|
||||||
|
|
||||||
group('Trusted Web Activity', () async {
|
group('Trusted Web Activity', () {
|
||||||
test('basic', () async {
|
test('basic', () async {
|
||||||
var chromeSafariBrowser = new MyChromeSafariBrowser();
|
var chromeSafariBrowser = new MyChromeSafariBrowser();
|
||||||
expect(chromeSafariBrowser.isOpened(), false);
|
expect(chromeSafariBrowser.isOpened(), false);
|
||||||
|
|
|
@ -11,7 +11,7 @@ final TEST_WEB_PLATFORM_BASE_URL = Uri.parse(Uri.base.toString().replaceFirst("/
|
||||||
final TEST_WEB_PLATFORM_URL_1 = Uri.parse(TEST_WEB_PLATFORM_BASE_URL.toString() + 'page.html');
|
final TEST_WEB_PLATFORM_URL_1 = Uri.parse(TEST_WEB_PLATFORM_BASE_URL.toString() + 'page.html');
|
||||||
final TEST_WEB_PLATFORM_URL_2 = Uri.parse(TEST_WEB_PLATFORM_BASE_URL.toString() + 'page-2.html');
|
final TEST_WEB_PLATFORM_URL_2 = Uri.parse(TEST_WEB_PLATFORM_BASE_URL.toString() + 'page-2.html');
|
||||||
final TEST_WEB_PLATFORM_URL_3 = Uri.parse(TEST_WEB_PLATFORM_BASE_URL.toString() + 'heavy-page.html');
|
final TEST_WEB_PLATFORM_URL_3 = Uri.parse(TEST_WEB_PLATFORM_BASE_URL.toString() + 'heavy-page.html');
|
||||||
final TEST_NOT_A_WEBSITE_URL = Uri.parse('https://www.notawebsite..com');
|
final TEST_NOT_A_WEBSITE_URL = Uri.parse('https://www.notawebsite..com/');
|
||||||
final TEST_CHROME_SAFE_BROWSING_MALWARE = Uri.parse('chrome://safe-browsing/match?type=malware');
|
final TEST_CHROME_SAFE_BROWSING_MALWARE = Uri.parse('chrome://safe-browsing/match?type=malware');
|
||||||
final TEST_PERMISSION_SITE = Uri.parse('https://permission.site/');
|
final TEST_PERMISSION_SITE = Uri.parse('https://permission.site/');
|
||||||
final TEST_SERVICE_WORKER_URL = Uri.parse('https://mdn.github.io/sw-test/');
|
final TEST_SERVICE_WORKER_URL = Uri.parse('https://mdn.github.io/sw-test/');
|
||||||
|
|
|
@ -8,8 +8,9 @@ import 'package:flutter_test/flutter_test.dart';
|
||||||
import '../constants.dart';
|
import '../constants.dart';
|
||||||
|
|
||||||
void setGetDelete() {
|
void setGetDelete() {
|
||||||
final shouldSkip = kIsWeb ||
|
final shouldSkip = kIsWeb
|
||||||
![
|
? true
|
||||||
|
: ![
|
||||||
TargetPlatform.android,
|
TargetPlatform.android,
|
||||||
TargetPlatform.iOS,
|
TargetPlatform.iOS,
|
||||||
TargetPlatform.macOS,
|
TargetPlatform.macOS,
|
||||||
|
@ -24,15 +25,13 @@ void setGetDelete() {
|
||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
child: InAppWebView(
|
child: InAppWebView(
|
||||||
key: GlobalKey(),
|
key: GlobalKey(),
|
||||||
initialUrlRequest:
|
initialUrlRequest: URLRequest(url: TEST_CROSS_PLATFORM_URL_1),
|
||||||
URLRequest(url: TEST_CROSS_PLATFORM_URL_1),
|
|
||||||
onWebViewCreated: (controller) {
|
onWebViewCreated: (controller) {
|
||||||
controllerCompleter.complete(controller);
|
controllerCompleter.complete(controller);
|
||||||
},
|
},
|
||||||
initialOptions: InAppWebViewGroupOptions(
|
initialSettings: InAppWebViewSettings(
|
||||||
crossPlatform: InAppWebViewOptions(
|
|
||||||
clearCache: true,
|
clearCache: true,
|
||||||
)),
|
),
|
||||||
onLoadStop: (controller, url) {
|
onLoadStop: (controller, url) {
|
||||||
pageLoaded.complete(url!.toString());
|
pageLoaded.complete(url!.toString());
|
||||||
},
|
},
|
||||||
|
@ -42,13 +41,11 @@ void setGetDelete() {
|
||||||
|
|
||||||
final url = Uri.parse(await pageLoaded.future);
|
final url = Uri.parse(await pageLoaded.future);
|
||||||
|
|
||||||
await cookieManager.setCookie(
|
await cookieManager.setCookie(url: url, name: "myCookie", value: "myValue");
|
||||||
url: url, name: "myCookie", value: "myValue");
|
|
||||||
List<Cookie> cookies = await cookieManager.getCookies(url: url);
|
List<Cookie> cookies = await cookieManager.getCookies(url: url);
|
||||||
expect(cookies, isNotEmpty);
|
expect(cookies, isNotEmpty);
|
||||||
|
|
||||||
Cookie? cookie =
|
Cookie? cookie = await cookieManager.getCookie(url: url, name: "myCookie");
|
||||||
await cookieManager.getCookie(url: url, name: "myCookie");
|
|
||||||
expect(cookie?.value.toString(), "myValue");
|
expect(cookie?.value.toString(), "myValue");
|
||||||
|
|
||||||
await cookieManager.deleteCookie(url: url, name: "myCookie");
|
await cookieManager.deleteCookie(url: url, name: "myCookie");
|
||||||
|
|
|
@ -8,8 +8,9 @@ import 'package:flutter_test/flutter_test.dart';
|
||||||
import '../constants.dart';
|
import '../constants.dart';
|
||||||
|
|
||||||
void customSize() {
|
void customSize() {
|
||||||
final shouldSkip = !kIsWeb ||
|
final shouldSkip = kIsWeb
|
||||||
![
|
? false
|
||||||
|
: ![
|
||||||
TargetPlatform.android,
|
TargetPlatform.android,
|
||||||
TargetPlatform.iOS,
|
TargetPlatform.iOS,
|
||||||
TargetPlatform.macOS,
|
TargetPlatform.macOS,
|
||||||
|
@ -19,8 +20,7 @@ void customSize() {
|
||||||
final Completer controllerCompleter = Completer<InAppWebViewController>();
|
final Completer controllerCompleter = Completer<InAppWebViewController>();
|
||||||
|
|
||||||
var headlessWebView = new HeadlessInAppWebView(
|
var headlessWebView = new HeadlessInAppWebView(
|
||||||
initialUrlRequest:
|
initialUrlRequest: URLRequest(url: TEST_CROSS_PLATFORM_URL_1),
|
||||||
URLRequest(url: TEST_CROSS_PLATFORM_URL_1),
|
|
||||||
initialSize: Size(600, 800),
|
initialSize: Size(600, 800),
|
||||||
onWebViewCreated: (controller) {
|
onWebViewCreated: (controller) {
|
||||||
controllerCompleter.complete(controller);
|
controllerCompleter.complete(controller);
|
||||||
|
|
|
@ -7,7 +7,7 @@ import 'package:flutter_test/flutter_test.dart';
|
||||||
import '../constants.dart';
|
import '../constants.dart';
|
||||||
|
|
||||||
void runAndDispose() {
|
void runAndDispose() {
|
||||||
final shouldSkip = !kIsWeb ||
|
final shouldSkip = kIsWeb ? false :
|
||||||
![
|
![
|
||||||
TargetPlatform.android,
|
TargetPlatform.android,
|
||||||
TargetPlatform.iOS,
|
TargetPlatform.iOS,
|
||||||
|
|
|
@ -7,8 +7,9 @@ import 'package:flutter_test/flutter_test.dart';
|
||||||
import '../constants.dart';
|
import '../constants.dart';
|
||||||
|
|
||||||
void setGetSettings() {
|
void setGetSettings() {
|
||||||
final shouldSkip = !kIsWeb ||
|
final shouldSkip = kIsWeb
|
||||||
![
|
? false
|
||||||
|
: ![
|
||||||
TargetPlatform.android,
|
TargetPlatform.android,
|
||||||
TargetPlatform.iOS,
|
TargetPlatform.iOS,
|
||||||
TargetPlatform.macOS,
|
TargetPlatform.macOS,
|
||||||
|
@ -19,8 +20,7 @@ void setGetSettings() {
|
||||||
final Completer<void> pageLoaded = Completer<void>();
|
final Completer<void> pageLoaded = Completer<void>();
|
||||||
|
|
||||||
var headlessWebView = new HeadlessInAppWebView(
|
var headlessWebView = new HeadlessInAppWebView(
|
||||||
initialUrlRequest:
|
initialUrlRequest: URLRequest(url: TEST_CROSS_PLATFORM_URL_1),
|
||||||
URLRequest(url: TEST_CROSS_PLATFORM_URL_1),
|
|
||||||
initialSettings: InAppWebViewSettings(javaScriptEnabled: false),
|
initialSettings: InAppWebViewSettings(javaScriptEnabled: false),
|
||||||
onWebViewCreated: (controller) {
|
onWebViewCreated: (controller) {
|
||||||
controllerCompleter.complete(controller);
|
controllerCompleter.complete(controller);
|
||||||
|
|
|
@ -7,8 +7,9 @@ import '../constants.dart';
|
||||||
import '../util.dart';
|
import '../util.dart';
|
||||||
|
|
||||||
void openDataAndClose() {
|
void openDataAndClose() {
|
||||||
final shouldSkip = kIsWeb ||
|
final shouldSkip = kIsWeb
|
||||||
![
|
? true
|
||||||
|
: ![
|
||||||
TargetPlatform.android,
|
TargetPlatform.android,
|
||||||
TargetPlatform.iOS,
|
TargetPlatform.iOS,
|
||||||
TargetPlatform.macOS,
|
TargetPlatform.macOS,
|
||||||
|
@ -45,8 +46,7 @@ void openDataAndClose() {
|
||||||
expect(inAppBrowser.isOpened(), true);
|
expect(inAppBrowser.isOpened(), true);
|
||||||
expect(() async {
|
expect(() async {
|
||||||
await inAppBrowser.openUrlRequest(
|
await inAppBrowser.openUrlRequest(
|
||||||
urlRequest:
|
urlRequest: URLRequest(url: TEST_URL_1));
|
||||||
URLRequest(url: TEST_URL_1));
|
|
||||||
}, throwsA(isInstanceOf<InAppBrowserAlreadyOpenedException>()));
|
}, throwsA(isInstanceOf<InAppBrowserAlreadyOpenedException>()));
|
||||||
|
|
||||||
await inAppBrowser.firstPageLoaded.future;
|
await inAppBrowser.firstPageLoaded.future;
|
||||||
|
|
|
@ -7,8 +7,9 @@ import '../constants.dart';
|
||||||
import '../util.dart';
|
import '../util.dart';
|
||||||
|
|
||||||
void openFileAndClose() {
|
void openFileAndClose() {
|
||||||
final shouldSkip = kIsWeb ||
|
final shouldSkip = kIsWeb
|
||||||
![
|
? true
|
||||||
|
: ![
|
||||||
TargetPlatform.android,
|
TargetPlatform.android,
|
||||||
TargetPlatform.iOS,
|
TargetPlatform.iOS,
|
||||||
TargetPlatform.macOS,
|
TargetPlatform.macOS,
|
||||||
|
@ -27,8 +28,7 @@ void openFileAndClose() {
|
||||||
expect(inAppBrowser.isOpened(), true);
|
expect(inAppBrowser.isOpened(), true);
|
||||||
expect(() async {
|
expect(() async {
|
||||||
await inAppBrowser.openUrlRequest(
|
await inAppBrowser.openUrlRequest(
|
||||||
urlRequest:
|
urlRequest: URLRequest(url: TEST_URL_1));
|
||||||
URLRequest(url: TEST_URL_1));
|
|
||||||
}, throwsA(isInstanceOf<InAppBrowserAlreadyOpenedException>()));
|
}, throwsA(isInstanceOf<InAppBrowserAlreadyOpenedException>()));
|
||||||
|
|
||||||
await inAppBrowser.firstPageLoaded.future;
|
await inAppBrowser.firstPageLoaded.future;
|
||||||
|
|
|
@ -7,8 +7,9 @@ import '../constants.dart';
|
||||||
import '../util.dart';
|
import '../util.dart';
|
||||||
|
|
||||||
void openUrlAndClose() {
|
void openUrlAndClose() {
|
||||||
final shouldSkip = kIsWeb ||
|
final shouldSkip = kIsWeb
|
||||||
![
|
? true
|
||||||
|
: ![
|
||||||
TargetPlatform.android,
|
TargetPlatform.android,
|
||||||
TargetPlatform.iOS,
|
TargetPlatform.iOS,
|
||||||
TargetPlatform.macOS,
|
TargetPlatform.macOS,
|
||||||
|
@ -21,8 +22,7 @@ void openUrlAndClose() {
|
||||||
await inAppBrowser.show();
|
await inAppBrowser.show();
|
||||||
}, throwsA(isInstanceOf<InAppBrowserNotOpenedException>()));
|
}, throwsA(isInstanceOf<InAppBrowserNotOpenedException>()));
|
||||||
|
|
||||||
await inAppBrowser.openUrlRequest(
|
await inAppBrowser.openUrlRequest(urlRequest: URLRequest(url: TEST_URL_1));
|
||||||
urlRequest: URLRequest(url: TEST_URL_1));
|
|
||||||
await inAppBrowser.browserCreated.future;
|
await inAppBrowser.browserCreated.future;
|
||||||
expect(inAppBrowser.isOpened(), true);
|
expect(inAppBrowser.isOpened(), true);
|
||||||
expect(() async {
|
expect(() async {
|
||||||
|
|
|
@ -6,8 +6,9 @@ import '../constants.dart';
|
||||||
import '../util.dart';
|
import '../util.dart';
|
||||||
|
|
||||||
void setGetSettings() {
|
void setGetSettings() {
|
||||||
final shouldSkip = kIsWeb ||
|
final shouldSkip = kIsWeb
|
||||||
![
|
? true
|
||||||
|
: ![
|
||||||
TargetPlatform.android,
|
TargetPlatform.android,
|
||||||
TargetPlatform.iOS,
|
TargetPlatform.iOS,
|
||||||
TargetPlatform.macOS,
|
TargetPlatform.macOS,
|
||||||
|
|
|
@ -6,8 +6,9 @@ import 'package:flutter_inappwebview/flutter_inappwebview.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
|
||||||
void loadAssetFile(InAppLocalhostServer localhostServer) {
|
void loadAssetFile(InAppLocalhostServer localhostServer) {
|
||||||
final shouldSkip = kIsWeb ||
|
final shouldSkip = kIsWeb
|
||||||
![
|
? true
|
||||||
|
: ![
|
||||||
TargetPlatform.android,
|
TargetPlatform.android,
|
||||||
TargetPlatform.iOS,
|
TargetPlatform.iOS,
|
||||||
TargetPlatform.macOS,
|
TargetPlatform.macOS,
|
||||||
|
@ -30,8 +31,7 @@ void loadAssetFile(InAppLocalhostServer localhostServer) {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
final InAppWebViewController controller =
|
final InAppWebViewController controller = await controllerCompleter.future;
|
||||||
await controllerCompleter.future;
|
|
||||||
final String? currentUrl = (await controller.getUrl())?.toString();
|
final String? currentUrl = (await controller.getUrl())?.toString();
|
||||||
expect(currentUrl, 'http://localhost:8080/test_assets/index.html');
|
expect(currentUrl, 'http://localhost:8080/test_assets/index.html');
|
||||||
}, skip: shouldSkip);
|
}, skip: shouldSkip);
|
||||||
|
|
|
@ -44,6 +44,8 @@ void onPermissionRequest() {
|
||||||
onPermissionRequest:
|
onPermissionRequest:
|
||||||
(controller, PermissionRequest permissionRequest) async {
|
(controller, PermissionRequest permissionRequest) async {
|
||||||
onPermissionRequestCompleter.complete(permissionRequest.resources);
|
onPermissionRequestCompleter.complete(permissionRequest.resources);
|
||||||
|
return PermissionResponse(resources: permissionRequest.resources,
|
||||||
|
action: PermissionResponseAction.GRANT);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -53,6 +55,7 @@ void onPermissionRequest() {
|
||||||
await pageLoaded.future;
|
await pageLoaded.future;
|
||||||
await controller.evaluateJavascript(
|
await controller.evaluateJavascript(
|
||||||
source: "document.querySelector('#camera').click();");
|
source: "document.querySelector('#camera').click();");
|
||||||
|
await tester.pump();
|
||||||
final List<PermissionResourceType> resources =
|
final List<PermissionResourceType> resources =
|
||||||
await onPermissionRequestCompleter.future;
|
await onPermissionRequestCompleter.future;
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@ void onPrint() {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
await tester.pump();
|
||||||
final String printUrl = await onPrintCompleter.future;
|
final String printUrl = await onPrintCompleter.future;
|
||||||
expect(printUrl, url.toString());
|
expect(printUrl, url.toString());
|
||||||
}, skip: shouldSkip);
|
}, skip: shouldSkip);
|
||||||
|
|
|
@ -41,7 +41,7 @@ void printCurrentPage() {
|
||||||
final InAppWebViewController controller =
|
final InAppWebViewController controller =
|
||||||
await controllerCompleter.future;
|
await controllerCompleter.future;
|
||||||
await pageLoaded.future;
|
await pageLoaded.future;
|
||||||
|
await tester.pump();
|
||||||
await expectLater(controller.printCurrentPage(), completes);
|
await expectLater(controller.printCurrentPage(), completes);
|
||||||
}, skip: shouldSkip);
|
}, skip: shouldSkip);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,8 +8,9 @@ import 'package:flutter_test/flutter_test.dart';
|
||||||
import '../constants.dart';
|
import '../constants.dart';
|
||||||
|
|
||||||
void takeScreenshot() {
|
void takeScreenshot() {
|
||||||
final shouldSkip = kIsWeb ||
|
final shouldSkip = kIsWeb
|
||||||
![
|
? true
|
||||||
|
: ![
|
||||||
TargetPlatform.android,
|
TargetPlatform.android,
|
||||||
TargetPlatform.iOS,
|
TargetPlatform.iOS,
|
||||||
TargetPlatform.macOS,
|
TargetPlatform.macOS,
|
||||||
|
@ -24,8 +25,7 @@ void takeScreenshot() {
|
||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
child: InAppWebView(
|
child: InAppWebView(
|
||||||
key: GlobalKey(),
|
key: GlobalKey(),
|
||||||
initialUrlRequest:
|
initialUrlRequest: URLRequest(url: TEST_CROSS_PLATFORM_URL_1),
|
||||||
URLRequest(url: TEST_CROSS_PLATFORM_URL_1),
|
|
||||||
onWebViewCreated: (controller) {
|
onWebViewCreated: (controller) {
|
||||||
controllerCompleter.complete(controller);
|
controllerCompleter.complete(controller);
|
||||||
},
|
},
|
||||||
|
@ -36,8 +36,7 @@ void takeScreenshot() {
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
final InAppWebViewController controller =
|
final InAppWebViewController controller = await controllerCompleter.future;
|
||||||
await controllerCompleter.future;
|
|
||||||
await pageLoaded.future;
|
await pageLoaded.future;
|
||||||
|
|
||||||
var screenshotConfiguration = ScreenshotConfiguration(
|
var screenshotConfiguration = ScreenshotConfiguration(
|
||||||
|
|
|
@ -190,6 +190,9 @@ void videoPlaybackPolicy() {
|
||||||
);
|
);
|
||||||
|
|
||||||
await pageLoaded.future;
|
await pageLoaded.future;
|
||||||
|
|
||||||
|
await tester.pump();
|
||||||
|
|
||||||
await expectLater(onEnterFullscreenCompleter.future, completes);
|
await expectLater(onEnterFullscreenCompleter.future, completes);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -228,6 +231,7 @@ void videoPlaybackPolicy() {
|
||||||
await pageLoaded.future;
|
await pageLoaded.future;
|
||||||
|
|
||||||
await Future.delayed(Duration(seconds: 2));
|
await Future.delayed(Duration(seconds: 2));
|
||||||
|
await tester.pump();
|
||||||
await controller.evaluateJavascript(source: "exitFullscreen();");
|
await controller.evaluateJavascript(source: "exitFullscreen();");
|
||||||
|
|
||||||
await expectLater(onExitFullscreenCompleter.future, completes);
|
await expectLater(onExitFullscreenCompleter.future, completes);
|
||||||
|
|
|
@ -25,8 +25,6 @@ void webHistory() {
|
||||||
|
|
||||||
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>();
|
final Completer controllerCompleter = Completer<InAppWebViewController>();
|
||||||
final StreamController<String> pageLoads =
|
|
||||||
StreamController<String>.broadcast();
|
|
||||||
|
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
Directionality(
|
Directionality(
|
||||||
|
@ -37,8 +35,8 @@ void webHistory() {
|
||||||
onWebViewCreated: (controller) {
|
onWebViewCreated: (controller) {
|
||||||
controllerCompleter.complete(controller);
|
controllerCompleter.complete(controller);
|
||||||
},
|
},
|
||||||
onLoadStop: (controller, url) {
|
onLoadStart: (controller, url) {
|
||||||
pageLoads.add(url!.toString());
|
// pageLoads.add(url!.toString());
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -46,7 +44,8 @@ void webHistory() {
|
||||||
|
|
||||||
final InAppWebViewController controller = await controllerCompleter.future;
|
final InAppWebViewController controller = await controllerCompleter.future;
|
||||||
|
|
||||||
var url = await pageLoads.stream.first;
|
await Future.delayed(Duration(seconds: 1));
|
||||||
|
var url = (await controller.getUrl()).toString();
|
||||||
var webHistory = await controller.getCopyBackForwardList();
|
var webHistory = await controller.getCopyBackForwardList();
|
||||||
expect(url, TEST_CROSS_PLATFORM_URL_1.toString());
|
expect(url, TEST_CROSS_PLATFORM_URL_1.toString());
|
||||||
expect(webHistory!.currentIndex, 0);
|
expect(webHistory!.currentIndex, 0);
|
||||||
|
@ -55,7 +54,8 @@ void webHistory() {
|
||||||
|
|
||||||
await controller.loadUrl(
|
await controller.loadUrl(
|
||||||
urlRequest: URLRequest(url: TEST_URL_1));
|
urlRequest: URLRequest(url: TEST_URL_1));
|
||||||
url = await pageLoads.stream.first;
|
await Future.delayed(Duration(seconds: 1));
|
||||||
|
url = (await controller.getUrl()).toString();
|
||||||
webHistory = await controller.getCopyBackForwardList();
|
webHistory = await controller.getCopyBackForwardList();
|
||||||
expect(url, TEST_URL_1.toString());
|
expect(url, TEST_URL_1.toString());
|
||||||
expect(await controller.canGoBack(), true);
|
expect(await controller.canGoBack(), true);
|
||||||
|
@ -69,7 +69,8 @@ void webHistory() {
|
||||||
|
|
||||||
await Future.delayed(Duration(seconds: 1));
|
await Future.delayed(Duration(seconds: 1));
|
||||||
await controller.goBack();
|
await controller.goBack();
|
||||||
url = await pageLoads.stream.first;
|
await Future.delayed(Duration(seconds: 1));
|
||||||
|
url = (await controller.getUrl()).toString();
|
||||||
webHistory = await controller.getCopyBackForwardList();
|
webHistory = await controller.getCopyBackForwardList();
|
||||||
expect(url, TEST_CROSS_PLATFORM_URL_1.toString());
|
expect(url, TEST_CROSS_PLATFORM_URL_1.toString());
|
||||||
expect(await controller.canGoBack(), false);
|
expect(await controller.canGoBack(), false);
|
||||||
|
@ -83,7 +84,8 @@ void webHistory() {
|
||||||
|
|
||||||
await Future.delayed(Duration(seconds: 1));
|
await Future.delayed(Duration(seconds: 1));
|
||||||
await controller.goForward();
|
await controller.goForward();
|
||||||
url = await pageLoads.stream.first;
|
await Future.delayed(Duration(seconds: 1));
|
||||||
|
url = (await controller.getUrl()).toString();
|
||||||
webHistory = await controller.getCopyBackForwardList();
|
webHistory = await controller.getCopyBackForwardList();
|
||||||
expect(url, TEST_URL_1.toString());
|
expect(url, TEST_URL_1.toString());
|
||||||
expect(await controller.canGoBack(), true);
|
expect(await controller.canGoBack(), true);
|
||||||
|
@ -97,7 +99,8 @@ void webHistory() {
|
||||||
|
|
||||||
await Future.delayed(Duration(seconds: 1));
|
await Future.delayed(Duration(seconds: 1));
|
||||||
await controller.goTo(historyItem: webHistory.list![0]);
|
await controller.goTo(historyItem: webHistory.list![0]);
|
||||||
url = await pageLoads.stream.first;
|
await Future.delayed(Duration(seconds: 1));
|
||||||
|
url = (await controller.getUrl()).toString();
|
||||||
webHistory = await controller.getCopyBackForwardList();
|
webHistory = await controller.getCopyBackForwardList();
|
||||||
expect(url, TEST_CROSS_PLATFORM_URL_1.toString());
|
expect(url, TEST_CROSS_PLATFORM_URL_1.toString());
|
||||||
expect(await controller.canGoBack(), false);
|
expect(await controller.canGoBack(), false);
|
||||||
|
@ -108,8 +111,6 @@ void webHistory() {
|
||||||
expect(webHistory.list!.length, 2);
|
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());
|
expect(webHistory.list![1].url.toString(), TEST_URL_1.toString());
|
||||||
|
|
||||||
pageLoads.close();
|
|
||||||
}, skip: shouldSkipTest1);
|
}, skip: shouldSkipTest1);
|
||||||
|
|
||||||
final shouldSkipTest2 = !kIsWeb;
|
final shouldSkipTest2 = !kIsWeb;
|
||||||
|
|
|
@ -98,19 +98,23 @@ void webMessage() {
|
||||||
allowedOriginRules: Set.from(["https://*.example.com"]),
|
allowedOriginRules: Set.from(["https://*.example.com"]),
|
||||||
onPostMessage:
|
onPostMessage:
|
||||||
(message, sourceOrigin, isMainFrame, replyProxy) {
|
(message, sourceOrigin, isMainFrame, replyProxy) {
|
||||||
assert(
|
if (isMainFrame &&
|
||||||
sourceOrigin.toString() == TEST_URL_EXAMPLE.toString());
|
(sourceOrigin.toString() + '/') ==
|
||||||
assert(isMainFrame);
|
TEST_URL_EXAMPLE.toString()) {
|
||||||
|
|
||||||
replyProxy.postMessage(message! + " and back");
|
replyProxy.postMessage(message! + " and back");
|
||||||
|
} else {
|
||||||
|
replyProxy.postMessage("Nope");
|
||||||
|
}
|
||||||
},
|
},
|
||||||
));
|
));
|
||||||
controllerCompleter.complete(controller);
|
controllerCompleter.complete(controller);
|
||||||
},
|
},
|
||||||
onConsoleMessage: (controller, consoleMessage) {
|
onConsoleMessage: (controller, consoleMessage) {
|
||||||
|
print(consoleMessage);
|
||||||
webMessageCompleter.complete(consoleMessage.message);
|
webMessageCompleter.complete(consoleMessage.message);
|
||||||
},
|
},
|
||||||
onLoadStop: (controller, url) async {
|
onLoadStop: (controller, url) async {
|
||||||
|
print(url);
|
||||||
if (url.toString() == TEST_URL_EXAMPLE.toString()) {
|
if (url.toString() == TEST_URL_EXAMPLE.toString()) {
|
||||||
pageLoaded.complete();
|
pageLoaded.complete();
|
||||||
}
|
}
|
||||||
|
|
|
@ -207,6 +207,8 @@ void webViewWindows() {
|
||||||
final InAppWebViewController controller =
|
final InAppWebViewController controller =
|
||||||
await controllerCompleter.future;
|
await controllerCompleter.future;
|
||||||
|
|
||||||
|
await tester.pump();
|
||||||
|
|
||||||
await controller.evaluateJavascript(
|
await controller.evaluateJavascript(
|
||||||
source: 'window.open("$TEST_URL_1");');
|
source: 'window.open("$TEST_URL_1");');
|
||||||
await pageLoads.stream.first;
|
await pageLoads.stream.first;
|
||||||
|
|
|
@ -8,8 +8,9 @@ import 'package:flutter_test/flutter_test.dart';
|
||||||
import '../constants.dart';
|
import '../constants.dart';
|
||||||
|
|
||||||
void setServiceWorkerClient() {
|
void setServiceWorkerClient() {
|
||||||
final shouldSkip = kIsWeb ||
|
final shouldSkip = kIsWeb
|
||||||
![
|
? true
|
||||||
|
: ![
|
||||||
TargetPlatform.android,
|
TargetPlatform.android,
|
||||||
].contains(defaultTargetPlatform);
|
].contains(defaultTargetPlatform);
|
||||||
|
|
||||||
|
@ -33,8 +34,7 @@ void setServiceWorkerClient() {
|
||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
child: InAppWebView(
|
child: InAppWebView(
|
||||||
key: GlobalKey(),
|
key: GlobalKey(),
|
||||||
initialUrlRequest:
|
initialUrlRequest: URLRequest(url: TEST_SERVICE_WORKER_URL),
|
||||||
URLRequest(url: TEST_SERVICE_WORKER_URL),
|
|
||||||
onLoadStop: (controller, url) {
|
onLoadStop: (controller, url) {
|
||||||
pageLoaded.complete(url!.toString());
|
pageLoaded.complete(url!.toString());
|
||||||
},
|
},
|
||||||
|
|
|
@ -8,8 +8,9 @@ import 'package:flutter_test/flutter_test.dart';
|
||||||
import '../constants.dart';
|
import '../constants.dart';
|
||||||
|
|
||||||
void shouldInterceptRequest() {
|
void shouldInterceptRequest() {
|
||||||
final shouldSkip = kIsWeb ||
|
final shouldSkip = kIsWeb
|
||||||
![
|
? true
|
||||||
|
: ![
|
||||||
TargetPlatform.android,
|
TargetPlatform.android,
|
||||||
].contains(defaultTargetPlatform);
|
].contains(defaultTargetPlatform);
|
||||||
|
|
||||||
|
|
|
@ -56,29 +56,14 @@ flutter:
|
||||||
uses-material-design: true
|
uses-material-design: true
|
||||||
|
|
||||||
assets:
|
assets:
|
||||||
- assets/index.html
|
- assets/
|
||||||
- assets/page-1.html
|
|
||||||
- assets/page-2.html
|
|
||||||
- assets/js/
|
- assets/js/
|
||||||
- assets/css/
|
- assets/css/
|
||||||
- assets/images/
|
- assets/images/
|
||||||
- assets/favicon.ico
|
- test_assets/
|
||||||
- assets/sample_audio.ogg
|
|
||||||
- assets/sample_video.mp4
|
|
||||||
- test_assets/certificate.pfx
|
|
||||||
- test_assets/in_app_webview_initial_file_test.html
|
|
||||||
- test_assets/in_app_webview_on_load_resource_test.html
|
|
||||||
- test_assets/in_app_webview_javascript_handler_test.html
|
|
||||||
- test_assets/in_app_webview_on_load_resource_custom_scheme_test.html
|
|
||||||
- test_assets/in_app_webview_on_console_message_test.html
|
|
||||||
- test_assets/in_app_webview_on_create_window_test.html
|
|
||||||
- test_assets/in_app_webview_on_js_dialog_test.html
|
|
||||||
- test_assets/js/
|
- test_assets/js/
|
||||||
- test_assets/css/
|
- test_assets/css/
|
||||||
- test_assets/images/
|
- test_assets/images/
|
||||||
- test_assets/favicon.ico
|
|
||||||
- test_assets/sample_audio.ogg
|
|
||||||
- test_assets/sample_video.mp4
|
|
||||||
|
|
||||||
# To add assets to your application, add an assets section, like this:
|
# To add assets to your application, add an assets section, like this:
|
||||||
# assets:
|
# assets:
|
||||||
|
|
|
@ -529,7 +529,7 @@ class InAppWebView extends StatefulWidget implements WebView {
|
||||||
}
|
}
|
||||||
|
|
||||||
class _InAppWebViewState extends State<InAppWebView> {
|
class _InAppWebViewState extends State<InAppWebView> {
|
||||||
late InAppWebViewController _controller;
|
InAppWebViewController? _controller;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
@ -663,18 +663,19 @@ class _InAppWebViewState extends State<InAppWebView> {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
dynamic viewId = _controller.getViewId();
|
dynamic viewId = _controller?.getViewId();
|
||||||
if (kIsWeb && WebPlatformManager.webViews.containsKey(viewId)) {
|
if (viewId != null && kIsWeb && WebPlatformManager.webViews.containsKey(viewId)) {
|
||||||
WebPlatformManager.webViews.remove(viewId);
|
WebPlatformManager.webViews.remove(viewId);
|
||||||
}
|
}
|
||||||
super.dispose();
|
super.dispose();
|
||||||
|
_controller = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onPlatformViewCreated(int id) {
|
void _onPlatformViewCreated(int id) {
|
||||||
_controller = InAppWebViewController(id, widget);
|
_controller = InAppWebViewController(id, widget);
|
||||||
widget.pullToRefreshController?.initMethodChannel(id);
|
widget.pullToRefreshController?.initMethodChannel(id);
|
||||||
if (widget.onWebViewCreated != null) {
|
if (widget.onWebViewCreated != null) {
|
||||||
widget.onWebViewCreated!(_controller);
|
widget.onWebViewCreated!(_controller!);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,10 +10,22 @@ function error() {
|
||||||
# on macOS local IP can be found using something like $(ipconfig getifaddr en0)
|
# on macOS local IP can be found using something like $(ipconfig getifaddr en0)
|
||||||
# on linux local IP can be found using something like $(ifconfig en0 | grep "inet " | grep -Fv 127.0.0.1 | awk '{print $2}') or $(ip route get 1 | awk '{print $NF;exit}')
|
# on linux local IP can be found using something like $(ifconfig en0 | grep "inet " | grep -Fv 127.0.0.1 | awk '{print $2}') or $(ip route get 1 | awk '{print $NF;exit}')
|
||||||
export NODE_SERVER_IP=$1
|
export NODE_SERVER_IP=$1
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
export NODE_SERVER_IP=$(ipconfig getifaddr en0)
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo Node Server IP: $NODE_SERVER_IP
|
||||||
|
|
||||||
|
if [ -z "$NODE_SERVER_IP" ]; then
|
||||||
|
echo No Server IP found
|
||||||
|
jobs -p | xargs kill
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
PLATFORM=$2
|
PLATFORM=$2
|
||||||
FAILED=0
|
FAILED=0
|
||||||
|
|
||||||
if [ $PLATFORM = "web" ]; then
|
if [ ! -z "$2" ] && [ $PLATFORM = "web" ]; then
|
||||||
$PROJECT_DIR/tool/chromedriver --port=4444 &
|
$PROJECT_DIR/tool/chromedriver --port=4444 &
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -26,7 +38,7 @@ flutter --version
|
||||||
flutter clean
|
flutter clean
|
||||||
cd $PROJECT_DIR/example
|
cd $PROJECT_DIR/example
|
||||||
flutter clean
|
flutter clean
|
||||||
if [ $PLATFORM = "web" ]; then
|
if [ ! -z "$2" ] && [ $PLATFORM = "web" ]; then
|
||||||
flutter driver --driver=test_driver/integration_test.dart --target=integration_test/webview_flutter_test.dart --device-id=chrome
|
flutter driver --driver=test_driver/integration_test.dart --target=integration_test/webview_flutter_test.dart --device-id=chrome
|
||||||
else
|
else
|
||||||
flutter driver --driver=test_driver/integration_test.dart --target=integration_test/webview_flutter_test.dart
|
flutter driver --driver=test_driver/integration_test.dart --target=integration_test/webview_flutter_test.dart
|
||||||
|
|
Loading…
Reference in New Issue