|
| 1 | +import 'dart:async'; |
1 | 2 | import 'dart:convert'; |
2 | 3 | import 'dart:io'; |
3 | 4 |
|
| 5 | +import 'package:dwds/service.dart'; |
4 | 6 | import 'package:dwds/src/chrome_proxy_service.dart'; |
5 | 7 | import 'package:dwds/src/helpers.dart'; |
6 | | -import 'package:dwds/service.dart'; |
7 | 8 | import 'package:http/http.dart' as http; |
8 | 9 | import 'package:test/test.dart'; |
9 | 10 | import 'package:webdriver/io.dart'; |
@@ -36,12 +37,18 @@ class TestContext { |
36 | 37 | webdev.stderr |
37 | 38 | .transform(const Utf8Decoder()) |
38 | 39 | .transform(const LineSplitter()) |
39 | | - .listen(printOnFailure); |
40 | | - await webdev.stdout |
| 40 | + .listen(print); |
| 41 | + var assetReadyCompleter = Completer(); |
| 42 | + webdev.stdout |
41 | 43 | .transform(const Utf8Decoder()) |
42 | 44 | .transform(const LineSplitter()) |
43 | | - .takeWhile((line) => !line.contains('$port')) |
44 | | - .drain(); |
| 45 | + .listen((line) { |
| 46 | + if (line.contains('$port') && !assetReadyCompleter.isCompleted) { |
| 47 | + assetReadyCompleter.complete(); |
| 48 | + } |
| 49 | + printOnFailure(line); |
| 50 | + }); |
| 51 | + await assetReadyCompleter.future; |
45 | 52 | appUrl = 'http://localhost:$port/hello_world/'; |
46 | 53 | var debugPort = await findUnusedPort(); |
47 | 54 | webDriver = await createDriver(desired: { |
@@ -71,8 +78,11 @@ class TestContext { |
71 | 78 | return result.body; |
72 | 79 | }; |
73 | 80 |
|
| 81 | + var instanceId = |
| 82 | + await tabConnection.runtime.evaluate(r'window.$dartAppInstanceId'); |
| 83 | + |
74 | 84 | debugService = await DebugService.start( |
75 | | - 'localhost', connection, assetHandler, 'instance-id-for-testing'); |
| 85 | + 'localhost', connection, assetHandler, instanceId.value.toString()); |
76 | 86 | } |
77 | 87 |
|
78 | 88 | Future<Null> tearDown() async { |
|
0 commit comments