iosWebViewFix/example/integration_test/in_app_webview/on_console_message.dart

43 lines
1.4 KiB
Dart
Raw Normal View History

part of 'main.dart';
2022-04-28 17:29:01 +00:00
void onConsoleMessage() {
2022-04-29 11:39:28 +00:00
final shouldSkip = kIsWeb
? false
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
].contains(defaultTargetPlatform);
2022-04-28 17:29:01 +00:00
skippableTestWidgets('onConsoleMessage', (WidgetTester tester) async {
2022-10-14 00:28:23 +00:00
final Completer<InAppWebViewController> controllerCompleter =
Completer<InAppWebViewController>();
2022-04-28 17:29:01 +00:00
final Completer<ConsoleMessage> onConsoleMessageCompleter =
Completer<ConsoleMessage>();
await tester.pumpWidget(
Directionality(
textDirection: TextDirection.ltr,
child: InAppWebView(
key: GlobalKey(),
initialFile: !kIsWeb
? "test_assets/in_app_webview_on_console_message_test.html"
: null,
initialUrlRequest:
kIsWeb ? URLRequest(url: TEST_WEB_PLATFORM_URL_1) : null,
onWebViewCreated: (controller) {
controllerCompleter.complete(controller);
},
onConsoleMessage: (controller, consoleMessage) {
onConsoleMessageCompleter.complete(consoleMessage);
},
),
),
);
final ConsoleMessage consoleMessage =
await onConsoleMessageCompleter.future;
expect(consoleMessage.message, 'message');
expect(consoleMessage.messageLevel, ConsoleMessageLevel.LOG);
}, skip: shouldSkip);
}