Unverified Commit 8bbaedde authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[flutter_tools] remove mocks from features test (#77760)

parent 08b225e0
...@@ -7,35 +7,39 @@ ...@@ -7,35 +7,39 @@
import 'package:flutter_tools/src/base/config.dart'; import 'package:flutter_tools/src/base/config.dart';
import 'package:flutter_tools/src/base/platform.dart'; import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/features.dart'; import 'package:flutter_tools/src/features.dart';
import 'package:flutter_tools/src/version.dart';
import 'package:mockito/mockito.dart';
import '../src/common.dart'; import '../src/common.dart';
import '../src/fakes.dart';
void main() { void main() {
group('Features', () { group('Features', () {
MockFlutterVerion mockFlutterVerion;
Config testConfig; Config testConfig;
MockPlatform mockPlatform; FakePlatform platform;
FlutterFeatureFlags featureFlags; FlutterFeatureFlags featureFlags;
setUp(() { setUp(() {
mockFlutterVerion = MockFlutterVerion();
testConfig = Config.test(); testConfig = Config.test();
mockPlatform = MockPlatform(); platform = FakePlatform(environment: <String, String>{});
when(mockPlatform.environment).thenReturn(<String, String>{});
for (final Feature feature in allFeatures) { for (final Feature feature in allFeatures) {
testConfig.setValue(feature.configSetting, false); testConfig.setValue(feature.configSetting, false);
} }
featureFlags = FlutterFeatureFlags( featureFlags = FlutterFeatureFlags(
flutterVersion: mockFlutterVerion, flutterVersion: FakeFlutterVersion(),
config: testConfig, config: testConfig,
platform: mockPlatform, platform: platform,
); );
}); });
FeatureFlags createFlags(String channel) {
return FlutterFeatureFlags(
flutterVersion: FakeFlutterVersion(channel: channel),
config: testConfig,
platform: platform,
);
}
testWithoutContext('setting has safe defaults', () { testWithoutContext('setting has safe defaults', () {
const FeatureChannelSetting featureSetting = FeatureChannelSetting(); const FeatureChannelSetting featureSetting = FeatureChannelSetting();
...@@ -52,11 +56,11 @@ void main() { ...@@ -52,11 +56,11 @@ void main() {
}); });
testWithoutContext('retrieves the correct setting for each branch', () { testWithoutContext('retrieves the correct setting for each branch', () {
final FeatureChannelSetting masterSetting = FeatureChannelSetting(available: nonconst(true)); const FeatureChannelSetting masterSetting = FeatureChannelSetting(available: true);
final FeatureChannelSetting devSetting = FeatureChannelSetting(available: nonconst(true)); const FeatureChannelSetting devSetting = FeatureChannelSetting(available: true);
final FeatureChannelSetting betaSetting = FeatureChannelSetting(available: nonconst(true)); const FeatureChannelSetting betaSetting = FeatureChannelSetting(available: true);
final FeatureChannelSetting stableSetting = FeatureChannelSetting(available: nonconst(true)); const FeatureChannelSetting stableSetting = FeatureChannelSetting(available: true);
final Feature feature = Feature( const Feature feature = Feature(
name: 'example', name: 'example',
master: masterSetting, master: masterSetting,
dev: devSetting, dev: devSetting,
...@@ -72,11 +76,11 @@ void main() { ...@@ -72,11 +76,11 @@ void main() {
}); });
testWithoutContext('env variables are only enabled with "true" string', () { testWithoutContext('env variables are only enabled with "true" string', () {
when(mockPlatform.environment).thenReturn(<String, String>{'FLUTTER_WEB': 'hello'}); platform.environment = <String, String>{'FLUTTER_WEB': 'hello'};
expect(featureFlags.isWebEnabled, false); expect(featureFlags.isWebEnabled, false);
when(mockPlatform.environment).thenReturn(<String, String>{'FLUTTER_WEB': 'true'}); platform.environment = <String, String>{'FLUTTER_WEB': 'true'};
expect(featureFlags.isWebEnabled, true); expect(featureFlags.isWebEnabled, true);
}); });
...@@ -125,82 +129,82 @@ void main() { ...@@ -125,82 +129,82 @@ void main() {
/// Flutter Web /// Flutter Web
testWithoutContext('Flutter web off by default on master', () { testWithoutContext('Flutter web off by default on master', () {
when(mockFlutterVerion.channel).thenReturn('master'); final FeatureFlags featureFlags = createFlags('master');
expect(featureFlags.isWebEnabled, false); expect(featureFlags.isWebEnabled, false);
}); });
testWithoutContext('Flutter web enabled with config on master', () { testWithoutContext('Flutter web enabled with config on master', () {
when(mockFlutterVerion.channel).thenReturn('master'); final FeatureFlags featureFlags = createFlags('master');
testConfig.setValue('enable-web', true); testConfig.setValue('enable-web', true);
expect(featureFlags.isWebEnabled, true); expect(featureFlags.isWebEnabled, true);
}); });
testWithoutContext('Flutter web enabled with environment variable on master', () { testWithoutContext('Flutter web enabled with environment variable on master', () {
when(mockFlutterVerion.channel).thenReturn('master'); final FeatureFlags featureFlags = createFlags('master');
when(mockPlatform.environment).thenReturn(<String, String>{'FLUTTER_WEB': 'true'}); platform.environment = <String, String>{'FLUTTER_WEB': 'true'};
expect(featureFlags.isWebEnabled, true); expect(featureFlags.isWebEnabled, true);
}); });
testWithoutContext('Flutter web off by default on dev', () { testWithoutContext('Flutter web off by default on dev', () {
when(mockFlutterVerion.channel).thenReturn('dev'); final FeatureFlags featureFlags = createFlags('dev');
expect(featureFlags.isWebEnabled, false); expect(featureFlags.isWebEnabled, false);
}); });
testWithoutContext('Flutter web enabled with config on dev', () { testWithoutContext('Flutter web enabled with config on dev', () {
when(mockFlutterVerion.channel).thenReturn('dev'); final FeatureFlags featureFlags = createFlags('dev');
testConfig.setValue('enable-web', true); testConfig.setValue('enable-web', true);
expect(featureFlags.isWebEnabled, true); expect(featureFlags.isWebEnabled, true);
}); });
testWithoutContext('Flutter web enabled with environment variable on dev', () { testWithoutContext('Flutter web enabled with environment variable on dev', () {
when(mockFlutterVerion.channel).thenReturn('dev'); final FeatureFlags featureFlags = createFlags('dev');
when(mockPlatform.environment).thenReturn(<String, String>{'FLUTTER_WEB': 'true'}); platform.environment = <String, String>{'FLUTTER_WEB': 'true'};
expect(featureFlags.isWebEnabled, true); expect(featureFlags.isWebEnabled, true);
}); });
testWithoutContext('Flutter web off by default on beta', () { testWithoutContext('Flutter web off by default on beta', () {
when(mockFlutterVerion.channel).thenReturn('beta'); final FeatureFlags featureFlags = createFlags('beta');
expect(featureFlags.isWebEnabled, false); expect(featureFlags.isWebEnabled, false);
}); });
testWithoutContext('Flutter web enabled with config on beta', () { testWithoutContext('Flutter web enabled with config on beta', () {
when(mockFlutterVerion.channel).thenReturn('beta'); final FeatureFlags featureFlags = createFlags('beta');
testConfig.setValue('enable-web', true); testConfig.setValue('enable-web', true);
expect(featureFlags.isWebEnabled, true); expect(featureFlags.isWebEnabled, true);
}); });
testWithoutContext('Flutter web not enabled with environment variable on beta', () { testWithoutContext('Flutter web not enabled with environment variable on beta', () {
when(mockFlutterVerion.channel).thenReturn('beta'); final FeatureFlags featureFlags = createFlags('beta');
when(mockPlatform.environment).thenReturn(<String, String>{'FLUTTER_WEB': 'true'}); platform.environment = <String, String>{'FLUTTER_WEB': 'true'};
expect(featureFlags.isWebEnabled, true); expect(featureFlags.isWebEnabled, true);
}); });
testWithoutContext('Flutter web on by default on stable', () { testWithoutContext('Flutter web on by default on stable', () {
when(mockFlutterVerion.channel).thenReturn('stable'); final FeatureFlags featureFlags = createFlags('stable');
testConfig.removeValue('enable-web'); testConfig.removeValue('enable-web');
expect(featureFlags.isWebEnabled, true); expect(featureFlags.isWebEnabled, true);
}); });
testWithoutContext('Flutter web enabled with config on stable', () { testWithoutContext('Flutter web enabled with config on stable', () {
when(mockFlutterVerion.channel).thenReturn('stable'); final FeatureFlags featureFlags = createFlags('stable');
testConfig.setValue('enable-web', true); testConfig.setValue('enable-web', true);
expect(featureFlags.isWebEnabled, true); expect(featureFlags.isWebEnabled, true);
}); });
testWithoutContext('Flutter web not enabled with environment variable on stable', () { testWithoutContext('Flutter web not enabled with environment variable on stable', () {
when(mockFlutterVerion.channel).thenReturn('stable'); final FeatureFlags featureFlags = createFlags('stable');
when(mockPlatform.environment).thenReturn(<String, String>{'FLUTTER_WEB': 'enabled'}); platform.environment = <String, String>{'FLUTTER_WEB': 'enabled'};
expect(featureFlags.isWebEnabled, false); expect(featureFlags.isWebEnabled, false);
}); });
...@@ -208,243 +212,243 @@ void main() { ...@@ -208,243 +212,243 @@ void main() {
/// Flutter macOS desktop. /// Flutter macOS desktop.
testWithoutContext('Flutter macos desktop off by default on master', () { testWithoutContext('Flutter macos desktop off by default on master', () {
when(mockFlutterVerion.channel).thenReturn('master'); final FeatureFlags featureFlags = createFlags('master');
expect(featureFlags.isMacOSEnabled, false); expect(featureFlags.isMacOSEnabled, false);
}); });
testWithoutContext('Flutter macos desktop enabled with config on master', () { testWithoutContext('Flutter macos desktop enabled with config on master', () {
when(mockFlutterVerion.channel).thenReturn('master'); final FeatureFlags featureFlags = createFlags('master');
testConfig.setValue('enable-macos-desktop', true); testConfig.setValue('enable-macos-desktop', true);
expect(featureFlags.isMacOSEnabled, true); expect(featureFlags.isMacOSEnabled, true);
}); });
testWithoutContext('Flutter macos desktop enabled with environment variable on master', () { testWithoutContext('Flutter macos desktop enabled with environment variable on master', () {
when(mockFlutterVerion.channel).thenReturn('master'); final FeatureFlags featureFlags = createFlags('master');
when(mockPlatform.environment).thenReturn(<String, String>{'FLUTTER_MACOS': 'true'}); platform.environment = <String, String>{'FLUTTER_MACOS': 'true'};
expect(featureFlags.isMacOSEnabled, true); expect(featureFlags.isMacOSEnabled, true);
}); });
testWithoutContext('Flutter macos desktop off by default on dev', () { testWithoutContext('Flutter macos desktop off by default on dev', () {
when(mockFlutterVerion.channel).thenReturn('dev'); final FeatureFlags featureFlags = createFlags('dev');
expect(featureFlags.isMacOSEnabled, false); expect(featureFlags.isMacOSEnabled, false);
}); });
testWithoutContext('Flutter macos desktop enabled with config on dev', () { testWithoutContext('Flutter macos desktop enabled with config on dev', () {
when(mockFlutterVerion.channel).thenReturn('dev'); final FeatureFlags featureFlags = createFlags('dev');
testConfig.setValue('enable-macos-desktop', true); testConfig.setValue('enable-macos-desktop', true);
expect(featureFlags.isMacOSEnabled, true); expect(featureFlags.isMacOSEnabled, true);
}); });
testWithoutContext('Flutter macos desktop enabled with environment variable on dev', () { testWithoutContext('Flutter macos desktop enabled with environment variable on dev', () {
when(mockFlutterVerion.channel).thenReturn('dev'); final FeatureFlags featureFlags = createFlags('dev');
when(mockPlatform.environment).thenReturn(<String, String>{'FLUTTER_MACOS': 'true'}); platform.environment = <String, String>{'FLUTTER_MACOS': 'true'};
expect(featureFlags.isMacOSEnabled, true); expect(featureFlags.isMacOSEnabled, true);
}); });
testWithoutContext('Flutter macos desktop off by default on beta', () { testWithoutContext('Flutter macos desktop off by default on beta', () {
when(mockFlutterVerion.channel).thenReturn('beta'); final FeatureFlags featureFlags = createFlags('beta');
expect(featureFlags.isMacOSEnabled, false); expect(featureFlags.isMacOSEnabled, false);
}); });
testWithoutContext('Flutter macos desktop enabled with config on beta', () { testWithoutContext('Flutter macos desktop enabled with config on beta', () {
when(mockFlutterVerion.channel).thenReturn('beta'); final FeatureFlags featureFlags = createFlags('beta');
testConfig.setValue('enable-macos-desktop', true); testConfig.setValue('enable-macos-desktop', true);
expect(featureFlags.isMacOSEnabled, true); expect(featureFlags.isMacOSEnabled, true);
}); });
testWithoutContext('Flutter macos desktop enabled with environment variable on beta', () { testWithoutContext('Flutter macos desktop enabled with environment variable on beta', () {
when(mockFlutterVerion.channel).thenReturn('beta'); final FeatureFlags featureFlags = createFlags('beta');
when(mockPlatform.environment).thenReturn(<String, String>{'FLUTTER_MACOS': 'true'}); platform.environment = <String, String>{'FLUTTER_MACOS': 'true'};
expect(featureFlags.isMacOSEnabled, true); expect(featureFlags.isMacOSEnabled, true);
}); });
testWithoutContext('Flutter macos desktop off by default on stable', () { testWithoutContext('Flutter macos desktop off by default on stable', () {
when(mockFlutterVerion.channel).thenReturn('stable'); final FeatureFlags featureFlags = createFlags('stable');
expect(featureFlags.isMacOSEnabled, false); expect(featureFlags.isMacOSEnabled, false);
}); });
testWithoutContext('Flutter macos desktop enabled with config on stable', () { testWithoutContext('Flutter macos desktop enabled with config on stable', () {
when(mockFlutterVerion.channel).thenReturn('stable'); final FeatureFlags featureFlags = createFlags('stable');
testConfig.setValue('enable-macos-desktop', true); testConfig.setValue('enable-macos-desktop', true);
expect(featureFlags.isMacOSEnabled, true); expect(featureFlags.isMacOSEnabled, true);
}); });
testWithoutContext('Flutter macos desktop enabled with environment variable on stable', () { testWithoutContext('Flutter macos desktop enabled with environment variable on stable', () {
when(mockFlutterVerion.channel).thenReturn('stable'); final FeatureFlags featureFlags = createFlags('stable');
when(mockPlatform.environment).thenReturn(<String, String>{'FLUTTER_MACOS': 'true'}); platform.environment = <String, String>{'FLUTTER_MACOS': 'true'};
expect(featureFlags.isMacOSEnabled, true); expect(featureFlags.isMacOSEnabled, true);
}); });
/// Flutter Linux Desktop /// Flutter Linux Desktop
testWithoutContext('Flutter linux desktop off by default on master', () { testWithoutContext('Flutter linux desktop off by default on master', () {
when(mockFlutterVerion.channel).thenReturn('master'); final FeatureFlags featureFlags = createFlags('stable');
expect(featureFlags.isLinuxEnabled, false); expect(featureFlags.isLinuxEnabled, false);
}); });
testWithoutContext('Flutter linux desktop enabled with config on master', () { testWithoutContext('Flutter linux desktop enabled with config on master', () {
when(mockFlutterVerion.channel).thenReturn('master'); final FeatureFlags featureFlags = createFlags('master');
testConfig.setValue('enable-linux-desktop', true); testConfig.setValue('enable-linux-desktop', true);
expect(featureFlags.isLinuxEnabled, true); expect(featureFlags.isLinuxEnabled, true);
}); });
testWithoutContext('Flutter linux desktop enabled with environment variable on master', () { testWithoutContext('Flutter linux desktop enabled with environment variable on master', () {
when(mockFlutterVerion.channel).thenReturn('master'); final FeatureFlags featureFlags = createFlags('master');
when(mockPlatform.environment).thenReturn(<String, String>{'FLUTTER_LINUX': 'true'}); platform.environment = <String, String>{'FLUTTER_LINUX': 'true'};
expect(featureFlags.isLinuxEnabled, true); expect(featureFlags.isLinuxEnabled, true);
}); });
testWithoutContext('Flutter linux desktop off by default on dev', () { testWithoutContext('Flutter linux desktop off by default on dev', () {
when(mockFlutterVerion.channel).thenReturn('dev'); final FeatureFlags featureFlags = createFlags('dev');
expect(featureFlags.isLinuxEnabled, false); expect(featureFlags.isLinuxEnabled, false);
}); });
testWithoutContext('Flutter linux desktop enabled with config on dev', () { testWithoutContext('Flutter linux desktop enabled with config on dev', () {
when(mockFlutterVerion.channel).thenReturn('dev'); final FeatureFlags featureFlags = createFlags('dev');
testConfig.setValue('enable-linux-desktop', true); testConfig.setValue('enable-linux-desktop', true);
expect(featureFlags.isLinuxEnabled, true); expect(featureFlags.isLinuxEnabled, true);
}); });
testWithoutContext('Flutter linux desktop enabled with environment variable on dev', () { testWithoutContext('Flutter linux desktop enabled with environment variable on dev', () {
when(mockFlutterVerion.channel).thenReturn('dev'); final FeatureFlags featureFlags = createFlags('dev');
when(mockPlatform.environment).thenReturn(<String, String>{'FLUTTER_LINUX': 'true'}); platform.environment = <String, String>{'FLUTTER_LINUX': 'true'};
expect(featureFlags.isLinuxEnabled, true); expect(featureFlags.isLinuxEnabled, true);
}); });
testWithoutContext('Flutter linux desktop off by default on beta', () { testWithoutContext('Flutter linux desktop off by default on beta', () {
when(mockFlutterVerion.channel).thenReturn('beta'); final FeatureFlags featureFlags = createFlags('beta');
expect(featureFlags.isLinuxEnabled, false); expect(featureFlags.isLinuxEnabled, false);
}); });
testWithoutContext('Flutter linux desktop enabled with config on beta', () { testWithoutContext('Flutter linux desktop enabled with config on beta', () {
when(mockFlutterVerion.channel).thenReturn('beta'); final FeatureFlags featureFlags = createFlags('beta');
testConfig.setValue('enable-linux-desktop', true); testConfig.setValue('enable-linux-desktop', true);
expect(featureFlags.isLinuxEnabled, true); expect(featureFlags.isLinuxEnabled, true);
}); });
testWithoutContext('Flutter linux desktop enabled with environment variable on beta', () { testWithoutContext('Flutter linux desktop enabled with environment variable on beta', () {
when(mockFlutterVerion.channel).thenReturn('beta'); final FeatureFlags featureFlags = createFlags('beta');
when(mockPlatform.environment).thenReturn(<String, String>{'FLUTTER_LINUX': 'true'}); platform.environment = <String, String>{'FLUTTER_LINUX': 'true'};
expect(featureFlags.isLinuxEnabled, true); expect(featureFlags.isLinuxEnabled, true);
}); });
testWithoutContext('Flutter linux desktop off by default on stable', () { testWithoutContext('Flutter linux desktop off by default on stable', () {
when(mockFlutterVerion.channel).thenReturn('stable'); final FeatureFlags featureFlags = createFlags('stable');
expect(featureFlags.isLinuxEnabled, false); expect(featureFlags.isLinuxEnabled, false);
}); });
testWithoutContext('Flutter linux desktop enabled with config on stable', () { testWithoutContext('Flutter linux desktop enabled with config on stable', () {
when(mockFlutterVerion.channel).thenReturn('stable'); final FeatureFlags featureFlags = createFlags('stable');
testConfig.setValue('enable-linux-desktop', true); testConfig.setValue('enable-linux-desktop', true);
expect(featureFlags.isLinuxEnabled, true); expect(featureFlags.isLinuxEnabled, true);
}); });
testWithoutContext('Flutter linux desktop enabled with environment variable on stable', () { testWithoutContext('Flutter linux desktop enabled with environment variable on stable', () {
when(mockFlutterVerion.channel).thenReturn('stable'); final FeatureFlags featureFlags = createFlags('stable');
when(mockPlatform.environment).thenReturn(<String, String>{'FLUTTER_LINUX': 'true'}); platform.environment = <String, String>{'FLUTTER_LINUX': 'true'};
expect(featureFlags.isLinuxEnabled, true); expect(featureFlags.isLinuxEnabled, true);
}); });
/// Flutter Windows desktop. /// Flutter Windows desktop.
testWithoutContext('Flutter Windows desktop off by default on master', () { testWithoutContext('Flutter Windows desktop off by default on master', () {
when(mockFlutterVerion.channel).thenReturn('master'); final FeatureFlags featureFlags = createFlags('master');
expect(featureFlags.isWindowsEnabled, false); expect(featureFlags.isWindowsEnabled, false);
}); });
testWithoutContext('Flutter Windows desktop enabled with config on master', () { testWithoutContext('Flutter Windows desktop enabled with config on master', () {
when(mockFlutterVerion.channel).thenReturn('master'); final FeatureFlags featureFlags = createFlags('master');
testConfig.setValue('enable-windows-desktop', true); testConfig.setValue('enable-windows-desktop', true);
expect(featureFlags.isWindowsEnabled, true); expect(featureFlags.isWindowsEnabled, true);
}); });
testWithoutContext('Flutter Windows desktop enabled with environment variable on master', () { testWithoutContext('Flutter Windows desktop enabled with environment variable on master', () {
when(mockFlutterVerion.channel).thenReturn('master'); final FeatureFlags featureFlags = createFlags('master');
when(mockPlatform.environment).thenReturn(<String, String>{'FLUTTER_WINDOWS': 'true'}); platform.environment = <String, String>{'FLUTTER_WINDOWS': 'true'};
expect(featureFlags.isWindowsEnabled, true); expect(featureFlags.isWindowsEnabled, true);
}); });
testWithoutContext('Flutter Windows desktop off by default on dev', () { testWithoutContext('Flutter Windows desktop off by default on dev', () {
when(mockFlutterVerion.channel).thenReturn('dev'); final FeatureFlags featureFlags = createFlags('dev');
expect(featureFlags.isWindowsEnabled, false); expect(featureFlags.isWindowsEnabled, false);
}); });
testWithoutContext('Flutter Windows desktop enabled with config on dev', () { testWithoutContext('Flutter Windows desktop enabled with config on dev', () {
when(mockFlutterVerion.channel).thenReturn('dev'); final FeatureFlags featureFlags = createFlags('dev');
testConfig.setValue('enable-windows-desktop', true); testConfig.setValue('enable-windows-desktop', true);
expect(featureFlags.isWindowsEnabled, true); expect(featureFlags.isWindowsEnabled, true);
}); });
testWithoutContext('Flutter Windows desktop not enabled with environment variable on dev', () { testWithoutContext('Flutter Windows desktop not enabled with environment variable on dev', () {
when(mockFlutterVerion.channel).thenReturn('dev'); final FeatureFlags featureFlags = createFlags('dev');
when(mockPlatform.environment).thenReturn(<String, String>{'FLUTTER_WINDOWS': 'true'}); platform.environment = <String, String>{'FLUTTER_WINDOWS': 'true'};
expect(featureFlags.isWindowsEnabled, true); expect(featureFlags.isWindowsEnabled, true);
}); });
testWithoutContext('Flutter Windows desktop off by default on beta', () { testWithoutContext('Flutter Windows desktop off by default on beta', () {
when(mockFlutterVerion.channel).thenReturn('beta'); final FeatureFlags featureFlags = createFlags('beta');
expect(featureFlags.isWindowsEnabled, false); expect(featureFlags.isWindowsEnabled, false);
}); });
testWithoutContext('Flutter Windows desktop enabled with config on beta', () { testWithoutContext('Flutter Windows desktop enabled with config on beta', () {
when(mockFlutterVerion.channel).thenReturn('beta'); final FeatureFlags featureFlags = createFlags('beta');
testConfig.setValue('enable-windows-desktop', true); testConfig.setValue('enable-windows-desktop', true);
expect(featureFlags.isWindowsEnabled, true); expect(featureFlags.isWindowsEnabled, true);
}); });
testWithoutContext('Flutter Windows desktop enabled with environment variable on beta', () { testWithoutContext('Flutter Windows desktop enabled with environment variable on beta', () {
when(mockFlutterVerion.channel).thenReturn('beta'); final FeatureFlags featureFlags = createFlags('beta');
when(mockPlatform.environment).thenReturn(<String, String>{'FLUTTER_WINDOWS': 'true'}); platform.environment = <String, String>{'FLUTTER_WINDOWS': 'true'};
expect(featureFlags.isWindowsEnabled, true); expect(featureFlags.isWindowsEnabled, true);
}); });
testWithoutContext('Flutter Windows desktop off by default on stable', () { testWithoutContext('Flutter Windows desktop off by default on stable', () {
when(mockFlutterVerion.channel).thenReturn('stable'); final FeatureFlags featureFlags = createFlags('stable');
expect(featureFlags.isWindowsEnabled, false); expect(featureFlags.isWindowsEnabled, false);
}); });
testWithoutContext('Flutter Windows desktop enabled with config on stable', () { testWithoutContext('Flutter Windows desktop enabled with config on stable', () {
when(mockFlutterVerion.channel).thenReturn('stable'); final FeatureFlags featureFlags = createFlags('stable');
testConfig.setValue('enable-windows-desktop', true); testConfig.setValue('enable-windows-desktop', true);
expect(featureFlags.isWindowsEnabled, true); expect(featureFlags.isWindowsEnabled, true);
}); });
testWithoutContext('Flutter Windows desktop enabled with environment variable on stable', () { testWithoutContext('Flutter Windows desktop enabled with environment variable on stable', () {
when(mockFlutterVerion.channel).thenReturn('stable'); final FeatureFlags featureFlags = createFlags('stable');
when(mockPlatform.environment).thenReturn(<String, String>{'FLUTTER_WINDOWS': 'true'}); platform.environment = <String, String>{'FLUTTER_WINDOWS': 'true'};
expect(featureFlags.isWindowsEnabled, true); expect(featureFlags.isWindowsEnabled, true);
}); });
...@@ -452,34 +456,29 @@ void main() { ...@@ -452,34 +456,29 @@ void main() {
// Windows UWP desktop // Windows UWP desktop
testWithoutContext('Flutter Windows UWP desktop off by default on master', () { testWithoutContext('Flutter Windows UWP desktop off by default on master', () {
when(mockFlutterVerion.channel).thenReturn('master'); final FeatureFlags featureFlags = createFlags('master');
expect(featureFlags.isWindowsUwpEnabled, false); expect(featureFlags.isWindowsUwpEnabled, false);
}); });
testWithoutContext('Flutter Windows UWP desktop enabled with config on master', () { testWithoutContext('Flutter Windows UWP desktop enabled with config on master', () {
when(mockFlutterVerion.channel).thenReturn('master'); final FeatureFlags featureFlags = createFlags('master');
testConfig.setValue('enable-windows-uwp-desktop', true); testConfig.setValue('enable-windows-uwp-desktop', true);
expect(featureFlags.isWindowsUwpEnabled, true); expect(featureFlags.isWindowsUwpEnabled, true);
}); });
testWithoutContext('Flutter Windows UWP desktop off by default on stable', () { testWithoutContext('Flutter Windows UWP desktop off by default on stable', () {
when(mockFlutterVerion.channel).thenReturn('stable'); final FeatureFlags featureFlags = createFlags('stable');
expect(featureFlags.isWindowsUwpEnabled, false); expect(featureFlags.isWindowsUwpEnabled, false);
}); });
testWithoutContext('Flutter Windows UWP desktop not enabled with config on stable', () { testWithoutContext('Flutter Windows UWP desktop not enabled with config on stable', () {
when(mockFlutterVerion.channel).thenReturn('stable'); final FeatureFlags featureFlags = createFlags('stable');
testConfig.setValue('enable-windows-uwp-desktop', true); testConfig.setValue('enable-windows-uwp-desktop', true);
expect(featureFlags.isWindowsUwpEnabled, false); expect(featureFlags.isWindowsUwpEnabled, false);
}); });
}); });
} }
class MockFlutterVerion extends Mock implements FlutterVersion {}
class MockPlatform extends Mock implements Platform {}
T nonconst<T>(T item) => item;
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