iosWebViewFix/example/integration_test/in_app_webview/load_file.dart

50 lines
1.5 KiB
Dart
Raw Normal View History

part of 'main.dart';
2022-04-28 18:34:54 +00:00
void loadFile() {
2022-04-29 11:39:28 +00:00
final shouldSkip = kIsWeb
? false
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
].contains(defaultTargetPlatform);
2022-04-28 18:34:54 +00:00
skippableTestWidgets('loadFile', (WidgetTester tester) async {
final Completer<InAppWebViewController> controllerCompleter =
Completer<InAppWebViewController>();
2022-04-28 18:34:54 +00:00
final StreamController<String> pageLoads =
2022-04-29 11:39:28 +00:00
StreamController<String>.broadcast();
2022-04-28 18:34:54 +00: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());
},
),
),
);
final InAppWebViewController controller = await controllerCompleter.future;
2022-04-28 18:34:54 +00: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 08:49:01 +00:00
expect(url!.scheme, kIsWeb ? 'http' : 'file');
2022-04-28 18:34:54 +00:00
expect(url.path,
endsWith("test_assets/in_app_webview_initial_file_test.html"));
pageLoads.close();
}, skip: shouldSkip);
}