updated tests, fixed ios and macos headless to inappwebview conversion

This commit is contained in:
Lorenzo Pichilli 2023-11-15 00:56:10 +01:00
parent b190d02925
commit 79024b24da
5 changed files with 25 additions and 11 deletions

View File

@ -194,6 +194,12 @@ void main() {
].contains(defaultTargetPlatform); ].contains(defaultTargetPlatform);
skippableGroup('InAppWebView', () { skippableGroup('InAppWebView', () {
setUpAll(() async {
if (!kIsWeb && defaultTargetPlatform == TargetPlatform.android) {
await InAppWebViewController.setWebContentsDebuggingEnabled(true);
}
});
initialUrlRequest(); initialUrlRequest();
setGetSettings(); setGetSettings();
javascriptCodeEvaluation(); javascriptCodeEvaluation();

View File

@ -121,7 +121,7 @@ void webMessage() {
if (event.ports[0] != null) { if (event.ports[0] != null) {
port = event.ports[0]; port = event.ports[0];
port.onmessage = function (event) { port.onmessage = function (event) {
console.log(event.data); console.log(bufferToString(event.data));
}; };
} }
} }

View File

@ -18,10 +18,6 @@ import 'tracing_controller/main.dart' as tracing_controller_tests;
void main() { void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized(); IntegrationTestWidgetsFlutterBinding.ensureInitialized();
if (!kIsWeb && defaultTargetPlatform == TargetPlatform.android) {
InAppWebViewController.setWebContentsDebuggingEnabled(true);
}
WebView.debugLoggingSettings.usePrint = true; WebView.debugLoggingSettings.usePrint = true;
WebView.debugLoggingSettings.maxLogMessageLength = 7000; WebView.debugLoggingSettings.maxLogMessageLength = 7000;
InAppBrowser.debugLoggingSettings.usePrint = true; InAppBrowser.debugLoggingSettings.usePrint = true;

View File

@ -71,20 +71,26 @@ public class HeadlessInAppWebView : Disposable {
view.alpha = 1.0 view.alpha = 1.0
// remove from parent // remove from parent
view.removeFromSuperview() view.removeFromSuperview()
dispose() dispose(disposeWebView: false)
} }
return newFlutterWebView return newFlutterWebView
} }
public func dispose() { public func dispose(disposeWebView: Bool) {
channelDelegate?.dispose() channelDelegate?.dispose()
channelDelegate = nil channelDelegate = nil
plugin?.headlessInAppWebViewManager?.webViews[id] = nil plugin?.headlessInAppWebViewManager?.webViews[id] = nil
if disposeWebView {
flutterWebView?.dispose(removeFromSuperview: true) flutterWebView?.dispose(removeFromSuperview: true)
}
flutterWebView = nil flutterWebView = nil
plugin = nil plugin = nil
} }
public func dispose() {
dispose(disposeWebView: true)
}
deinit { deinit {
debugPrint("HeadlessInAppWebView - dealloc") debugPrint("HeadlessInAppWebView - dealloc")
dispose() dispose()

View File

@ -72,21 +72,27 @@ public class HeadlessInAppWebView : Disposable {
view.alphaValue = 1.0 view.alphaValue = 1.0
// remove from parent // remove from parent
view.removeFromSuperview() view.removeFromSuperview()
dispose() dispose(disposeWebView: false)
} }
return newFlutterWebView return newFlutterWebView
} }
public func dispose() { public func dispose(disposeWebView: Bool) {
channelDelegate?.dispose() channelDelegate?.dispose()
channelDelegate = nil channelDelegate = nil
plugin?.headlessInAppWebViewManager?.webViews[id] = nil plugin?.headlessInAppWebViewManager?.webViews[id] = nil
if disposeWebView {
flutterWebView?.dispose(removeFromSuperview: true) flutterWebView?.dispose(removeFromSuperview: true)
}
flutterWebView = nil flutterWebView = nil
plugin = nil plugin = nil
} }
public func dispose() {
dispose(disposeWebView: true)
}
deinit { deinit {
debugPrint("HeadlessInAppWebView - dealloc") debugPrint("HeadlessInAppWebView - dealloc")
dispose() dispose()