93 lines
2.9 KiB
Dart
Raw Normal View History

part of 'main.dart';
2022-04-27 18:59:19 +02:00
2022-04-27 02:23:59 +02:00
void initialUrlRequest() {
2022-04-29 13:39:28 +02:00
final shouldSkip = kIsWeb
? false
: ![
2022-04-28 16:48:39 +02:00
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
].contains(defaultTargetPlatform);
skippableGroup('initial url request', () {
2022-04-29 13:39:28 +02:00
final shouldSkipTest2 = kIsWeb
? true
: ![
TargetPlatform.iOS,
TargetPlatform.macOS,
].contains(defaultTargetPlatform);
2022-04-28 16:48:39 +02:00
skippableTestWidgets(
'launches with allowsBackForwardNavigationGestures true',
2022-04-28 16:48:39 +02:00
(WidgetTester tester) async {
2022-10-06 15:13:31 +02:00
final Completer<void> pageLoaded = Completer<void>();
2022-10-14 02:28:23 +02:00
final Completer<InAppWebViewController> controllerCompleter =
Completer<InAppWebViewController>();
2022-10-06 15:13:31 +02:00
2022-04-28 16:48:39 +02:00
await tester.pumpWidget(
Directionality(
textDirection: TextDirection.ltr,
child: SizedBox(
width: 400,
height: 300,
child: InAppWebView(
key: GlobalKey(),
2022-04-29 13:39:28 +02:00
initialUrlRequest: URLRequest(url: TEST_URL_1),
2022-04-28 16:48:39 +02:00
initialSettings: InAppWebViewSettings(
allowsBackForwardNavigationGestures: true),
onWebViewCreated: (controller) {
controllerCompleter.complete(controller);
},
2022-10-06 15:13:31 +02:00
onLoadStop: (controller, url) {
pageLoaded.complete();
},
2022-04-28 16:48:39 +02:00
),
),
),
);
2022-10-06 15:13:31 +02:00
await pageLoaded.future;
2022-04-28 16:48:39 +02:00
final InAppWebViewController controller =
await controllerCompleter.future;
final String? currentUrl = (await controller.getUrl())?.toString();
expect(currentUrl, TEST_URL_1.toString());
}, skip: shouldSkipTest2);
2022-10-06 15:13:31 +02:00
final shouldSkipTest1 = kIsWeb
? false
: ![
2022-10-11 16:19:36 +02:00
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
].contains(defaultTargetPlatform);
2022-10-06 15:13:31 +02:00
skippableTestWidgets('basic', (WidgetTester tester) async {
2022-10-06 15:13:31 +02:00
final Completer<void> pageLoaded = Completer<void>();
2022-10-14 02:28:23 +02:00
final Completer<InAppWebViewController> controllerCompleter =
Completer<InAppWebViewController>();
2022-10-06 15:13:31 +02:00
await tester.pumpWidget(
Directionality(
textDirection: TextDirection.ltr,
child: InAppWebView(
key: GlobalKey(),
initialUrlRequest: URLRequest(url: TEST_CROSS_PLATFORM_URL_1),
onWebViewCreated: (controller) {
controllerCompleter.complete(controller);
},
onLoadStop: (controller, url) {
pageLoaded.complete();
},
),
),
);
await pageLoaded.future;
final InAppWebViewController controller =
2022-10-11 16:19:36 +02:00
await controllerCompleter.future;
2022-10-06 15:13:31 +02:00
final String? currentUrl = (await controller.getUrl())?.toString();
expect(currentUrl, TEST_CROSS_PLATFORM_URL_1.toString());
}, skip: shouldSkipTest1);
2022-04-28 23:23:38 +02:00
}, skip: shouldSkip);
2022-04-28 16:48:39 +02:00
}