Unverified Commit 9618788e authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[flutter_tools] remove globals from features (#70515)

parent 148ae7bf
...@@ -185,7 +185,11 @@ Future<T> runInContext<T>( ...@@ -185,7 +185,11 @@ Future<T> runInContext<T>(
fileSystem: globals.fs, fileSystem: globals.fs,
androidWorkflow: androidWorkflow, androidWorkflow: androidWorkflow,
), ),
FeatureFlags: () => const FlutterFeatureFlags(), FeatureFlags: () => FlutterFeatureFlags(
flutterVersion: globals.flutterVersion,
config: globals.config,
platform: globals.platform,
),
FlutterVersion: () => FlutterVersion(clock: const SystemClock()), FlutterVersion: () => FlutterVersion(clock: const SystemClock()),
FuchsiaArtifacts: () => FuchsiaArtifacts.find(), FuchsiaArtifacts: () => FuchsiaArtifacts.find(),
FuchsiaDeviceTools: () => FuchsiaDeviceTools(), FuchsiaDeviceTools: () => FuchsiaDeviceTools(),
......
...@@ -4,8 +4,10 @@ ...@@ -4,8 +4,10 @@
import 'package:meta/meta.dart'; import 'package:meta/meta.dart';
import 'base/config.dart';
import 'base/context.dart'; import 'base/context.dart';
import 'globals.dart' as globals; import 'base/platform.dart';
import 'version.dart';
/// The current [FeatureFlags] implementation. /// The current [FeatureFlags] implementation.
/// ///
...@@ -54,7 +56,17 @@ abstract class FeatureFlags { ...@@ -54,7 +56,17 @@ abstract class FeatureFlags {
} }
class FlutterFeatureFlags implements FeatureFlags { class FlutterFeatureFlags implements FeatureFlags {
const FlutterFeatureFlags(); FlutterFeatureFlags({
@required FlutterVersion flutterVersion,
@required Config config,
@required Platform platform,
}) : _flutterVersion = flutterVersion,
_config = config,
_platform = platform;
final FlutterVersion _flutterVersion;
final Config _config;
final Platform _platform;
@override @override
bool get isLinuxEnabled => isEnabled(flutterLinuxDesktopFeature); bool get isLinuxEnabled => isEnabled(flutterLinuxDesktopFeature);
...@@ -82,20 +94,20 @@ class FlutterFeatureFlags implements FeatureFlags { ...@@ -82,20 +94,20 @@ class FlutterFeatureFlags implements FeatureFlags {
@override @override
bool isEnabled(Feature feature) { bool isEnabled(Feature feature) {
final String currentChannel = globals.flutterVersion.channel; final String currentChannel = _flutterVersion.channel;
final FeatureChannelSetting featureSetting = feature.getSettingForChannel(currentChannel); final FeatureChannelSetting featureSetting = feature.getSettingForChannel(currentChannel);
if (!featureSetting.available) { if (!featureSetting.available) {
return false; return false;
} }
bool isEnabled = featureSetting.enabledByDefault; bool isEnabled = featureSetting.enabledByDefault;
if (feature.configSetting != null) { if (feature.configSetting != null) {
final bool configOverride = globals.config.getValue(feature.configSetting) as bool; final bool configOverride = _config.getValue(feature.configSetting) as bool;
if (configOverride != null) { if (configOverride != null) {
isEnabled = configOverride; isEnabled = configOverride;
} }
} }
if (feature.environmentOverride != null) { if (feature.environmentOverride != null) {
if (globals.platform.environment[feature.environmentOverride]?.toLowerCase() == 'true') { if (_platform.environment[feature.environmentOverride]?.toLowerCase() == 'true') {
isEnabled = true; isEnabled = true;
} }
} }
......
...@@ -9,37 +9,36 @@ import 'package:flutter_tools/src/version.dart'; ...@@ -9,37 +9,36 @@ import 'package:flutter_tools/src/version.dart';
import 'package:mockito/mockito.dart'; import 'package:mockito/mockito.dart';
import '../src/common.dart'; import '../src/common.dart';
import '../src/testbed.dart';
void main() { void main() {
group('Features', () { group('Features', () {
MockFlutterVerion mockFlutterVerion; MockFlutterVerion mockFlutterVerion;
MockFlutterConfig mockFlutterConfig; MockFlutterConfig mockFlutterConfig;
MockPlatform mockPlatform; MockPlatform mockPlatform;
Testbed testbed; FlutterFeatureFlags featureFlags;
setUp(() { setUp(() {
mockFlutterVerion = MockFlutterVerion(); mockFlutterVerion = MockFlutterVerion();
mockFlutterConfig = MockFlutterConfig(); mockFlutterConfig = MockFlutterConfig();
mockPlatform = MockPlatform(); mockPlatform = MockPlatform();
when(mockPlatform.environment).thenReturn(<String, String>{});
when<bool>(mockFlutterConfig.getValue(any) as bool).thenReturn(false); when<bool>(mockFlutterConfig.getValue(any) as bool).thenReturn(false);
when(mockPlatform.environment).thenReturn(const <String, String>{});
testbed = Testbed(overrides: <Type, Generator>{ featureFlags = FlutterFeatureFlags(
FlutterVersion: () => mockFlutterVerion, flutterVersion: mockFlutterVerion,
FeatureFlags: () => const FlutterFeatureFlags(), config: mockFlutterConfig,
Config: () => mockFlutterConfig, platform: mockPlatform,
Platform: () => mockPlatform, );
});
}); });
test('setting has safe defaults', () { testWithoutContext('setting has safe defaults', () {
const FeatureChannelSetting featureSetting = FeatureChannelSetting(); const FeatureChannelSetting featureSetting = FeatureChannelSetting();
expect(featureSetting.available, false); expect(featureSetting.available, false);
expect(featureSetting.enabledByDefault, false); expect(featureSetting.enabledByDefault, false);
}); });
test('has safe defaults', () { testWithoutContext('has safe defaults', () {
const Feature feature = Feature(name: 'example'); const Feature feature = Feature(name: 'example');
expect(feature.name, 'example'); expect(feature.name, 'example');
...@@ -47,7 +46,7 @@ void main() { ...@@ -47,7 +46,7 @@ void main() {
expect(feature.configSetting, null); expect(feature.configSetting, null);
}); });
test('retrieves the correct setting for each branch', () { testWithoutContext('retrieves the correct setting for each branch', () {
final FeatureChannelSetting masterSetting = FeatureChannelSetting(available: nonconst(true)); final FeatureChannelSetting masterSetting = FeatureChannelSetting(available: nonconst(true));
final FeatureChannelSetting devSetting = FeatureChannelSetting(available: nonconst(true)); final FeatureChannelSetting devSetting = FeatureChannelSetting(available: nonconst(true));
final FeatureChannelSetting betaSetting = FeatureChannelSetting(available: nonconst(true)); final FeatureChannelSetting betaSetting = FeatureChannelSetting(available: nonconst(true));
...@@ -67,7 +66,7 @@ void main() { ...@@ -67,7 +66,7 @@ void main() {
expect(feature.getSettingForChannel('unknown'), masterSetting); expect(feature.getSettingForChannel('unknown'), masterSetting);
}); });
test('env variables are only enabled with "true" string', () => testbed.run(() { testWithoutContext('env variables are only enabled with "true" string', () {
when(mockPlatform.environment).thenReturn(<String, String>{'FLUTTER_WEB': 'hello'}); when(mockPlatform.environment).thenReturn(<String, String>{'FLUTTER_WEB': 'hello'});
expect(featureFlags.isWebEnabled, false); expect(featureFlags.isWebEnabled, false);
...@@ -75,34 +74,34 @@ void main() { ...@@ -75,34 +74,34 @@ void main() {
when(mockPlatform.environment).thenReturn(<String, String>{'FLUTTER_WEB': 'true'}); when(mockPlatform.environment).thenReturn(<String, String>{'FLUTTER_WEB': 'true'});
expect(featureFlags.isWebEnabled, true); expect(featureFlags.isWebEnabled, true);
})); });
test('flutter web help string', () { testWithoutContext('flutter web help string', () {
expect(flutterWebFeature.generateHelpMessage(), expect(flutterWebFeature.generateHelpMessage(),
'Enable or disable Flutter for web. ' 'Enable or disable Flutter for web. '
'This setting will take effect on the master, dev, and beta channels.'); 'This setting will take effect on the master, dev, and beta channels.');
}); });
test('flutter macOS desktop help string', () { testWithoutContext('flutter macOS desktop help string', () {
expect(flutterMacOSDesktopFeature.generateHelpMessage(), expect(flutterMacOSDesktopFeature.generateHelpMessage(),
'Enable or disable Flutter for desktop on macOS. ' 'Enable or disable Flutter for desktop on macOS. '
'This setting will take effect on the master and dev channels.'); 'This setting will take effect on the master and dev channels.');
}); });
test('flutter Linux desktop help string', () { testWithoutContext('flutter Linux desktop help string', () {
expect(flutterLinuxDesktopFeature.generateHelpMessage(), expect(flutterLinuxDesktopFeature.generateHelpMessage(),
'Enable or disable Flutter for desktop on Linux. ' 'Enable or disable Flutter for desktop on Linux. '
'This setting will take effect on the master and dev channels.'); 'This setting will take effect on the master and dev channels.');
}); });
test('flutter Windows desktop help string', () { testWithoutContext('flutter Windows desktop help string', () {
expect(flutterWindowsDesktopFeature.generateHelpMessage(), expect(flutterWindowsDesktopFeature.generateHelpMessage(),
'Enable or disable Flutter for desktop on Windows. ' 'Enable or disable Flutter for desktop on Windows. '
'This setting will take effect on the master and dev channels.'); 'This setting will take effect on the master and dev channels.');
}); });
test('help string on multiple channels', () { testWithoutContext('help string on multiple channels', () {
const Feature testFeature = Feature( const Feature testWithoutContextFeature = Feature(
name: 'example', name: 'example',
master: FeatureChannelSetting(available: true), master: FeatureChannelSetting(available: true),
dev: FeatureChannelSetting(available: true), dev: FeatureChannelSetting(available: true),
...@@ -111,335 +110,335 @@ void main() { ...@@ -111,335 +110,335 @@ void main() {
configSetting: 'foo', configSetting: 'foo',
); );
expect(testFeature.generateHelpMessage(), 'Enable or disable example. ' expect(testWithoutContextFeature.generateHelpMessage(), 'Enable or disable example. '
'This setting will take effect on the master, dev, beta, and stable channels.'); 'This setting will take effect on the master, dev, beta, and stable channels.');
}); });
/// Flutter Web /// Flutter Web
test('flutter web off by default on master', () => testbed.run(() { testWithoutContext('flutter web off by default on master', () {
when(mockFlutterVerion.channel).thenReturn('master'); when(mockFlutterVerion.channel).thenReturn('master');
expect(featureFlags.isWebEnabled, false); expect(featureFlags.isWebEnabled, false);
})); });
test('flutter web enabled with config on master', () => testbed.run(() { testWithoutContext('flutter web enabled with config on master', () {
when(mockFlutterVerion.channel).thenReturn('master'); when(mockFlutterVerion.channel).thenReturn('master');
when<bool>(mockFlutterConfig.getValue('enable-web') as bool).thenReturn(true); when<bool>(mockFlutterConfig.getValue('enable-web') as bool).thenReturn(true);
expect(featureFlags.isWebEnabled, true); expect(featureFlags.isWebEnabled, true);
})); });
test('flutter web enabled with environment variable on master', () => testbed.run(() { testWithoutContext('flutter web enabled with environment variable on master', () {
when(mockFlutterVerion.channel).thenReturn('master'); when(mockFlutterVerion.channel).thenReturn('master');
when(mockPlatform.environment).thenReturn(<String, String>{'FLUTTER_WEB': 'true'}); when(mockPlatform.environment).thenReturn(<String, String>{'FLUTTER_WEB': 'true'});
expect(featureFlags.isWebEnabled, true); expect(featureFlags.isWebEnabled, true);
})); });
test('flutter web off by default on dev', () => testbed.run(() { testWithoutContext('flutter web off by default on dev', () {
when(mockFlutterVerion.channel).thenReturn('dev'); when(mockFlutterVerion.channel).thenReturn('dev');
expect(featureFlags.isWebEnabled, false); expect(featureFlags.isWebEnabled, false);
})); });
test('flutter web enabled with config on dev', () => testbed.run(() { testWithoutContext('flutter web enabled with config on dev', () {
when(mockFlutterVerion.channel).thenReturn('dev'); when(mockFlutterVerion.channel).thenReturn('dev');
when<bool>(mockFlutterConfig.getValue('enable-web') as bool).thenReturn(true); when<bool>(mockFlutterConfig.getValue('enable-web') as bool).thenReturn(true);
expect(featureFlags.isWebEnabled, true); expect(featureFlags.isWebEnabled, true);
})); });
test('flutter web enabled with environment variable on dev', () => testbed.run(() { testWithoutContext('flutter web enabled with environment variable on dev', () {
when(mockFlutterVerion.channel).thenReturn('dev'); when(mockFlutterVerion.channel).thenReturn('dev');
when(mockPlatform.environment).thenReturn(<String, String>{'FLUTTER_WEB': 'true'}); when(mockPlatform.environment).thenReturn(<String, String>{'FLUTTER_WEB': 'true'});
expect(featureFlags.isWebEnabled, true); expect(featureFlags.isWebEnabled, true);
})); });
test('flutter web off by default on beta', () => testbed.run(() { testWithoutContext('flutter web off by default on beta', () {
when(mockFlutterVerion.channel).thenReturn('beta'); when(mockFlutterVerion.channel).thenReturn('beta');
expect(featureFlags.isWebEnabled, false); expect(featureFlags.isWebEnabled, false);
})); });
test('flutter web enabled with config on beta', () => testbed.run(() { testWithoutContext('flutter web enabled with config on beta', () {
when(mockFlutterVerion.channel).thenReturn('beta'); when(mockFlutterVerion.channel).thenReturn('beta');
when<bool>(mockFlutterConfig.getValue('enable-web') as bool).thenReturn(true); when<bool>(mockFlutterConfig.getValue('enable-web') as bool).thenReturn(true);
expect(featureFlags.isWebEnabled, true); expect(featureFlags.isWebEnabled, true);
})); });
test('flutter web not enabled with environment variable on beta', () => testbed.run(() { testWithoutContext('flutter web not enabled with environment variable on beta', () {
when(mockFlutterVerion.channel).thenReturn('beta'); when(mockFlutterVerion.channel).thenReturn('beta');
when(mockPlatform.environment).thenReturn(<String, String>{'FLUTTER_WEB': 'true'}); when(mockPlatform.environment).thenReturn(<String, String>{'FLUTTER_WEB': 'true'});
expect(featureFlags.isWebEnabled, true); expect(featureFlags.isWebEnabled, true);
})); });
test('flutter web off by default on stable', () => testbed.run(() { testWithoutContext('flutter web off by default on stable', () {
when(mockFlutterVerion.channel).thenReturn('stable'); when(mockFlutterVerion.channel).thenReturn('stable');
expect(featureFlags.isWebEnabled, false); expect(featureFlags.isWebEnabled, false);
})); });
test('flutter web not enabled with config on stable', () => testbed.run(() { testWithoutContext('flutter web not enabled with config on stable', () {
when(mockFlutterVerion.channel).thenReturn('stable'); when(mockFlutterVerion.channel).thenReturn('stable');
when<bool>(mockFlutterConfig.getValue('enable-web') as bool).thenReturn(true); when<bool>(mockFlutterConfig.getValue('enable-web') as bool).thenReturn(true);
expect(featureFlags.isWebEnabled, false); expect(featureFlags.isWebEnabled, false);
})); });
test('flutter web not enabled with environment variable on stable', () => testbed.run(() { testWithoutContext('flutter web not enabled with environment variable on stable', () {
when(mockFlutterVerion.channel).thenReturn('stable'); when(mockFlutterVerion.channel).thenReturn('stable');
when(mockPlatform.environment).thenReturn(<String, String>{'FLUTTER_WEB': 'enabled'}); when(mockPlatform.environment).thenReturn(<String, String>{'FLUTTER_WEB': 'enabled'});
expect(featureFlags.isWebEnabled, false); expect(featureFlags.isWebEnabled, false);
})); });
/// Flutter macOS desktop. /// Flutter macOS desktop.
test('flutter macos desktop off by default on master', () => testbed.run(() { testWithoutContext('flutter macos desktop off by default on master', () {
when(mockFlutterVerion.channel).thenReturn('master'); when(mockFlutterVerion.channel).thenReturn('master');
expect(featureFlags.isMacOSEnabled, false); expect(featureFlags.isMacOSEnabled, false);
})); });
test('flutter macos desktop enabled with config on master', () => testbed.run(() { testWithoutContext('flutter macos desktop enabled with config on master', () {
when(mockFlutterVerion.channel).thenReturn('master'); when(mockFlutterVerion.channel).thenReturn('master');
when<bool>(mockFlutterConfig.getValue('enable-macos-desktop') as bool).thenReturn(true); when<bool>(mockFlutterConfig.getValue('enable-macos-desktop') as bool).thenReturn(true);
expect(featureFlags.isMacOSEnabled, true); expect(featureFlags.isMacOSEnabled, true);
})); });
test('flutter macos desktop enabled with environment variable on master', () => testbed.run(() { testWithoutContext('flutter macos desktop enabled with environment variable on master', () {
when(mockFlutterVerion.channel).thenReturn('master'); when(mockFlutterVerion.channel).thenReturn('master');
when(mockPlatform.environment).thenReturn(<String, String>{'FLUTTER_MACOS': 'true'}); when(mockPlatform.environment).thenReturn(<String, String>{'FLUTTER_MACOS': 'true'});
expect(featureFlags.isMacOSEnabled, true); expect(featureFlags.isMacOSEnabled, true);
})); });
test('flutter macos desktop off by default on dev', () => testbed.run(() { testWithoutContext('flutter macos desktop off by default on dev', () {
when(mockFlutterVerion.channel).thenReturn('dev'); when(mockFlutterVerion.channel).thenReturn('dev');
expect(featureFlags.isMacOSEnabled, false); expect(featureFlags.isMacOSEnabled, false);
})); });
test('flutter macos desktop enabled with config on dev', () => testbed.run(() { testWithoutContext('flutter macos desktop enabled with config on dev', () {
when(mockFlutterVerion.channel).thenReturn('dev'); when(mockFlutterVerion.channel).thenReturn('dev');
when<bool>(mockFlutterConfig.getValue('enable-macos-desktop') as bool).thenReturn(true); when<bool>(mockFlutterConfig.getValue('enable-macos-desktop') as bool).thenReturn(true);
expect(featureFlags.isMacOSEnabled, true); expect(featureFlags.isMacOSEnabled, true);
})); });
test('flutter macos desktop enabled with environment variable on dev', () => testbed.run(() { testWithoutContext('flutter macos desktop enabled with environment variable on dev', () {
when(mockFlutterVerion.channel).thenReturn('dev'); when(mockFlutterVerion.channel).thenReturn('dev');
when(mockPlatform.environment).thenReturn(<String, String>{'FLUTTER_MACOS': 'true'}); when(mockPlatform.environment).thenReturn(<String, String>{'FLUTTER_MACOS': 'true'});
expect(featureFlags.isMacOSEnabled, true); expect(featureFlags.isMacOSEnabled, true);
})); });
test('flutter macos desktop off by default on beta', () => testbed.run(() { testWithoutContext('flutter macos desktop off by default on beta', () {
when(mockFlutterVerion.channel).thenReturn('beta'); when(mockFlutterVerion.channel).thenReturn('beta');
expect(featureFlags.isMacOSEnabled, false); expect(featureFlags.isMacOSEnabled, false);
})); });
test('fflutter macos desktop not enabled with config on beta', () => testbed.run(() { testWithoutContext('fflutter macos desktop not enabled with config on beta', () {
when(mockFlutterVerion.channel).thenReturn('beta'); when(mockFlutterVerion.channel).thenReturn('beta');
when<bool>(mockFlutterConfig.getValue('flutter-desktop-macos') as bool).thenReturn(true); when<bool>(mockFlutterConfig.getValue('flutter-desktop-macos') as bool).thenReturn(true);
expect(featureFlags.isMacOSEnabled, false); expect(featureFlags.isMacOSEnabled, false);
})); });
test('flutter macos desktop not enabled with environment variable on beta', () => testbed.run(() { testWithoutContext('flutter macos desktop not enabled with environment variable on beta', () {
when(mockFlutterVerion.channel).thenReturn('beta'); when(mockFlutterVerion.channel).thenReturn('beta');
when(mockPlatform.environment).thenReturn(<String, String>{'FLUTTER_MACOS': 'true'}); when(mockPlatform.environment).thenReturn(<String, String>{'FLUTTER_MACOS': 'true'});
expect(featureFlags.isMacOSEnabled, false); expect(featureFlags.isMacOSEnabled, false);
})); });
test('flutter macos desktop off by default on stable', () => testbed.run(() { testWithoutContext('flutter macos desktop off by default on stable', () {
when(mockFlutterVerion.channel).thenReturn('stable'); when(mockFlutterVerion.channel).thenReturn('stable');
expect(featureFlags.isMacOSEnabled, false); expect(featureFlags.isMacOSEnabled, false);
})); });
test('flutter macos desktop not enabled with config on stable', () => testbed.run(() { testWithoutContext('flutter macos desktop not enabled with config on stable', () {
when(mockFlutterVerion.channel).thenReturn('stable'); when(mockFlutterVerion.channel).thenReturn('stable');
when<bool>(mockFlutterConfig.getValue('flutter-desktop-macos') as bool).thenReturn(true); when<bool>(mockFlutterConfig.getValue('flutter-desktop-macos') as bool).thenReturn(true);
expect(featureFlags.isMacOSEnabled, false); expect(featureFlags.isMacOSEnabled, false);
})); });
test('flutter macos desktop not enabled with environment variable on stable', () => testbed.run(() { testWithoutContext('flutter macos desktop not enabled with environment variable on stable', () {
when(mockFlutterVerion.channel).thenReturn('stable'); when(mockFlutterVerion.channel).thenReturn('stable');
when(mockPlatform.environment).thenReturn(<String, String>{'FLUTTER_MACOS': 'true'}); when(mockPlatform.environment).thenReturn(<String, String>{'FLUTTER_MACOS': 'true'});
expect(featureFlags.isMacOSEnabled, false); expect(featureFlags.isMacOSEnabled, false);
})); });
/// Flutter Linux Desktop /// Flutter Linux Desktop
test('flutter linux desktop off by default on master', () => testbed.run(() { testWithoutContext('flutter linux desktop off by default on master', () {
when(mockFlutterVerion.channel).thenReturn('master'); when(mockFlutterVerion.channel).thenReturn('master');
expect(featureFlags.isLinuxEnabled, false); expect(featureFlags.isLinuxEnabled, false);
})); });
test('flutter linux desktop enabled with config on master', () => testbed.run(() { testWithoutContext('flutter linux desktop enabled with config on master', () {
when(mockFlutterVerion.channel).thenReturn('master'); when(mockFlutterVerion.channel).thenReturn('master');
when<bool>(mockFlutterConfig.getValue('enable-linux-desktop') as bool).thenReturn(true); when<bool>(mockFlutterConfig.getValue('enable-linux-desktop') as bool).thenReturn(true);
expect(featureFlags.isLinuxEnabled, true); expect(featureFlags.isLinuxEnabled, true);
})); });
test('flutter linux desktop enabled with environment variable on master', () => testbed.run(() { testWithoutContext('flutter linux desktop enabled with environment variable on master', () {
when(mockFlutterVerion.channel).thenReturn('master'); when(mockFlutterVerion.channel).thenReturn('master');
when(mockPlatform.environment).thenReturn(<String, String>{'FLUTTER_LINUX': 'true'}); when(mockPlatform.environment).thenReturn(<String, String>{'FLUTTER_LINUX': 'true'});
expect(featureFlags.isLinuxEnabled, true); expect(featureFlags.isLinuxEnabled, true);
})); });
test('flutter linux desktop off by default on dev', () => testbed.run(() { testWithoutContext('flutter linux desktop off by default on dev', () {
when(mockFlutterVerion.channel).thenReturn('dev'); when(mockFlutterVerion.channel).thenReturn('dev');
expect(featureFlags.isLinuxEnabled, false); expect(featureFlags.isLinuxEnabled, false);
})); });
test('flutter linux desktop enabled with config on dev', () => testbed.run(() { testWithoutContext('flutter linux desktop enabled with config on dev', () {
when(mockFlutterVerion.channel).thenReturn('dev'); when(mockFlutterVerion.channel).thenReturn('dev');
when<bool>(mockFlutterConfig.getValue('enable-linux-desktop') as bool).thenReturn(true); when<bool>(mockFlutterConfig.getValue('enable-linux-desktop') as bool).thenReturn(true);
expect(featureFlags.isLinuxEnabled, true); expect(featureFlags.isLinuxEnabled, true);
})); });
test('flutter linux desktop enabled with environment variable on dev', () => testbed.run(() { testWithoutContext('flutter linux desktop enabled with environment variable on dev', () {
when(mockFlutterVerion.channel).thenReturn('dev'); when(mockFlutterVerion.channel).thenReturn('dev');
when(mockPlatform.environment).thenReturn(<String, String>{'FLUTTER_LINUX': 'true'}); when(mockPlatform.environment).thenReturn(<String, String>{'FLUTTER_LINUX': 'true'});
expect(featureFlags.isLinuxEnabled, true); expect(featureFlags.isLinuxEnabled, true);
})); });
test('flutter linux desktop off by default on beta', () => testbed.run(() { testWithoutContext('flutter linux desktop off by default on beta', () {
when(mockFlutterVerion.channel).thenReturn('beta'); when(mockFlutterVerion.channel).thenReturn('beta');
expect(featureFlags.isLinuxEnabled, false); expect(featureFlags.isLinuxEnabled, false);
})); });
test('fflutter linux desktop not enabled with config on beta', () => testbed.run(() { testWithoutContext('fflutter linux desktop not enabled with config on beta', () {
when(mockFlutterVerion.channel).thenReturn('beta'); when(mockFlutterVerion.channel).thenReturn('beta');
when<bool>(mockFlutterConfig.getValue('enable-linux-desktop') as bool).thenReturn(true); when<bool>(mockFlutterConfig.getValue('enable-linux-desktop') as bool).thenReturn(true);
expect(featureFlags.isLinuxEnabled, false); expect(featureFlags.isLinuxEnabled, false);
})); });
test('flutter linux desktop not enabled with environment variable on beta', () => testbed.run(() { testWithoutContext('flutter linux desktop not enabled with environment variable on beta', () {
when(mockFlutterVerion.channel).thenReturn('beta'); when(mockFlutterVerion.channel).thenReturn('beta');
when(mockPlatform.environment).thenReturn(<String, String>{'FLUTTER_LINUX': 'true'}); when(mockPlatform.environment).thenReturn(<String, String>{'FLUTTER_LINUX': 'true'});
expect(featureFlags.isLinuxEnabled, false); expect(featureFlags.isLinuxEnabled, false);
})); });
test('flutter linux desktop off by default on stable', () => testbed.run(() { testWithoutContext('flutter linux desktop off by default on stable', () {
when(mockFlutterVerion.channel).thenReturn('stable'); when(mockFlutterVerion.channel).thenReturn('stable');
expect(featureFlags.isLinuxEnabled, false); expect(featureFlags.isLinuxEnabled, false);
})); });
test('flutter linux desktop not enabled with config on stable', () => testbed.run(() { testWithoutContext('flutter linux desktop not enabled with config on stable', () {
when(mockFlutterVerion.channel).thenReturn('stable'); when(mockFlutterVerion.channel).thenReturn('stable');
when<bool>(mockFlutterConfig.getValue('enable-linux-desktop') as bool).thenReturn(true); when<bool>(mockFlutterConfig.getValue('enable-linux-desktop') as bool).thenReturn(true);
expect(featureFlags.isLinuxEnabled, false); expect(featureFlags.isLinuxEnabled, false);
})); });
test('flutter linux desktop not enabled with environment variable on stable', () => testbed.run(() { testWithoutContext('flutter linux desktop not enabled with environment variable on stable', () {
when(mockFlutterVerion.channel).thenReturn('stable'); when(mockFlutterVerion.channel).thenReturn('stable');
when(mockPlatform.environment).thenReturn(<String, String>{'FLUTTER_LINUX': 'true'}); when(mockPlatform.environment).thenReturn(<String, String>{'FLUTTER_LINUX': 'true'});
expect(featureFlags.isLinuxEnabled, false); expect(featureFlags.isLinuxEnabled, false);
})); });
/// Flutter Windows desktop. /// Flutter Windows desktop.
test('flutter windows desktop off by default on master', () => testbed.run(() { testWithoutContext('flutter windows desktop off by default on master', () {
when(mockFlutterVerion.channel).thenReturn('master'); when(mockFlutterVerion.channel).thenReturn('master');
expect(featureFlags.isWindowsEnabled, false); expect(featureFlags.isWindowsEnabled, false);
})); });
test('flutter windows desktop enabled with config on master', () => testbed.run(() { testWithoutContext('flutter windows desktop enabled with config on master', () {
when(mockFlutterVerion.channel).thenReturn('master'); when(mockFlutterVerion.channel).thenReturn('master');
when<bool>(mockFlutterConfig.getValue('enable-windows-desktop') as bool).thenReturn(true); when<bool>(mockFlutterConfig.getValue('enable-windows-desktop') as bool).thenReturn(true);
expect(featureFlags.isWindowsEnabled, true); expect(featureFlags.isWindowsEnabled, true);
})); });
test('flutter windows desktop enabled with environment variable on master', () => testbed.run(() { testWithoutContext('flutter windows desktop enabled with environment variable on master', () {
when(mockFlutterVerion.channel).thenReturn('master'); when(mockFlutterVerion.channel).thenReturn('master');
when(mockPlatform.environment).thenReturn(<String, String>{'FLUTTER_WINDOWS': 'true'}); when(mockPlatform.environment).thenReturn(<String, String>{'FLUTTER_WINDOWS': 'true'});
expect(featureFlags.isWindowsEnabled, true); expect(featureFlags.isWindowsEnabled, true);
})); });
test('flutter windows desktop off by default on dev', () => testbed.run(() { testWithoutContext('flutter windows desktop off by default on dev', () {
when(mockFlutterVerion.channel).thenReturn('dev'); when(mockFlutterVerion.channel).thenReturn('dev');
expect(featureFlags.isWindowsEnabled, false); expect(featureFlags.isWindowsEnabled, false);
})); });
test('flutter windows desktop enabled with config on dev', () => testbed.run(() { testWithoutContext('flutter windows desktop enabled with config on dev', () {
when(mockFlutterVerion.channel).thenReturn('dev'); when(mockFlutterVerion.channel).thenReturn('dev');
when<bool>(mockFlutterConfig.getValue('enable-windows-desktop') as bool).thenReturn(true); when<bool>(mockFlutterConfig.getValue('enable-windows-desktop') as bool).thenReturn(true);
expect(featureFlags.isWindowsEnabled, true); expect(featureFlags.isWindowsEnabled, true);
})); });
test('flutter windows desktop not enabled with environment variable on dev', () => testbed.run(() { testWithoutContext('flutter windows desktop not enabled with environment variable on dev', () {
when(mockFlutterVerion.channel).thenReturn('dev'); when(mockFlutterVerion.channel).thenReturn('dev');
when(mockPlatform.environment).thenReturn(<String, String>{'FLUTTER_WINDOWS': 'true'}); when(mockPlatform.environment).thenReturn(<String, String>{'FLUTTER_WINDOWS': 'true'});
expect(featureFlags.isWindowsEnabled, true); expect(featureFlags.isWindowsEnabled, true);
})); });
test('flutter windows desktop off by default on beta', () => testbed.run(() { testWithoutContext('flutter windows desktop off by default on beta', () {
when(mockFlutterVerion.channel).thenReturn('beta'); when(mockFlutterVerion.channel).thenReturn('beta');
expect(featureFlags.isWindowsEnabled, false); expect(featureFlags.isWindowsEnabled, false);
})); });
test('fflutter windows desktop not enabled with config on beta', () => testbed.run(() { testWithoutContext('fflutter windows desktop not enabled with config on beta', () {
when(mockFlutterVerion.channel).thenReturn('beta'); when(mockFlutterVerion.channel).thenReturn('beta');
when<bool>(mockFlutterConfig.getValue('enable-windows-desktop') as bool).thenReturn(true); when<bool>(mockFlutterConfig.getValue('enable-windows-desktop') as bool).thenReturn(true);
expect(featureFlags.isWindowsEnabled, false); expect(featureFlags.isWindowsEnabled, false);
})); });
test('flutter windows desktop not enabled with environment variable on beta', () => testbed.run(() { testWithoutContext('flutter windows desktop not enabled with environment variable on beta', () {
when(mockFlutterVerion.channel).thenReturn('beta'); when(mockFlutterVerion.channel).thenReturn('beta');
when(mockPlatform.environment).thenReturn(<String, String>{'FLUTTER_WINDOWS': 'true'}); when(mockPlatform.environment).thenReturn(<String, String>{'FLUTTER_WINDOWS': 'true'});
expect(featureFlags.isWindowsEnabled, false); expect(featureFlags.isWindowsEnabled, false);
})); });
test('flutter windows desktop off by default on stable', () => testbed.run(() { testWithoutContext('flutter windows desktop off by default on stable', () {
when(mockFlutterVerion.channel).thenReturn('stable'); when(mockFlutterVerion.channel).thenReturn('stable');
expect(featureFlags.isWindowsEnabled, false); expect(featureFlags.isWindowsEnabled, false);
})); });
test('flutter windows desktop not enabled with config on stable', () => testbed.run(() { testWithoutContext('flutter windows desktop not enabled with config on stable', () {
when(mockFlutterVerion.channel).thenReturn('stable'); when(mockFlutterVerion.channel).thenReturn('stable');
when<bool>(mockFlutterConfig.getValue('enable-windows-desktop') as bool).thenReturn(true); when<bool>(mockFlutterConfig.getValue('enable-windows-desktop') as bool).thenReturn(true);
expect(featureFlags.isWindowsEnabled, false); expect(featureFlags.isWindowsEnabled, false);
})); });
test('flutter windows desktop not enabled with environment variable on stable', () => testbed.run(() { testWithoutContext('flutter windows desktop not enabled with environment variable on stable', () {
when(mockFlutterVerion.channel).thenReturn('stable'); when(mockFlutterVerion.channel).thenReturn('stable');
when(mockPlatform.environment).thenReturn(<String, String>{'FLUTTER_WINDOWS': 'true'}); when(mockPlatform.environment).thenReturn(<String, String>{'FLUTTER_WINDOWS': 'true'});
expect(featureFlags.isWindowsEnabled, false); expect(featureFlags.isWindowsEnabled, false);
})); });
}); });
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment