|
4 | 4 |
|
5 | 5 | import 'dart:async';
|
6 | 6 | import 'dart:html' as html;
|
| 7 | +import 'dart:io'; |
7 | 8 |
|
8 | 9 | import 'package:flutter/material.dart';
|
9 | 10 | import 'package:flutter/widgets.dart';
|
10 | 11 | import 'package:flutter_test/flutter_test.dart';
|
11 | 12 | import 'package:integration_test/integration_test.dart';
|
12 | 13 | import 'package:webview_flutter_web_example/legacy/web_view.dart';
|
13 | 14 |
|
14 |
| -void main() { |
| 15 | +void main() async { |
15 | 16 | IntegrationTestWidgetsFlutterBinding.ensureInitialized();
|
16 | 17 |
|
17 |
| - // URLs to navigate to in tests. These need to be URLs that we are confident will |
18 |
| - // always be accessible, and won't do redirection. (E.g., just |
19 |
| - // 'https://www.google.com/' will sometimes redirect traffic that looks |
20 |
| - // like it's coming from a bot, which is true of these tests). |
21 |
| - const String primaryUrl = 'https://flutter.dev/'; |
22 |
| - const String secondaryUrl = 'https://www.google.com/robots.txt'; |
| 18 | + const String primaryPage = 'first.txt'; |
| 19 | + const String secondaryPage = 'second.txt'; |
| 20 | + final HttpServer server = |
| 21 | + await HttpServer.bind(InternetAddress.loopbackIPv4, 0); |
| 22 | + unawaited(server.forEach((HttpRequest request) { |
| 23 | + if (request.uri.path == '/$primaryPage') { |
| 24 | + request.response.writeln('Hello, world.'); |
| 25 | + } |
| 26 | + if (request.uri.path == '/$secondaryPage') { |
| 27 | + request.response.writeln('Another page.'); |
| 28 | + } else { |
| 29 | + fail('unexpected request: ${request.method} ${request.uri}'); |
| 30 | + } |
| 31 | + request.response.close(); |
| 32 | + })); |
| 33 | + final String prefixUrl = 'http://localhost:${server.port}'; |
| 34 | + final String primaryUrl = '$prefixUrl/$primaryPage'; |
| 35 | + final String secondaryUrl = '$prefixUrl/$secondaryPage'; |
23 | 36 |
|
24 | 37 | testWidgets('initialUrl', (WidgetTester tester) async {
|
25 | 38 | final Completer<WebViewController> controllerCompleter =
|
|
0 commit comments