50 lines
1.5 KiB
Dart
Raw Normal View History

part of 'main.dart';
2022-04-28 20:34:54 +02:00
void loadFile() {
2022-04-29 13:39:28 +02:00
final shouldSkip = kIsWeb
? false
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
].contains(defaultTargetPlatform);
2022-04-28 20:34:54 +02:00
skippableTestWidgets('loadFile', (WidgetTester tester) async {
2022-10-14 02:28:23 +02:00
final Completer<InAppWebViewController> controllerCompleter =
Completer<InAppWebViewController>();
2022-04-28 20:34:54 +02:00
final StreamController<String> pageLoads =
2022-04-29 13:39:28 +02:00
StreamController<String>.broadcast();
2022-04-28 20:34:54 +02:00
await tester.pumpWidget(
Directionality(
textDirection: TextDirection.ltr,
child: InAppWebView(
key: GlobalKey(),
initialUrlRequest: URLRequest(url: TEST_URL_ABOUT_BLANK),
onWebViewCreated: (controller) {
controllerCompleter.complete(controller);
},
onLoadStop: (controller, url) {
pageLoads.add(url!.toString());
},
),
),
);
2022-04-29 13:39:28 +02:00
final InAppWebViewController controller = await controllerCompleter.future;
2022-04-28 20:34:54 +02:00
await pageLoads.stream.first;
await controller.loadFile(
assetFilePath: "test_assets/in_app_webview_initial_file_test.html");
await pageLoads.stream.first;
final Uri? url = await controller.getUrl();
expect(url, isNotNull);
2022-10-11 10:49:01 +02:00
expect(url!.scheme, kIsWeb ? 'http' : 'file');
2022-04-28 20:34:54 +02:00
expect(url.path,
endsWith("test_assets/in_app_webview_initial_file_test.html"));
pageLoads.close();
}, skip: shouldSkip);
}