fixed android content blocker, updated flutter driver tests
This commit is contained in:
parent
64f6995d83
commit
ec47b1918d
|
@ -9,6 +9,7 @@ about: Something is crashing or not working as intended
|
|||
**App version:** <!-- Add branch if necessary -->
|
||||
**Android version:** <!-- If customize ROM, write which -->
|
||||
**Device information:** <!-- Manufacturer and model -->
|
||||
**Flutter version:** <!-- Flutter version used -->
|
||||
|
||||
## Description
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -66,6 +66,9 @@ public class ContentBlockerHandler {
|
|||
for (ContentBlocker contentBlocker : ruleListCopy) {
|
||||
ContentBlockerTrigger trigger = contentBlocker.trigger;
|
||||
List<ContentBlockerTriggerResourceType> resourceTypes = trigger.resourceType;
|
||||
if (resourceTypes.contains(ContentBlockerTriggerResourceType.IMAGE) && !resourceTypes.contains(ContentBlockerTriggerResourceType.SVG_DOCUMENT)) {
|
||||
resourceTypes.add(ContentBlockerTriggerResourceType.SVG_DOCUMENT);
|
||||
}
|
||||
|
||||
ContentBlockerAction action = contentBlocker.action;
|
||||
|
||||
|
@ -173,6 +176,7 @@ public class ContentBlockerHandler {
|
|||
? contentTypeSplitted[1].replace("charset=", "").trim()
|
||||
: "utf-8";
|
||||
|
||||
response.body().close();
|
||||
response.close();
|
||||
|
||||
return new WebResourceResponse(contentType, encoding, dataStream);
|
||||
|
@ -180,6 +184,7 @@ public class ContentBlockerHandler {
|
|||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
if (response != null) {
|
||||
response.body().close();
|
||||
response.close();
|
||||
}
|
||||
Log.e(LOG_TAG, e.getMessage());
|
||||
|
@ -220,12 +225,14 @@ public class ContentBlockerHandler {
|
|||
? contentTypeSplitted[1].replace("charset=", "").trim()
|
||||
: "utf-8";
|
||||
|
||||
response.body().close();
|
||||
response.close();
|
||||
responseResourceType = getResourceTypeFromContentType(contentType);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
if (response != null) {
|
||||
response.body().close();
|
||||
response.close();
|
||||
}
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# This is a generated file; do not edit or check into version control.
|
||||
export "FLUTTER_ROOT=/Users/lorenzopichilli/flutter"
|
||||
export "FLUTTER_APPLICATION_PATH=/Users/lorenzopichilli/Desktop/flutter_inappbrowser/example"
|
||||
export "FLUTTER_TARGET=lib/main.dart"
|
||||
export "FLUTTER_TARGET=/Users/lorenzopichilli/Desktop/flutter_inappbrowser/example/test_driver/app.dart"
|
||||
export "FLUTTER_BUILD_DIR=build"
|
||||
export "SYMROOT=${SOURCE_ROOT}/../build/ios"
|
||||
export "FLUTTER_FRAMEWORK_DIR=/Users/lorenzopichilli/flutter/bin/cache/artifacts/engine/ios"
|
||||
|
|
|
@ -31,6 +31,7 @@ class _InAppWebViewExampleScreenState extends State<InAppWebViewExampleScreen> {
|
|||
InAppWebViewController webView;
|
||||
String url = "";
|
||||
double progress = 0;
|
||||
CookieManager cookieManager = CookieManager.instance();
|
||||
|
||||
TextEditingController _textFieldController = TextEditingController();
|
||||
|
||||
|
@ -124,7 +125,8 @@ class _InAppWebViewExampleScreenState extends State<InAppWebViewExampleScreen> {
|
|||
//initialUrl: "chrome://safe-browsing/match?type=malware",
|
||||
//initialUrl: "http://192.168.1.20:8081/",
|
||||
//initialUrl: "https://192.168.1.20:4433/",
|
||||
initialFile: "assets/index.html",
|
||||
//initialFile: "assets/index.html",
|
||||
initialUrl: "https://flutter.dev/",
|
||||
initialHeaders: {},
|
||||
initialOptions: InAppWebViewWidgetOptions(
|
||||
inAppWebViewOptions: InAppWebViewOptions(
|
||||
|
@ -134,7 +136,7 @@ class _InAppWebViewExampleScreenState extends State<InAppWebViewExampleScreen> {
|
|||
clearCache: true,
|
||||
//useShouldOverrideUrlLoading: true,
|
||||
useOnTargetBlank: true,
|
||||
//useOnLoadResource: true,
|
||||
useOnLoadResource: true,
|
||||
//useOnDownloadStart: true,
|
||||
//useShouldInterceptAjaxRequest: true,
|
||||
//useShouldInterceptFetchRequest: true,
|
||||
|
@ -151,7 +153,7 @@ class _InAppWebViewExampleScreenState extends State<InAppWebViewExampleScreen> {
|
|||
ContentBlockerTriggerResourceType.STYLE_SHEET
|
||||
],
|
||||
ifTopUrl: [
|
||||
"https://getbootstrap.com/"
|
||||
"https://flutter.dev/"
|
||||
]),
|
||||
action: ContentBlockerAction(
|
||||
type: ContentBlockerActionType.BLOCK))
|
||||
|
@ -195,11 +197,13 @@ class _InAppWebViewExampleScreenState extends State<InAppWebViewExampleScreen> {
|
|||
},
|
||||
onLoadStop: (InAppWebViewController controller, String url) async {
|
||||
print("stopped $url");
|
||||
|
||||
if (Platform.isAndroid) {
|
||||
controller.clearSslPreferences();
|
||||
controller.clearClientCertPreferences();
|
||||
}
|
||||
//controller.findAllAsync("flutter");
|
||||
//controller.findAllAsync(find: "InAppWebView");
|
||||
//controller.findAllAsync(find: "InAppWebViewInitialFileTest");
|
||||
print(await controller.getFavicons());
|
||||
print(await CookieManager.instance().getCookies(url: url));
|
||||
//await CookieManager.instance().setCookie(url: url, name: "myCookie", value: "myValue");
|
||||
|
|
|
@ -53,11 +53,8 @@ flutter:
|
|||
- 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_ajax_test.html
|
||||
- test_assets/in_app_webview_fetch_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_download_start_test.html
|
||||
- test_assets/in_app_webview_on_target_blank_test.html
|
||||
- test_assets/in_app_webview_on_js_dialog_test.html
|
||||
- test_assets/css/
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>InAppWebViewAjaxTest</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>InAppWebViewAjaxTest</h1>
|
||||
<script>
|
||||
window.addEventListener('flutterInAppBrowserPlatformReady', function(event) {
|
||||
var xhttp = new XMLHttpRequest();
|
||||
xhttp.open("POST", "http://192.168.1.20:8082/test-ajax-post");
|
||||
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
|
||||
xhttp.send("firstname=Foo&lastname=Bar");
|
||||
|
||||
var xhttp2 = new XMLHttpRequest();
|
||||
xhttp2.open("GET", "http://192.168.1.20:8082/test-download-file");
|
||||
xhttp2.send();
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -1,40 +0,0 @@
|
|||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>InAppWebViewFetchTest</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>InAppWebViewFetchTest</h1>
|
||||
<script>
|
||||
window.addEventListener('flutterInAppBrowserPlatformReady', function(event) {
|
||||
fetch(new Request("http://192.168.1.20:8082/test-download-file")).then(function(response) {
|
||||
window.flutter_inappbrowser.callHandler('fetchGet', response.status);
|
||||
}).catch(function(error) {
|
||||
window.flutter_inappbrowser.callHandler('fetchGet', "ERROR: " + error);
|
||||
});
|
||||
|
||||
fetch("http://192.168.1.20:8082/test-ajax-post", {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
firstname: 'Foo',
|
||||
lastname: 'Bar'
|
||||
}),
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
}).then(function(response) {
|
||||
response.json().then(function(value) {
|
||||
window.flutter_inappbrowser.callHandler('fetchPost', value);
|
||||
}).catch(function(error) {
|
||||
window.flutter_inappbrowser.callHandler('fetchPost', "ERROR: " + error);
|
||||
});
|
||||
}).catch(function(error) {
|
||||
window.flutter_inappbrowser.callHandler('fetchPost', "ERROR: " + error);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -1,18 +0,0 @@
|
|||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>InAppWebViewOnDownloadStartTest</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>InAppWebViewOnDownloadStartTest</h1>
|
||||
<a id="download-file" href="http://192.168.1.20:8082/test-download-file">download file</a>
|
||||
<script>
|
||||
window.addEventListener("flutterInAppBrowserPlatformReady", function(event) {
|
||||
document.querySelector("#download-file").click();
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,26 @@
|
|||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>InAppWebViewOnNavigationStateChangeTest</title>
|
||||
<base href="index.html">
|
||||
</head>
|
||||
<body>
|
||||
<h1>InAppWebViewOnNavigationStateChangeTest</h1>
|
||||
<script>
|
||||
window.addEventListener("flutterInAppBrowserPlatformReady", function(event) {
|
||||
var state = {}
|
||||
var title = ''
|
||||
var url = 'first-push';
|
||||
history.pushState(state, title, url);
|
||||
|
||||
setTimeout(function() {
|
||||
var url = 'second-push';
|
||||
history.pushState(state, title, url);
|
||||
}, 100);
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1 @@
|
|||
final environment = {"NODE_SERVER_IP":"192.168.1.20"};
|
|
@ -1,5 +1,4 @@
|
|||
import 'package:flutter_driver/driver_extension.dart';
|
||||
import 'app_test.dart';
|
||||
import 'main_test.dart' as app;
|
||||
|
||||
void main() {
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
// Imports the Flutter Driver API.
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter_driver/flutter_driver.dart';
|
||||
import 'package:test/test.dart';
|
||||
import '.env.dart';
|
||||
|
||||
void main() {
|
||||
|
||||
|
@ -22,38 +24,101 @@ void main() {
|
|||
}
|
||||
});
|
||||
|
||||
//
|
||||
// IMPORTANT NOTE!!!
|
||||
// These tests need to follow the same order of "var routes" in "buildRoutes()" function
|
||||
// defined in main_test.dart
|
||||
//
|
||||
|
||||
test('InAppWebViewInitialUrlTest', () async {
|
||||
await Future.delayed(const Duration(milliseconds: 2000));
|
||||
final appBarTitle = find.byValueKey('AppBarTitle');
|
||||
final sideMenuButton = find.byValueKey('SideMenu');
|
||||
final listTiles = find.byValueKey('ListTiles');
|
||||
final nextTest = find.byValueKey('InAppWebViewInitialFileTest');
|
||||
|
||||
while((await driver.getText(appBarTitle)) == "InAppWebViewInitialUrlTest") {
|
||||
await Future.delayed(const Duration(milliseconds: 1000));
|
||||
await Future.delayed(const Duration(milliseconds: 500));
|
||||
}
|
||||
|
||||
String url = await driver.getText(appBarTitle);
|
||||
expect(url, "https://flutter.dev/");
|
||||
|
||||
await driver.tap(sideMenuButton);
|
||||
await driver.scrollUntilVisible(listTiles, nextTest, dyScroll: -300.0);
|
||||
await driver.tap(nextTest);
|
||||
}, timeout: new Timeout(new Duration(minutes: 5)));
|
||||
|
||||
test('InAppWebViewInitialFileTest', () async {
|
||||
await Future.delayed(const Duration(milliseconds: 2000));
|
||||
final appBarTitle = find.byValueKey('AppBarTitle');
|
||||
|
||||
final sideMenuButton = find.byValueKey('SideMenu');
|
||||
final listTiles = find.byValueKey('ListTiles');
|
||||
final nextTest = find.byValueKey('InAppWebViewInitialDataTest');
|
||||
|
||||
while((await driver.getText(appBarTitle)) == "InAppWebViewInitialFileTest") {
|
||||
await Future.delayed(const Duration(milliseconds: 1000));
|
||||
await Future.delayed(const Duration(milliseconds: 500));
|
||||
}
|
||||
|
||||
String title = await driver.getText(appBarTitle);
|
||||
expect(title, "true");
|
||||
|
||||
await driver.tap(sideMenuButton);
|
||||
await driver.scrollUntilVisible(listTiles, nextTest, dyScroll: -300.0);
|
||||
await driver.tap(nextTest);
|
||||
}, timeout: new Timeout(new Duration(minutes: 5)));
|
||||
|
||||
test('InAppWebViewInitialDataTest', () async {
|
||||
final appBarTitle = find.byValueKey('AppBarTitle');
|
||||
|
||||
final sideMenuButton = find.byValueKey('SideMenu');
|
||||
final listTiles = find.byValueKey('ListTiles');
|
||||
final nextTest = find.byValueKey('InAppWebViewOnProgressChangedTest');
|
||||
|
||||
while((await driver.getText(appBarTitle)) == "InAppWebViewInitialDataTest") {
|
||||
await Future.delayed(const Duration(milliseconds: 500));
|
||||
}
|
||||
|
||||
String title = await driver.getText(appBarTitle);
|
||||
expect(title, "true");
|
||||
|
||||
await driver.tap(sideMenuButton);
|
||||
await driver.scrollUntilVisible(listTiles, nextTest, dyScroll: -300.0);
|
||||
await driver.tap(nextTest);
|
||||
}, timeout: new Timeout(new Duration(minutes: 5)));
|
||||
|
||||
test('InAppWebViewOnProgressChangedTest', () async {
|
||||
final appBarTitle = find.byValueKey('AppBarTitle');
|
||||
|
||||
final sideMenuButton = find.byValueKey('SideMenu');
|
||||
final listTiles = find.byValueKey('ListTiles');
|
||||
final nextTest = find.byValueKey('InAppWebViewOnScrollChangedTest');
|
||||
|
||||
while((await driver.getText(appBarTitle)) == "InAppWebViewOnProgressChangedTest") {
|
||||
await Future.delayed(const Duration(milliseconds: 500));
|
||||
}
|
||||
|
||||
String title = await driver.getText(appBarTitle);
|
||||
expect(title, "true");
|
||||
|
||||
await driver.tap(sideMenuButton);
|
||||
await driver.scrollUntilVisible(listTiles, nextTest, dyScroll: -300.0);
|
||||
await driver.tap(nextTest);
|
||||
}, timeout: new Timeout(new Duration(minutes: 5)));
|
||||
|
||||
test('InAppWebViewOnScrollChangedTest', () async {
|
||||
final appBarTitle = find.byValueKey('AppBarTitle');
|
||||
|
||||
final sideMenuButton = find.byValueKey('SideMenu');
|
||||
final listTiles = find.byValueKey('ListTiles');
|
||||
final nextTest = find.byValueKey('InAppWebViewOnLoadResourceTest');
|
||||
|
||||
while((await driver.getText(appBarTitle)) == "InAppWebViewOnScrollChangedTest") {
|
||||
await Future.delayed(const Duration(milliseconds: 500));
|
||||
}
|
||||
|
||||
String title = await driver.getText(appBarTitle);
|
||||
expect(title, "true");
|
||||
|
||||
await driver.tap(sideMenuButton);
|
||||
await driver.scrollUntilVisible(listTiles, nextTest, dyScroll: -300.0);
|
||||
await driver.tap(nextTest);
|
||||
}, timeout: new Timeout(new Duration(minutes: 5)));
|
||||
|
||||
test('InAppWebViewOnLoadResourceTest', () async {
|
||||
await Future.delayed(const Duration(milliseconds: 2000));
|
||||
List<String> resourceList = [
|
||||
"https://getbootstrap.com/docs/4.3/dist/css/bootstrap.min.css",
|
||||
"https://code.jquery.com/jquery-3.3.1.min.js",
|
||||
|
@ -61,114 +126,177 @@ void main() {
|
|||
];
|
||||
final appBarTitle = find.byValueKey('AppBarTitle');
|
||||
|
||||
final sideMenuButton = find.byValueKey('SideMenu');
|
||||
final listTiles = find.byValueKey('ListTiles');
|
||||
final nextTest = find.byValueKey('InAppWebViewJavaScriptHandlerTest');
|
||||
|
||||
while((await driver.getText(appBarTitle)) == "InAppWebViewOnLoadResourceTest") {
|
||||
await Future.delayed(const Duration(milliseconds: 1000));
|
||||
await Future.delayed(const Duration(milliseconds: 500));
|
||||
}
|
||||
|
||||
String title = await driver.getText(appBarTitle);
|
||||
for (String resource in resourceList) {
|
||||
expect(true, title.contains(resource));
|
||||
}
|
||||
|
||||
await driver.tap(sideMenuButton);
|
||||
await driver.scrollUntilVisible(listTiles, nextTest, dyScroll: -300.0);
|
||||
await driver.tap(nextTest);
|
||||
}, timeout: new Timeout(new Duration(minutes: 5)));
|
||||
|
||||
test('InAppWebViewJavaScriptHandlerTest', () async {
|
||||
await Future.delayed(const Duration(milliseconds: 2000));
|
||||
final appBarTitle = find.byValueKey('AppBarTitle');
|
||||
|
||||
final sideMenuButton = find.byValueKey('SideMenu');
|
||||
final listTiles = find.byValueKey('ListTiles');
|
||||
final nextTest = find.byValueKey('InAppWebViewAjaxTest');
|
||||
|
||||
while((await driver.getText(appBarTitle)) == "InAppWebViewJavaScriptHandlerTest") {
|
||||
await Future.delayed(const Duration(milliseconds: 1000));
|
||||
await Future.delayed(const Duration(milliseconds: 500));
|
||||
}
|
||||
|
||||
String title = await driver.getText(appBarTitle);
|
||||
expect(true, !title.contains("false"));
|
||||
|
||||
await driver.tap(sideMenuButton);
|
||||
await driver.scrollUntilVisible(listTiles, nextTest, dyScroll: -300.0);
|
||||
await driver.tap(nextTest);
|
||||
}, timeout: new Timeout(new Duration(minutes: 5)));
|
||||
|
||||
test('InAppWebViewAjaxTest', () async {
|
||||
await Future.delayed(const Duration(milliseconds: 2000));
|
||||
final appBarTitle = find.byValueKey('AppBarTitle');
|
||||
|
||||
final sideMenuButton = find.byValueKey('SideMenu');
|
||||
final listTiles = find.byValueKey('ListTiles');
|
||||
final nextTest = find.byValueKey('InAppWebViewFetchTest');
|
||||
|
||||
while((await driver.getText(appBarTitle)) == "InAppWebViewAjaxTest") {
|
||||
await Future.delayed(const Duration(milliseconds: 1000));
|
||||
await Future.delayed(const Duration(milliseconds: 500));
|
||||
}
|
||||
|
||||
String title = await driver.getText(appBarTitle);
|
||||
expect(title, "Lorenzo Pichilli Lorenzo Pichilli");
|
||||
}, timeout: new Timeout(new Duration(minutes: 5)));
|
||||
|
||||
test('InAppWebViewOnLoadResourceCustomSchemeTest', () async {
|
||||
await Future.delayed(const Duration(milliseconds: 2000));
|
||||
final appBarTitle = find.byValueKey('AppBarTitle');
|
||||
|
||||
while((await driver.getText(appBarTitle)) == "InAppWebViewOnLoadResourceCustomSchemeTest") {
|
||||
await Future.delayed(const Duration(milliseconds: 1000));
|
||||
}
|
||||
|
||||
String title = await driver.getText(appBarTitle);
|
||||
expect(title, "true");
|
||||
await driver.tap(sideMenuButton);
|
||||
await driver.scrollUntilVisible(listTiles, nextTest, dyScroll: -300.0);
|
||||
await driver.tap(nextTest);
|
||||
}, timeout: new Timeout(new Duration(minutes: 5)));
|
||||
|
||||
test('InAppWebViewFetchTest', () async {
|
||||
await Future.delayed(const Duration(milliseconds: 2000));
|
||||
final appBarTitle = find.byValueKey('AppBarTitle');
|
||||
|
||||
final sideMenuButton = find.byValueKey('SideMenu');
|
||||
final listTiles = find.byValueKey('ListTiles');
|
||||
final nextTest = find.byValueKey('InAppWebViewOnLoadResourceCustomSchemeTest');
|
||||
|
||||
while((await driver.getText(appBarTitle)) == "InAppWebViewFetchTest") {
|
||||
await Future.delayed(const Duration(milliseconds: 1000));
|
||||
await Future.delayed(const Duration(milliseconds: 500));
|
||||
}
|
||||
|
||||
String title = await driver.getText(appBarTitle);
|
||||
expect(true, title.contains("Lorenzo Pichilli") && title.contains("200"));
|
||||
|
||||
await driver.tap(sideMenuButton);
|
||||
await driver.scrollUntilVisible(listTiles, nextTest, dyScroll: -300.0);
|
||||
await driver.tap(nextTest);
|
||||
}, timeout: new Timeout(new Duration(minutes: 5)));
|
||||
|
||||
test('InAppWebViewOnLoadResourceCustomSchemeTest', () async {
|
||||
final appBarTitle = find.byValueKey('AppBarTitle');
|
||||
|
||||
final sideMenuButton = find.byValueKey('SideMenu');
|
||||
final listTiles = find.byValueKey('ListTiles');
|
||||
final nextTest = find.byValueKey('InAppWebViewShouldOverrideUrlLoadingTest');
|
||||
|
||||
while((await driver.getText(appBarTitle)) == "InAppWebViewOnLoadResourceCustomSchemeTest") {
|
||||
await Future.delayed(const Duration(milliseconds: 500));
|
||||
}
|
||||
|
||||
String title = await driver.getText(appBarTitle);
|
||||
expect(title, "true");
|
||||
|
||||
await driver.tap(sideMenuButton);
|
||||
await driver.scrollUntilVisible(listTiles, nextTest, dyScroll: -300.0);
|
||||
await driver.tap(nextTest);
|
||||
}, timeout: new Timeout(new Duration(minutes: 5)));
|
||||
|
||||
test('InAppWebViewShouldOverrideUrlLoadingTest', () async {
|
||||
await Future.delayed(const Duration(milliseconds: 2000));
|
||||
final appBarTitle = find.byValueKey('AppBarTitle');
|
||||
|
||||
final sideMenuButton = find.byValueKey('SideMenu');
|
||||
final listTiles = find.byValueKey('ListTiles');
|
||||
final nextTest = find.byValueKey('InAppWebViewOnConsoleMessageTest');
|
||||
|
||||
while((await driver.getText(appBarTitle)) == "InAppWebViewShouldOverrideUrlLoadingTest") {
|
||||
await Future.delayed(const Duration(milliseconds: 1000));
|
||||
await Future.delayed(const Duration(milliseconds: 500));
|
||||
}
|
||||
|
||||
String url = await driver.getText(appBarTitle);
|
||||
expect(url, "https://flutter.dev/");
|
||||
|
||||
await driver.tap(sideMenuButton);
|
||||
await driver.scrollUntilVisible(listTiles, nextTest, dyScroll: -300.0);
|
||||
await driver.tap(nextTest);
|
||||
}, timeout: new Timeout(new Duration(minutes: 5)));
|
||||
|
||||
test('InAppWebViewOnConsoleMessageTest', () async {
|
||||
await Future.delayed(const Duration(milliseconds: 2000));
|
||||
final appBarTitle = find.byValueKey('AppBarTitle');
|
||||
|
||||
final sideMenuButton = find.byValueKey('SideMenu');
|
||||
final listTiles = find.byValueKey('ListTiles');
|
||||
final nextTest = find.byValueKey('InAppWebViewOnDownloadStartTest');
|
||||
|
||||
while((await driver.getText(appBarTitle)) == "InAppWebViewOnConsoleMessageTest") {
|
||||
await Future.delayed(const Duration(milliseconds: 1000));
|
||||
await Future.delayed(const Duration(milliseconds: 500));
|
||||
}
|
||||
|
||||
String title = await driver.getText(appBarTitle);
|
||||
expect(title, "message LOG");
|
||||
|
||||
await driver.tap(sideMenuButton);
|
||||
await driver.scrollUntilVisible(listTiles, nextTest, dyScroll: -300.0);
|
||||
await driver.tap(nextTest);
|
||||
}, timeout: new Timeout(new Duration(minutes: 5)));
|
||||
|
||||
test('InAppWebViewOnDownloadStartTest', () async {
|
||||
await Future.delayed(const Duration(milliseconds: 2000));
|
||||
final appBarTitle = find.byValueKey('AppBarTitle');
|
||||
|
||||
final sideMenuButton = find.byValueKey('SideMenu');
|
||||
final listTiles = find.byValueKey('ListTiles');
|
||||
final nextTest = find.byValueKey('InAppWebViewOnTargetBlankTest');
|
||||
|
||||
while((await driver.getText(appBarTitle)) == "InAppWebViewOnDownloadStartTest") {
|
||||
await Future.delayed(const Duration(milliseconds: 1000));
|
||||
await Future.delayed(const Duration(milliseconds: 500));
|
||||
}
|
||||
|
||||
String url = await driver.getText(appBarTitle);
|
||||
expect(url, "http://192.168.1.20:8082/test-download-file");
|
||||
expect(url, "http://${environment["NODE_SERVER_IP"]}:8082/test-download-file");
|
||||
|
||||
await driver.tap(sideMenuButton);
|
||||
await driver.scrollUntilVisible(listTiles, nextTest, dyScroll: -300.0);
|
||||
await driver.tap(nextTest);
|
||||
}, timeout: new Timeout(new Duration(minutes: 5)));
|
||||
|
||||
test('InAppWebViewOnTargetBlankTest', () async {
|
||||
await Future.delayed(const Duration(milliseconds: 2000));
|
||||
final appBarTitle = find.byValueKey('AppBarTitle');
|
||||
|
||||
final sideMenuButton = find.byValueKey('SideMenu');
|
||||
final listTiles = find.byValueKey('ListTiles');
|
||||
final nextTest = find.byValueKey('InAppWebViewOnJsDialogTest');
|
||||
|
||||
while((await driver.getText(appBarTitle)) == "InAppWebViewOnTargetBlankTest") {
|
||||
await Future.delayed(const Duration(milliseconds: 1000));
|
||||
await Future.delayed(const Duration(milliseconds: 500));
|
||||
}
|
||||
|
||||
String url = await driver.getText(appBarTitle);
|
||||
expect(url, "https://flutter.dev/");
|
||||
|
||||
await driver.tap(sideMenuButton);
|
||||
await driver.scrollUntilVisible(listTiles, nextTest, dyScroll: -300.0);
|
||||
await driver.tap(nextTest);
|
||||
}, timeout: new Timeout(new Duration(minutes: 5)));
|
||||
|
||||
test('InAppWebViewOnJsDialogTest', () async {
|
||||
await Future.delayed(const Duration(milliseconds: 2000));
|
||||
final appBarTitle = find.byValueKey('AppBarTitle');
|
||||
final alertButtonOk = find.byValueKey('AlertButtonOk');
|
||||
final confirmButtonCancel = find.byValueKey('ConfirmButtonCancel');
|
||||
|
@ -177,8 +305,12 @@ void main() {
|
|||
final promptButtonCancel = find.byValueKey('PromptButtonCancel');
|
||||
final promptButtonOk = find.byValueKey('PromptButtonOk');
|
||||
|
||||
final sideMenuButton = find.byValueKey('SideMenu');
|
||||
final listTiles = find.byValueKey('ListTiles');
|
||||
final nextTest = find.byValueKey('InAppWebViewOnSafeBrowsingHitTest');
|
||||
|
||||
while((await driver.getText(appBarTitle)) == "InAppWebViewOnJsDialogTest") {
|
||||
await Future.delayed(const Duration(milliseconds: 1000));
|
||||
await Future.delayed(const Duration(milliseconds: 500));
|
||||
}
|
||||
|
||||
await driver.tap(alertButtonOk);
|
||||
|
@ -204,30 +336,196 @@ void main() {
|
|||
title = await driver.getText(appBarTitle);
|
||||
expect(title, "prompt new value");
|
||||
|
||||
await driver.tap(sideMenuButton);
|
||||
await driver.scrollUntilVisible(listTiles, nextTest, dyScroll: -300.0);
|
||||
await driver.tap(nextTest);
|
||||
}, timeout: new Timeout(new Duration(minutes: 5)));
|
||||
|
||||
test('InAppWebViewOnSafeBrowsingHitTest', () async {
|
||||
await Future.delayed(const Duration(milliseconds: 2000));
|
||||
final appBarTitle = find.byValueKey('AppBarTitle');
|
||||
|
||||
final sideMenuButton = find.byValueKey('SideMenu');
|
||||
final listTiles = find.byValueKey('ListTiles');
|
||||
final nextTest = find.byValueKey('InAppWebViewOnReceivedHttpAuthRequestTest');
|
||||
|
||||
while((await driver.getText(appBarTitle)) == "InAppWebViewOnSafeBrowsingHitTest") {
|
||||
await Future.delayed(const Duration(milliseconds: 1000));
|
||||
await Future.delayed(const Duration(milliseconds: 500));
|
||||
}
|
||||
|
||||
String url = await driver.getText(appBarTitle);
|
||||
expect(url, "chrome://safe-browsing/match?type=malware");
|
||||
if (Platform.isAndroid)
|
||||
expect(url, "chrome://safe-browsing/match?type=malware");
|
||||
|
||||
await driver.tap(sideMenuButton);
|
||||
await driver.scrollUntilVisible(listTiles, nextTest, dyScroll: -300.0);
|
||||
await driver.tap(nextTest);
|
||||
}, timeout: new Timeout(new Duration(minutes: 5)));
|
||||
|
||||
test('InAppWebViewOnReceivedHttpAuthRequestTest', () async {
|
||||
await Future.delayed(const Duration(milliseconds: 2000));
|
||||
final appBarTitle = find.byValueKey('AppBarTitle');
|
||||
|
||||
final sideMenuButton = find.byValueKey('SideMenu');
|
||||
final listTiles = find.byValueKey('ListTiles');
|
||||
final nextTest = find.byValueKey('InAppWebViewSslRequestTest');
|
||||
|
||||
while((await driver.getText(appBarTitle)) == "InAppWebViewOnReceivedHttpAuthRequestTest") {
|
||||
await Future.delayed(const Duration(milliseconds: 1000));
|
||||
await Future.delayed(const Duration(milliseconds: 500));
|
||||
}
|
||||
|
||||
String title = await driver.getText(appBarTitle);
|
||||
expect(title, "Authorized");
|
||||
|
||||
await driver.tap(sideMenuButton);
|
||||
await driver.scrollUntilVisible(listTiles, nextTest, dyScroll: -300.0);
|
||||
await driver.tap(nextTest);
|
||||
}, timeout: new Timeout(new Duration(minutes: 5)));
|
||||
|
||||
test('InAppWebViewSslRequestTest', () async {
|
||||
final appBarTitle = find.byValueKey('AppBarTitle');
|
||||
|
||||
final sideMenuButton = find.byValueKey('SideMenu');
|
||||
final listTiles = find.byValueKey('ListTiles');
|
||||
final nextTest = find.byValueKey('InAppWebViewOnFindResultReceivedTest');
|
||||
|
||||
while((await driver.getText(appBarTitle)) == "InAppWebViewSslRequestTest") {
|
||||
await Future.delayed(const Duration(milliseconds: 500));
|
||||
}
|
||||
|
||||
String title = await driver.getText(appBarTitle);
|
||||
expect(title, "Authorized");
|
||||
|
||||
await driver.tap(sideMenuButton);
|
||||
await driver.scrollUntilVisible(listTiles, nextTest, dyScroll: -300.0);
|
||||
await driver.tap(nextTest);
|
||||
}, timeout: new Timeout(new Duration(minutes: 5)));
|
||||
|
||||
test('InAppWebViewOnFindResultReceivedTest', () async {
|
||||
final appBarTitle = find.byValueKey('AppBarTitle');
|
||||
|
||||
final sideMenuButton = find.byValueKey('SideMenu');
|
||||
final listTiles = find.byValueKey('ListTiles');
|
||||
final nextTest = find.byValueKey('InAppWebViewOnNavigationStateChangeTest');
|
||||
|
||||
while((await driver.getText(appBarTitle)) == "InAppWebViewOnFindResultReceivedTest") {
|
||||
await Future.delayed(const Duration(milliseconds: 500));
|
||||
}
|
||||
|
||||
String title = await driver.getText(appBarTitle);
|
||||
expect(title, "2");
|
||||
|
||||
await driver.tap(sideMenuButton);
|
||||
await driver.scrollUntilVisible(listTiles, nextTest, dyScroll: -300.0);
|
||||
await driver.tap(nextTest);
|
||||
}, timeout: new Timeout(new Duration(minutes: 5)));
|
||||
|
||||
test('InAppWebViewOnNavigationStateChangeTest', () async {
|
||||
final appBarTitle = find.byValueKey('AppBarTitle');
|
||||
|
||||
final sideMenuButton = find.byValueKey('SideMenu');
|
||||
final listTiles = find.byValueKey('ListTiles');
|
||||
final nextTest = find.byValueKey('InAppWebViewOnLoadErrorTest');
|
||||
|
||||
while((await driver.getText(appBarTitle)) == "InAppWebViewOnNavigationStateChangeTest") {
|
||||
await Future.delayed(const Duration(milliseconds: 500));
|
||||
}
|
||||
|
||||
String title = await driver.getText(appBarTitle);
|
||||
expect(true, title.contains("first-push") && title.contains("second-push"));
|
||||
|
||||
await driver.tap(sideMenuButton);
|
||||
await driver.scrollUntilVisible(listTiles, nextTest, dyScroll: -300.0);
|
||||
await driver.tap(nextTest);
|
||||
}, timeout: new Timeout(new Duration(minutes: 5)));
|
||||
|
||||
test('InAppWebViewOnLoadErrorTest', () async {
|
||||
final appBarTitle = find.byValueKey('AppBarTitle');
|
||||
|
||||
final sideMenuButton = find.byValueKey('SideMenu');
|
||||
final listTiles = find.byValueKey('ListTiles');
|
||||
final nextTest = find.byValueKey('InAppWebViewOnLoadHttpErrorTest');
|
||||
|
||||
while((await driver.getText(appBarTitle)) == "InAppWebViewOnLoadErrorTest") {
|
||||
await Future.delayed(const Duration(milliseconds: 500));
|
||||
}
|
||||
|
||||
String title = await driver.getText(appBarTitle);
|
||||
if (Platform.isAndroid) {
|
||||
expect(title, "-2");
|
||||
} else if (Platform.isIOS) {
|
||||
expect(title, "-1022");
|
||||
}
|
||||
|
||||
await driver.tap(sideMenuButton);
|
||||
await driver.scrollUntilVisible(listTiles, nextTest, dyScroll: -300.0);
|
||||
await driver.tap(nextTest);
|
||||
}, timeout: new Timeout(new Duration(minutes: 5)));
|
||||
|
||||
test('InAppWebViewOnLoadHttpErrorTest', () async {
|
||||
final appBarTitle = find.byValueKey('AppBarTitle');
|
||||
|
||||
final sideMenuButton = find.byValueKey('SideMenu');
|
||||
final listTiles = find.byValueKey('ListTiles');
|
||||
final nextTest = find.byValueKey('InAppWebViewCookieManagerTest');
|
||||
|
||||
while((await driver.getText(appBarTitle)) == "InAppWebViewOnLoadHttpErrorTest") {
|
||||
await Future.delayed(const Duration(milliseconds: 500));
|
||||
}
|
||||
|
||||
String title = await driver.getText(appBarTitle);
|
||||
expect(title, "404");
|
||||
|
||||
await driver.tap(sideMenuButton);
|
||||
await driver.scrollUntilVisible(listTiles, nextTest, dyScroll: -300.0);
|
||||
await driver.tap(nextTest);
|
||||
}, timeout: new Timeout(new Duration(minutes: 5)));
|
||||
|
||||
test('InAppWebViewCookieManagerTest', () async {
|
||||
final appBarTitle = find.byValueKey('AppBarTitle');
|
||||
|
||||
final sideMenuButton = find.byValueKey('SideMenu');
|
||||
final listTiles = find.byValueKey('ListTiles');
|
||||
final nextTest = find.byValueKey('InAppWebViewHttpAuthCredentialDatabaseTest');
|
||||
|
||||
while((await driver.getText(appBarTitle)) == "InAppWebViewCookieManagerTest") {
|
||||
await Future.delayed(const Duration(milliseconds: 500));
|
||||
}
|
||||
|
||||
String title = await driver.getText(appBarTitle);
|
||||
expect(title, "myValue true true");
|
||||
|
||||
await driver.tap(sideMenuButton);
|
||||
await driver.scrollUntilVisible(listTiles, nextTest, dyScroll: -300.0);
|
||||
await driver.tap(nextTest);
|
||||
}, timeout: new Timeout(new Duration(minutes: 5)));
|
||||
|
||||
test('InAppWebViewHttpAuthCredentialDatabaseTest', () async {
|
||||
final appBarTitle = find.byValueKey('AppBarTitle');
|
||||
|
||||
final sideMenuButton = find.byValueKey('SideMenu');
|
||||
final listTiles = find.byValueKey('ListTiles');
|
||||
final nextTest = find.byValueKey('InAppWebViewContentBlockerTest');
|
||||
|
||||
while((await driver.getText(appBarTitle)) == "InAppWebViewHttpAuthCredentialDatabaseTest") {
|
||||
await Future.delayed(const Duration(milliseconds: 500));
|
||||
}
|
||||
|
||||
String title = await driver.getText(appBarTitle);
|
||||
expect(title, "Authorized true true");
|
||||
|
||||
await driver.tap(sideMenuButton);
|
||||
await driver.scrollUntilVisible(listTiles, nextTest, dyScroll: -300.0);
|
||||
await driver.tap(nextTest);
|
||||
}, timeout: new Timeout(new Duration(minutes: 5)));
|
||||
|
||||
test('InAppWebViewContentBlockerTest', () async {
|
||||
final appBarTitle = find.byValueKey('AppBarTitle');
|
||||
|
||||
while((await driver.getText(appBarTitle)) == "InAppWebViewContentBlockerTest") {
|
||||
await Future.delayed(const Duration(milliseconds: 500));
|
||||
}
|
||||
|
||||
String title = await driver.getText(appBarTitle);
|
||||
expect(title, "true");
|
||||
}, timeout: new Timeout(new Duration(minutes: 5)));
|
||||
|
||||
});
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
import 'package:flutter_inappbrowser/flutter_inappbrowser.dart';
|
||||
|
@ -14,6 +15,7 @@ class WidgetTest extends StatefulWidget {
|
|||
}
|
||||
|
||||
class WidgetTestState extends State<WidgetTest> {
|
||||
final GlobalKey<ScaffoldState> scaffoldKey = new GlobalKey<ScaffoldState>();
|
||||
InAppWebViewController webView;
|
||||
String appBarTitle;
|
||||
|
||||
|
|
|
@ -3,8 +3,8 @@ import 'package:flutter/material.dart';
|
|||
import 'package:flutter_inappbrowser/flutter_inappbrowser.dart';
|
||||
|
||||
import 'main_test.dart';
|
||||
import 'util_test.dart';
|
||||
import 'custom_widget_test.dart';
|
||||
import '.env.dart';
|
||||
|
||||
class InAppWebViewAjaxTest extends WidgetTest {
|
||||
final InAppWebViewAjaxTestState state = InAppWebViewAjaxTestState();
|
||||
|
@ -21,13 +21,40 @@ class InAppWebViewAjaxTestState extends WidgetTestState {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
key: this.scaffoldKey,
|
||||
appBar: myAppBar(state: this, title: appBarTitle),
|
||||
drawer: myDrawer(context: context),
|
||||
body: Container(
|
||||
child: Column(children: <Widget>[
|
||||
Expanded(
|
||||
child: Container(
|
||||
child: InAppWebView(
|
||||
initialFile: "test_assets/in_app_webview_ajax_test.html",
|
||||
initialData: InAppWebViewInitialData(data: """
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>InAppWebViewAjaxTest</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>InAppWebViewAjaxTest</h1>
|
||||
<script>
|
||||
window.addEventListener('flutterInAppBrowserPlatformReady', function(event) {
|
||||
var xhttp = new XMLHttpRequest();
|
||||
xhttp.open("POST", "http://${environment["NODE_SERVER_IP"]}:8082/test-ajax-post");
|
||||
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
|
||||
xhttp.send("firstname=Foo&lastname=Bar");
|
||||
|
||||
var xhttp2 = new XMLHttpRequest();
|
||||
xhttp2.open("GET", "http://${environment["NODE_SERVER_IP"]}:8082/test-download-file");
|
||||
xhttp2.send();
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
"""),
|
||||
initialHeaders: {},
|
||||
initialOptions: InAppWebViewWidgetOptions(
|
||||
inAppWebViewOptions: InAppWebViewOptions(
|
||||
|
@ -80,7 +107,6 @@ class InAppWebViewAjaxTestState extends WidgetTestState {
|
|||
testsDone++;
|
||||
if (testsDone == totTests) {
|
||||
setState(() { });
|
||||
nextTest(context: context, state: this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:flutter_inappbrowser/flutter_inappbrowser.dart';
|
||||
|
||||
import 'custom_widget_test.dart';
|
||||
import 'main_test.dart';
|
||||
|
||||
class InAppWebViewContentBlockerTest extends WidgetTest {
|
||||
final InAppWebViewContentBlockerTestState state = InAppWebViewContentBlockerTestState();
|
||||
|
||||
@override
|
||||
InAppWebViewContentBlockerTestState createState() => state;
|
||||
}
|
||||
|
||||
class InAppWebViewContentBlockerTestState extends WidgetTestState {
|
||||
|
||||
String appBarTitle = "InAppWebViewContentBlockerTest";
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
key: this.scaffoldKey,
|
||||
appBar: myAppBar(state: this, title: appBarTitle),
|
||||
drawer: myDrawer(context: context),
|
||||
body: Container(
|
||||
child: Column(children: <Widget>[
|
||||
Expanded(
|
||||
child: Container(
|
||||
child: InAppWebView(
|
||||
initialUrl: "https://flutter.dev/",
|
||||
initialHeaders: {},
|
||||
initialOptions: InAppWebViewWidgetOptions(
|
||||
inAppWebViewOptions: InAppWebViewOptions(
|
||||
clearCache: true,
|
||||
debuggingEnabled: true,
|
||||
contentBlockers: [
|
||||
ContentBlocker(
|
||||
trigger: ContentBlockerTrigger(
|
||||
urlFilter: ".*",
|
||||
resourceType: [
|
||||
ContentBlockerTriggerResourceType.IMAGE,
|
||||
ContentBlockerTriggerResourceType.STYLE_SHEET
|
||||
],
|
||||
ifTopUrl: [
|
||||
"https://flutter.dev/"
|
||||
]),
|
||||
action: ContentBlockerAction(
|
||||
type: ContentBlockerActionType.BLOCK))
|
||||
]
|
||||
)
|
||||
),
|
||||
onWebViewCreated: (InAppWebViewController controller) {
|
||||
webView = controller;
|
||||
},
|
||||
onLoadStart: (InAppWebViewController controller, String url) {
|
||||
|
||||
},
|
||||
onLoadStop: (InAppWebViewController controller, String url) {
|
||||
setState(() {
|
||||
appBarTitle = "true";
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
])
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:flutter_inappbrowser/flutter_inappbrowser.dart';
|
||||
|
||||
import 'custom_widget_test.dart';
|
||||
import 'main_test.dart';
|
||||
|
||||
class InAppWebViewCookieManagerTest extends WidgetTest {
|
||||
final InAppWebViewCookieManagerTestState state = InAppWebViewCookieManagerTestState();
|
||||
|
||||
@override
|
||||
InAppWebViewCookieManagerTestState createState() => state;
|
||||
}
|
||||
|
||||
class InAppWebViewCookieManagerTestState extends WidgetTestState {
|
||||
|
||||
String appBarTitle = "InAppWebViewCookieManagerTest";
|
||||
CookieManager cookieManager = CookieManager.instance();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
key: this.scaffoldKey,
|
||||
appBar: myAppBar(state: this, title: appBarTitle),
|
||||
drawer: myDrawer(context: context),
|
||||
body: Container(
|
||||
child: Column(children: <Widget>[
|
||||
Expanded(
|
||||
child: Container(
|
||||
child: InAppWebView(
|
||||
initialUrl: "https://flutter.dev/",
|
||||
initialHeaders: {},
|
||||
initialOptions: InAppWebViewWidgetOptions(
|
||||
inAppWebViewOptions: InAppWebViewOptions(
|
||||
clearCache: true,
|
||||
debuggingEnabled: true
|
||||
)
|
||||
),
|
||||
onWebViewCreated: (InAppWebViewController controller) {
|
||||
webView = controller;
|
||||
},
|
||||
onLoadStart: (InAppWebViewController controller, String url) {
|
||||
|
||||
},
|
||||
onLoadStop: (InAppWebViewController controller, String url) async {
|
||||
var title = "";
|
||||
await cookieManager.getCookies(url: url);
|
||||
await cookieManager.setCookie(url: url, name: "myCookie", value: "myValue");
|
||||
Cookie cookie = await cookieManager.getCookie(url: url, name: "myCookie");
|
||||
title = cookie.value.toString();
|
||||
await cookieManager.deleteCookie(url: url, name: "myCookie");
|
||||
cookie = await cookieManager.getCookie(url: url, name: "myCookie");
|
||||
title += " " + ((cookie == null) ? "true" : "false");
|
||||
await cookieManager.deleteCookies(url: url);
|
||||
List<Cookie> cookies = await cookieManager.getCookies(url: url);
|
||||
title += " " + ((cookies.length == 0) ? "true" : "false");
|
||||
|
||||
setState(() {
|
||||
appBarTitle = title;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
])
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
|
@ -5,8 +5,8 @@ import 'package:flutter/material.dart';
|
|||
import 'package:flutter_inappbrowser/flutter_inappbrowser.dart';
|
||||
|
||||
import 'main_test.dart';
|
||||
import 'util_test.dart';
|
||||
import 'custom_widget_test.dart';
|
||||
import '.env.dart';
|
||||
|
||||
class InAppWebViewFetchTest extends WidgetTest {
|
||||
final InAppWebViewFetchTestState state = InAppWebViewFetchTestState();
|
||||
|
@ -23,13 +23,56 @@ class InAppWebViewFetchTestState extends WidgetTestState {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
key: this.scaffoldKey,
|
||||
appBar: myAppBar(state: this, title: appBarTitle),
|
||||
drawer: myDrawer(context: context),
|
||||
body: Container(
|
||||
child: Column(children: <Widget>[
|
||||
Expanded(
|
||||
child: Container(
|
||||
child: InAppWebView(
|
||||
initialFile: "test_assets/in_app_webview_fetch_test.html",
|
||||
initialData: InAppWebViewInitialData(data: """
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>InAppWebViewFetchTest</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>InAppWebViewFetchTest</h1>
|
||||
<script>
|
||||
window.addEventListener('flutterInAppBrowserPlatformReady', function(event) {
|
||||
fetch(new Request("http://${environment["NODE_SERVER_IP"]}:8082/test-download-file")).then(function(response) {
|
||||
window.flutter_inappbrowser.callHandler('fetchGet', response.status);
|
||||
}).catch(function(error) {
|
||||
window.flutter_inappbrowser.callHandler('fetchGet', "ERROR: " + error);
|
||||
});
|
||||
|
||||
fetch("http://${environment["NODE_SERVER_IP"]}:8082/test-ajax-post", {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
firstname: 'Foo',
|
||||
lastname: 'Bar'
|
||||
}),
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
}).then(function(response) {
|
||||
response.json().then(function(value) {
|
||||
window.flutter_inappbrowser.callHandler('fetchPost', value);
|
||||
}).catch(function(error) {
|
||||
window.flutter_inappbrowser.callHandler('fetchPost', "ERROR: " + error);
|
||||
});
|
||||
}).catch(function(error) {
|
||||
window.flutter_inappbrowser.callHandler('fetchPost', "ERROR: " + error);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
"""),
|
||||
initialHeaders: {},
|
||||
initialOptions: InAppWebViewWidgetOptions(
|
||||
inAppWebViewOptions: InAppWebViewOptions(
|
||||
|
@ -79,7 +122,6 @@ class InAppWebViewFetchTestState extends WidgetTestState {
|
|||
testsDone++;
|
||||
if (testsDone == totTests) {
|
||||
setState(() { });
|
||||
nextTest(context: context, state: this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:flutter_inappbrowser/flutter_inappbrowser.dart';
|
||||
|
||||
import 'custom_widget_test.dart';
|
||||
import 'main_test.dart';
|
||||
import '.env.dart';
|
||||
|
||||
class InAppWebViewHttpAuthCredentialDatabaseTest extends WidgetTest {
|
||||
final InAppWebViewHttpAuthCredentialDatabaseTestState state = InAppWebViewHttpAuthCredentialDatabaseTestState();
|
||||
|
||||
@override
|
||||
InAppWebViewHttpAuthCredentialDatabaseTestState createState() => state;
|
||||
}
|
||||
|
||||
class InAppWebViewHttpAuthCredentialDatabaseTestState extends WidgetTestState {
|
||||
|
||||
String appBarTitle = "InAppWebViewHttpAuthCredentialDatabaseTest";
|
||||
HttpAuthCredentialDatabase httpAuthCredentialDatabase = HttpAuthCredentialDatabase.instance();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
httpAuthCredentialDatabase.setHttpAuthCredential(
|
||||
protectionSpace: ProtectionSpace(host: environment["NODE_SERVER_IP"], protocol: "http", realm: "Node", port: 8081),
|
||||
credential: HttpAuthCredential(username: "USERNAME", password: "PASSWORD")
|
||||
);
|
||||
|
||||
return Scaffold(
|
||||
key: this.scaffoldKey,
|
||||
appBar: myAppBar(state: this, title: appBarTitle),
|
||||
drawer: myDrawer(context: context),
|
||||
body: Container(
|
||||
child: Column(children: <Widget>[
|
||||
Expanded(
|
||||
child: Container(
|
||||
child: InAppWebView(
|
||||
initialUrl: "http://${environment["NODE_SERVER_IP"]}:8081/",
|
||||
initialHeaders: {},
|
||||
initialOptions: InAppWebViewWidgetOptions(
|
||||
inAppWebViewOptions: InAppWebViewOptions(
|
||||
clearCache: true,
|
||||
debuggingEnabled: true
|
||||
)
|
||||
),
|
||||
onWebViewCreated: (InAppWebViewController controller) {
|
||||
webView = controller;
|
||||
},
|
||||
onLoadStart: (InAppWebViewController controller, String url) {
|
||||
|
||||
},
|
||||
onLoadStop: (InAppWebViewController controller, String url) async {
|
||||
var title = "";
|
||||
String h1Content = await controller.evaluateJavascript(source: "document.body.querySelector('h1').textContent");
|
||||
title = h1Content;
|
||||
var credentials = await httpAuthCredentialDatabase.getHttpAuthCredentials(protectionSpace:
|
||||
ProtectionSpace(host: environment["NODE_SERVER_IP"], protocol: "http", realm: "Node", port: 8081)
|
||||
);
|
||||
title += " " + ((credentials.length == 1) ? "true" : "false");
|
||||
await httpAuthCredentialDatabase.clearAllAuthCredentials();
|
||||
credentials = await httpAuthCredentialDatabase.getHttpAuthCredentials(protectionSpace:
|
||||
ProtectionSpace(host: environment["NODE_SERVER_IP"], protocol: "http", realm: "Node", port: 8081)
|
||||
);
|
||||
title += " " + ((credentials.length == 0) ? "true" : "false");
|
||||
setState(() {
|
||||
appBarTitle = title;
|
||||
});
|
||||
},
|
||||
onReceivedHttpAuthRequest: (InAppWebViewController controller, HttpAuthChallenge challenge) async {
|
||||
return new HttpAuthResponse(action: HttpAuthResponseAction.USE_SAVED_HTTP_AUTH_CREDENTIALS);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
])
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,92 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:flutter_inappbrowser/flutter_inappbrowser.dart';
|
||||
|
||||
import 'main_test.dart';
|
||||
import 'custom_widget_test.dart';
|
||||
|
||||
class InAppWebViewInitialDataTest extends WidgetTest {
|
||||
final InAppWebViewInitialDataTestState state = InAppWebViewInitialDataTestState();
|
||||
|
||||
@override
|
||||
InAppWebViewInitialDataTestState createState() => state;
|
||||
}
|
||||
|
||||
class InAppWebViewInitialDataTestState extends WidgetTestState {
|
||||
String appBarTitle = "InAppWebViewInitialDataTest";
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
key: this.scaffoldKey,
|
||||
appBar: myAppBar(state: this, title: appBarTitle),
|
||||
drawer: myDrawer(context: context),
|
||||
body: Container(
|
||||
child: Column(children: <Widget>[
|
||||
Expanded(
|
||||
child: Container(
|
||||
child: InAppWebView(
|
||||
initialData: InAppWebViewInitialData(data: """
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>InAppWebViewInitialDataTest</title>
|
||||
<link rel="stylesheet" href="https://getbootstrap.com/docs/4.3/dist/css/bootstrap.min.css">
|
||||
<link rel="stylesheet" href="css/style.css">
|
||||
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
|
||||
<link rel="shortcut icon" href="favicon.ico">
|
||||
</head>
|
||||
<body class="text-center">
|
||||
<div class="cover-container d-flex w-100 h-100 p-3 mx-auto flex-column">
|
||||
<header class="masthead mb-auto">
|
||||
<div class="inner">
|
||||
<h3 class="masthead-brand">InAppWebViewInitialDataTest</h3>
|
||||
<nav class="nav nav-masthead justify-content-center">
|
||||
<a class="nav-link active" href="index.html">Home</a>
|
||||
<a class="nav-link" href="page-1.html">Page 1</a>
|
||||
<a class="nav-link" href="page-2.html">Page 2</a>
|
||||
</nav>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<main role="main" class="inner cover">
|
||||
<h1 class="cover-heading">InAppWebViewInitialFileTest</h1>
|
||||
<img src="images/flutter-logo.svg" alt="flutter logo">
|
||||
<p>
|
||||
<img src="https://via.placeholder.com/100x50" alt="placeholder 100x50">
|
||||
</p>
|
||||
<a id="link" href="https://github.com/pichillilorenzo/flutter_inappbrowser">flutter_inappbrowser</a>
|
||||
</main>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
"""),
|
||||
initialHeaders: {},
|
||||
initialOptions: InAppWebViewWidgetOptions(
|
||||
inAppWebViewOptions: InAppWebViewOptions(
|
||||
clearCache: true,
|
||||
debuggingEnabled: true
|
||||
)
|
||||
),
|
||||
onWebViewCreated: (InAppWebViewController controller) {
|
||||
webView = controller;
|
||||
},
|
||||
onLoadStart: (InAppWebViewController controller, String url) {
|
||||
|
||||
},
|
||||
onLoadStop: (InAppWebViewController controller, String url) {
|
||||
setState(() {
|
||||
appBarTitle = "true";
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
])
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
|
@ -3,7 +3,6 @@ import 'package:flutter/material.dart';
|
|||
import 'package:flutter_inappbrowser/flutter_inappbrowser.dart';
|
||||
|
||||
import 'main_test.dart';
|
||||
import 'util_test.dart';
|
||||
import 'custom_widget_test.dart';
|
||||
|
||||
class InAppWebViewInitialFileTest extends WidgetTest {
|
||||
|
@ -19,7 +18,9 @@ class InAppWebViewInitialFileTestState extends WidgetTestState {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
key: this.scaffoldKey,
|
||||
appBar: myAppBar(state: this, title: appBarTitle),
|
||||
drawer: myDrawer(context: context),
|
||||
body: Container(
|
||||
child: Column(children: <Widget>[
|
||||
Expanded(
|
||||
|
@ -43,7 +44,6 @@ class InAppWebViewInitialFileTestState extends WidgetTestState {
|
|||
setState(() {
|
||||
appBarTitle = "true";
|
||||
});
|
||||
nextTest(context: context, state: this);
|
||||
},
|
||||
),
|
||||
),
|
||||
|
|
|
@ -4,7 +4,6 @@ import 'package:flutter_inappbrowser/flutter_inappbrowser.dart';
|
|||
|
||||
import 'custom_widget_test.dart';
|
||||
import 'main_test.dart';
|
||||
import 'util_test.dart';
|
||||
|
||||
class InAppWebViewInitialUrlTest extends WidgetTest {
|
||||
final InAppWebViewInitialUrlTestState state = InAppWebViewInitialUrlTestState();
|
||||
|
@ -20,7 +19,9 @@ class InAppWebViewInitialUrlTestState extends WidgetTestState {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
key: this.scaffoldKey,
|
||||
appBar: myAppBar(state: this, title: appBarTitle),
|
||||
drawer: myDrawer(context: context),
|
||||
body: Container(
|
||||
child: Column(children: <Widget>[
|
||||
Expanded(
|
||||
|
@ -44,7 +45,6 @@ class InAppWebViewInitialUrlTestState extends WidgetTestState {
|
|||
setState(() {
|
||||
appBarTitle = url;
|
||||
});
|
||||
nextTest(context: context, state: this);
|
||||
},
|
||||
),
|
||||
),
|
||||
|
|
|
@ -3,7 +3,6 @@ import 'package:flutter/material.dart';
|
|||
import 'package:flutter_inappbrowser/flutter_inappbrowser.dart';
|
||||
|
||||
import 'main_test.dart';
|
||||
import 'util_test.dart';
|
||||
import 'custom_widget_test.dart';
|
||||
|
||||
class Foo {
|
||||
|
@ -34,7 +33,9 @@ class InAppWebViewJavaScriptHandlerTestState extends WidgetTestState {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
key: this.scaffoldKey,
|
||||
appBar: myAppBar(state: this, title: appBarTitle),
|
||||
drawer: myDrawer(context: context),
|
||||
body: Container(
|
||||
child: Column(children: <Widget>[
|
||||
Expanded(
|
||||
|
@ -64,7 +65,6 @@ class InAppWebViewJavaScriptHandlerTestState extends WidgetTestState {
|
|||
appBarTitle += " " + (args[3] is Map).toString();
|
||||
appBarTitle += " " + (args[4] is Map).toString();
|
||||
setState(() { });
|
||||
nextTest(context: context, state: this);
|
||||
});
|
||||
|
||||
},
|
||||
|
|
|
@ -3,7 +3,6 @@ import 'package:flutter/material.dart';
|
|||
import 'package:flutter_inappbrowser/flutter_inappbrowser.dart';
|
||||
|
||||
import 'main_test.dart';
|
||||
import 'util_test.dart';
|
||||
import 'custom_widget_test.dart';
|
||||
|
||||
class InAppWebViewOnConsoleMessageTest extends WidgetTest {
|
||||
|
@ -19,7 +18,9 @@ class InAppWebViewOnConsoleMessageTestState extends WidgetTestState {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
key: this.scaffoldKey,
|
||||
appBar: myAppBar(state: this, title: appBarTitle),
|
||||
drawer: myDrawer(context: context),
|
||||
body: Container(
|
||||
child: Column(children: <Widget>[
|
||||
Expanded(
|
||||
|
@ -46,7 +47,6 @@ class InAppWebViewOnConsoleMessageTestState extends WidgetTestState {
|
|||
setState(() {
|
||||
appBarTitle = consoleMessage.message + " " + consoleMessage.messageLevel.toString();
|
||||
});
|
||||
nextTest(context: context, state: this);
|
||||
},
|
||||
),
|
||||
),
|
||||
|
|
|
@ -3,8 +3,8 @@ import 'package:flutter/material.dart';
|
|||
import 'package:flutter_inappbrowser/flutter_inappbrowser.dart';
|
||||
|
||||
import 'main_test.dart';
|
||||
import 'util_test.dart';
|
||||
import 'custom_widget_test.dart';
|
||||
import '.env.dart';
|
||||
|
||||
class InAppWebViewOnDownloadStartTest extends WidgetTest {
|
||||
final InAppWebViewOnDownloadStartTestState state = InAppWebViewOnDownloadStartTestState();
|
||||
|
@ -19,13 +19,34 @@ class InAppWebViewOnDownloadStartTestState extends WidgetTestState {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
key: this.scaffoldKey,
|
||||
appBar: myAppBar(state: this, title: appBarTitle),
|
||||
drawer: myDrawer(context: context),
|
||||
body: Container(
|
||||
child: Column(children: <Widget>[
|
||||
Expanded(
|
||||
child: Container(
|
||||
child: InAppWebView(
|
||||
initialFile: "test_assets/in_app_webview_on_download_start_test.html",
|
||||
initialData: InAppWebViewInitialData(data: """
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>InAppWebViewOnDownloadStartTest</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>InAppWebViewOnDownloadStartTest</h1>
|
||||
<a id="download-file" href="http://${environment["NODE_SERVER_IP"]}:8082/test-download-file">download file</a>
|
||||
<script>
|
||||
window.addEventListener("flutterInAppBrowserPlatformReady", function(event) {
|
||||
document.querySelector("#download-file").click();
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
"""),
|
||||
initialHeaders: {},
|
||||
initialOptions: InAppWebViewWidgetOptions(
|
||||
inAppWebViewOptions: InAppWebViewOptions(
|
||||
|
@ -47,7 +68,6 @@ class InAppWebViewOnDownloadStartTestState extends WidgetTestState {
|
|||
setState(() {
|
||||
appBarTitle = url;
|
||||
});
|
||||
nextTest(context: context, state: this);
|
||||
},
|
||||
),
|
||||
),
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:flutter_inappbrowser/flutter_inappbrowser.dart';
|
||||
|
||||
import 'main_test.dart';
|
||||
import 'custom_widget_test.dart';
|
||||
|
||||
class InAppWebViewOnFindResultReceivedTest extends WidgetTest {
|
||||
final InAppWebViewOnFindResultReceivedTestState state = InAppWebViewOnFindResultReceivedTestState();
|
||||
|
||||
@override
|
||||
InAppWebViewOnFindResultReceivedTestState createState() => state;
|
||||
}
|
||||
|
||||
class InAppWebViewOnFindResultReceivedTestState extends WidgetTestState {
|
||||
String appBarTitle = "InAppWebViewOnFindResultReceivedTest";
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
key: this.scaffoldKey,
|
||||
appBar: myAppBar(state: this, title: appBarTitle),
|
||||
drawer: myDrawer(context: context),
|
||||
body: Container(
|
||||
child: Column(children: <Widget>[
|
||||
Expanded(
|
||||
child: Container(
|
||||
child: InAppWebView(
|
||||
initialFile: "test_assets/in_app_webview_initial_file_test.html",
|
||||
initialHeaders: {},
|
||||
initialOptions: InAppWebViewWidgetOptions(
|
||||
inAppWebViewOptions: InAppWebViewOptions(
|
||||
clearCache: true,
|
||||
debuggingEnabled: true
|
||||
)
|
||||
),
|
||||
onWebViewCreated: (InAppWebViewController controller) {
|
||||
webView = controller;
|
||||
},
|
||||
onLoadStart: (InAppWebViewController controller, String url) {
|
||||
|
||||
},
|
||||
onLoadStop: (InAppWebViewController controller, String url) {
|
||||
controller.findAllAsync(find: "InAppWebViewInitialFileTest");
|
||||
},
|
||||
onFindResultReceived: (InAppWebViewController controller, int activeMatchOrdinal, int numberOfMatches, bool isDoneCounting) async {
|
||||
if (isDoneCounting) {
|
||||
setState(() {
|
||||
appBarTitle = numberOfMatches.toString();
|
||||
});
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
])
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
|
@ -3,7 +3,6 @@ import 'package:flutter/material.dart';
|
|||
import 'package:flutter_inappbrowser/flutter_inappbrowser.dart';
|
||||
|
||||
import 'main_test.dart';
|
||||
import 'util_test.dart';
|
||||
import 'custom_widget_test.dart';
|
||||
|
||||
class InAppWebViewOnJsDialogTest extends WidgetTest {
|
||||
|
@ -27,7 +26,9 @@ class InAppWebViewOnJsDialogTestState extends WidgetTestState {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
key: this.scaffoldKey,
|
||||
appBar: myAppBar(state: this, title: appBarTitle),
|
||||
drawer: myDrawer(context: context),
|
||||
body: Container(
|
||||
child: Column(children: <Widget>[
|
||||
Expanded(
|
||||
|
@ -54,7 +55,6 @@ class InAppWebViewOnJsDialogTestState extends WidgetTestState {
|
|||
setState(() {
|
||||
appBarTitle = "prompt " + args[0];
|
||||
});
|
||||
nextTest(context: context, state: this);
|
||||
});
|
||||
},
|
||||
onLoadStart: (InAppWebViewController controller, String url) {
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:flutter_inappbrowser/flutter_inappbrowser.dart';
|
||||
|
||||
import 'custom_widget_test.dart';
|
||||
import 'main_test.dart';
|
||||
|
||||
class InAppWebViewOnLoadErrorTest extends WidgetTest {
|
||||
final InAppWebViewOnLoadErrorTestState state = InAppWebViewOnLoadErrorTestState();
|
||||
|
||||
@override
|
||||
InAppWebViewOnLoadErrorTestState createState() => state;
|
||||
}
|
||||
|
||||
class InAppWebViewOnLoadErrorTestState extends WidgetTestState {
|
||||
|
||||
String appBarTitle = "InAppWebViewOnLoadErrorTest";
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
key: this.scaffoldKey,
|
||||
appBar: myAppBar(state: this, title: appBarTitle),
|
||||
drawer: myDrawer(context: context),
|
||||
body: Container(
|
||||
child: Column(children: <Widget>[
|
||||
Expanded(
|
||||
child: Container(
|
||||
child: InAppWebView(
|
||||
initialUrl: "http://not-existing-domain.org/",
|
||||
initialHeaders: {},
|
||||
initialOptions: InAppWebViewWidgetOptions(
|
||||
inAppWebViewOptions: InAppWebViewOptions(
|
||||
clearCache: true,
|
||||
debuggingEnabled: true
|
||||
)
|
||||
),
|
||||
onWebViewCreated: (InAppWebViewController controller) {
|
||||
webView = controller;
|
||||
},
|
||||
onLoadStart: (InAppWebViewController controller, String url) {
|
||||
|
||||
},
|
||||
onLoadStop: (InAppWebViewController controller, String url) {
|
||||
|
||||
},
|
||||
onLoadError: (InAppWebViewController controller, String url, int code, String message) async {
|
||||
setState(() {
|
||||
appBarTitle = code.toString();
|
||||
});
|
||||
}
|
||||
),
|
||||
),
|
||||
),
|
||||
])
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:flutter_inappbrowser/flutter_inappbrowser.dart';
|
||||
|
||||
import 'custom_widget_test.dart';
|
||||
import 'main_test.dart';
|
||||
|
||||
class InAppWebViewOnLoadHttpErrorTest extends WidgetTest {
|
||||
final InAppWebViewOnLoadHttpErrorTestState state = InAppWebViewOnLoadHttpErrorTestState();
|
||||
|
||||
@override
|
||||
InAppWebViewOnLoadHttpErrorTestState createState() => state;
|
||||
}
|
||||
|
||||
class InAppWebViewOnLoadHttpErrorTestState extends WidgetTestState {
|
||||
|
||||
String appBarTitle = "InAppWebViewOnLoadHttpErrorTest";
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
key: this.scaffoldKey,
|
||||
appBar: myAppBar(state: this, title: appBarTitle),
|
||||
drawer: myDrawer(context: context),
|
||||
body: Container(
|
||||
child: Column(children: <Widget>[
|
||||
Expanded(
|
||||
child: Container(
|
||||
child: InAppWebView(
|
||||
initialUrl: "https://google.com/404",
|
||||
initialHeaders: {},
|
||||
initialOptions: InAppWebViewWidgetOptions(
|
||||
inAppWebViewOptions: InAppWebViewOptions(
|
||||
clearCache: true,
|
||||
debuggingEnabled: true
|
||||
)
|
||||
),
|
||||
onWebViewCreated: (InAppWebViewController controller) {
|
||||
webView = controller;
|
||||
},
|
||||
onLoadStart: (InAppWebViewController controller, String url) {
|
||||
|
||||
},
|
||||
onLoadStop: (InAppWebViewController controller, String url) {
|
||||
|
||||
},
|
||||
onLoadHttpError: (InAppWebViewController controller, String url, int statusCode, String description) async {
|
||||
setState(() {
|
||||
appBarTitle = statusCode.toString();
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
])
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
|
@ -4,7 +4,6 @@ import 'package:flutter/services.dart';
|
|||
import 'package:flutter_inappbrowser/flutter_inappbrowser.dart';
|
||||
|
||||
import 'main_test.dart';
|
||||
import 'util_test.dart';
|
||||
import 'custom_widget_test.dart';
|
||||
|
||||
class InAppWebViewOnLoadResourceCustomSchemeTest extends WidgetTest {
|
||||
|
@ -20,7 +19,9 @@ class InAppWebViewOnLoadResourceCustomSchemeTestState extends WidgetTestState {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
key: this.scaffoldKey,
|
||||
appBar: myAppBar(state: this, title: appBarTitle),
|
||||
drawer: myDrawer(context: context),
|
||||
body: Container(
|
||||
child: Column(children: <Widget>[
|
||||
Expanded(
|
||||
|
@ -42,7 +43,6 @@ class InAppWebViewOnLoadResourceCustomSchemeTestState extends WidgetTestState {
|
|||
setState(() {
|
||||
appBarTitle = "true";
|
||||
});
|
||||
nextTest(context: context, state: this);
|
||||
});
|
||||
},
|
||||
onLoadStart: (InAppWebViewController controller, String url) {
|
||||
|
|
|
@ -3,7 +3,6 @@ import 'package:flutter/material.dart';
|
|||
import 'package:flutter_inappbrowser/flutter_inappbrowser.dart';
|
||||
|
||||
import 'main_test.dart';
|
||||
import 'util_test.dart';
|
||||
import 'custom_widget_test.dart';
|
||||
|
||||
class InAppWebViewOnLoadResourceTest extends WidgetTest {
|
||||
|
@ -25,7 +24,9 @@ class InAppWebViewOnLoadResourceTestState extends WidgetTestState {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
key: this.scaffoldKey,
|
||||
appBar: myAppBar(state: this, title: appBarTitle),
|
||||
drawer: myDrawer(context: context),
|
||||
body: Container(
|
||||
child: Column(children: <Widget>[
|
||||
Expanded(
|
||||
|
@ -54,7 +55,6 @@ class InAppWebViewOnLoadResourceTestState extends WidgetTestState {
|
|||
countResources++;
|
||||
if (countResources == resourceList.length) {
|
||||
setState(() { });
|
||||
nextTest(context: context, state: this);
|
||||
}
|
||||
}
|
||||
),
|
||||
|
|
|
@ -0,0 +1,72 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:flutter_inappbrowser/flutter_inappbrowser.dart';
|
||||
|
||||
import 'main_test.dart';
|
||||
import 'custom_widget_test.dart';
|
||||
|
||||
class InAppWebViewOnNavigationStateChangeTest extends WidgetTest {
|
||||
final InAppWebViewOnNavigationStateChangeTestState state = InAppWebViewOnNavigationStateChangeTestState();
|
||||
|
||||
@override
|
||||
InAppWebViewOnNavigationStateChangeTestState createState() => state;
|
||||
}
|
||||
|
||||
class InAppWebViewOnNavigationStateChangeTestState extends WidgetTestState {
|
||||
String appBarTitle = "InAppWebViewOnNavigationStateChangeTest";
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
key: this.scaffoldKey,
|
||||
appBar: myAppBar(state: this, title: appBarTitle),
|
||||
drawer: myDrawer(context: context),
|
||||
body: Container(
|
||||
child: Column(children: <Widget>[
|
||||
Expanded(
|
||||
child: Container(
|
||||
child: InAppWebView(
|
||||
initialUrl: "https://flutter.dev/",
|
||||
initialHeaders: {},
|
||||
initialOptions: InAppWebViewWidgetOptions(
|
||||
inAppWebViewOptions: InAppWebViewOptions(
|
||||
clearCache: true,
|
||||
debuggingEnabled: true
|
||||
)
|
||||
),
|
||||
onWebViewCreated: (InAppWebViewController controller) {
|
||||
webView = controller;
|
||||
},
|
||||
onLoadStart: (InAppWebViewController controller, String url) {
|
||||
|
||||
},
|
||||
onLoadStop: (InAppWebViewController controller, String url) {
|
||||
controller.evaluateJavascript(source: """
|
||||
var state = {}
|
||||
var title = ''
|
||||
var url = 'first-push';
|
||||
history.pushState(state, title, url);
|
||||
|
||||
setTimeout(function() {
|
||||
var url = 'second-push';
|
||||
history.pushState(state, title, url);
|
||||
}, 100);
|
||||
""");
|
||||
},
|
||||
onNavigationStateChange: (InAppWebViewController controller, String url) async {
|
||||
if (url.endsWith("second-push")) {
|
||||
setState(() {
|
||||
appBarTitle += " " + url;
|
||||
});
|
||||
} else {
|
||||
appBarTitle = url;
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
])
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:flutter_inappbrowser/flutter_inappbrowser.dart';
|
||||
|
||||
import 'custom_widget_test.dart';
|
||||
import 'main_test.dart';
|
||||
|
||||
class InAppWebViewOnProgressChangedTest extends WidgetTest {
|
||||
final InAppWebViewOnProgressChangedTestState state = InAppWebViewOnProgressChangedTestState();
|
||||
|
||||
@override
|
||||
InAppWebViewOnProgressChangedTestState createState() => state;
|
||||
}
|
||||
|
||||
class InAppWebViewOnProgressChangedTestState extends WidgetTestState {
|
||||
|
||||
String appBarTitle = "InAppWebViewOnProgressChangedTest";
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
key: this.scaffoldKey,
|
||||
appBar: myAppBar(state: this, title: appBarTitle),
|
||||
drawer: myDrawer(context: context),
|
||||
body: Container(
|
||||
child: Column(children: <Widget>[
|
||||
Expanded(
|
||||
child: Container(
|
||||
child: InAppWebView(
|
||||
initialUrl: "https://flutter.dev/",
|
||||
initialHeaders: {},
|
||||
initialOptions: InAppWebViewWidgetOptions(
|
||||
inAppWebViewOptions: InAppWebViewOptions(
|
||||
clearCache: true,
|
||||
debuggingEnabled: true
|
||||
)
|
||||
),
|
||||
onWebViewCreated: (InAppWebViewController controller) {
|
||||
webView = controller;
|
||||
},
|
||||
onLoadStart: (InAppWebViewController controller, String url) {
|
||||
|
||||
},
|
||||
onLoadStop: (InAppWebViewController controller, String url) {
|
||||
|
||||
},
|
||||
onProgressChanged: (InAppWebViewController controller, int progress) {
|
||||
if (progress == 100) {
|
||||
setState(() {
|
||||
appBarTitle = "true";
|
||||
});
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
])
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
|
@ -4,7 +4,7 @@ import 'package:flutter_inappbrowser/flutter_inappbrowser.dart';
|
|||
|
||||
import 'custom_widget_test.dart';
|
||||
import 'main_test.dart';
|
||||
import 'util_test.dart';
|
||||
import '.env.dart';
|
||||
|
||||
class InAppWebViewOnReceivedHttpAuthRequestTest extends WidgetTest {
|
||||
final InAppWebViewOnReceivedHttpAuthRequestTestState state = InAppWebViewOnReceivedHttpAuthRequestTestState();
|
||||
|
@ -20,13 +20,15 @@ class InAppWebViewOnReceivedHttpAuthRequestTestState extends WidgetTestState {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
key: this.scaffoldKey,
|
||||
appBar: myAppBar(state: this, title: appBarTitle),
|
||||
drawer: myDrawer(context: context),
|
||||
body: Container(
|
||||
child: Column(children: <Widget>[
|
||||
Expanded(
|
||||
child: Container(
|
||||
child: InAppWebView(
|
||||
initialUrl: "http://192.168.1.20:8081/",
|
||||
initialUrl: "http://${environment["NODE_SERVER_IP"]}:8081/",
|
||||
initialHeaders: {},
|
||||
initialOptions: InAppWebViewWidgetOptions(
|
||||
inAppWebViewOptions: InAppWebViewOptions(
|
||||
|
@ -45,7 +47,6 @@ class InAppWebViewOnReceivedHttpAuthRequestTestState extends WidgetTestState {
|
|||
setState(() {
|
||||
appBarTitle = h1Content;
|
||||
});
|
||||
nextTest(context: context, state: this);
|
||||
},
|
||||
onReceivedHttpAuthRequest: (InAppWebViewController controller, HttpAuthChallenge challenge) async {
|
||||
return new HttpAuthResponse(
|
||||
|
|
|
@ -6,7 +6,6 @@ import 'package:flutter_inappbrowser/flutter_inappbrowser.dart';
|
|||
|
||||
import 'custom_widget_test.dart';
|
||||
import 'main_test.dart';
|
||||
import 'util_test.dart';
|
||||
|
||||
class InAppWebViewOnSafeBrowsingHitTest extends WidgetTest {
|
||||
final InAppWebViewOnSafeBrowsingHitTestState state = InAppWebViewOnSafeBrowsingHitTestState();
|
||||
|
@ -22,13 +21,15 @@ class InAppWebViewOnSafeBrowsingHitTestState extends WidgetTestState {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
key: this.scaffoldKey,
|
||||
appBar: myAppBar(state: this, title: appBarTitle),
|
||||
drawer: myDrawer(context: context),
|
||||
body: Container(
|
||||
child: Column(children: <Widget>[
|
||||
Expanded(
|
||||
child: Container(
|
||||
child: InAppWebView(
|
||||
initialUrl: "chrome://safe-browsing/match?type=malware",
|
||||
initialUrl: (Platform.isAndroid) ? "chrome://safe-browsing/match?type=malware" : "https://flutter.dev/",
|
||||
initialHeaders: {},
|
||||
initialOptions: InAppWebViewWidgetOptions(
|
||||
inAppWebViewOptions: InAppWebViewOptions(
|
||||
|
@ -38,8 +39,6 @@ class InAppWebViewOnSafeBrowsingHitTestState extends WidgetTestState {
|
|||
debuggingEnabled: true
|
||||
),
|
||||
androidInAppWebViewOptions: AndroidInAppWebViewOptions(
|
||||
databaseEnabled: true,
|
||||
domStorageEnabled: true,
|
||||
safeBrowsingEnabled: true,
|
||||
),
|
||||
),
|
||||
|
@ -55,7 +54,6 @@ class InAppWebViewOnSafeBrowsingHitTestState extends WidgetTestState {
|
|||
setState(() {
|
||||
appBarTitle = url;
|
||||
});
|
||||
nextTest(context: context, state: this);
|
||||
},
|
||||
onSafeBrowsingHit: (InAppWebViewController controller, String url, SafeBrowsingThreat threatType) async {
|
||||
return SafeBrowsingResponse(report: true, action: SafeBrowsingResponseAction.PROCEED);
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:flutter_inappbrowser/flutter_inappbrowser.dart';
|
||||
|
||||
import 'custom_widget_test.dart';
|
||||
import 'main_test.dart';
|
||||
|
||||
class InAppWebViewOnScrollChangedTest extends WidgetTest {
|
||||
final InAppWebViewOnScrollChangedTestState state = InAppWebViewOnScrollChangedTestState();
|
||||
|
||||
@override
|
||||
InAppWebViewOnScrollChangedTestState createState() => state;
|
||||
}
|
||||
|
||||
class InAppWebViewOnScrollChangedTestState extends WidgetTestState {
|
||||
|
||||
String appBarTitle = "InAppWebViewOnScrollChangedTest";
|
||||
bool scrolled = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
key: this.scaffoldKey,
|
||||
appBar: myAppBar(state: this, title: appBarTitle),
|
||||
drawer: myDrawer(context: context),
|
||||
body: Container(
|
||||
child: Column(children: <Widget>[
|
||||
Expanded(
|
||||
child: Container(
|
||||
child: InAppWebView(
|
||||
initialUrl: "https://flutter.dev/",
|
||||
initialHeaders: {},
|
||||
initialOptions: InAppWebViewWidgetOptions(
|
||||
inAppWebViewOptions: InAppWebViewOptions(
|
||||
clearCache: true,
|
||||
debuggingEnabled: true
|
||||
)
|
||||
),
|
||||
onWebViewCreated: (InAppWebViewController controller) {
|
||||
webView = controller;
|
||||
},
|
||||
onLoadStart: (InAppWebViewController controller, String url) {
|
||||
|
||||
},
|
||||
onLoadStop: (InAppWebViewController controller, String url) {
|
||||
controller.scrollTo(x: 0, y: 500);
|
||||
},
|
||||
onScrollChanged: (InAppWebViewController controller, int x, int y) {
|
||||
if (!scrolled) {
|
||||
scrolled = true;
|
||||
setState(() {
|
||||
appBarTitle = "true";
|
||||
});
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
])
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
|
@ -3,7 +3,6 @@ import 'package:flutter/material.dart';
|
|||
import 'package:flutter_inappbrowser/flutter_inappbrowser.dart';
|
||||
|
||||
import 'main_test.dart';
|
||||
import 'util_test.dart';
|
||||
import 'custom_widget_test.dart';
|
||||
|
||||
class InAppWebViewOnTargetBlankTest extends WidgetTest {
|
||||
|
@ -19,7 +18,9 @@ class InAppWebViewOnTargetBlankTestState extends WidgetTestState {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
key: this.scaffoldKey,
|
||||
appBar: myAppBar(state: this, title: appBarTitle),
|
||||
drawer: myDrawer(context: context),
|
||||
body: Container(
|
||||
child: Column(children: <Widget>[
|
||||
Expanded(
|
||||
|
@ -46,7 +47,6 @@ class InAppWebViewOnTargetBlankTestState extends WidgetTestState {
|
|||
setState(() {
|
||||
appBarTitle = url;
|
||||
});
|
||||
nextTest(context: context, state: this);
|
||||
}
|
||||
},
|
||||
onTargetBlank: (InAppWebViewController controller, String url) {
|
||||
|
|
|
@ -4,7 +4,6 @@ import 'package:flutter_inappbrowser/flutter_inappbrowser.dart';
|
|||
|
||||
import 'custom_widget_test.dart';
|
||||
import 'main_test.dart';
|
||||
import 'util_test.dart';
|
||||
|
||||
class InAppWebViewShouldOverrideUrlLoadingTest extends WidgetTest {
|
||||
final InAppWebViewShouldOverrideUrlLoadingTestState state = InAppWebViewShouldOverrideUrlLoadingTestState();
|
||||
|
@ -19,7 +18,9 @@ class InAppWebViewShouldOverrideUrlLoadingTestState extends WidgetTestState {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
key: this.scaffoldKey,
|
||||
appBar: myAppBar(state: this, title: appBarTitle),
|
||||
drawer: myDrawer(context: context),
|
||||
body: Container(
|
||||
child: Column(children: <Widget>[
|
||||
Expanded(
|
||||
|
@ -45,7 +46,6 @@ class InAppWebViewShouldOverrideUrlLoadingTestState extends WidgetTestState {
|
|||
setState(() {
|
||||
appBarTitle = url;
|
||||
});
|
||||
nextTest(context: context, state: this);
|
||||
} else {
|
||||
controller.evaluateJavascript(source: "document.querySelector('#link').click();");
|
||||
}
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:flutter_inappbrowser/flutter_inappbrowser.dart';
|
||||
|
||||
import 'custom_widget_test.dart';
|
||||
import 'main_test.dart';
|
||||
import '.env.dart';
|
||||
|
||||
class InAppWebViewSslRequestTest extends WidgetTest {
|
||||
final InAppWebViewSslRequestTestState state = InAppWebViewSslRequestTestState();
|
||||
|
||||
@override
|
||||
InAppWebViewSslRequestTestState createState() => state;
|
||||
}
|
||||
|
||||
class InAppWebViewSslRequestTestState extends WidgetTestState {
|
||||
|
||||
String appBarTitle = "InAppWebViewSslRequestTest";
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
key: this.scaffoldKey,
|
||||
appBar: myAppBar(state: this, title: appBarTitle),
|
||||
drawer: myDrawer(context: context),
|
||||
body: Container(
|
||||
child: Column(children: <Widget>[
|
||||
Expanded(
|
||||
child: Container(
|
||||
child: InAppWebView(
|
||||
initialUrl: "https://${environment["NODE_SERVER_IP"]}:4433/",
|
||||
initialHeaders: {},
|
||||
initialOptions: InAppWebViewWidgetOptions(
|
||||
inAppWebViewOptions: InAppWebViewOptions(
|
||||
clearCache: true,
|
||||
debuggingEnabled: true
|
||||
)
|
||||
),
|
||||
onWebViewCreated: (InAppWebViewController controller) {
|
||||
webView = controller;
|
||||
},
|
||||
onLoadStart: (InAppWebViewController controller, String url) {
|
||||
|
||||
},
|
||||
onLoadStop: (InAppWebViewController controller, String url) async {
|
||||
String h1Content = await controller.evaluateJavascript(source: "document.body.querySelector('h1').textContent");
|
||||
setState(() {
|
||||
appBarTitle = h1Content;
|
||||
});
|
||||
},
|
||||
onReceivedServerTrustAuthRequest: (InAppWebViewController controller, ServerTrustChallenge challenge) async {
|
||||
return new ServerTrustAuthResponse(action: ServerTrustAuthResponseAction.PROCEED);
|
||||
},
|
||||
onReceivedClientCertRequest: (InAppWebViewController controller, ClientCertChallenge challenge) async {
|
||||
return new ClientCertResponse(
|
||||
certificatePath: "test_assets/certificate.pfx",
|
||||
certificatePassword: "",
|
||||
androidKeyStoreType: "PKCS12",
|
||||
action: ClientCertResponseAction.PROCEED);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
])
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
|
@ -4,31 +4,43 @@ import 'package:flutter/material.dart';
|
|||
|
||||
import 'custom_widget_test.dart';
|
||||
import 'in_app_webview_ajax_test.dart';
|
||||
import 'in_app_webview_content_blocker_test.dart';
|
||||
import 'in_app_webview_cookie_manager_test.dart';
|
||||
import 'in_app_webview_fetch_test.dart';
|
||||
import 'in_app_webview_http_auth_credential_database_test.dart';
|
||||
import 'in_app_webview_initial_data_test.dart';
|
||||
import 'in_app_webview_initial_file_test.dart';
|
||||
import 'in_app_webview_initial_url_test.dart';
|
||||
import 'in_app_webview_javascript_handler_test.dart';
|
||||
import 'in_app_webview_on_console_message_test.dart';
|
||||
import 'in_app_webview_on_download_start_test.dart';
|
||||
import 'in_app_webview_on_find_result_received_test.dart';
|
||||
import 'in_app_webview_on_js_dialog_test.dart';
|
||||
import 'in_app_webview_on_load_error_test.dart';
|
||||
import 'in_app_webview_on_load_http_error_test.dart';
|
||||
import 'in_app_webview_on_load_resource_custom_scheme_test.dart';
|
||||
import 'in_app_webview_on_load_resource_test.dart';
|
||||
import 'in_app_webview_on_navigation_state_change_test.dart';
|
||||
import 'in_app_webview_on_progress_changed_test.dart';
|
||||
import 'in_app_webview_on_received_http_auth_request_test.dart';
|
||||
import 'in_app_webview_on_safe_browsing_hit_test.dart';
|
||||
import 'in_app_webview_on_scroll_changed_test.dart';
|
||||
import 'in_app_webview_on_target_blank_test.dart';
|
||||
import 'in_app_webview_should_override_url_loading_test.dart';
|
||||
import 'in_app_webview_ssl_request_test.dart';
|
||||
|
||||
List<String> testRoutes = [];
|
||||
Map<String, WidgetBuilder> buildRoutes({@required BuildContext context}) {
|
||||
Map<String, WidgetBuilder> getTestRoutes({@required BuildContext context}) {
|
||||
var routes = {
|
||||
'/': (context) => InAppWebViewInitialUrlTest(),
|
||||
'/InAppWebViewInitialFileTest': (context) => InAppWebViewInitialFileTest(),
|
||||
'/InAppWebViewInitialDataTest': (context) => InAppWebViewInitialDataTest(),
|
||||
'/InAppWebViewOnProgressChangedTest': (context) => InAppWebViewOnProgressChangedTest(),
|
||||
'/InAppWebViewOnScrollChangedTest': (context) => InAppWebViewOnScrollChangedTest(),
|
||||
'/InAppWebViewOnLoadResourceTest': (context) => InAppWebViewOnLoadResourceTest(),
|
||||
'/InAppWebViewJavaScriptHandlerTest': (context) => InAppWebViewJavaScriptHandlerTest(),
|
||||
'/InAppWebViewAjaxTest': (context) => InAppWebViewAjaxTest(),
|
||||
'/InAppWebViewFetchTest': (context) => InAppWebViewFetchTest(),
|
||||
'/InAppWebViewOnLoadResourceCustomSchemeTest': (context) => InAppWebViewOnLoadResourceCustomSchemeTest(),
|
||||
'/InAppWebViewFetchTest': (context) => InAppWebViewFetchTest(),
|
||||
'/InAppWebViewFetchTest': (context) => InAppWebViewFetchTest(),
|
||||
'/InAppWebViewShouldOverrideUrlLoadingTest': (context) => InAppWebViewShouldOverrideUrlLoadingTest(),
|
||||
'/InAppWebViewOnConsoleMessageTest': (context) => InAppWebViewOnConsoleMessageTest(),
|
||||
'/InAppWebViewOnDownloadStartTest': (context) => InAppWebViewOnDownloadStartTest(),
|
||||
|
@ -36,18 +48,33 @@ Map<String, WidgetBuilder> buildRoutes({@required BuildContext context}) {
|
|||
'/InAppWebViewOnJsDialogTest': (context) => InAppWebViewOnJsDialogTest(),
|
||||
'/InAppWebViewOnSafeBrowsingHitTest': (context) => InAppWebViewOnSafeBrowsingHitTest(),
|
||||
'/InAppWebViewOnReceivedHttpAuthRequestTest': (context) => InAppWebViewOnReceivedHttpAuthRequestTest(),
|
||||
'/InAppWebViewSslRequestTest': (context) => InAppWebViewSslRequestTest(),
|
||||
'/InAppWebViewOnFindResultReceivedTest': (context) => InAppWebViewOnFindResultReceivedTest(),
|
||||
'/InAppWebViewOnNavigationStateChangeTest': (context) => InAppWebViewOnNavigationStateChangeTest(),
|
||||
'/InAppWebViewOnLoadErrorTest': (context) => InAppWebViewOnLoadErrorTest(),
|
||||
'/InAppWebViewOnLoadHttpErrorTest': (context) => InAppWebViewOnLoadHttpErrorTest(),
|
||||
'/InAppWebViewCookieManagerTest': (context) => InAppWebViewCookieManagerTest(),
|
||||
'/InAppWebViewHttpAuthCredentialDatabaseTest': (context) => InAppWebViewHttpAuthCredentialDatabaseTest(),
|
||||
'/InAppWebViewContentBlockerTest': (context) => InAppWebViewContentBlockerTest(),
|
||||
};
|
||||
routes.forEach((k, v) => testRoutes.add(k));
|
||||
return routes;
|
||||
}
|
||||
|
||||
AppBar myAppBar({@required WidgetTestState state, @required String title}) {
|
||||
|
||||
return AppBar(
|
||||
title: Text(
|
||||
title,
|
||||
key: Key("AppBarTitle")
|
||||
),
|
||||
actions: <Widget>[
|
||||
IconButton(
|
||||
icon: Icon(Icons.menu),
|
||||
key: Key("SideMenu"),
|
||||
onPressed: () {
|
||||
state.scaffoldKey.currentState.openDrawer();
|
||||
},
|
||||
),
|
||||
IconButton(
|
||||
icon: Icon(Icons.refresh),
|
||||
onPressed: () {
|
||||
|
@ -59,6 +86,40 @@ AppBar myAppBar({@required WidgetTestState state, @required String title}) {
|
|||
);
|
||||
}
|
||||
|
||||
Drawer myDrawer({@required context}) {
|
||||
var routes = getTestRoutes(context: context);
|
||||
List<Widget> listTiles = [
|
||||
DrawerHeader(
|
||||
child: Text('Tests'),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.blue,
|
||||
),
|
||||
)
|
||||
];
|
||||
for (String k in routes.keys) {
|
||||
var title = "";
|
||||
if (k == "/") {
|
||||
title = "InAppWebViewInitialUrlTest";
|
||||
} else {
|
||||
title = k.substring(1);
|
||||
}
|
||||
listTiles.add(ListTile(
|
||||
title: Text(title),
|
||||
key: Key(title),
|
||||
onTap: () {
|
||||
Navigator.pushReplacementNamed(context, k);
|
||||
},
|
||||
));
|
||||
}
|
||||
return Drawer(
|
||||
child: ListView(
|
||||
key: Key("ListTiles"),
|
||||
padding: EdgeInsets.zero,
|
||||
children: listTiles,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future main() async {
|
||||
runApp(new MyApp());
|
||||
}
|
||||
|
@ -85,7 +146,7 @@ class _MyAppState extends State<MyApp> {
|
|||
return MaterialApp(
|
||||
title: 'flutter_inappbrowser tests',
|
||||
initialRoute: '/',
|
||||
routes: buildRoutes(context: context)
|
||||
routes: getTestRoutes(context: context)
|
||||
);
|
||||
}
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'custom_widget_test.dart';
|
||||
import 'main_test.dart';
|
||||
|
||||
int currentTest = 0;
|
||||
|
||||
void nextTest({@required BuildContext context, @required WidgetTestState state}) {
|
||||
if (currentTest + 1 < testRoutes.length) {
|
||||
currentTest++;
|
||||
String nextRoute = testRoutes[currentTest];
|
||||
Future.delayed(const Duration(milliseconds: 2000)).then((value) {
|
||||
Navigator.pushReplacementNamed(context, nextRoute);
|
||||
});
|
||||
}
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'types.dart';
|
||||
|
||||
///ContentBlocker class represents a set of rules to use block content in the browser window.
|
||||
///
|
||||
|
@ -34,56 +35,6 @@ class ContentBlocker {
|
|||
}
|
||||
}
|
||||
|
||||
///ContentBlockerTriggerResourceType class represents the possible resource type defined for a [ContentBlockerTrigger].
|
||||
class ContentBlockerTriggerResourceType {
|
||||
final String _value;
|
||||
const ContentBlockerTriggerResourceType._internal(this._value);
|
||||
static ContentBlockerTriggerResourceType fromValue(String value) {
|
||||
return (["document", "image", "style-sheet", "script", "font",
|
||||
"media", "svg-document", "raw"].contains(value)) ? ContentBlockerTriggerResourceType._internal(value) : null;
|
||||
}
|
||||
String toValue() => _value;
|
||||
@override
|
||||
String toString() => _value;
|
||||
|
||||
static const DOCUMENT = const ContentBlockerTriggerResourceType._internal('document');
|
||||
static const IMAGE = const ContentBlockerTriggerResourceType._internal('image');
|
||||
static const STYLE_SHEET = const ContentBlockerTriggerResourceType._internal('style-sheet');
|
||||
static const SCRIPT = const ContentBlockerTriggerResourceType._internal('script');
|
||||
static const FONT = const ContentBlockerTriggerResourceType._internal('font');
|
||||
static const MEDIA = const ContentBlockerTriggerResourceType._internal('media');
|
||||
static const SVG_DOCUMENT = const ContentBlockerTriggerResourceType._internal('svg-document');
|
||||
///Any untyped load
|
||||
static const RAW = const ContentBlockerTriggerResourceType._internal('raw');
|
||||
|
||||
bool operator ==(value) => value == _value;
|
||||
|
||||
@override
|
||||
int get hashCode => _value.hashCode;
|
||||
}
|
||||
|
||||
///ContentBlockerTriggerLoadType class represents the possible load type for a [ContentBlockerTrigger].
|
||||
class ContentBlockerTriggerLoadType {
|
||||
final String _value;
|
||||
const ContentBlockerTriggerLoadType._internal(this._value);
|
||||
static ContentBlockerTriggerLoadType fromValue(String value) {
|
||||
return (["first-party", "third-party"].contains(value)) ? ContentBlockerTriggerLoadType._internal(value) : null;
|
||||
}
|
||||
String toValue() => _value;
|
||||
@override
|
||||
String toString() => _value;
|
||||
|
||||
///FIRST_PARTY is triggered only if the resource has the same scheme, domain, and port as the main page resource.
|
||||
static const FIRST_PARTY = const ContentBlockerTriggerLoadType._internal('first-party');
|
||||
///THIRD_PARTY is triggered if the resource is not from the same domain as the main page resource.
|
||||
static const THIRD_PARTY = const ContentBlockerTriggerLoadType._internal('third-party');
|
||||
|
||||
bool operator ==(value) => value == _value;
|
||||
|
||||
@override
|
||||
int get hashCode => _value.hashCode;
|
||||
}
|
||||
|
||||
///Trigger of the content blocker. The trigger tells to the WebView when to perform the corresponding action.
|
||||
///A trigger dictionary must include an [ContentBlockerTrigger.urlFilter], which specifies a pattern to match the URL against.
|
||||
///The remaining properties are optional and modify the behavior of the trigger.
|
||||
|
@ -184,32 +135,6 @@ class ContentBlockerTrigger {
|
|||
}
|
||||
}
|
||||
|
||||
///ContentBlockerActionType class represents the kind of action that can be used with a [ContentBlockerTrigger].
|
||||
class ContentBlockerActionType {
|
||||
final String _value;
|
||||
const ContentBlockerActionType._internal(this._value);
|
||||
static ContentBlockerActionType fromValue(String value) {
|
||||
return (["block", "css-display-none", "make-https"].contains(value)) ? ContentBlockerActionType._internal(value) : null;
|
||||
}
|
||||
String toValue() => _value;
|
||||
@override
|
||||
String toString() => _value;
|
||||
|
||||
///Stops loading of the resource. If the resource was cached, the cache is ignored.
|
||||
static const BLOCK = const ContentBlockerActionType._internal('block');
|
||||
///Hides elements of the page based on a CSS selector. A selector field contains the selector list. Any matching element has its display property set to none, which hides it.
|
||||
///
|
||||
///**NOTE**: on Android, JavaScript must be enabled.
|
||||
static const CSS_DISPLAY_NONE = const ContentBlockerActionType._internal('css-display-none');
|
||||
///Changes a URL from http to https. URLs with a specified (nondefault) port and links using other protocols are unaffected.
|
||||
static const MAKE_HTTPS = const ContentBlockerActionType._internal('make-https');
|
||||
|
||||
bool operator ==(value) => value == _value;
|
||||
|
||||
@override
|
||||
int get hashCode => _value.hashCode;
|
||||
}
|
||||
|
||||
///Action associated to the trigger. The action tells to the WebView what to do when the trigger is matched.
|
||||
///When a trigger matches a resource, the browser queues the associated action for execution.
|
||||
///The WebView evaluates all the triggers, it executes the actions in order.
|
||||
|
|
|
@ -3,6 +3,8 @@ import 'dart:async';
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import 'types.dart';
|
||||
|
||||
///Manages the cookies used by WebView instances.
|
||||
///
|
||||
///**NOTE for iOS**: available from iOS 11.0+.
|
||||
|
@ -56,22 +58,22 @@ class CookieManager {
|
|||
}
|
||||
|
||||
///Gets all the cookies for the given [url].
|
||||
Future<List<Map<String, dynamic>>> getCookies({@required String url}) async {
|
||||
Future<List<Cookie>> getCookies({@required String url}) async {
|
||||
assert(url != null && url.isNotEmpty);
|
||||
|
||||
Map<String, dynamic> args = <String, dynamic>{};
|
||||
args.putIfAbsent('url', () => url);
|
||||
List<dynamic> cookies = await _channel.invokeMethod('getCookies', args);
|
||||
cookies = cookies.cast<Map<dynamic, dynamic>>();
|
||||
for(var i = 0; i < cookies.length; i++) {
|
||||
cookies[i] = cookies[i].cast<String, dynamic>();
|
||||
List<dynamic> cookieListMap = await _channel.invokeMethod('getCookies', args);
|
||||
cookieListMap = cookieListMap.cast<Map<dynamic, dynamic>>();
|
||||
List<Cookie> cookies = [];
|
||||
for(var i = 0; i < cookieListMap.length; i++) {
|
||||
cookies.add(Cookie(name: cookieListMap[i]["name"], value: cookieListMap[i]["value"]));
|
||||
}
|
||||
cookies = cookies.cast<Map<String, dynamic>>();
|
||||
return cookies;
|
||||
}
|
||||
|
||||
///Gets a cookie by its [name] for the given [url].
|
||||
Future<Map<String, dynamic>> getCookie({@required String url, @required String name}) async {
|
||||
Future<Cookie> getCookie({@required String url, @required String name}) async {
|
||||
assert(url != null && url.isNotEmpty);
|
||||
assert(name != null && name.isNotEmpty);
|
||||
|
||||
|
@ -82,7 +84,7 @@ class CookieManager {
|
|||
for(var i = 0; i < cookies.length; i++) {
|
||||
cookies[i] = cookies[i].cast<String, dynamic>();
|
||||
if (cookies[i]["name"] == name)
|
||||
return cookies[i];
|
||||
return Cookie(name: cookies[i]["name"], value: cookies[i]["value"]);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -1499,4 +1499,91 @@ class FetchRequest {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
///ContentBlockerTriggerResourceType class represents the possible resource type defined for a [ContentBlockerTrigger].
|
||||
class ContentBlockerTriggerResourceType {
|
||||
final String _value;
|
||||
const ContentBlockerTriggerResourceType._internal(this._value);
|
||||
static ContentBlockerTriggerResourceType fromValue(String value) {
|
||||
return (["document", "image", "style-sheet", "script", "font",
|
||||
"media", "svg-document", "raw"].contains(value)) ? ContentBlockerTriggerResourceType._internal(value) : null;
|
||||
}
|
||||
String toValue() => _value;
|
||||
@override
|
||||
String toString() => _value;
|
||||
|
||||
static const DOCUMENT = const ContentBlockerTriggerResourceType._internal('document');
|
||||
static const IMAGE = const ContentBlockerTriggerResourceType._internal('image');
|
||||
static const STYLE_SHEET = const ContentBlockerTriggerResourceType._internal('style-sheet');
|
||||
static const SCRIPT = const ContentBlockerTriggerResourceType._internal('script');
|
||||
static const FONT = const ContentBlockerTriggerResourceType._internal('font');
|
||||
static const MEDIA = const ContentBlockerTriggerResourceType._internal('media');
|
||||
static const SVG_DOCUMENT = const ContentBlockerTriggerResourceType._internal('svg-document');
|
||||
///Any untyped load
|
||||
static const RAW = const ContentBlockerTriggerResourceType._internal('raw');
|
||||
|
||||
bool operator ==(value) => value == _value;
|
||||
|
||||
@override
|
||||
int get hashCode => _value.hashCode;
|
||||
}
|
||||
|
||||
|
||||
///ContentBlockerTriggerLoadType class represents the possible load type for a [ContentBlockerTrigger].
|
||||
class ContentBlockerTriggerLoadType {
|
||||
final String _value;
|
||||
const ContentBlockerTriggerLoadType._internal(this._value);
|
||||
static ContentBlockerTriggerLoadType fromValue(String value) {
|
||||
return (["first-party", "third-party"].contains(value)) ? ContentBlockerTriggerLoadType._internal(value) : null;
|
||||
}
|
||||
String toValue() => _value;
|
||||
@override
|
||||
String toString() => _value;
|
||||
|
||||
///FIRST_PARTY is triggered only if the resource has the same scheme, domain, and port as the main page resource.
|
||||
static const FIRST_PARTY = const ContentBlockerTriggerLoadType._internal('first-party');
|
||||
///THIRD_PARTY is triggered if the resource is not from the same domain as the main page resource.
|
||||
static const THIRD_PARTY = const ContentBlockerTriggerLoadType._internal('third-party');
|
||||
|
||||
bool operator ==(value) => value == _value;
|
||||
|
||||
@override
|
||||
int get hashCode => _value.hashCode;
|
||||
}
|
||||
|
||||
///ContentBlockerActionType class represents the kind of action that can be used with a [ContentBlockerTrigger].
|
||||
class ContentBlockerActionType {
|
||||
final String _value;
|
||||
const ContentBlockerActionType._internal(this._value);
|
||||
static ContentBlockerActionType fromValue(String value) {
|
||||
return (["block", "css-display-none", "make-https"].contains(value)) ? ContentBlockerActionType._internal(value) : null;
|
||||
}
|
||||
String toValue() => _value;
|
||||
@override
|
||||
String toString() => _value;
|
||||
|
||||
///Stops loading of the resource. If the resource was cached, the cache is ignored.
|
||||
static const BLOCK = const ContentBlockerActionType._internal('block');
|
||||
///Hides elements of the page based on a CSS selector. A selector field contains the selector list. Any matching element has its display property set to none, which hides it.
|
||||
///
|
||||
///**NOTE**: on Android, JavaScript must be enabled.
|
||||
static const CSS_DISPLAY_NONE = const ContentBlockerActionType._internal('css-display-none');
|
||||
///Changes a URL from http to https. URLs with a specified (nondefault) port and links using other protocols are unaffected.
|
||||
static const MAKE_HTTPS = const ContentBlockerActionType._internal('make-https');
|
||||
|
||||
bool operator ==(value) => value == _value;
|
||||
|
||||
@override
|
||||
int get hashCode => _value.hashCode;
|
||||
}
|
||||
|
||||
///Cookie class represents a cookie returned by the [CookieManager].
|
||||
class Cookie {
|
||||
///The name;
|
||||
String name;
|
||||
///The value;
|
||||
dynamic value;
|
||||
|
||||
Cookie({@required this.name, @required this.value});
|
||||
}
|
|
@ -22,44 +22,56 @@ appHttps.get('/', (req, res) => {
|
|||
console.log(JSON.stringify(req.headers))
|
||||
const cert = req.connection.getPeerCertificate()
|
||||
|
||||
// The `req.client.authorized` flag will be true if the certificate is valid and was issued by a CA we white-listed
|
||||
// earlier in `opts.ca`. We display the name of our user (CN = Common Name) and the name of the issuer, which is
|
||||
// `localhost`.
|
||||
// The `req.client.authorized` flag will be true if the certificate is valid and was issued by a CA we white-listed
|
||||
// earlier in `opts.ca`. We display the name of our user (CN = Common Name) and the name of the issuer, which is
|
||||
// `localhost`.
|
||||
|
||||
if (req.client.authorized) {
|
||||
res.send(`
|
||||
<html>
|
||||
<head>
|
||||
<script src="/fakeResource" type="text/javascript"></script>
|
||||
</head>
|
||||
<body>
|
||||
<p>Hello ${cert.subject.CN}, your certificate was issued by ${cert.issuer.CN}!</p>
|
||||
</body>
|
||||
</html>
|
||||
`)
|
||||
// They can still provide a certificate which is not accepted by us. Unfortunately, the `cert` object will be an empty
|
||||
// object instead of `null` if there is no certificate at all, so we have to check for a known field rather than
|
||||
// truthiness.
|
||||
<html>
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Authorized</h1>
|
||||
</body>
|
||||
</html>
|
||||
`);
|
||||
// They can still provide a certificate which is not accepted by us. Unfortunately, the `cert` object will be an empty
|
||||
// object instead of `null` if there is no certificate at all, so we have to check for a known field rather than
|
||||
// truthiness.
|
||||
|
||||
} else if (cert.subject) {
|
||||
res.status(403).send(`Sorry ${cert.subject.CN}, certificates from ${cert.issuer.CN} are not welcome here.`)
|
||||
// And last, they can come to us with no certificate at all:
|
||||
console.log(`Sorry ${cert.subject.CN}, certificates from ${cert.issuer.CN} are not welcome here.`);
|
||||
res.status(403).send(`
|
||||
<html>
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Forbidden</h1>
|
||||
</body>
|
||||
</html>
|
||||
`);
|
||||
// And last, they can come to us with no certificate at all:
|
||||
} else {
|
||||
res.status(401).send(`Sorry, but you need to provide a client certificate to continue.`)
|
||||
console.log(`Sorry, but you need to provide a client certificate to continue.`)
|
||||
res.status(401).send(`
|
||||
<html>
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Unauthorized</h1>
|
||||
</body>
|
||||
</html>
|
||||
`);
|
||||
}
|
||||
res.end()
|
||||
})
|
||||
|
||||
appHttps.get('/fakeResource', (req, res) => {
|
||||
console.log(JSON.stringify(req.headers))
|
||||
res.set("Content-Type", "text/javascript")
|
||||
res.send(`alert("HI");`)
|
||||
res.end()
|
||||
})
|
||||
|
||||
// Let's create our HTTPS server and we're ready to go.
|
||||
https.createServer(options, appHttps).listen(4433)
|
||||
|
||||
|
||||
|
||||
// Ensure this is before any other middleware or routes
|
||||
appAuthBasic.use((req, res, next) => {
|
||||
let user = auth(req)
|
||||
|
@ -98,6 +110,8 @@ appAuthBasic.get("/", (req, res) => {
|
|||
|
||||
appAuthBasic.listen(8081)
|
||||
|
||||
|
||||
|
||||
// Parse URL-encoded bodies (as sent by HTML forms)
|
||||
app.use(express.urlencoded());
|
||||
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
#!/bin/bash
|
||||
export NODE_SERVER_IP=$1
|
||||
dart tool/env.dart
|
||||
cd nodejs_server_test_auth_basic_and_ssl
|
||||
node index.js &
|
||||
cd ../example
|
||||
flutter driver -t test_driver/app.dart
|
||||
kill $(jobs -p)
|
|
@ -0,0 +1,12 @@
|
|||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
Future<void> main() async {
|
||||
final config = {
|
||||
'NODE_SERVER_IP': Platform.environment['NODE_SERVER_IP'],
|
||||
};
|
||||
|
||||
final filename = 'example/test_driver/.env.dart';
|
||||
File(filename).writeAsString('final environment = ${json.encode(config)};');
|
||||
}
|
Loading…
Reference in New Issue