@@ -10,7 +10,6 @@ import 'package:build_daemon/data/build_status.dart';
1010import 'package:build_daemon/data/build_target.dart' ;
1111import 'package:dwds/dwds.dart' ;
1212import 'package:dwds/src/services/chrome_proxy_service.dart' ;
13- import 'package:dwds/src/services/debug_service.dart' ;
1413import 'package:dwds/src/utilities/shared.dart' ;
1514import 'package:http/http.dart' as http;
1615import 'package:path/path.dart' as p;
@@ -23,14 +22,14 @@ import 'utilities.dart';
2322
2423class TestContext {
2524 String appUrl;
26- DebugService debugService;
27- ChromeProxyService get chromeProxyService =>
28- debugService.chromeProxyService as ChromeProxyService ;
2925 WipConnection tabConnection;
3026 TestServer testServer;
3127 BuildDaemonClient daemonClient;
3228 WebDriver webDriver;
3329 Process chromeDriver;
30+ AppConnection appConnection;
31+ DebugConnection debugConnection;
32+ ChromeProxyService chromeProxyService;
3433 int port;
3534
3635 /// Top level directory in which we run the test server..
@@ -64,15 +63,6 @@ class TestContext {
6463
6564 daemonClient = await connectClient (
6665 workingDirectory, [], (log) => printOnFailure (log.toString ()));
67- testServer = await TestServer .start (
68- 'localhost' ,
69- port,
70- daemonPort (workingDirectory),
71- pathToServe,
72- ReloadConfiguration .none,
73- false ,
74- daemonClient.buildResults,
75- );
7666 daemonClient.registerBuildTarget (
7767 DefaultBuildTarget ((b) => b..target = pathToServe));
7868 daemonClient.startBuild ();
@@ -82,7 +72,6 @@ class TestContext {
8272 .any ((result) => result.status == BuildStatus .succeeded))
8373 .timeout (Duration (seconds: 60 ));
8474
85- appUrl = 'http://localhost:$port /$path ' ;
8675 var debugPort = await findUnusedPort ();
8776 var capabilities = Capabilities .chrome
8877 ..addAll ({
@@ -92,33 +81,35 @@ class TestContext {
9281 });
9382 webDriver =
9483 await createDriver (spec: WebDriverSpec .JsonWire , desired: capabilities);
95- await webDriver.get (appUrl);
9684 var connection = ChromeConnection ('localhost' , debugPort);
85+
86+ testServer = await TestServer .start (
87+ 'localhost' ,
88+ port,
89+ daemonPort (workingDirectory),
90+ pathToServe,
91+ ReloadConfiguration .none,
92+ false ,
93+ daemonClient.buildResults,
94+ () async => connection,
95+ );
96+
97+ appUrl = 'http://localhost:$port /$path ' ;
98+ await webDriver.get (appUrl);
9799 var tab = await connection.getTab ((t) => t.url == appUrl);
98100 tabConnection = await tab.connect ();
99101 await tabConnection.runtime.enable ();
100102 await tabConnection.debugger.enable ();
101103
102- // Check if the app is already loaded, look for the top level
103- // `registerExtension` variable which we set as the last step.
104- var result = await tabConnection.runtime
105- .evaluate ('(window.registerExtension !== undefined).toString();' );
106- if (result.value != 'true' ) {
107- // If it wasn't already loaded, then wait for the 'Page Ready' log.
108- await tabConnection.runtime.onConsoleAPICalled.firstWhere ((event) =>
109- event.type == 'debug' && event.args[0 ].value == 'Page Ready' );
110- }
104+ appConnection = await testServer.dwds.connectedApps.first;
105+ debugConnection = await testServer.dwds.debugConnection (appConnection);
111106
112107 var assetHandler = (String path) async {
113108 var result = await http.get ('http://localhost:$port /$path ' );
114109 return result.body;
115110 };
116-
117- var instanceId =
118- await tabConnection.runtime.evaluate (r'window.$dartAppInstanceId' );
119-
120- debugService = await DebugService .start (
121- 'localhost' , connection, assetHandler, instanceId.value.toString ());
111+ chromeProxyService = await ChromeProxyService .create (
112+ connection, assetHandler, appConnection.request.instanceId);
122113 }
123114
124115 Future <Null > tearDown () async {
0 commit comments