iosWebViewFix/example/integration_test/in_app_webview/on_print.dart

37 lines
1.1 KiB
Dart
Raw Normal View History

part of 'main.dart';
2022-04-28 17:29:01 +00:00
void onPrint() {
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
var url = !kIsWeb ? TEST_URL_1 : TEST_WEB_PLATFORM_URL_1;
skippableTestWidgets('onPrint', (WidgetTester tester) async {
2022-04-28 17:29:01 +00:00
final Completer<String> onPrintCompleter = Completer<String>();
await tester.pumpWidget(
Directionality(
textDirection: TextDirection.ltr,
child: InAppWebView(
key: GlobalKey(),
2022-04-29 11:39:28 +00:00
initialUrlRequest: URLRequest(url: url),
2022-04-28 17:29:01 +00:00
onLoadStop: (controller, url) async {
await controller.evaluateJavascript(source: "window.print();");
},
onPrintRequest: (controller, url, printJob) async {
2022-04-28 17:29:01 +00:00
onPrintCompleter.complete(url?.toString());
return false;
2022-04-28 17:29:01 +00:00
},
),
),
);
2022-04-29 00:07:01 +00:00
await tester.pump();
2022-04-28 17:29:01 +00:00
final String printUrl = await onPrintCompleter.future;
expect(printUrl, url.toString());
}, skip: shouldSkip);
2022-04-29 11:39:28 +00:00
}