iosWebViewFix/example/integration_test/in_app_webview/initial_url_request.dart

39 lines
1.2 KiB
Dart
Raw Normal View History

2022-04-27 00:23:59 +00:00
import 'dart:async';
import 'package:flutter/foundation.dart';
2022-04-27 00:23:59 +00:00
import 'package:flutter/widgets.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
import 'package:flutter_test/flutter_test.dart';
2022-04-27 16:59:19 +00:00
import '../constants.dart';
2022-04-27 00:23:59 +00:00
void initialUrlRequest() {
2022-04-27 16:59:19 +00:00
final shouldSkip = !kIsWeb || ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
].contains(defaultTargetPlatform);
2022-04-27 00:23:59 +00:00
testWidgets('initialUrlRequest', (WidgetTester tester) async {
final Completer controllerCompleter = Completer<InAppWebViewController>();
await tester.pumpWidget(
Directionality(
textDirection: TextDirection.ltr,
child: InAppWebView(
key: GlobalKey(),
initialUrlRequest:
2022-04-27 16:59:19 +00:00
URLRequest(url: TEST_CROSS_PLATFORM_URL_1),
2022-04-27 00:23:59 +00:00
onWebViewCreated: (controller) {
controllerCompleter.complete(controller);
},
),
),
);
2022-04-27 16:59:19 +00:00
2022-04-27 00:23:59 +00:00
final InAppWebViewController controller =
await controllerCompleter.future;
final String? currentUrl = (await controller.getUrl())?.toString();
2022-04-27 16:59:19 +00:00
expect(currentUrl, TEST_CROSS_PLATFORM_URL_1.toString());
}, skip: shouldSkip);
2022-04-27 00:23:59 +00:00
}