Skip to content

Commit 5c334d1

Browse files
Revert "show web-server in flutter devices (#121373)" (#121532)
Revert "[flutter_tools] show web-server in flutter devices"
1 parent fd65fd1 commit 5c334d1

File tree

3 files changed

+32
-3
lines changed

3 files changed

+32
-3
lines changed

packages/flutter_tools/lib/src/runner/flutter_command_runner.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import '../cache.dart';
1818
import '../convert.dart';
1919
import '../globals.dart' as globals;
2020
import '../tester/flutter_tester.dart';
21+
import '../web/web_device.dart';
2122

2223
class FlutterCommandRunner extends CommandRunner<void> {
2324
FlutterCommandRunner({ bool verboseHelp = false }) : super(
@@ -111,6 +112,11 @@ class FlutterCommandRunner extends CommandRunner<void> {
111112
hide: !verboseHelp,
112113
help: 'List the special "flutter-tester" device in device listings. '
113114
'This headless device is used to test Flutter tooling.');
115+
argParser.addFlag('show-web-server-device',
116+
negatable: false,
117+
hide: !verboseHelp,
118+
help: 'List the special "web-server" device in device listings.',
119+
);
114120
}
115121

116122
@override
@@ -209,6 +215,10 @@ class FlutterCommandRunner extends CommandRunner<void> {
209215
|| topLevelResults['device-id'] == FlutterTesterDevices.kTesterDeviceId) {
210216
FlutterTesterDevices.showFlutterTesterDevice = true;
211217
}
218+
if (((topLevelResults['show-web-server-device'] as bool?) ?? false)
219+
|| topLevelResults['device-id'] == WebServerDevice.kWebServerDeviceId) {
220+
WebServerDevice.showWebServerDevice = true;
221+
}
212222

213223
// Set up the tooling configuration.
214224
final EngineBuildPaths? engineBuildPaths = await globals.localEngineLocator?.findEnginePath(

packages/flutter_tools/lib/src/web/web_device.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ abstract class ChromiumDevice extends Device {
111111
Future<String?> get emulatorId async => null;
112112

113113
@override
114-
bool isSupported() => chromeLauncher.canFindExecutable();
114+
bool isSupported() => chromeLauncher.canFindExecutable();
115115

116116
@override
117117
DevicePortForwarder? get portForwarder => const NoOpDevicePortForwarder();
@@ -357,7 +357,8 @@ class WebDevices extends PollingDeviceDiscovery {
357357
}
358358
final MicrosoftEdgeDevice? edgeDevice = _edgeDevice;
359359
return <Device>[
360-
_webServerDevice,
360+
if (WebServerDevice.showWebServerDevice)
361+
_webServerDevice,
361362
if (_chromeDevice.isSupported())
362363
_chromeDevice,
363364
if (edgeDevice != null && await edgeDevice._meetsVersionConstraint())
@@ -391,6 +392,7 @@ class WebServerDevice extends Device {
391392
);
392393

393394
static const String kWebServerDeviceId = 'web-server';
395+
static bool showWebServerDevice = false;
394396

395397
final Logger _logger;
396398

packages/flutter_tools/test/general.shard/web/devices_test.dart

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,8 @@ void main() {
189189
isNot(contains(isA<GoogleChromeDevice>())));
190190
});
191191

192-
testWithoutContext('Web Server device is listed', () async {
192+
testWithoutContext('Web Server device is listed if enabled via showWebServerDevice', () async {
193+
WebServerDevice.showWebServerDevice = true;
193194
final WebDevices webDevices = WebDevices(
194195
featureFlags: TestFeatureFlags(isWebEnabled: true),
195196
fileSystem: MemoryFileSystem.test(),
@@ -204,6 +205,22 @@ void main() {
204205
contains(isA<WebServerDevice>()));
205206
});
206207

208+
testWithoutContext('Web Server device is not listed if disabled via showWebServerDevice', () async {
209+
WebServerDevice.showWebServerDevice = false;
210+
final WebDevices webDevices = WebDevices(
211+
featureFlags: TestFeatureFlags(isWebEnabled: true),
212+
fileSystem: MemoryFileSystem.test(),
213+
logger: BufferLogger.test(),
214+
platform: FakePlatform(
215+
environment: <String, String>{}
216+
),
217+
processManager: FakeProcessManager.any(),
218+
);
219+
220+
expect(await webDevices.pollingGetDevices(),
221+
isNot(contains(isA<WebServerDevice>())));
222+
});
223+
207224
testWithoutContext('Chrome invokes version command on non-Windows platforms', () async {
208225
final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
209226
const FakeCommand(

0 commit comments

Comments
 (0)