fixed ios tests

This commit is contained in:
Lorenzo Pichilli 2022-10-06 16:43:19 +02:00
parent 3a63c35a68
commit fd17bd4624
6 changed files with 24 additions and 19 deletions

View File

@ -40,7 +40,9 @@ void reload() {
controllerCompleter.complete(controller); controllerCompleter.complete(controller);
}, },
onLoadStop: (controller, url) { onLoadStop: (controller, url) {
pageLoaded.complete(); if (!pageLoaded.isCompleted) {
pageLoaded.complete();
}
}, },
), ),
), ),

View File

@ -19,13 +19,13 @@ void main() {
} }
WebView.debugLoggingSettings.usePrint = true; WebView.debugLoggingSettings.usePrint = true;
WebView.debugLoggingSettings.maxLogMessageLength = -1; WebView.debugLoggingSettings.maxLogMessageLength = 7000;
InAppBrowser.debugLoggingSettings.usePrint = true; InAppBrowser.debugLoggingSettings.usePrint = true;
InAppBrowser.debugLoggingSettings.maxLogMessageLength = -1; InAppBrowser.debugLoggingSettings.maxLogMessageLength = 7000;
ChromeSafariBrowser.debugLoggingSettings.usePrint = true; ChromeSafariBrowser.debugLoggingSettings.usePrint = true;
ChromeSafariBrowser.debugLoggingSettings.maxLogMessageLength = -1; ChromeSafariBrowser.debugLoggingSettings.maxLogMessageLength = 7000;
WebAuthenticationSession.debugLoggingSettings.usePrint = true; WebAuthenticationSession.debugLoggingSettings.usePrint = true;
WebAuthenticationSession.debugLoggingSettings.maxLogMessageLength = -1; WebAuthenticationSession.debugLoggingSettings.maxLogMessageLength = 7000;
in_app_webview_tests.main(); in_app_webview_tests.main();
service_worker_controller_tests.main(); service_worker_controller_tests.main();

View File

@ -3,11 +3,12 @@
export "FLUTTER_ROOT=/Users/lorenzopichilli/fvm/versions/2.10.4" export "FLUTTER_ROOT=/Users/lorenzopichilli/fvm/versions/2.10.4"
export "FLUTTER_APPLICATION_PATH=/Users/lorenzopichilli/Desktop/flutter_inappwebview/example" export "FLUTTER_APPLICATION_PATH=/Users/lorenzopichilli/Desktop/flutter_inappwebview/example"
export "COCOAPODS_PARALLEL_CODE_SIGN=true" export "COCOAPODS_PARALLEL_CODE_SIGN=true"
export "FLUTTER_TARGET=lib/main.dart" export "FLUTTER_TARGET=integration_test/webview_flutter_test.dart"
export "FLUTTER_BUILD_DIR=build" export "FLUTTER_BUILD_DIR=build"
export "FLUTTER_BUILD_NAME=1.0.0" export "FLUTTER_BUILD_NAME=1.0.0"
export "FLUTTER_BUILD_NUMBER=1" export "FLUTTER_BUILD_NUMBER=1"
export "DART_DEFINES=RkxVVFRFUl9XRUJfQVVUT19ERVRFQ1Q9dHJ1ZQ=="
export "DART_OBFUSCATION=false" export "DART_OBFUSCATION=false"
export "TRACK_WIDGET_CREATION=true" export "TRACK_WIDGET_CREATION=true"
export "TREE_SHAKE_ICONS=false" export "TREE_SHAKE_ICONS=false"
export "PACKAGE_CONFIG=.dart_tool/package_config.json" export "PACKAGE_CONFIG=/Users/lorenzopichilli/Desktop/flutter_inappwebview/example/.dart_tool/package_config.json"

View File

@ -95,7 +95,7 @@ public class FlutterWebViewController: NSObject, FlutterPlatformView, Disposable
let windowId = params["windowId"] as? Int64 let windowId = params["windowId"] as? Int64
let initialUrlRequest = params["initialUrlRequest"] as? [String: Any?] let initialUrlRequest = params["initialUrlRequest"] as? [String: Any?]
let initialFile = params["initialFile"] as? String let initialFile = params["initialFile"] as? String
let initialData = params["initialData"] as? [String: String] let initialData = params["initialData"] as? [String: String?]
if windowId == nil { if windowId == nil {
if #available(iOS 11.0, *) { if #available(iOS 11.0, *) {
@ -131,7 +131,7 @@ public class FlutterWebViewController: NSObject, FlutterPlatformView, Disposable
} }
} }
func load(initialUrlRequest: [String:Any?]?, initialFile: String?, initialData: [String: String]?) { func load(initialUrlRequest: [String:Any?]?, initialFile: String?, initialData: [String: String?]?) {
guard let webView = webView() else { guard let webView = webView() else {
return return
} }
@ -144,11 +144,9 @@ public class FlutterWebViewController: NSObject, FlutterPlatformView, Disposable
dump(error) dump(error)
} }
} }
else if let initialData = initialData { else if let initialData = initialData, let data = initialData["data"]!,
let data = initialData["data"]! let mimeType = initialData["mimeType"]!, let encoding = initialData["encoding"]!,
let mimeType = initialData["mimeType"]! let baseUrl = URL(string: initialData["baseUrl"]! ?? "about:blank") {
let encoding = initialData["encoding"]!
let baseUrl = URL(string: initialData["baseUrl"] ?? "about:blank")!
var allowingReadAccessToURL: URL? = nil var allowingReadAccessToURL: URL? = nil
if let allowingReadAccessTo = webView.settings?.allowingReadAccessTo, baseUrl.scheme == "file" { if let allowingReadAccessTo = webView.settings?.allowingReadAccessTo, baseUrl.scheme == "file" {
allowingReadAccessToURL = URL(string: allowingReadAccessTo) allowingReadAccessToURL = URL(string: allowingReadAccessTo)
@ -156,7 +154,11 @@ public class FlutterWebViewController: NSObject, FlutterPlatformView, Disposable
allowingReadAccessToURL = nil allowingReadAccessToURL = nil
} }
} }
webView.loadData(data: data, mimeType: mimeType, encoding: encoding, baseUrl: baseUrl, allowingReadAccessTo: allowingReadAccessToURL) webView.loadData(data: data,
mimeType: mimeType,
encoding: encoding,
baseUrl: baseUrl,
allowingReadAccessTo: allowingReadAccessToURL)
} }
else if let initialUrlRequest = initialUrlRequest { else if let initialUrlRequest = initialUrlRequest {
let urlRequest = URLRequest.init(fromPluginMap: initialUrlRequest) let urlRequest = URLRequest.init(fromPluginMap: initialUrlRequest)

View File

@ -760,7 +760,7 @@ public class WebViewChannelDelegate : ChannelDelegate {
"defaultValue": defaultValue, "defaultValue": defaultValue,
"isMainFrame": isMainFrame "isMainFrame": isMainFrame
] ]
channel?.invokeMethod("onJsConfirm", arguments: arguments, callback: callback) channel?.invokeMethod("onJsPrompt", arguments: arguments, callback: callback)
} }
public class CreateWindowCallback : BaseCallbackResult<Bool> { public class CreateWindowCallback : BaseCallbackResult<Bool> {

View File

@ -8,10 +8,10 @@
import Foundation import Foundation
public class PermissionResponse : NSObject { public class PermissionResponse : NSObject {
var resources: [String] var resources: [Any]
var action: Int? var action: Int?
public init(resources: [String], action: Int? = nil) { public init(resources: [Any], action: Int? = nil) {
self.resources = resources self.resources = resources
self.action = action self.action = action
} }
@ -20,7 +20,7 @@ public class PermissionResponse : NSObject {
guard let map = map else { guard let map = map else {
return nil return nil
} }
let resources = map["resources"] as! [String] let resources = map["resources"] as! [Any]
let action = map["action"] as? Int let action = map["action"] as? Int
return PermissionResponse(resources: resources, action: action) return PermissionResponse(resources: resources, action: action)
} }