Revert "Use FlutterFeatures to configure web and desktop devices (#36465)" (#36654)
This reverts commit bd52a78c7162e26721a383b76bac53744e5656a7.
diff --git a/dev/bots/test.dart b/dev/bots/test.dart
index 48be0bb..f103674 100644
--- a/dev/bots/test.dart
+++ b/dev/bots/test.dart
@@ -289,9 +289,6 @@
workingDirectory: path.join(flutterRoot, relativePathToApplication),
expectNonZeroExit: false,
timeout: _kShortTimeout,
- environment: <String, String>{
- 'FLUTTER_WEB': 'true',
- }
);
print('Done.');
}
diff --git a/packages/flutter_tools/lib/src/commands/assemble.dart b/packages/flutter_tools/lib/src/commands/assemble.dart
index 9919e65..e5a6659 100644
--- a/packages/flutter_tools/lib/src/commands/assemble.dart
+++ b/packages/flutter_tools/lib/src/commands/assemble.dart
@@ -30,6 +30,8 @@
@override
String get name => 'assemble';
+ @override
+ bool get isExperimental => true;
@override
Future<FlutterCommandResult> runCommand() {
@@ -125,6 +127,9 @@
String get name => 'run';
@override
+ bool get isExperimental => true;
+
+ @override
Future<FlutterCommandResult> runCommand() async {
final BuildResult result = await buildSystem.build(targetName, environment, BuildSystemConfig(
resourcePoolSize: argResults['resource-pool-size'],
@@ -151,6 +156,9 @@
String get name => 'describe';
@override
+ bool get isExperimental => true;
+
+ @override
Future<FlutterCommandResult> runCommand() {
try {
printStatus(
@@ -173,6 +181,9 @@
String get name => 'inputs';
@override
+ bool get isExperimental => true;
+
+ @override
Future<FlutterCommandResult> runCommand() {
try {
final List<Map<String, Object>> results = buildSystem.describe(targetName, environment);
@@ -199,6 +210,9 @@
String get name => 'build-dir';
@override
+ bool get isExperimental => true;
+
+ @override
Future<FlutterCommandResult> runCommand() {
printStatus(environment.buildDir.path);
return null;
diff --git a/packages/flutter_tools/lib/src/commands/build_bundle.dart b/packages/flutter_tools/lib/src/commands/build_bundle.dart
index d15cfa4..ef2235f 100644
--- a/packages/flutter_tools/lib/src/commands/build_bundle.dart
+++ b/packages/flutter_tools/lib/src/commands/build_bundle.dart
@@ -8,10 +8,10 @@
import '../base/file_system.dart';
import '../build_info.dart';
import '../bundle.dart';
-import '../features.dart';
import '../project.dart';
import '../reporting/usage.dart';
import '../runner/flutter_command.dart' show FlutterOptions, FlutterCommandResult;
+import '../version.dart';
import 'build.dart';
class BuildBundleCommand extends BuildSubCommand {
@@ -98,21 +98,13 @@
if (platform == null) {
throwToolExit('Unknown platform: $targetPlatform');
}
- // Check for target platforms that are only allowed via feature flags.
+ // Check for target platforms that are only allowed on unstable Flutter.
switch (platform) {
case TargetPlatform.darwin_x64:
- if (!featureFlags.isMacOSEnabled) {
- throwToolExit('macOS is not a supported target platform.');
- }
- break;
case TargetPlatform.windows_x64:
- if (!featureFlags.isWindowsEnabled) {
- throwToolExit('Windows is not a supported target platform.');
- }
- break;
case TargetPlatform.linux_x64:
- if (!featureFlags.isLinuxEnabled) {
- throwToolExit('Linux is not a supported target platform.');
+ if (!FlutterVersion.instance.isMaster) {
+ throwToolExit('$targetPlatform is not supported on stable Flutter.');
}
break;
default:
diff --git a/packages/flutter_tools/lib/src/commands/build_fuchsia.dart b/packages/flutter_tools/lib/src/commands/build_fuchsia.dart
index 39e0a84..473f943 100644
--- a/packages/flutter_tools/lib/src/commands/build_fuchsia.dart
+++ b/packages/flutter_tools/lib/src/commands/build_fuchsia.dart
@@ -25,6 +25,9 @@
final String name = 'fuchsia';
@override
+ bool isExperimental = true;
+
+ @override
bool hidden = true;
@override
diff --git a/packages/flutter_tools/lib/src/commands/build_linux.dart b/packages/flutter_tools/lib/src/commands/build_linux.dart
index e75e411..4175b6d 100644
--- a/packages/flutter_tools/lib/src/commands/build_linux.dart
+++ b/packages/flutter_tools/lib/src/commands/build_linux.dart
@@ -8,7 +8,6 @@
import '../base/platform.dart';
import '../build_info.dart';
import '../cache.dart';
-import '../features.dart';
import '../linux/build_linux.dart';
import '../project.dart';
import '../runner/flutter_command.dart' show FlutterCommandResult;
@@ -36,6 +35,9 @@
final String name = 'linux';
@override
+ bool isExperimental = true;
+
+ @override
bool hidden = true;
@override
@@ -52,9 +54,6 @@
Cache.releaseLockEarly();
final BuildInfo buildInfo = getBuildInfo();
final FlutterProject flutterProject = FlutterProject.current();
- if (!featureFlags.isLinuxEnabled) {
- throwToolExit('"build linux" is not currently supported.');
- }
if (!platform.isLinux) {
throwToolExit('"build linux" only supported on Linux hosts.');
}
diff --git a/packages/flutter_tools/lib/src/commands/build_macos.dart b/packages/flutter_tools/lib/src/commands/build_macos.dart
index f871186..e773f42 100644
--- a/packages/flutter_tools/lib/src/commands/build_macos.dart
+++ b/packages/flutter_tools/lib/src/commands/build_macos.dart
@@ -8,7 +8,6 @@
import '../base/platform.dart';
import '../build_info.dart';
import '../cache.dart';
-import '../features.dart';
import '../macos/build_macos.dart';
import '../project.dart';
import '../runner/flutter_command.dart' show FlutterCommandResult;
@@ -36,6 +35,9 @@
final String name = 'macos';
@override
+ bool isExperimental = true;
+
+ @override
bool hidden = true;
@override
@@ -45,16 +47,13 @@
};
@override
- String get description => 'build the macOS desktop target.';
+ String get description => 'build the macOS desktop target (Experimental).';
@override
Future<FlutterCommandResult> runCommand() async {
Cache.releaseLockEarly();
final BuildInfo buildInfo = getBuildInfo();
final FlutterProject flutterProject = FlutterProject.current();
- if (!featureFlags.isMacOSEnabled) {
- throwToolExit('"build macos" is not currently supported.');
- }
if (!platform.isMacOS) {
throwToolExit('"build macos" only supported on macOS hosts.');
}
diff --git a/packages/flutter_tools/lib/src/commands/build_web.dart b/packages/flutter_tools/lib/src/commands/build_web.dart
index 575d1b0..32cea06 100644
--- a/packages/flutter_tools/lib/src/commands/build_web.dart
+++ b/packages/flutter_tools/lib/src/commands/build_web.dart
@@ -4,9 +4,7 @@
import 'dart:async';
-import '../base/common.dart';
import '../build_info.dart';
-import '../features.dart';
import '../project.dart';
import '../runner/flutter_command.dart'
show DevelopmentArtifact, FlutterCommandResult;
@@ -34,13 +32,13 @@
bool get hidden => true;
@override
- final String description = 'build a web application bundle.';
+ bool get isExperimental => true;
+
+ @override
+ final String description = '(EXPERIMENTAL) build a web application bundle.';
@override
Future<FlutterCommandResult> runCommand() async {
- if (!featureFlags.isWebEnabled) {
- throwToolExit('"build web" is not currently supported.');
- }
final FlutterProject flutterProject = FlutterProject.current();
final String target = argResults['target'];
final BuildInfo buildInfo = getBuildInfo();
diff --git a/packages/flutter_tools/lib/src/commands/build_windows.dart b/packages/flutter_tools/lib/src/commands/build_windows.dart
index e41de03..884d26f 100644
--- a/packages/flutter_tools/lib/src/commands/build_windows.dart
+++ b/packages/flutter_tools/lib/src/commands/build_windows.dart
@@ -8,7 +8,6 @@
import '../base/platform.dart';
import '../build_info.dart';
import '../cache.dart';
-import '../features.dart';
import '../project.dart';
import '../runner/flutter_command.dart' show FlutterCommandResult;
import '../windows/build_windows.dart';
@@ -36,6 +35,9 @@
final String name = 'windows';
@override
+ bool isExperimental = true;
+
+ @override
bool hidden = true;
@override
@@ -45,16 +47,13 @@
};
@override
- String get description => 'build the desktop Windows target.';
+ String get description => 'build the desktop Windows target (Experimental).';
@override
Future<FlutterCommandResult> runCommand() async {
Cache.releaseLockEarly();
final FlutterProject flutterProject = FlutterProject.current();
final BuildInfo buildInfo = getBuildInfo();
- if (!featureFlags.isWindowsEnabled) {
- throwToolExit('"build windows" is not currently supported.');
- }
if (!platform.isWindows) {
throwToolExit('"build windows" only supported on Windows hosts.');
}
diff --git a/packages/flutter_tools/lib/src/commands/create.dart b/packages/flutter_tools/lib/src/commands/create.dart
index 875beae..17458ee 100644
--- a/packages/flutter_tools/lib/src/commands/create.dart
+++ b/packages/flutter_tools/lib/src/commands/create.dart
@@ -20,7 +20,6 @@
import '../convert.dart';
import '../dart/pub.dart';
import '../doctor.dart';
-import '../features.dart';
import '../globals.dart';
import '../project.dart';
import '../reporting/usage.dart';
@@ -614,7 +613,7 @@
'iosLanguage': iosLanguage,
'flutterRevision': FlutterVersion.instance.frameworkRevision,
'flutterChannel': FlutterVersion.instance.channel,
- 'web': web && featureFlags.isWebEnabled,
+ 'web': web && FlutterVersion.instance.isMaster
};
}
diff --git a/packages/flutter_tools/lib/src/commands/run.dart b/packages/flutter_tools/lib/src/commands/run.dart
index 0254e3e..91de004 100644
--- a/packages/flutter_tools/lib/src/commands/run.dart
+++ b/packages/flutter_tools/lib/src/commands/run.dart
@@ -13,7 +13,6 @@
import '../build_info.dart';
import '../cache.dart';
import '../device.dart';
-import '../features.dart';
import '../globals.dart';
import '../macos/xcode.dart';
import '../project.dart';
@@ -411,11 +410,11 @@
);
flutterDevices.add(flutterDevice);
}
- // Only support "web mode" with a single web device due to resident runner
- // refactoring required otherwise.
- final bool webMode = featureFlags.isWebEnabled &&
- devices.length == 1 &&
- await devices.single.targetPlatform == TargetPlatform.web_javascript;
+ // Only support "web mode" on non-stable branches with a single web device
+ // in a "hot mode".
+ final bool webMode = FlutterVersion.instance.isMaster
+ && devices.length == 1
+ && await devices.single.targetPlatform == TargetPlatform.web_javascript;
ResidentRunner runner;
final String applicationBinaryPath = argResults['use-application-binary'];
diff --git a/packages/flutter_tools/lib/src/commands/unpack.dart b/packages/flutter_tools/lib/src/commands/unpack.dart
index 481c326..799815e 100644
--- a/packages/flutter_tools/lib/src/commands/unpack.dart
+++ b/packages/flutter_tools/lib/src/commands/unpack.dart
@@ -70,6 +70,9 @@
bool get hidden => true;
@override
+ bool get isExperimental => true;
+
+ @override
Future<Set<DevelopmentArtifact>> get requiredArtifacts async {
final Set<DevelopmentArtifact> result = <DevelopmentArtifact>{
DevelopmentArtifact.universal,
diff --git a/packages/flutter_tools/lib/src/desktop.dart b/packages/flutter_tools/lib/src/desktop.dart
index e62c4e7..501e241 100644
--- a/packages/flutter_tools/lib/src/desktop.dart
+++ b/packages/flutter_tools/lib/src/desktop.dart
@@ -4,10 +4,32 @@
import 'dart:async';
+import 'package:meta/meta.dart';
+
+import 'base/common.dart';
import 'base/io.dart';
+import 'base/platform.dart';
import 'base/process_manager.dart';
import 'convert.dart';
import 'device.dart';
+import 'version.dart';
+
+@visibleForTesting
+bool debugDisableDesktop = false;
+
+/// Only launch or display desktop embedding devices from the command line
+/// or if `ENABLE_FLUTTER_DESKTOP` environment variable is set to true.
+bool get flutterDesktopEnabled {
+ if (debugDisableDesktop) {
+ return false;
+ }
+ if (isRunningFromDaemon) {
+ final bool platformEnabled = platform
+ .environment['ENABLE_FLUTTER_DESKTOP']?.toLowerCase() == 'true';
+ return platformEnabled && FlutterVersion.instance.isMaster;
+ }
+ return FlutterVersion.instance.isMaster;
+}
/// Kills a process on linux or macOS.
Future<bool> killProcess(String executable) async {
diff --git a/packages/flutter_tools/lib/src/device.dart b/packages/flutter_tools/lib/src/device.dart
index 734172f..936bf15 100644
--- a/packages/flutter_tools/lib/src/device.dart
+++ b/packages/flutter_tools/lib/src/device.dart
@@ -14,7 +14,9 @@
import 'base/file_system.dart';
import 'base/utils.dart';
import 'build_info.dart';
+import 'desktop.dart';
import 'fuchsia/fuchsia_device.dart';
+
import 'globals.dart';
import 'ios/devices.dart';
import 'ios/simulators.dart';
@@ -23,6 +25,7 @@
import 'project.dart';
import 'tester/flutter_tester.dart';
import 'web/web_device.dart';
+import 'web/workflow.dart';
import 'windows/windows_device.dart';
DeviceManager get deviceManager => context.get<DeviceManager>();
@@ -71,11 +74,23 @@
IOSSimulators(),
FuchsiaDevices(),
FlutterTesterDevices(),
- MacOSDevices(),
- LinuxDevices(),
- WindowsDevices(),
- WebDevices(),
- ]);
+ ] + _conditionalDesktopDevices + _conditionalWebDevices);
+
+ /// Only add desktop devices if the flag is enabled.
+ static List<DeviceDiscovery> get _conditionalDesktopDevices {
+ return flutterDesktopEnabled ? <DeviceDiscovery>[
+ MacOSDevices(),
+ LinuxDevices(),
+ WindowsDevices(),
+ ] : <DeviceDiscovery>[];
+ }
+
+ /// Only add web devices if the flag is enabled.
+ static List<DeviceDiscovery> get _conditionalWebDevices {
+ return flutterWebEnabled ? <DeviceDiscovery>[
+ WebDevices(),
+ ] : <DeviceDiscovery>[];
+ }
String _specifiedDeviceId;
diff --git a/packages/flutter_tools/lib/src/doctor.dart b/packages/flutter_tools/lib/src/doctor.dart
index cf697c7..fa4081d 100644
--- a/packages/flutter_tools/lib/src/doctor.dart
+++ b/packages/flutter_tools/lib/src/doctor.dart
@@ -19,6 +19,7 @@
import 'base/utils.dart';
import 'base/version.dart';
import 'cache.dart';
+import 'desktop.dart';
import 'device.dart';
import 'fuchsia/fuchsia_workflow.dart';
import 'globals.dart';
@@ -73,10 +74,12 @@
GroupedValidator(<DoctorValidator>[xcodeValidator, cocoapodsValidator]),
if (webWorkflow.appliesToHostPlatform)
const WebValidator(),
- if (linuxWorkflow.appliesToHostPlatform)
- LinuxDoctorValidator(),
- if (windowsWorkflow.appliesToHostPlatform)
- visualStudioValidator,
+ // Add desktop doctors to workflow if the flag is enabled.
+ if (flutterDesktopEnabled)
+ ...<DoctorValidator>[
+ if (linuxWorkflow.appliesToHostPlatform) LinuxDoctorValidator(),
+ if (windowsWorkflow.appliesToHostPlatform) visualStudioValidator,
+ ],
if (ideValidators.isNotEmpty)
...ideValidators
else
diff --git a/packages/flutter_tools/lib/src/linux/linux_workflow.dart b/packages/flutter_tools/lib/src/linux/linux_workflow.dart
index e51c26b..4959f72 100644
--- a/packages/flutter_tools/lib/src/linux/linux_workflow.dart
+++ b/packages/flutter_tools/lib/src/linux/linux_workflow.dart
@@ -4,8 +4,8 @@
import '../base/context.dart';
import '../base/platform.dart';
+import '../desktop.dart';
import '../doctor.dart';
-import '../features.dart';
/// The [WindowsWorkflow] instance.
LinuxWorkflow get linuxWorkflow => context.get<LinuxWorkflow>();
@@ -18,13 +18,13 @@
const LinuxWorkflow();
@override
- bool get appliesToHostPlatform => platform.isLinux && featureFlags.isLinuxEnabled;
+ bool get appliesToHostPlatform => platform.isLinux;
@override
- bool get canLaunchDevices => platform.isLinux && featureFlags.isLinuxEnabled;
+ bool get canLaunchDevices => platform.isLinux && flutterDesktopEnabled;
@override
- bool get canListDevices => platform.isLinux && featureFlags.isLinuxEnabled;
+ bool get canListDevices => platform.isLinux && flutterDesktopEnabled;
@override
bool get canListEmulators => false;
diff --git a/packages/flutter_tools/lib/src/macos/macos_workflow.dart b/packages/flutter_tools/lib/src/macos/macos_workflow.dart
index 1c0391f..e85e3d4 100644
--- a/packages/flutter_tools/lib/src/macos/macos_workflow.dart
+++ b/packages/flutter_tools/lib/src/macos/macos_workflow.dart
@@ -4,8 +4,8 @@
import '../base/context.dart';
import '../base/platform.dart';
+import '../desktop.dart';
import '../doctor.dart';
-import '../features.dart';
/// The [MacOSWorkflow] instance.
MacOSWorkflow get macOSWorkflow => context.get<MacOSWorkflow>();
@@ -18,13 +18,13 @@
const MacOSWorkflow();
@override
- bool get appliesToHostPlatform => platform.isMacOS && featureFlags.isMacOSEnabled;
+ bool get appliesToHostPlatform => platform.isMacOS;
@override
- bool get canLaunchDevices => platform.isMacOS && featureFlags.isMacOSEnabled;
+ bool get canLaunchDevices => platform.isMacOS && flutterDesktopEnabled;
@override
- bool get canListDevices => platform.isMacOS && featureFlags.isMacOSEnabled;
+ bool get canListDevices => platform.isMacOS && flutterDesktopEnabled;
@override
bool get canListEmulators => false;
diff --git a/packages/flutter_tools/lib/src/plugins.dart b/packages/flutter_tools/lib/src/plugins.dart
index 021ec84..0242a62 100644
--- a/packages/flutter_tools/lib/src/plugins.dart
+++ b/packages/flutter_tools/lib/src/plugins.dart
@@ -9,7 +9,7 @@
import 'base/file_system.dart';
import 'dart/package_map.dart';
-import 'features.dart';
+import 'desktop.dart';
import 'globals.dart';
import 'macos/cocoapods.dart';
import 'project.dart';
@@ -364,7 +364,7 @@
// TODO(stuartmorgan): Revisit the condition here once the plans for handling
// desktop in existing projects are in place. For now, ignore checkProjects
// on desktop and always treat it as true.
- if (featureFlags.isMacOSEnabled && project.macos.existsSync()) {
+ if (flutterDesktopEnabled && project.macos.existsSync()) {
await _writeMacOSPluginRegistrant(project, plugins);
}
for (final XcodeBasedProject subproject in <XcodeBasedProject>[project.ios, project.macos]) {
diff --git a/packages/flutter_tools/lib/src/project.dart b/packages/flutter_tools/lib/src/project.dart
index 95b526e..0a1b5b8 100644
--- a/packages/flutter_tools/lib/src/project.dart
+++ b/packages/flutter_tools/lib/src/project.dart
@@ -14,7 +14,7 @@
import 'build_info.dart';
import 'bundle.dart' as bundle;
import 'cache.dart';
-import 'features.dart';
+import 'desktop.dart';
import 'flutter_manifest.dart';
import 'globals.dart';
import 'ios/ios_workflow.dart';
@@ -22,6 +22,7 @@
import 'ios/xcodeproj.dart' as xcode;
import 'plugins.dart';
import 'template.dart';
+import 'web/workflow.dart';
FlutterProjectFactory get projectFactory => context.get<FlutterProjectFactory>() ?? const FlutterProjectFactory();
@@ -205,10 +206,10 @@
}
// TODO(stuartmorgan): Add checkProjects logic once a create workflow exists
// for macOS. For now, always treat checkProjects as true for macOS.
- if (featureFlags.isMacOSEnabled && macos.existsSync()) {
+ if (flutterDesktopEnabled && macos.existsSync()) {
await macos.ensureReadyForPlatformSpecificTooling();
}
- if (featureFlags.isWebEnabled && web.existsSync()) {
+ if (flutterWebEnabled && web.existsSync()) {
await web.ensureReadyForPlatformSpecificTooling();
}
await injectPlugins(this, checkProjects: checkProjects);
diff --git a/packages/flutter_tools/lib/src/runner/flutter_command.dart b/packages/flutter_tools/lib/src/runner/flutter_command.dart
index 2f56364..e9d9211 100644
--- a/packages/flutter_tools/lib/src/runner/flutter_command.dart
+++ b/packages/flutter_tools/lib/src/runner/flutter_command.dart
@@ -25,10 +25,10 @@
import '../dart/pub.dart';
import '../device.dart';
import '../doctor.dart';
-import '../features.dart';
import '../globals.dart';
import '../project.dart';
import '../reporting/usage.dart';
+import '../version.dart';
import 'flutter_command_runner.dart';
export '../cache.dart' show DevelopmentArtifact;
@@ -355,6 +355,11 @@
}
}
+ /// Whether this feature should not be usable on stable branches.
+ ///
+ /// Defaults to false, meaning it is usable.
+ bool get isExperimental => false;
+
/// Additional usage values to be sent with the usage ping.
Future<Map<String, String>> get usageValues async => const <String, String>{};
@@ -550,6 +555,12 @@
@protected
@mustCallSuper
Future<void> validateCommand() async {
+ // If we're on a stable branch, then don't allow the usage of
+ // "experimental" features.
+ if (isExperimental && !FlutterVersion.instance.isMaster) {
+ throwToolExit('Experimental feature $name is not supported on stable branches');
+ }
+
if (_requiresPubspecYaml && !PackageMap.isUsingCustomPackagesPath) {
// Don't expect a pubspec.yaml file if the user passed in an explicit .packages file path.
if (!fs.isFileSync('pubspec.yaml')) {
@@ -642,17 +653,17 @@
case TargetPlatform.ios:
return DevelopmentArtifact.iOS;
case TargetPlatform.darwin_x64:
- if (featureFlags.isMacOSEnabled) {
+ if (FlutterVersion.instance.isMaster) {
return DevelopmentArtifact.macOS;
}
return null;
case TargetPlatform.windows_x64:
- if (featureFlags.isWindowsEnabled) {
+ if (!FlutterVersion.instance.isMaster) {
return DevelopmentArtifact.windows;
}
return null;
case TargetPlatform.linux_x64:
- if (featureFlags.isLinuxEnabled) {
+ if (!FlutterVersion.instance.isMaster) {
return DevelopmentArtifact.linux;
}
return null;
diff --git a/packages/flutter_tools/lib/src/web/web_device.dart b/packages/flutter_tools/lib/src/web/web_device.dart
index 689eb72..ecd8f41 100644
--- a/packages/flutter_tools/lib/src/web/web_device.dart
+++ b/packages/flutter_tools/lib/src/web/web_device.dart
@@ -11,7 +11,6 @@
import '../base/process_manager.dart';
import '../build_info.dart';
import '../device.dart';
-import '../features.dart';
import '../project.dart';
import 'chrome.dart';
import 'workflow.dart';
@@ -75,7 +74,7 @@
Future<String> get emulatorId async => null;
@override
- bool isSupported() => featureFlags.isWebEnabled && canFindChrome();
+ bool isSupported() => flutterWebEnabled && canFindChrome();
@override
String get name => 'Chrome';
@@ -152,7 +151,7 @@
final ChromeDevice _webDevice = ChromeDevice();
@override
- bool get canListAnything => featureFlags.isWebEnabled;
+ bool get canListAnything => flutterWebEnabled;
@override
Future<List<Device>> pollingGetDevices() async {
@@ -162,7 +161,7 @@
}
@override
- bool get supportsPlatform => featureFlags.isWebEnabled;
+ bool get supportsPlatform => flutterWebEnabled;
}
@visibleForTesting
diff --git a/packages/flutter_tools/lib/src/web/workflow.dart b/packages/flutter_tools/lib/src/web/workflow.dart
index 1f388ca..925ec3d 100644
--- a/packages/flutter_tools/lib/src/web/workflow.dart
+++ b/packages/flutter_tools/lib/src/web/workflow.dart
@@ -2,13 +2,33 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+import 'package:meta/meta.dart';
+
+import '../base/common.dart';
import '../base/context.dart';
import '../base/platform.dart';
import '../base/process_manager.dart';
import '../doctor.dart';
-import '../features.dart';
+import '../version.dart';
import 'chrome.dart';
+@visibleForTesting
+bool debugDisableWeb = false;
+
+/// Only launch or display web devices if `FLUTTER_WEB`
+/// environment variable is set to true from the daemon.
+bool get flutterWebEnabled {
+ if (debugDisableWeb) {
+ return false;
+ }
+ if (isRunningFromDaemon) {
+ final bool platformEnabled = platform
+ .environment['FLUTTER_WEB']?.toLowerCase() == 'true';
+ return platformEnabled && FlutterVersion.instance.isMaster;
+ }
+ return FlutterVersion.instance.isMaster;
+}
+
/// The web workflow instance.
WebWorkflow get webWorkflow => context.get<WebWorkflow>();
@@ -16,13 +36,13 @@
const WebWorkflow();
@override
- bool get appliesToHostPlatform => featureFlags.isWebEnabled && (platform.isWindows || platform.isMacOS || platform.isLinux);
+ bool get appliesToHostPlatform => flutterWebEnabled && (platform.isWindows || platform.isMacOS || platform.isLinux);
@override
- bool get canLaunchDevices => featureFlags.isWebEnabled && canFindChrome();
+ bool get canLaunchDevices => flutterWebEnabled && canFindChrome();
@override
- bool get canListDevices => featureFlags.isWebEnabled && canFindChrome();
+ bool get canListDevices => flutterWebEnabled && canFindChrome();
@override
bool get canListEmulators => false;
diff --git a/packages/flutter_tools/lib/src/windows/windows_workflow.dart b/packages/flutter_tools/lib/src/windows/windows_workflow.dart
index 2a423bb..8d8e34e 100644
--- a/packages/flutter_tools/lib/src/windows/windows_workflow.dart
+++ b/packages/flutter_tools/lib/src/windows/windows_workflow.dart
@@ -4,8 +4,8 @@
import '../base/context.dart';
import '../base/platform.dart';
+import '../desktop.dart';
import '../doctor.dart';
-import '../features.dart';
/// The [WindowsWorkflow] instance.
WindowsWorkflow get windowsWorkflow => context.get<WindowsWorkflow>();
@@ -18,13 +18,13 @@
const WindowsWorkflow();
@override
- bool get appliesToHostPlatform => platform.isWindows && featureFlags.isWindowsEnabled;
+ bool get appliesToHostPlatform => platform.isWindows;
@override
- bool get canLaunchDevices => platform.isWindows && featureFlags.isWindowsEnabled;
+ bool get canLaunchDevices => platform.isWindows && flutterDesktopEnabled;
@override
- bool get canListDevices => platform.isWindows && featureFlags.isWindowsEnabled;
+ bool get canListDevices => platform.isWindows && flutterDesktopEnabled;
@override
bool get canListEmulators => false;
diff --git a/packages/flutter_tools/test/general.shard/commands/build_bundle_test.dart b/packages/flutter_tools/test/general.shard/commands/build_bundle_test.dart
index 782ac26..23e7a41 100644
--- a/packages/flutter_tools/test/general.shard/commands/build_bundle_test.dart
+++ b/packages/flutter_tools/test/general.shard/commands/build_bundle_test.dart
@@ -3,196 +3,93 @@
// found in the LICENSE file.
import 'package:args/command_runner.dart';
-import 'package:file/memory.dart';
-import 'package:flutter_tools/src/base/common.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/commands/build_bundle.dart';
import 'package:flutter_tools/src/bundle.dart';
-import 'package:flutter_tools/src/features.dart';
import 'package:flutter_tools/src/reporting/usage.dart';
import 'package:mockito/mockito.dart';
import '../../src/common.dart';
import '../../src/context.dart';
-import '../../src/testbed.dart';
void main() {
Cache.disableLocking();
- Directory tempDir;
- MockBundleBuilder mockBundleBuilder;
- setUp(() {
- tempDir = fs.systemTempDirectory.createTempSync('flutter_tools_packages_test.');
+ group('getUsage', () {
+ Directory tempDir;
+ MockBundleBuilder mockBundleBuilder;
- mockBundleBuilder = MockBundleBuilder();
- when(
- mockBundleBuilder.build(
- platform: anyNamed('platform'),
- buildMode: anyNamed('buildMode'),
- mainPath: anyNamed('mainPath'),
- manifestPath: anyNamed('manifestPath'),
- applicationKernelFilePath: anyNamed('applicationKernelFilePath'),
- depfilePath: anyNamed('depfilePath'),
- privateKeyPath: anyNamed('privateKeyPath'),
- assetDirPath: anyNamed('assetDirPath'),
- packagesPath: anyNamed('packagesPath'),
- precompiledSnapshot: anyNamed('precompiledSnapshot'),
- reportLicensedPackages: anyNamed('reportLicensedPackages'),
- trackWidgetCreation: anyNamed('trackWidgetCreation'),
- extraFrontEndOptions: anyNamed('extraFrontEndOptions'),
- extraGenSnapshotOptions: anyNamed('extraGenSnapshotOptions'),
- fileSystemRoots: anyNamed('fileSystemRoots'),
- fileSystemScheme: anyNamed('fileSystemScheme'),
- ),
- ).thenAnswer((_) => Future<void>.value());
- });
+ setUp(() {
+ tempDir = fs.systemTempDirectory.createTempSync('flutter_tools_packages_test.');
- tearDown(() {
- tryToDelete(tempDir);
- });
+ mockBundleBuilder = MockBundleBuilder();
+ when(
+ mockBundleBuilder.build(
+ platform: anyNamed('platform'),
+ buildMode: anyNamed('buildMode'),
+ mainPath: anyNamed('mainPath'),
+ manifestPath: anyNamed('manifestPath'),
+ applicationKernelFilePath: anyNamed('applicationKernelFilePath'),
+ depfilePath: anyNamed('depfilePath'),
+ privateKeyPath: anyNamed('privateKeyPath'),
+ assetDirPath: anyNamed('assetDirPath'),
+ packagesPath: anyNamed('packagesPath'),
+ precompiledSnapshot: anyNamed('precompiledSnapshot'),
+ reportLicensedPackages: anyNamed('reportLicensedPackages'),
+ trackWidgetCreation: anyNamed('trackWidgetCreation'),
+ extraFrontEndOptions: anyNamed('extraFrontEndOptions'),
+ extraGenSnapshotOptions: anyNamed('extraGenSnapshotOptions'),
+ fileSystemRoots: anyNamed('fileSystemRoots'),
+ fileSystemScheme: anyNamed('fileSystemScheme'),
+ ),
+ ).thenAnswer((_) => Future<void>.value());
+ });
- Future<BuildBundleCommand> runCommandIn(String projectPath, { List<String> arguments }) async {
- final BuildBundleCommand command = BuildBundleCommand(bundleBuilder: mockBundleBuilder);
- final CommandRunner<void> runner = createTestCommandRunner(command);
- await runner.run(<String>[
- 'bundle',
- ...?arguments,
- '--target=$projectPath/lib/main.dart',
- ]);
- return command;
- }
+ tearDown(() {
+ tryToDelete(tempDir);
+ });
- testUsingContext('bundle getUsage indicate that project is a module', () async {
- final String projectPath = await createProject(tempDir,
- arguments: <String>['--no-pub', '--template=module']);
+ Future<BuildBundleCommand> runCommandIn(String projectPath, { List<String> arguments }) async {
+ final BuildBundleCommand command = BuildBundleCommand(bundleBuilder: mockBundleBuilder);
+ final CommandRunner<void> runner = createTestCommandRunner(command);
+ await runner.run(<String>[
+ 'bundle',
+ ...?arguments,
+ '--target=$projectPath/lib/main.dart',
+ ]);
+ return command;
+ }
- final BuildBundleCommand command = await runCommandIn(projectPath);
+ testUsingContext('indicate that project is a module', () async {
+ final String projectPath = await createProject(tempDir,
+ arguments: <String>['--no-pub', '--template=module']);
- expect(await command.usageValues,
- containsPair(kCommandBuildBundleIsModule, 'true'));
- }, timeout: allowForCreateFlutterProject);
+ final BuildBundleCommand command = await runCommandIn(projectPath);
- testUsingContext('bundle getUsage indicate that project is not a module', () async {
- final String projectPath = await createProject(tempDir,
- arguments: <String>['--no-pub', '--template=app']);
+ expect(await command.usageValues,
+ containsPair(kCommandBuildBundleIsModule, 'true'));
+ }, timeout: allowForCreateFlutterProject);
- final BuildBundleCommand command = await runCommandIn(projectPath);
+ testUsingContext('indicate that project is not a module', () async {
+ final String projectPath = await createProject(tempDir,
+ arguments: <String>['--no-pub', '--template=app']);
- expect(await command.usageValues,
- containsPair(kCommandBuildBundleIsModule, 'false'));
- }, timeout: allowForCreateFlutterProject);
+ final BuildBundleCommand command = await runCommandIn(projectPath);
- testUsingContext('bundle getUsage indicate the target platform', () async {
- final String projectPath = await createProject(tempDir,
- arguments: <String>['--no-pub', '--template=app']);
+ expect(await command.usageValues,
+ containsPair(kCommandBuildBundleIsModule, 'false'));
+ }, timeout: allowForCreateFlutterProject);
- final BuildBundleCommand command = await runCommandIn(projectPath);
+ testUsingContext('indicate the target platform', () async {
+ final String projectPath = await createProject(tempDir,
+ arguments: <String>['--no-pub', '--template=app']);
- expect(await command.usageValues,
- containsPair(kCommandBuildBundleTargetPlatform, 'android-arm'));
- }, timeout: allowForCreateFlutterProject);
+ final BuildBundleCommand command = await runCommandIn(projectPath);
- testUsingContext('bundle fails to build for Windows if feature is disabled', () async {
- fs.file('lib/main.dart').createSync(recursive: true);
- fs.file('pubspec.yaml').createSync(recursive: true);
- fs.file('.packages').createSync(recursive: true);
- final CommandRunner<void> runner = createTestCommandRunner(BuildBundleCommand()
- ..bundleBuilder = MockBundleBuilder());
-
- expect(() => runner.run(<String>[
- 'bundle',
- '--no-pub',
- '--target-platform=windows-x64'
- ]), throwsA(isInstanceOf<ToolExit>()));
- }, overrides: <Type, Generator>{
- FileSystem: () => MemoryFileSystem(),
- FeatureFlags: () => TestFeatureFlags(isWindowsEnabled: false),
- });
-
- testUsingContext('bundle fails to build for Linux if feature is disabled', () async {
- fs.file('lib/main.dart').createSync(recursive: true);
- fs.file('pubspec.yaml').createSync();
- fs.file('.packages').createSync();
- final CommandRunner<void> runner = createTestCommandRunner(BuildBundleCommand()
- ..bundleBuilder = MockBundleBuilder());
-
- expect(() => runner.run(<String>[
- 'bundle',
- '--no-pub',
- '--target-platform=linux-x64'
- ]), throwsA(isInstanceOf<ToolExit>()));
- }, overrides: <Type, Generator>{
- FileSystem: () => MemoryFileSystem(),
- FeatureFlags: () => TestFeatureFlags(isLinuxEnabled: false),
- });
-
- testUsingContext('bundle fails to build for macOS if feature is disabled', () async {
- fs.file('lib/main.dart').createSync(recursive: true);
- fs.file('pubspec.yaml').createSync();
- fs.file('.packages').createSync();
- final CommandRunner<void> runner = createTestCommandRunner(BuildBundleCommand()
- ..bundleBuilder = MockBundleBuilder());
-
- expect(() => runner.run(<String>[
- 'bundle',
- '--no-pub',
- '--target-platform=darwin-x64'
- ]), throwsA(isInstanceOf<ToolExit>()));
- }, overrides: <Type, Generator>{
- FileSystem: () => MemoryFileSystem(),
- FeatureFlags: () => TestFeatureFlags(isMacOSEnabled: false),
- });
-
- testUsingContext('bundle can build for Windows if feature is enabled', () async {
- fs.file('lib/main.dart').createSync(recursive: true);
- fs.file('pubspec.yaml').createSync();
- fs.file('.packages').createSync();
- final CommandRunner<void> runner = createTestCommandRunner(BuildBundleCommand()
- ..bundleBuilder = MockBundleBuilder());
-
- await runner.run(<String>[
- 'bundle',
- '--no-pub',
- '--target-platform=windows-x64'
- ]);
- }, overrides: <Type, Generator>{
- FileSystem: () => MemoryFileSystem(),
- FeatureFlags: () => TestFeatureFlags(isWindowsEnabled: true),
- });
-
- testUsingContext('bundle can build for Linux if feature is enabled', () async {
- fs.file('lib/main.dart').createSync(recursive: true);
- fs.file('pubspec.yaml').createSync();
- fs.file('.packages').createSync();
- final CommandRunner<void> runner = createTestCommandRunner(BuildBundleCommand()
- ..bundleBuilder = MockBundleBuilder());
-
- await runner.run(<String>[
- 'bundle',
- '--no-pub',
- '--target-platform=linux-x64'
- ]);
- }, overrides: <Type, Generator>{
- FileSystem: () => MemoryFileSystem(),
- FeatureFlags: () => TestFeatureFlags(isLinuxEnabled: true),
- });
-
- testUsingContext('bundle can build for macOS if feature is enabled', () async {
- fs.file('lib/main.dart').createSync(recursive: true);
- fs.file('pubspec.yaml').createSync();
- fs.file('.packages').createSync();
- final CommandRunner<void> runner = createTestCommandRunner(BuildBundleCommand()
- ..bundleBuilder = MockBundleBuilder());
-
- await runner.run(<String>[
- 'bundle',
- '--no-pub',
- '--target-platform=darwin-x64'
- ]);
- }, overrides: <Type, Generator>{
- FileSystem: () => MemoryFileSystem(),
- FeatureFlags: () => TestFeatureFlags(isMacOSEnabled: true),
+ expect(await command.usageValues,
+ containsPair(kCommandBuildBundleTargetPlatform, 'android-arm'));
+ }, timeout: allowForCreateFlutterProject);
});
}
diff --git a/packages/flutter_tools/test/general.shard/commands/build_linux_test.dart b/packages/flutter_tools/test/general.shard/commands/build_linux_test.dart
index 0e1c809..638a20b 100644
--- a/packages/flutter_tools/test/general.shard/commands/build_linux_test.dart
+++ b/packages/flutter_tools/test/general.shard/commands/build_linux_test.dart
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-import 'package:args/command_runner.dart';
import 'package:file/memory.dart';
import 'package:flutter_tools/src/base/common.dart';
import 'package:flutter_tools/src/base/file_system.dart';
@@ -10,7 +9,6 @@
import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/commands/build.dart';
-import 'package:flutter_tools/src/features.dart';
import 'package:flutter_tools/src/linux/makefile.dart';
import 'package:flutter_tools/src/project.dart';
import 'package:mockito/mockito.dart';
@@ -19,7 +17,6 @@
import '../../src/common.dart';
import '../../src/context.dart';
import '../../src/mocks.dart';
-import '../../src/testbed.dart';
void main() {
MockProcessManager mockProcessManager;
@@ -58,7 +55,6 @@
}, overrides: <Type, Generator>{
Platform: () => linuxPlatform,
FileSystem: () => MemoryFileSystem(),
- FeatureFlags: () => TestFeatureFlags(isLinuxEnabled: true),
});
testUsingContext('Linux build fails on non-linux platform', () async {
@@ -75,7 +71,6 @@
}, overrides: <Type, Generator>{
Platform: () => notLinuxPlatform,
FileSystem: () => MemoryFileSystem(),
- FeatureFlags: () => TestFeatureFlags(isLinuxEnabled: true),
});
testUsingContext('Linux build invokes make and writes temporary files', () async {
@@ -102,7 +97,6 @@
FileSystem: () => MemoryFileSystem(),
ProcessManager: () => mockProcessManager,
Platform: () => linuxPlatform,
- FeatureFlags: () => TestFeatureFlags(isLinuxEnabled: true),
});
testUsingContext('linux can extract binary name from Makefile', () async {
@@ -118,19 +112,7 @@
final FlutterProject flutterProject = FlutterProject.current();
expect(makefileExecutableName(flutterProject.linux), 'fizz_bar');
- }, overrides: <Type, Generator>{
- FileSystem: () => MemoryFileSystem(),
- FeatureFlags: () => TestFeatureFlags(isLinuxEnabled: true),
- });
-
- testUsingContext('Refuses to build for Linux when feature is disabled', () {
- final CommandRunner<void> runner = createTestCommandRunner(BuildCommand());
-
- expect(() => runner.run(<String>['build', 'linux']),
- throwsA(isInstanceOf<ToolExit>()));
- }, overrides: <Type, Generator>{
- FeatureFlags: () => TestFeatureFlags(isLinuxEnabled: false),
- });
+ }, overrides: <Type, Generator>{FileSystem: () => MemoryFileSystem()});
}
class MockProcessManager extends Mock implements ProcessManager {}
diff --git a/packages/flutter_tools/test/general.shard/commands/build_macos_test.dart b/packages/flutter_tools/test/general.shard/commands/build_macos_test.dart
index 462e2d8..ceb07b8 100644
--- a/packages/flutter_tools/test/general.shard/commands/build_macos_test.dart
+++ b/packages/flutter_tools/test/general.shard/commands/build_macos_test.dart
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-import 'package:args/command_runner.dart';
import 'package:file/memory.dart';
import 'package:flutter_tools/src/base/common.dart';
import 'package:flutter_tools/src/base/file_system.dart';
@@ -11,7 +10,6 @@
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/commands/build.dart';
-import 'package:flutter_tools/src/features.dart';
import 'package:flutter_tools/src/project.dart';
import 'package:mockito/mockito.dart';
import 'package:process/process.dart';
@@ -19,7 +17,6 @@
import '../../src/common.dart';
import '../../src/context.dart';
import '../../src/mocks.dart';
-import '../../src/testbed.dart';
void main() {
MockProcessManager mockProcessManager;
@@ -59,7 +56,6 @@
), throwsA(isInstanceOf<ToolExit>()));
}, overrides: <Type, Generator>{
Platform: () => macosPlatform,
- FeatureFlags: () => TestFeatureFlags(isMacOSEnabled: true),
});
testUsingContext('macOS build fails on non-macOS platform', () async {
@@ -75,7 +71,6 @@
}, overrides: <Type, Generator>{
Platform: () => notMacosPlatform,
FileSystem: () => memoryFilesystem,
- FeatureFlags: () => TestFeatureFlags(isMacOSEnabled: true),
});
testUsingContext('macOS build invokes build script', () async {
@@ -109,16 +104,6 @@
FileSystem: () => memoryFilesystem,
ProcessManager: () => mockProcessManager,
Platform: () => macosPlatform,
- FeatureFlags: () => TestFeatureFlags(isMacOSEnabled: true),
- });
-
- testUsingContext('Refuses to build for macOS when feature is disabled', () {
- final CommandRunner<void> runner = createTestCommandRunner(BuildCommand());
-
- expect(() => runner.run(<String>['build', 'macos']),
- throwsA(isInstanceOf<ToolExit>()));
- }, overrides: <Type, Generator>{
- FeatureFlags: () => TestFeatureFlags(isMacOSEnabled: false),
});
}
diff --git a/packages/flutter_tools/test/general.shard/commands/build_web_test.dart b/packages/flutter_tools/test/general.shard/commands/build_web_test.dart
index 3046570..2adb818 100644
--- a/packages/flutter_tools/test/general.shard/commands/build_web_test.dart
+++ b/packages/flutter_tools/test/general.shard/commands/build_web_test.dart
@@ -2,15 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-import 'package:args/command_runner.dart';
import 'package:flutter_tools/src/base/common.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/cache.dart';
-import 'package:flutter_tools/src/commands/build.dart';
import 'package:flutter_tools/src/device.dart';
-import 'package:flutter_tools/src/features.dart';
import 'package:flutter_tools/src/project.dart';
import 'package:flutter_tools/src/resident_runner.dart';
import 'package:flutter_tools/src/resident_web_runner.dart';
@@ -27,7 +24,6 @@
MockPlatform mockPlatform;
setUpAll(() {
- Cache.flutterRoot = '';
Cache.disableLocking();
});
@@ -53,7 +49,6 @@
WebCompilationProxy: () => mockWebCompilationProxy,
Platform: () => mockPlatform,
FlutterVersion: () => MockFlutterVersion(),
- FeatureFlags: () => TestFeatureFlags(isWebEnabled: true),
});
});
@@ -87,15 +82,6 @@
BuildInfo.debug,
);
}));
-
- test('Refuses to build for web when feature is disabled', () => testbed.run(() async {
- final CommandRunner<void> runner = createTestCommandRunner(BuildCommand());
-
- expect(() => runner.run(<String>['build', 'web']),
- throwsA(isInstanceOf<ToolExit>()));
- }, overrides: <Type, Generator>{
- FeatureFlags: () => TestFeatureFlags(isWebEnabled: false),
- }));
}
class MockWebCompilationProxy extends Mock implements WebCompilationProxy {}
diff --git a/packages/flutter_tools/test/general.shard/commands/build_windows_test.dart b/packages/flutter_tools/test/general.shard/commands/build_windows_test.dart
index 948eae0..301fa7d 100644
--- a/packages/flutter_tools/test/general.shard/commands/build_windows_test.dart
+++ b/packages/flutter_tools/test/general.shard/commands/build_windows_test.dart
@@ -9,7 +9,6 @@
import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/commands/build.dart';
-import 'package:flutter_tools/src/features.dart';
import 'package:flutter_tools/src/windows/visual_studio.dart';
import 'package:mockito/mockito.dart';
import 'package:process/process.dart';
@@ -18,7 +17,6 @@
import '../../src/common.dart';
import '../../src/context.dart';
import '../../src/mocks.dart';
-import '../../src/testbed.dart';
void main() {
MockProcessManager mockProcessManager;
@@ -67,7 +65,6 @@
Platform: () => windowsPlatform,
FileSystem: () => memoryFilesystem,
VisualStudio: () => mockVisualStudio,
- FeatureFlags: () => TestFeatureFlags(isWindowsEnabled: true),
});
testUsingContext('Windows build fails when there is no windows project', () async {
@@ -81,7 +78,6 @@
Platform: () => windowsPlatform,
FileSystem: () => memoryFilesystem,
VisualStudio: () => mockVisualStudio,
- FeatureFlags: () => TestFeatureFlags(isWindowsEnabled: true),
});
testUsingContext('Windows build fails on non windows platform', () async {
@@ -100,7 +96,6 @@
Platform: () => notWindowsPlatform,
FileSystem: () => memoryFilesystem,
VisualStudio: () => mockVisualStudio,
- FeatureFlags: () => TestFeatureFlags(isWindowsEnabled: true),
});
testUsingContext('Windows build invokes msbuild and writes generated files', () async {
@@ -137,7 +132,6 @@
ProcessManager: () => mockProcessManager,
Platform: () => windowsPlatform,
VisualStudio: () => mockVisualStudio,
- FeatureFlags: () => TestFeatureFlags(isWindowsEnabled: true),
});
}
diff --git a/packages/flutter_tools/test/general.shard/commands/devices_test.dart b/packages/flutter_tools/test/general.shard/commands/devices_test.dart
index ee6e095..01bbb9a 100644
--- a/packages/flutter_tools/test/general.shard/commands/devices_test.dart
+++ b/packages/flutter_tools/test/general.shard/commands/devices_test.dart
@@ -20,6 +20,9 @@
group('devices', () {
setUpAll(() {
Cache.disableLocking();
+ // TODO(jonahwilliams): adjust the individual tests so they do not
+ // depend on the host environment.
+ debugDisableWebAndDesktop = true;
});
testUsingContext('returns 0 when called', () async {
diff --git a/packages/flutter_tools/test/general.shard/commands/update_packages_test.dart b/packages/flutter_tools/test/general.shard/commands/update_packages_test.dart
new file mode 100644
index 0000000..6097ba0
--- /dev/null
+++ b/packages/flutter_tools/test/general.shard/commands/update_packages_test.dart
@@ -0,0 +1,18 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+import 'package:flutter_tools/src/commands/update_packages.dart';
+
+import '../../src/common.dart';
+import '../../src/context.dart';
+
+void main() {
+ group('UpdatePackagesCommand', () {
+ // Marking it as experimental breaks bots tests and packaging scripts on stable branches.
+ testUsingContext('is not marked as experimental', () async {
+ final UpdatePackagesCommand command = UpdatePackagesCommand();
+ expect(command.isExperimental, isFalse);
+ });
+ });
+}
diff --git a/packages/flutter_tools/test/general.shard/doctor.dart b/packages/flutter_tools/test/general.shard/doctor.dart
deleted file mode 100644
index db574e6..0000000
--- a/packages/flutter_tools/test/general.shard/doctor.dart
+++ /dev/null
@@ -1,62 +0,0 @@
-// Copyright 2019 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-import 'package:flutter_tools/src/doctor.dart';
-import 'package:flutter_tools/src/features.dart';
-import 'package:flutter_tools/src/linux/linux_doctor.dart';
-import 'package:flutter_tools/src/web/web_validator.dart';
-import 'package:flutter_tools/src/windows/visual_studio_validator.dart';
-
-import '../src/common.dart';
-import '../src/testbed.dart';
-
-void main() {
- Testbed testbed;
-
- setUp(() {
- testbed = Testbed();
- });
-
- test('doctor validators includes desktop when features are enabled', () => testbed.run(() {
- expect(DoctorValidatorsProvider.defaultInstance.validators,
- contains(isInstanceOf<LinuxDoctorValidator>()));
- expect(DoctorValidatorsProvider.defaultInstance.validators,
- contains(isInstanceOf<VisualStudioValidator>()));
- }, overrides: <Type, Generator>{
- FeatureFlags: () => TestFeatureFlags(
- isLinuxEnabled: true,
- isWindowsEnabled: true,
- )
- }));
-
- test('doctor validators does not include desktop when features are enabled', () => testbed.run(() {
- expect(DoctorValidatorsProvider.defaultInstance.validators,
- isNot(contains(isInstanceOf<LinuxDoctorValidator>())));
- expect(DoctorValidatorsProvider.defaultInstance.validators,
- isNot(contains(isInstanceOf<VisualStudioValidator>())));
- }, overrides: <Type, Generator>{
- FeatureFlags: () => TestFeatureFlags(
- isLinuxEnabled: false,
- isWindowsEnabled: false,
- )
- }));
-
- test('doctor validators includes web when feature is enabled', () => testbed.run(() {
- expect(DoctorValidatorsProvider.defaultInstance.validators,
- contains(isInstanceOf<WebValidator>()));
- }, overrides: <Type, Generator>{
- FeatureFlags: () => TestFeatureFlags(
- isWebEnabled: true,
- )
- }));
-
- test('doctor validators does not include web when feature is disabled', () => testbed.run(() {
- expect(DoctorValidatorsProvider.defaultInstance.validators,
- isNot(contains(isInstanceOf<WebValidator>())));
- }, overrides: <Type, Generator>{
- FeatureFlags: () => TestFeatureFlags(
- isWebEnabled: false,
- )
- }));
-}
diff --git a/packages/flutter_tools/test/general.shard/linux/linux_workflow_test.dart b/packages/flutter_tools/test/general.shard/linux/linux_workflow_test.dart
index 8723c47..1445cff 100644
--- a/packages/flutter_tools/test/general.shard/linux/linux_workflow_test.dart
+++ b/packages/flutter_tools/test/general.shard/linux/linux_workflow_test.dart
@@ -2,57 +2,42 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-import 'package:flutter_tools/src/features.dart';
import 'package:mockito/mockito.dart';
import 'package:flutter_tools/src/linux/linux_workflow.dart';
import 'package:flutter_tools/src/base/platform.dart';
import '../../src/common.dart';
import '../../src/context.dart';
-import '../../src/testbed.dart';
void main() {
- MockPlatform linux;
- MockPlatform notLinux;
- Testbed testbed;
-
- setUp(() {
- linux = MockPlatform();
- notLinux = MockPlatform();
+ group(LinuxWorkflow, () {
+ final MockPlatform linux = MockPlatform();
+ final MockPlatform linuxWithFde = MockPlatform()
+ ..environment['ENABLE_FLUTTER_DESKTOP'] = 'true';
+ final MockPlatform notLinux = MockPlatform();
when(linux.isLinux).thenReturn(true);
+ when(linuxWithFde.isLinux).thenReturn(true);
when(notLinux.isLinux).thenReturn(false);
- testbed = Testbed(
- overrides: <Type, Generator>{
- Platform: () => linux,
- FeatureFlags: () => TestFeatureFlags(isLinuxEnabled: true),
- }
- );
+
+ testUsingContext('Applies to linux platform', () {
+ expect(linuxWorkflow.appliesToHostPlatform, true);
+ }, overrides: <Type, Generator>{
+ Platform: () => linux,
+ });
+ testUsingContext('Does not apply to non-linux platform', () {
+ expect(linuxWorkflow.appliesToHostPlatform, false);
+ }, overrides: <Type, Generator>{
+ Platform: () => notLinux,
+ });
+
+ testUsingContext('defaults', () {
+ expect(linuxWorkflow.canListEmulators, false);
+ expect(linuxWorkflow.canLaunchDevices, true);
+ expect(linuxWorkflow.canListDevices, true);
+ }, overrides: <Type, Generator>{
+ Platform: () => linuxWithFde,
+ });
});
-
- test('Applies to linux platform', () => testbed.run(() {
- expect(linuxWorkflow.appliesToHostPlatform, true);
- expect(linuxWorkflow.canLaunchDevices, true);
- expect(linuxWorkflow.canListDevices, true);
- expect(linuxWorkflow.canListEmulators, false);
- }));
-
- test('Does not apply to non-linux platform', () => testbed.run(() {
- expect(linuxWorkflow.appliesToHostPlatform, false);
- expect(linuxWorkflow.canLaunchDevices, false);
- expect(linuxWorkflow.canListDevices, false);
- expect(linuxWorkflow.canListEmulators, false);
- }, overrides: <Type, Generator>{
- Platform: () => notLinux,
- }));
-
- test('Does not apply when feature is disabled', () => testbed.run(() {
- expect(linuxWorkflow.appliesToHostPlatform, false);
- expect(linuxWorkflow.canLaunchDevices, false);
- expect(linuxWorkflow.canListDevices, false);
- expect(linuxWorkflow.canListEmulators, false);
- }, overrides: <Type, Generator>{
- FeatureFlags: () => TestFeatureFlags(isLinuxEnabled: false),
- }));
}
class MockPlatform extends Mock implements Platform {
diff --git a/packages/flutter_tools/test/general.shard/macos/macos_workflow_test.dart b/packages/flutter_tools/test/general.shard/macos/macos_workflow_test.dart
index 9dadfe9..b63bdde 100644
--- a/packages/flutter_tools/test/general.shard/macos/macos_workflow_test.dart
+++ b/packages/flutter_tools/test/general.shard/macos/macos_workflow_test.dart
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-import 'package:flutter_tools/src/features.dart';
+import 'package:flutter_tools/src/base/io.dart';
import 'package:mockito/mockito.dart';
import 'package:flutter_tools/src/base/platform.dart';
@@ -11,48 +11,40 @@
import '../../src/common.dart';
import '../../src/context.dart';
-import '../../src/testbed.dart';
void main() {
- MockPlatform mac;
- MockPlatform notMac;
- Testbed testbed;
-
- setUp(() {
- mac = MockPlatform();
- notMac = MockPlatform();
+ group(MacOSWorkflow, () {
+ final MockPlatform mac = MockPlatform();
+ final MockPlatform macWithFde = MockPlatform()
+ ..environment['ENABLE_FLUTTER_DESKTOP'] = 'true';
+ final MockPlatform notMac = MockPlatform();
when(mac.isMacOS).thenReturn(true);
+ when(macWithFde.isMacOS).thenReturn(true);
when(notMac.isMacOS).thenReturn(false);
- testbed = Testbed(overrides: <Type, Generator>{
+
+ final MockProcessManager mockProcessManager = MockProcessManager();
+ when(mockProcessManager.run(any)).thenAnswer((Invocation invocation) async {
+ return ProcessResult(0, 1, '', '');
+ });
+ testUsingContext('Applies to mac platform', () {
+ expect(macOSWorkflow.appliesToHostPlatform, true);
+ }, overrides: <Type, Generator>{
Platform: () => mac,
- FeatureFlags: () => TestFeatureFlags(isMacOSEnabled: true),
+ });
+ testUsingContext('Does not apply to non-mac platform', () {
+ expect(macOSWorkflow.appliesToHostPlatform, false);
+ }, overrides: <Type, Generator>{
+ Platform: () => notMac,
+ });
+
+ testUsingContext('defaults', () {
+ expect(macOSWorkflow.canListEmulators, false);
+ expect(macOSWorkflow.canLaunchDevices, true);
+ expect(macOSWorkflow.canListDevices, true);
+ }, overrides: <Type, Generator>{
+ Platform: () => macWithFde,
});
});
-
- test('Applies to macOS platform', () => testbed.run(() {
- expect(macOSWorkflow.appliesToHostPlatform, true);
- expect(macOSWorkflow.canListDevices, true);
- expect(macOSWorkflow.canLaunchDevices, true);
- expect(macOSWorkflow.canListEmulators, false);
- }));
-
- test('Does not apply to non-macOS platform', () => testbed.run(() {
- expect(macOSWorkflow.appliesToHostPlatform, false);
- expect(macOSWorkflow.canListDevices, false);
- expect(macOSWorkflow.canLaunchDevices, false);
- expect(macOSWorkflow.canListEmulators, false);
- }, overrides: <Type, Generator>{
- Platform: () => notMac,
- }));
-
- test('Does not apply when feature is disabled', () => testbed.run(() {
- expect(macOSWorkflow.appliesToHostPlatform, false);
- expect(macOSWorkflow.canListDevices, false);
- expect(macOSWorkflow.canLaunchDevices, false);
- expect(macOSWorkflow.canListEmulators, false);
- }, overrides: <Type, Generator>{
- FeatureFlags: () => TestFeatureFlags(isMacOSEnabled: false),
- }));
}
class MockPlatform extends Mock implements Platform {
diff --git a/packages/flutter_tools/test/general.shard/runner/flutter_command_test.dart b/packages/flutter_tools/test/general.shard/runner/flutter_command_test.dart
index eb06c9d..c781e3c 100644
--- a/packages/flutter_tools/test/general.shard/runner/flutter_command_test.dart
+++ b/packages/flutter_tools/test/general.shard/runner/flutter_command_test.dart
@@ -243,6 +243,27 @@
SystemClock: () => clock,
Usage: () => usage,
});
+
+ });
+
+ group('Experimental commands', () {
+ final MockVersion stableVersion = MockVersion();
+ final MockVersion betaVersion = MockVersion();
+ final FakeCommand fakeCommand = FakeCommand();
+ when(stableVersion.isMaster).thenReturn(false);
+ when(betaVersion.isMaster).thenReturn(true);
+
+ testUsingContext('Can be disabled on stable branch', () async {
+ expect(() => fakeCommand.run(), throwsA(isA<ToolExit>()));
+ }, overrides: <Type, Generator>{
+ FlutterVersion: () => stableVersion,
+ });
+
+ testUsingContext('Works normally on regular branches', () async {
+ expect(fakeCommand.run(), completes);
+ }, overrides: <Type, Generator>{
+ FlutterVersion: () => betaVersion,
+ });
});
}
@@ -255,6 +276,9 @@
String get name => 'fake';
@override
+ bool get isExperimental => true;
+
+ @override
Future<FlutterCommandResult> runCommand() async {
return null;
}
diff --git a/packages/flutter_tools/test/general.shard/web/workflow_test.dart b/packages/flutter_tools/test/general.shard/web/workflow_test.dart
index ab11aea..86a8d6b 100644
--- a/packages/flutter_tools/test/general.shard/web/workflow_test.dart
+++ b/packages/flutter_tools/test/general.shard/web/workflow_test.dart
@@ -4,7 +4,7 @@
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/platform.dart';
-import 'package:flutter_tools/src/features.dart';
+import 'package:flutter_tools/src/version.dart';
import 'package:flutter_tools/src/web/chrome.dart';
import 'package:flutter_tools/src/web/workflow.dart';
import 'package:mockito/mockito.dart';
@@ -22,9 +22,13 @@
MockPlatform linux;
MockPlatform macos;
MockProcessManager mockProcessManager;
+ MockFlutterVersion unstable;
+ MockFlutterVersion stable;
WebWorkflow workflow;
setUpAll(() {
+ unstable = MockFlutterVersion(false);
+ stable = MockFlutterVersion(true);
notSupported = MockPlatform(linux: false, windows: false, macos: false);
windows = MockPlatform(windows: true);
linux = MockPlatform(linux: true);
@@ -35,7 +39,7 @@
fs.file('chrome').createSync();
when(mockProcessManager.canRun('chrome')).thenReturn(true);
}, overrides: <Type, Generator>{
- FeatureFlags: () => TestFeatureFlags(isWebEnabled: true),
+ FlutterVersion: () => unstable,
ProcessManager: () => mockProcessManager,
});
});
@@ -77,18 +81,27 @@
Platform: () => notSupported,
}));
- test('does not apply if feature flag is disabled', () => testbed.run(() {
+ test('does not apply on stable branch', () => testbed.run(() {
expect(workflow.appliesToHostPlatform, false);
expect(workflow.canLaunchDevices, false);
expect(workflow.canListDevices, false);
expect(workflow.canListEmulators, false);
}, overrides: <Type, Generator>{
Platform: () => macos,
- FeatureFlags: () => TestFeatureFlags(isWebEnabled: false),
+ FlutterVersion: () => stable,
}));
});
}
+class MockFlutterVersion extends Mock implements FlutterVersion {
+ MockFlutterVersion(this.isStable);
+
+ final bool isStable;
+
+ @override
+ bool get isMaster => !isStable;
+}
+
class MockProcessManager extends Mock implements ProcessManager {}
class MockPlatform extends Mock implements Platform {
diff --git a/packages/flutter_tools/test/general.shard/windows/windows_workflow_test.dart b/packages/flutter_tools/test/general.shard/windows/windows_workflow_test.dart
index 86a566b..4c9d202 100644
--- a/packages/flutter_tools/test/general.shard/windows/windows_workflow_test.dart
+++ b/packages/flutter_tools/test/general.shard/windows/windows_workflow_test.dart
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-import 'package:flutter_tools/src/features.dart';
import 'package:mockito/mockito.dart';
import 'package:flutter_tools/src/base/platform.dart';
@@ -10,50 +9,36 @@
import '../../src/common.dart';
import '../../src/context.dart';
-import '../../src/testbed.dart';
void main() {
- Testbed testbed;
- MockPlatform windows;
- MockPlatform notWindows;
-
- setUp(() {
- windows = MockPlatform();
- notWindows = MockPlatform();
+ group(WindowsWorkflow, () {
+ final MockPlatform windows = MockPlatform();
+ final MockPlatform windowsWithFde = MockPlatform()
+ ..environment['ENABLE_FLUTTER_DESKTOP'] = 'true';
+ final MockPlatform notWindows = MockPlatform();
when(windows.isWindows).thenReturn(true);
+ when(windowsWithFde.isWindows).thenReturn(true);
when(notWindows.isWindows).thenReturn(false);
- testbed = Testbed(
- overrides: <Type, Generator>{
- Platform: () => windows,
- FeatureFlags: () => TestFeatureFlags(isWindowsEnabled: true),
- }
- );
+
+ testUsingContext('Applies to windows platform', () {
+ expect(windowsWorkflow.appliesToHostPlatform, true);
+ }, overrides: <Type, Generator>{
+ Platform: () => windows,
+ });
+ testUsingContext('Does not apply to non-windows platform', () {
+ expect(windowsWorkflow.appliesToHostPlatform, false);
+ }, overrides: <Type, Generator>{
+ Platform: () => notWindows,
+ });
+
+ testUsingContext('defaults', () {
+ expect(windowsWorkflow.canListEmulators, false);
+ expect(windowsWorkflow.canLaunchDevices, true);
+ expect(windowsWorkflow.canListDevices, true);
+ }, overrides: <Type, Generator>{
+ Platform: () => windowsWithFde,
+ });
});
-
- test('Windows default workflow values', () => testbed.run(() {
- expect(windowsWorkflow.appliesToHostPlatform, true);
- expect(windowsWorkflow.canListDevices, true);
- expect(windowsWorkflow.canLaunchDevices, true);
- expect(windowsWorkflow.canListEmulators, false);
- }));
-
- test('Windows defaults on non-windows platform', () => testbed.run(() {
- expect(windowsWorkflow.appliesToHostPlatform, false);
- expect(windowsWorkflow.canListDevices, false);
- expect(windowsWorkflow.canLaunchDevices, false);
- expect(windowsWorkflow.canListEmulators, false);
- }, overrides: <Type, Generator>{
- Platform: () => notWindows,
- }));
-
- test('Windows defaults on non-windows platform', () => testbed.run(() {
- expect(windowsWorkflow.appliesToHostPlatform, false);
- expect(windowsWorkflow.canListDevices, false);
- expect(windowsWorkflow.canLaunchDevices, false);
- expect(windowsWorkflow.canListEmulators, false);
- }, overrides: <Type, Generator>{
- FeatureFlags: () => TestFeatureFlags(isWindowsEnabled: false),
- }));
}
class MockPlatform extends Mock implements Platform {
diff --git a/packages/flutter_tools/test/src/common.dart b/packages/flutter_tools/test/src/common.dart
index 3a3a4ea..2b8f22a 100644
--- a/packages/flutter_tools/test/src/common.dart
+++ b/packages/flutter_tools/test/src/common.dart
@@ -5,6 +5,8 @@
import 'dart:async';
import 'package:args/command_runner.dart';
+import 'package:flutter_tools/src/desktop.dart';
+import 'package:flutter_tools/src/web/workflow.dart';
import 'package:test_api/test_api.dart' hide TypeMatcher, isInstanceOf;
import 'package:test_api/test_api.dart' as test_package show TypeMatcher;
@@ -18,6 +20,19 @@
export 'package:test_core/test_core.dart' hide TypeMatcher, isInstanceOf; // Defines a 'package:test' shim.
+/// Disable both web and desktop to make testing easier. For example, prevent
+/// them from showing up in the devices list if the host happens to be setup
+/// properly.
+set debugDisableWebAndDesktop(bool value) {
+ if (value) {
+ debugDisableDesktop = true;
+ debugDisableWeb = true;
+ } else {
+ debugDisableDesktop = false;
+ debugDisableWeb = false;
+ }
+}
+
/// A matcher that compares the type of the actual value to the type argument T.
// TODO(ianh): Remove this once https://github.com/dart-lang/matcher/issues/98 is fixed
Matcher isInstanceOf<T>() => test_package.TypeMatcher<T>();
diff --git a/packages/flutter_tools/test/src/testbed.dart b/packages/flutter_tools/test/src/testbed.dart
index c0a6873..ac4901c 100644
--- a/packages/flutter_tools/test/src/testbed.dart
+++ b/packages/flutter_tools/test/src/testbed.dart
@@ -17,7 +17,6 @@
import 'package:flutter_tools/src/base/terminal.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/context_runner.dart';
-import 'package:flutter_tools/src/features.dart';
import 'package:flutter_tools/src/reporting/usage.dart';
import 'package:flutter_tools/src/version.dart';
@@ -688,26 +687,3 @@
return null;
}
}
-
-// A test implementation of [FeatureFlags] that allows enabling without reading
-// config. If not otherwise specified, all values default to false.
-class TestFeatureFlags implements FeatureFlags {
- TestFeatureFlags({
- this.isLinuxEnabled = false,
- this.isMacOSEnabled = false,
- this.isWebEnabled = false,
- this.isWindowsEnabled = false,
-});
-
- @override
- final bool isLinuxEnabled;
-
- @override
- final bool isMacOSEnabled;
-
- @override
- final bool isWebEnabled;
-
- @override
- final bool isWindowsEnabled;
-}