updated driver tests, updated onTargetBlank event for Android
This commit is contained in:
parent
3106caf437
commit
2a1e0b8204
930
.idea/workspace.xml
generated
930
.idea/workspace.xml
generated
File diff suppressed because it is too large
Load Diff
@ -46,6 +46,11 @@
|
|||||||
- Renamed `injectStyleCode` to `injectCSSCode`
|
- Renamed `injectStyleCode` to `injectCSSCode`
|
||||||
- Renamed `injectStyleFile` to `injectCSSFileFromUrl`
|
- Renamed `injectStyleFile` to `injectCSSFileFromUrl`
|
||||||
|
|
||||||
|
## 1.2.2
|
||||||
|
|
||||||
|
- Merge "added a shared WKProcessPool for webview instances" [#198](https://github.com/pichillilorenzo/flutter_inappbrowser/pull/198) (thanks to [robertcnst](https://github.com/robertcnst))
|
||||||
|
- Fixed iOS setCookie.
|
||||||
|
|
||||||
## 1.2.1
|
## 1.2.1
|
||||||
|
|
||||||
- Merge "Add new option to control the contentMode in Android platform" [#101](https://github.com/pichillilorenzo/flutter_inappbrowser/pull/101) (thanks to [DreamBuddy](https://github.com/DreamBuddy))
|
- Merge "Add new option to control the contentMode in Android platform" [#101](https://github.com/pichillilorenzo/flutter_inappbrowser/pull/101) (thanks to [DreamBuddy](https://github.com/DreamBuddy))
|
||||||
|
@ -9,6 +9,7 @@ import android.graphics.BitmapFactory;
|
|||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
import android.os.Message;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.webkit.ConsoleMessage;
|
import android.webkit.ConsoleMessage;
|
||||||
@ -18,6 +19,7 @@ import android.webkit.JsResult;
|
|||||||
import android.webkit.ValueCallback;
|
import android.webkit.ValueCallback;
|
||||||
import android.webkit.WebChromeClient;
|
import android.webkit.WebChromeClient;
|
||||||
import android.webkit.WebView;
|
import android.webkit.WebView;
|
||||||
|
import android.webkit.WebViewClient;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
@ -395,12 +397,40 @@ public class InAppWebChromeClient extends WebChromeClient implements PluginRegis
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateWindow(WebView view, boolean dialog, boolean userGesture, android.os.Message resultMsg) {
|
public boolean onCreateWindow(WebView view, boolean isDialog, boolean userGesture, final Message resultMsg) {
|
||||||
WebView.HitTestResult result = view.getHitTestResult();
|
final Map<String, Object> obj = new HashMap<>();
|
||||||
String data = result.getExtra();
|
|
||||||
Map<String, Object> obj = new HashMap<>();
|
|
||||||
if (inAppBrowserActivity != null)
|
if (inAppBrowserActivity != null)
|
||||||
obj.put("uuid", inAppBrowserActivity.uuid);
|
obj.put("uuid", inAppBrowserActivity.uuid);
|
||||||
|
|
||||||
|
WebView.HitTestResult result = view.getHitTestResult();
|
||||||
|
String data = result.getExtra();
|
||||||
|
|
||||||
|
if (data == null) {
|
||||||
|
// to get the URL, create a temp weview
|
||||||
|
final WebView newWebView = new WebView(view.getContext());
|
||||||
|
// disable javascript
|
||||||
|
newWebView.getSettings().setJavaScriptEnabled(false);
|
||||||
|
newWebView.setWebViewClient(new WebViewClient(){
|
||||||
|
@Override
|
||||||
|
public void onPageStarted(WebView v, String url, Bitmap favicon) {
|
||||||
|
super.onPageStarted(v, url, favicon);
|
||||||
|
|
||||||
|
obj.put("url", url);
|
||||||
|
getChannel().invokeMethod("onTargetBlank", obj);
|
||||||
|
|
||||||
|
// stop webview loading
|
||||||
|
v.stopLoading();
|
||||||
|
|
||||||
|
// this will throw the error "Application attempted to call on a destroyed AwAutofillManager" that will kill the webview.
|
||||||
|
// that's ok.
|
||||||
|
v.destroy();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
((WebView.WebViewTransport)resultMsg.obj).setWebView(newWebView);
|
||||||
|
resultMsg.sendToTarget();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
obj.put("url", data);
|
obj.put("url", data);
|
||||||
getChannel().invokeMethod("onTargetBlank", obj);
|
getChannel().invokeMethod("onTargetBlank", obj);
|
||||||
return false;
|
return false;
|
||||||
|
@ -42,6 +42,7 @@ class _InAppWebViewExampleScreenState extends State<InAppWebViewExampleScreen> {
|
|||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
super.dispose();
|
super.dispose();
|
||||||
|
_textFieldController.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -122,11 +123,11 @@ class _InAppWebViewExampleScreenState extends State<InAppWebViewExampleScreen> {
|
|||||||
BoxDecoration(border: Border.all(color: Colors.blueAccent)),
|
BoxDecoration(border: Border.all(color: Colors.blueAccent)),
|
||||||
child: InAppWebView(
|
child: InAppWebView(
|
||||||
//initialUrl: "https://www.youtube.com/embed/M7lc1UVf-VE?playsinline=1",
|
//initialUrl: "https://www.youtube.com/embed/M7lc1UVf-VE?playsinline=1",
|
||||||
initialUrl: "https://github.com",
|
//initialUrl: "https://github.com",
|
||||||
//initialUrl: "chrome://safe-browsing/match?type=malware",
|
//initialUrl: "chrome://safe-browsing/match?type=malware",
|
||||||
//initialUrl: "http://192.168.1.20:8081/",
|
//initialUrl: "http://192.168.1.20:8081/",
|
||||||
//initialUrl: "https://192.168.1.20:4433/",
|
//initialUrl: "https://192.168.1.20:4433/",
|
||||||
//initialFile: "assets/index.html",
|
initialFile: "assets/index.html",
|
||||||
initialHeaders: {},
|
initialHeaders: {},
|
||||||
initialOptions: InAppWebViewWidgetOptions(
|
initialOptions: InAppWebViewWidgetOptions(
|
||||||
inAppWebViewOptions: InAppWebViewOptions(
|
inAppWebViewOptions: InAppWebViewOptions(
|
||||||
|
@ -56,6 +56,10 @@ flutter:
|
|||||||
- test_assets/in_app_webview_ajax_test.html
|
- test_assets/in_app_webview_ajax_test.html
|
||||||
- test_assets/in_app_webview_fetch_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_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/
|
- test_assets/css/
|
||||||
- test_assets/images/
|
- test_assets/images/
|
||||||
- test_assets/favicon.ico
|
- test_assets/favicon.ico
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
<p>
|
<p>
|
||||||
<img src="https://via.placeholder.com/100x50" alt="placeholder 100x50">
|
<img src="https://via.placeholder.com/100x50" alt="placeholder 100x50">
|
||||||
</p>
|
</p>
|
||||||
|
<a id="link" href="https://github.com/pichillilorenzo/flutter_inappbrowser">flutter_inappbrowser</a>
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
19
example/test_assets/in_app_webview_on_js_dialog_test.html
Normal file
19
example/test_assets/in_app_webview_on_js_dialog_test.html
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<!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>InAppWebViewOnJsDialogTest</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>InAppWebViewOnJsDialogTest</h1>
|
||||||
|
<script>
|
||||||
|
window.addEventListener("flutterInAppBrowserPlatformReady", function(event) {
|
||||||
|
alert("alert message");
|
||||||
|
window.flutter_inappbrowser.callHandler('confirm', confirm("confirm message"));
|
||||||
|
window.flutter_inappbrowser.callHandler('prompt', prompt("prompt message", "prompt default value"));
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -8,11 +8,9 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>InAppWebViewOnTargetBlankTest</h1>
|
<h1>InAppWebViewOnTargetBlankTest</h1>
|
||||||
<a id="target-blank" href="https://flutter.dev/">target blank</a>
|
<a id="target-blank" href="https://flutter.dev/" target="_blank">target blank</a>
|
||||||
<script>
|
<script>
|
||||||
window.addEventListener("flutterInAppBrowserPlatformReady", function(event) {
|
document.querySelector('#target-blank').click();
|
||||||
document.querySelector("#target-blank").click();
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
@ -12,6 +12,7 @@ void main() {
|
|||||||
// Connect to the Flutter driver before running any tests.
|
// Connect to the Flutter driver before running any tests.
|
||||||
setUpAll(() async {
|
setUpAll(() async {
|
||||||
driver = await FlutterDriver.connect();
|
driver = await FlutterDriver.connect();
|
||||||
|
await driver.setTextEntryEmulation(enabled: true);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Close the connection to the driver after the tests have completed.
|
// Close the connection to the driver after the tests have completed.
|
||||||
@ -166,5 +167,44 @@ void main() {
|
|||||||
expect(url, "https://flutter.dev/");
|
expect(url, "https://flutter.dev/");
|
||||||
}, timeout: new Timeout(new Duration(minutes: 5)));
|
}, 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');
|
||||||
|
final confirmButtonOk = find.byValueKey('ConfirmButtonOk');
|
||||||
|
final promptTextField = find.byValueKey('PromptTextField');
|
||||||
|
final promptButtonCancel = find.byValueKey('PromptButtonCancel');
|
||||||
|
final promptButtonOk = find.byValueKey('PromptButtonOk');
|
||||||
|
|
||||||
|
while((await driver.getText(appBarTitle)) == "InAppWebViewOnJsDialogTest") {
|
||||||
|
await Future.delayed(const Duration(milliseconds: 1000));
|
||||||
|
}
|
||||||
|
|
||||||
|
await driver.tap(alertButtonOk);
|
||||||
|
|
||||||
|
String title = await driver.getText(appBarTitle);
|
||||||
|
expect(title, "alert");
|
||||||
|
|
||||||
|
await Future.delayed(const Duration(milliseconds: 500));
|
||||||
|
|
||||||
|
await driver.tap(confirmButtonOk);
|
||||||
|
|
||||||
|
title = await driver.getText(appBarTitle);
|
||||||
|
expect(title, "confirm true");
|
||||||
|
|
||||||
|
await Future.delayed(const Duration(milliseconds: 500));
|
||||||
|
|
||||||
|
await driver.tap(promptTextField);
|
||||||
|
await driver.enterText("new value");
|
||||||
|
await driver.waitFor(find.text("new value"));
|
||||||
|
|
||||||
|
await driver.tap(promptButtonOk);
|
||||||
|
|
||||||
|
title = await driver.getText(appBarTitle);
|
||||||
|
expect(title, "prompt new value");
|
||||||
|
|
||||||
|
}, timeout: new Timeout(new Duration(minutes: 5)));
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
@ -40,10 +40,7 @@ class InAppWebViewOnConsoleMessageTestState extends WidgetTestState {
|
|||||||
|
|
||||||
},
|
},
|
||||||
onLoadStop: (InAppWebViewController controller, String url) {
|
onLoadStop: (InAppWebViewController controller, String url) {
|
||||||
setState(() {
|
|
||||||
appBarTitle = "true";
|
|
||||||
});
|
|
||||||
nextTest(context: context, state: this);
|
|
||||||
},
|
},
|
||||||
onConsoleMessage: (InAppWebViewController controller, ConsoleMessage consoleMessage) {
|
onConsoleMessage: (InAppWebViewController controller, ConsoleMessage consoleMessage) {
|
||||||
setState(() {
|
setState(() {
|
||||||
|
@ -25,7 +25,7 @@ class InAppWebViewOnDownloadStartTestState extends WidgetTestState {
|
|||||||
Expanded(
|
Expanded(
|
||||||
child: Container(
|
child: Container(
|
||||||
child: InAppWebView(
|
child: InAppWebView(
|
||||||
initialFile: "test_assets/in_app_webview_on_downlaod_start_test.html",
|
initialFile: "test_assets/in_app_webview_on_download_start_test.html",
|
||||||
initialHeaders: {},
|
initialHeaders: {},
|
||||||
initialOptions: InAppWebViewWidgetOptions(
|
initialOptions: InAppWebViewWidgetOptions(
|
||||||
inAppWebViewOptions: InAppWebViewOptions(
|
inAppWebViewOptions: InAppWebViewOptions(
|
||||||
|
200
example/test_driver/in_app_webview_on_js_dialog_test.dart
Normal file
200
example/test_driver/in_app_webview_on_js_dialog_test.dart
Normal file
@ -0,0 +1,200 @@
|
|||||||
|
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 {
|
||||||
|
final InAppWebViewOnJsDialogTestState state = InAppWebViewOnJsDialogTestState();
|
||||||
|
|
||||||
|
@override
|
||||||
|
InAppWebViewOnJsDialogTestState createState() => state;
|
||||||
|
}
|
||||||
|
|
||||||
|
class InAppWebViewOnJsDialogTestState extends WidgetTestState {
|
||||||
|
String appBarTitle = "InAppWebViewOnJsDialogTest";
|
||||||
|
|
||||||
|
TextEditingController _textFieldController = TextEditingController();
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
super.dispose();
|
||||||
|
_textFieldController.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: myAppBar(state: this, title: appBarTitle),
|
||||||
|
body: Container(
|
||||||
|
child: Column(children: <Widget>[
|
||||||
|
Expanded(
|
||||||
|
child: Container(
|
||||||
|
child: InAppWebView(
|
||||||
|
initialFile: "test_assets/in_app_webview_on_js_dialog_test.html",
|
||||||
|
initialHeaders: {},
|
||||||
|
initialOptions: InAppWebViewWidgetOptions(
|
||||||
|
inAppWebViewOptions: InAppWebViewOptions(
|
||||||
|
clearCache: true,
|
||||||
|
debuggingEnabled: true
|
||||||
|
)
|
||||||
|
),
|
||||||
|
onWebViewCreated: (InAppWebViewController controller) {
|
||||||
|
webView = controller;
|
||||||
|
|
||||||
|
controller.addJavaScriptHandler(handlerName: 'confirm', callback: (args) {
|
||||||
|
setState(() {
|
||||||
|
appBarTitle = "confirm " + ((args[0] is bool && args[0]) ? "true" : "false");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
controller.addJavaScriptHandler(handlerName: 'prompt', callback: (args) {
|
||||||
|
setState(() {
|
||||||
|
appBarTitle = "prompt " + args[0];
|
||||||
|
});
|
||||||
|
nextTest(context: context, state: this);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
onLoadStart: (InAppWebViewController controller, String url) {
|
||||||
|
|
||||||
|
},
|
||||||
|
onLoadStop: (InAppWebViewController controller, String url) {
|
||||||
|
setState(() {
|
||||||
|
appBarTitle = "loaded";
|
||||||
|
});
|
||||||
|
},
|
||||||
|
onJsAlert:
|
||||||
|
(InAppWebViewController controller, String message) async {
|
||||||
|
JsAlertResponseAction action =
|
||||||
|
await createAlertDialog(context, message);
|
||||||
|
return JsAlertResponse(
|
||||||
|
handledByClient: true, action: action);
|
||||||
|
},
|
||||||
|
onJsConfirm:
|
||||||
|
(InAppWebViewController controller, String message) async {
|
||||||
|
JsConfirmResponseAction action =
|
||||||
|
await createConfirmDialog(context, message);
|
||||||
|
return JsConfirmResponse(
|
||||||
|
handledByClient: true, action: action);
|
||||||
|
},
|
||||||
|
onJsPrompt: (InAppWebViewController controller, String message,
|
||||||
|
String defaultValue) async {
|
||||||
|
_textFieldController.text = defaultValue;
|
||||||
|
JsPromptResponseAction action =
|
||||||
|
await createPromptDialog(context, message);
|
||||||
|
return JsPromptResponse(
|
||||||
|
handledByClient: true,
|
||||||
|
action: action,
|
||||||
|
value: _textFieldController.text);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
])
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<JsAlertResponseAction> createAlertDialog(
|
||||||
|
BuildContext context, String message) async {
|
||||||
|
JsAlertResponseAction action;
|
||||||
|
|
||||||
|
await showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return AlertDialog(
|
||||||
|
content: Text(message),
|
||||||
|
actions: <Widget>[
|
||||||
|
FlatButton(
|
||||||
|
child: Text("Ok"),
|
||||||
|
key: Key("AlertButtonOk"),
|
||||||
|
onPressed: () {
|
||||||
|
action = JsAlertResponseAction.CONFIRM;
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
setState(() {
|
||||||
|
appBarTitle = "alert";
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
return action;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<JsConfirmResponseAction> createConfirmDialog(
|
||||||
|
BuildContext context, String message) async {
|
||||||
|
JsConfirmResponseAction action;
|
||||||
|
|
||||||
|
await showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return AlertDialog(
|
||||||
|
content: Text(message),
|
||||||
|
actions: <Widget>[
|
||||||
|
FlatButton(
|
||||||
|
child: Text("Cancel"),
|
||||||
|
key: Key("ConfirmButtonCancel"),
|
||||||
|
onPressed: () {
|
||||||
|
action = JsConfirmResponseAction.CANCEL;
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
FlatButton(
|
||||||
|
child: Text("Ok"),
|
||||||
|
key: Key("ConfirmButtonOk"),
|
||||||
|
onPressed: () {
|
||||||
|
action = JsConfirmResponseAction.CONFIRM;
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
return action;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<JsPromptResponseAction> createPromptDialog(
|
||||||
|
BuildContext context, String message) async {
|
||||||
|
JsPromptResponseAction action;
|
||||||
|
|
||||||
|
await showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return AlertDialog(
|
||||||
|
title: Text(message),
|
||||||
|
content: TextField(
|
||||||
|
key: Key("PromptTextField"),
|
||||||
|
controller: _textFieldController,
|
||||||
|
),
|
||||||
|
actions: <Widget>[
|
||||||
|
FlatButton(
|
||||||
|
child: Text("Cancel"),
|
||||||
|
key: Key("PromptButtonCancel"),
|
||||||
|
onPressed: () {
|
||||||
|
action = JsPromptResponseAction.CANCEL;
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
FlatButton(
|
||||||
|
child: Text("Ok"),
|
||||||
|
key: Key("PromptButtonOk"),
|
||||||
|
onPressed: () {
|
||||||
|
action = JsPromptResponseAction.CONFIRM;
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
return action;
|
||||||
|
}
|
||||||
|
}
|
@ -31,7 +31,8 @@ class InAppWebViewOnTargetBlankTestState extends WidgetTestState {
|
|||||||
inAppWebViewOptions: InAppWebViewOptions(
|
inAppWebViewOptions: InAppWebViewOptions(
|
||||||
clearCache: true,
|
clearCache: true,
|
||||||
debuggingEnabled: true,
|
debuggingEnabled: true,
|
||||||
useOnTargetBlank: true
|
useOnTargetBlank: true,
|
||||||
|
javaScriptCanOpenWindowsAutomatically: true,
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
onWebViewCreated: (InAppWebViewController controller) {
|
onWebViewCreated: (InAppWebViewController controller) {
|
||||||
@ -41,13 +42,15 @@ class InAppWebViewOnTargetBlankTestState extends WidgetTestState {
|
|||||||
|
|
||||||
},
|
},
|
||||||
onLoadStop: (InAppWebViewController controller, String url) {
|
onLoadStop: (InAppWebViewController controller, String url) {
|
||||||
|
if (url == "https://flutter.dev/") {
|
||||||
|
setState(() {
|
||||||
|
appBarTitle = url;
|
||||||
|
});
|
||||||
|
nextTest(context: context, state: this);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onTargetBlank: (InAppWebViewController controller, String url) {
|
onTargetBlank: (InAppWebViewController controller, String url) {
|
||||||
setState(() {
|
controller.loadUrl(url: url);
|
||||||
appBarTitle = url;
|
|
||||||
});
|
|
||||||
nextTest(context: context, state: this);
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -14,7 +14,6 @@ class InAppWebViewShouldOverrideUrlLoadingTest extends WidgetTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class InAppWebViewShouldOverrideUrlLoadingTestState extends WidgetTestState {
|
class InAppWebViewShouldOverrideUrlLoadingTestState extends WidgetTestState {
|
||||||
String url = "https://flutter.dev/";
|
|
||||||
String appBarTitle = "InAppWebViewShouldOverrideUrlLoadingTest";
|
String appBarTitle = "InAppWebViewShouldOverrideUrlLoadingTest";
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -26,7 +25,7 @@ class InAppWebViewShouldOverrideUrlLoadingTestState extends WidgetTestState {
|
|||||||
Expanded(
|
Expanded(
|
||||||
child: Container(
|
child: Container(
|
||||||
child: InAppWebView(
|
child: InAppWebView(
|
||||||
initialUrl: "https://www.google.com/",
|
initialFile: "test_assets/in_app_webview_initial_file_test.html",
|
||||||
initialHeaders: {},
|
initialHeaders: {},
|
||||||
initialOptions: InAppWebViewWidgetOptions(
|
initialOptions: InAppWebViewWidgetOptions(
|
||||||
inAppWebViewOptions: InAppWebViewOptions(
|
inAppWebViewOptions: InAppWebViewOptions(
|
||||||
@ -42,13 +41,17 @@ class InAppWebViewShouldOverrideUrlLoadingTestState extends WidgetTestState {
|
|||||||
|
|
||||||
},
|
},
|
||||||
onLoadStop: (InAppWebViewController controller, String url) {
|
onLoadStop: (InAppWebViewController controller, String url) {
|
||||||
setState(() {
|
if (url == "https://flutter.dev/") {
|
||||||
appBarTitle = url;
|
setState(() {
|
||||||
});
|
appBarTitle = url;
|
||||||
nextTest(context: context, state: this);
|
});
|
||||||
|
nextTest(context: context, state: this);
|
||||||
|
} else {
|
||||||
|
controller.evaluateJavascript(source: "document.querySelector('#link').click();");
|
||||||
|
}
|
||||||
},
|
},
|
||||||
shouldOverrideUrlLoading: (InAppWebViewController controller, String url) {
|
shouldOverrideUrlLoading: (InAppWebViewController controller, String url) {
|
||||||
controller.loadUrl(url: url);
|
controller.loadUrl(url: "https://flutter.dev/");
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -10,6 +10,7 @@ import 'in_app_webview_initial_url_test.dart';
|
|||||||
import 'in_app_webview_javascript_handler_test.dart';
|
import 'in_app_webview_javascript_handler_test.dart';
|
||||||
import 'in_app_webview_on_console_message_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_download_start_test.dart';
|
||||||
|
import 'in_app_webview_on_js_dialog_test.dart';
|
||||||
import 'in_app_webview_on_load_resource_custom_scheme_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_load_resource_test.dart';
|
||||||
import 'in_app_webview_on_target_blank_test.dart';
|
import 'in_app_webview_on_target_blank_test.dart';
|
||||||
@ -30,6 +31,7 @@ Map<String, WidgetBuilder> buildRoutes({@required BuildContext context}) {
|
|||||||
'/InAppWebViewOnConsoleMessageTest': (context) => InAppWebViewOnConsoleMessageTest(),
|
'/InAppWebViewOnConsoleMessageTest': (context) => InAppWebViewOnConsoleMessageTest(),
|
||||||
'/InAppWebViewOnDownloadStartTest': (context) => InAppWebViewOnDownloadStartTest(),
|
'/InAppWebViewOnDownloadStartTest': (context) => InAppWebViewOnDownloadStartTest(),
|
||||||
'/InAppWebViewOnTargetBlankTest': (context) => InAppWebViewOnTargetBlankTest(),
|
'/InAppWebViewOnTargetBlankTest': (context) => InAppWebViewOnTargetBlankTest(),
|
||||||
|
'/InAppWebViewOnJsDialogTest': (context) => InAppWebViewOnJsDialogTest(),
|
||||||
};
|
};
|
||||||
routes.forEach((k, v) => testRoutes.add(k));
|
routes.forEach((k, v) => testRoutes.add(k));
|
||||||
return routes;
|
return routes;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user