@@ -136,46 +136,21 @@ class TestContext {
136136
137137 Future <void > setUp ({
138138 ReloadConfiguration reloadConfiguration = ReloadConfiguration .none,
139- bool serveDevTools = false ,
140- bool enableDebugExtension = false ,
139+ AppMetadata ? appMetadata ,
140+ TestDebugSettings ? debugSettings ,
141141 bool autoRun = true ,
142- bool enableDebugging = true ,
143- bool useSse = true ,
144- bool spawnDds = true ,
145- String hostname = 'localhost' ,
146142 bool waitToDebug = false ,
147- UrlEncoder ? urlEncoder,
148143 CompilationMode compilationMode = CompilationMode .buildDaemon,
149144 bool enableExpressionEvaluation = false ,
150145 bool verboseCompiler = false ,
151146 bool useDebuggerModuleNames = false ,
152147 bool launchChrome = true ,
153- bool isFlutterApp = false ,
154- bool isInternalBuild = false ,
155148 List <String > experiments = const < String > [],
156149 bool canaryFeatures = false ,
157- String ? workspaceName,
158150 }) async {
151+ appMetadata ?? = TestAppMetadata .externalDartApp ();
152+ debugSettings ?? = TestDebugSettings .noDevTools ();
159153 final sdkLayout = sdkConfigurationProvider.sdkLayout;
160- final toolConfiguration = createToolConfiguration (
161- debugSettings: DebugSettings (
162- enableDebugging: enableDebugging,
163- enableDebugExtension: enableDebugExtension,
164- useSseForDebugBackend: useSse,
165- useSseForDebugProxy: useSse,
166- useSseForInjectedClient: useSse,
167- spawnDds: spawnDds,
168- enableDevToolsLaunch: serveDevTools,
169- urlEncoder: urlEncoder,
170- ),
171- appMetadata: AppMetadata (
172- hostname: hostname,
173- isInternalBuild: isInternalBuild,
174- isFlutterApp: () => Future .value (isFlutterApp),
175- workspaceName: workspaceName,
176- ),
177- );
178- setGlobalsForTesting (toolConfiguration: toolConfiguration);
179154 try {
180155 // Make sure configuration was created correctly.
181156 final configuration = await sdkConfigurationProvider.configuration;
@@ -333,7 +308,7 @@ class TestContext {
333308
334309 _webRunner = ResidentWebRunner (
335310 mainUri: entry,
336- urlTunneler: urlEncoder,
311+ urlTunneler: debugSettings. urlEncoder,
337312 projectDirectory: p.toUri (project.absolutePackageDirectory),
338313 packageConfigFile: project.packageConfigFile,
339314 packageUriMapper: packageUriMapper,
@@ -350,7 +325,7 @@ class TestContext {
350325 final assetServerPort = await findUnusedPort ();
351326 await webRunner.run (
352327 fileSystem,
353- hostname,
328+ appMetadata. hostname,
354329 assetServerPort,
355330 filePathToServe,
356331 );
@@ -383,6 +358,7 @@ class TestContext {
383358 // then Chrome will be launched with a UI rather than headless.
384359 // If the extension is enabled, then Chrome will be launched with a UI
385360 // since headless Chrome does not support extensions.
361+ final enableDebugExtension = debugSettings.enableDebugExtension;
386362 final headless = Platform .environment['DWDS_DEBUG_CHROME' ] != 'true' &&
387363 ! enableDebugExtension;
388364 if (enableDebugExtension) {
@@ -410,27 +386,17 @@ class TestContext {
410386 final connection = ChromeConnection ('localhost' , debugPort);
411387
412388 _testServer = await TestServer .start (
413- hostname,
414- port,
415- assetHandler,
416- assetReader,
417- requireStrategy,
418- project.directoryToServe,
419- buildResults,
420- () async => connection,
421- serveDevTools,
422- enableDebugExtension,
423- autoRun,
424- enableDebugging,
425- useSse,
426- urlEncoder,
427- expressionCompiler,
428- spawnDds,
429- ddcService,
430- isFlutterApp,
431- isInternalBuild,
432- workspaceName,
433- sdkLayout,
389+ debugSettings:
390+ debugSettings.copyWith (expressionCompiler: expressionCompiler),
391+ appMetadata: appMetadata,
392+ port: port,
393+ assetHandler: assetHandler,
394+ assetReader: assetReader,
395+ strategy: requireStrategy,
396+ target: project.directoryToServe,
397+ buildResults: buildResults,
398+ chromeConnection: () async => connection,
399+ autoRun: autoRun,
434400 );
435401
436402 _appUrl = basePath.isEmpty
@@ -448,14 +414,14 @@ class TestContext {
448414 throw StateError ('Unable to connect to tab.' );
449415 }
450416
451- if (enableDebugExtension) {
417+ if (debugSettings. enableDebugExtension) {
452418 final extensionTab = await _fetchDartDebugExtensionTab (connection);
453419 extensionConnection = await extensionTab.connect ();
454420 await extensionConnection.runtime.enable ();
455421 }
456422
457423 appConnection = await testServer.dwds.connectedApps.first;
458- if (enableDebugging && ! waitToDebug) {
424+ if (debugSettings. enableDebugging && ! waitToDebug) {
459425 await startDebugging ();
460426 }
461427 }
0 commit comments