[flutter_tools] add tool feature/scaffold for UWP (#77399)

This commit is contained in:
Jonah Williams 2021-03-08 08:09:04 -08:00 committed by GitHub
parent a0ba646408
commit acda272cf2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 198 additions and 54 deletions

View file

@ -111,6 +111,8 @@ class ApplicationPackageFactory {
return applicationBinary == null
? FuchsiaApp.fromFuchsiaProject(FlutterProject.current().fuchsia)
: FuchsiaApp.fromPrebuiltApp(applicationBinary);
case TargetPlatform.windows_uwp_x64:
throw UnsupportedError('Cannot build for windows_uwp_x64');
}
assert(platform != null);
return null;

View file

@ -521,6 +521,9 @@ class CachedArtifacts implements Artifacts {
case TargetPlatform.android:
assert(false, 'cannot use TargetPlatform.android to look up artifacts');
return null;
case TargetPlatform.windows_uwp_x64:
assert(false, 'cannot use TargetPlatform.windows_uwp_x64 to look up artifacts');
return null;
}
assert(false, 'Invalid platform $platform.');
return null;

View file

@ -485,6 +485,7 @@ enum TargetPlatform {
linux_x64,
linux_arm64,
windows_x64,
windows_uwp_x64,
fuchsia_arm64,
fuchsia_x64,
tester,
@ -582,6 +583,8 @@ String getNameForTargetPlatform(TargetPlatform platform, {DarwinArch darwinArch}
return 'linux-arm64';
case TargetPlatform.windows_x64:
return 'windows-x64';
case TargetPlatform.windows_uwp_x64:
return 'windows-uwp-x64';
case TargetPlatform.fuchsia_arm64:
return 'fuchsia-arm64';
case TargetPlatform.fuchsia_x64:

View file

@ -418,6 +418,7 @@ class FlutterDeviceManager extends DeviceManager {
logger: logger,
fileSystem: fileSystem,
windowsWorkflow: windowsWorkflow,
featureFlags: featureFlags,
),
WebDevices(
featureFlags: featureFlags,

View file

@ -54,6 +54,9 @@ abstract class FeatureFlags {
/// Whether the CFE experimental invalidation strategy is enabled.
bool get isExperimentalInvalidationStrategyEnabled => true;
/// Whether the windows UWP embedding is enabled.
bool get isWindowsUwpEnabled => false;
/// Whether a particular feature is enabled for the current channel.
///
/// Prefer using one of the specific getters above instead of this API.
@ -100,6 +103,9 @@ class FlutterFeatureFlags implements FeatureFlags {
@override
bool get isExperimentalInvalidationStrategyEnabled => isEnabled(experimentalInvalidationStrategy);
@override
bool get isWindowsUwpEnabled => isEnabled(windowsUwpEmbedding);
@override
bool isEnabled(Feature feature) {
final String currentChannel = _flutterVersion.channel;
@ -336,6 +342,16 @@ const Feature experimentalInvalidationStrategy = Feature(
),
);
/// The feature for enabling the Windows UWP embeding.
const Feature windowsUwpEmbedding = Feature(
name: 'Flutter for Windows UWP',
configSetting: 'enable-windows-uwp-desktop',
master: FeatureChannelSetting(
available: true,
enabledByDefault: false,
),
);
/// A [Feature] is a process for conditionally enabling tool features.
///
/// All settings are optional, and if not provided will generally default to

View file

@ -1430,6 +1430,7 @@ DevelopmentArtifact _artifactFromTargetPlatform(TargetPlatform targetPlatform) {
case TargetPlatform.fuchsia_arm64:
case TargetPlatform.fuchsia_x64:
case TargetPlatform.tester:
case TargetPlatform.windows_uwp_x64:
// No artifacts currently supported.
return null;
}

View file

@ -7,12 +7,14 @@
import 'package:meta/meta.dart';
import 'package:process/process.dart';
import '../application_package.dart';
import '../base/file_system.dart';
import '../base/logger.dart';
import '../base/os.dart';
import '../build_info.dart';
import '../desktop_device.dart';
import '../device.dart';
import '../features.dart';
import '../project.dart';
import 'application_package.dart';
import 'build_windows.dart';
@ -68,6 +70,59 @@ class WindowsDevice extends DesktopDevice {
}
}
// A device that represents a desktop Windows UWP target.
class WindowsUWPDevice extends DesktopDevice {
WindowsUWPDevice({
@required ProcessManager processManager,
@required Logger logger,
@required FileSystem fileSystem,
@required OperatingSystemUtils operatingSystemUtils,
}) : super(
'windows-uwp',
platformType: PlatformType.windows,
ephemeral: false,
processManager: processManager,
logger: logger,
fileSystem: fileSystem,
operatingSystemUtils: operatingSystemUtils,
);
@override
bool isSupported() => false;
@override
String get name => 'Windows (UWP)';
@override
Future<TargetPlatform> get targetPlatform async => TargetPlatform.windows_uwp_x64;
@override
bool isSupportedForProject(FlutterProject flutterProject) {
// TODO(flutter): update with detection once FlutterProject knows
// about the UWP structure.
return false;
}
@override
Future<void> buildForDevice(
covariant WindowsApp package, {
String mainPath,
BuildInfo buildInfo,
}) async {
await buildWindows(
FlutterProject.current().windows,
buildInfo,
target: mainPath,
);
}
@override
String executablePathForDevice(ApplicationPackage package, BuildMode buildMode) {
// TODO(flutter): update once application package factory knows about UWP bundle.
throw UnsupportedError('Windows UWP device not implemented.');
}
}
class WindowsDevices extends PollingDeviceDiscovery {
WindowsDevices({
@required ProcessManager processManager,
@ -75,11 +130,13 @@ class WindowsDevices extends PollingDeviceDiscovery {
@required FileSystem fileSystem,
@required OperatingSystemUtils operatingSystemUtils,
@required WindowsWorkflow windowsWorkflow,
@required FeatureFlags featureFlags,
}) : _fileSystem = fileSystem,
_logger = logger,
_processManager = processManager,
_operatingSystemUtils = operatingSystemUtils,
_windowsWorkflow = windowsWorkflow,
_featureFlags = featureFlags,
super('windows devices');
final FileSystem _fileSystem;
@ -87,6 +144,7 @@ class WindowsDevices extends PollingDeviceDiscovery {
final ProcessManager _processManager;
final OperatingSystemUtils _operatingSystemUtils;
final WindowsWorkflow _windowsWorkflow;
final FeatureFlags _featureFlags;
@override
bool get supportsPlatform => _windowsWorkflow.appliesToHostPlatform;
@ -106,6 +164,13 @@ class WindowsDevices extends PollingDeviceDiscovery {
processManager: _processManager,
operatingSystemUtils: _operatingSystemUtils,
),
if (_featureFlags.isWindowsUwpEnabled)
WindowsUWPDevice(
fileSystem: _fileSystem,
logger: _logger,
processManager: _processManager,
operatingSystemUtils: _operatingSystemUtils,
)
];
}

View file

@ -81,27 +81,27 @@ void main() {
expect(featureFlags.isWebEnabled, true);
});
testWithoutContext('flutter web help string', () {
testWithoutContext('Flutter web help string', () {
expect(flutterWebFeature.generateHelpMessage(),
'Enable or disable Flutter for web. '
'This setting will take effect on the master, dev, beta, and stable channels.');
});
testWithoutContext('flutter macOS desktop help string', () {
testWithoutContext('Flutter macOS desktop help string', () {
expect(flutterMacOSDesktopFeature.generateHelpMessage(),
'Enable or disable beta-quality support for desktop on macOS. '
'This setting will take effect on the master, dev, beta, and stable channels. '
'Newer beta versions are available on the beta channel.');
});
testWithoutContext('flutter Linux desktop help string', () {
testWithoutContext('Flutter Linux desktop help string', () {
expect(flutterLinuxDesktopFeature.generateHelpMessage(),
'Enable or disable beta-quality support for desktop on Linux. '
'This setting will take effect on the master, dev, beta, and stable channels. '
'Newer beta versions are available on the beta channel.');
});
testWithoutContext('flutter Windows desktop help string', () {
testWithoutContext('Flutter Windows desktop help string', () {
expect(flutterWindowsDesktopFeature.generateHelpMessage(),
'Enable or disable beta-quality support for desktop on Windows. '
'This setting will take effect on the master, dev, beta, and stable channels. '
@ -124,81 +124,81 @@ void main() {
/// Flutter Web
testWithoutContext('flutter web off by default on master', () {
testWithoutContext('Flutter web off by default on master', () {
when(mockFlutterVerion.channel).thenReturn('master');
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');
testConfig.setValue('enable-web', 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');
when(mockPlatform.environment).thenReturn(<String, String>{'FLUTTER_WEB': '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');
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');
testConfig.setValue('enable-web', 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');
when(mockPlatform.environment).thenReturn(<String, String>{'FLUTTER_WEB': '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');
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');
testConfig.setValue('enable-web', 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');
when(mockPlatform.environment).thenReturn(<String, String>{'FLUTTER_WEB': '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');
testConfig.removeValue('enable-web');
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');
testConfig.setValue('enable-web', 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');
when(mockPlatform.environment).thenReturn(<String, String>{'FLUTTER_WEB': 'enabled'});
@ -207,80 +207,80 @@ void main() {
/// 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');
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');
testConfig.setValue('enable-macos-desktop', 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');
when(mockPlatform.environment).thenReturn(<String, String>{'FLUTTER_MACOS': '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');
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');
testConfig.setValue('enable-macos-desktop', 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');
when(mockPlatform.environment).thenReturn(<String, String>{'FLUTTER_MACOS': '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');
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');
testConfig.setValue('enable-macos-desktop', 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');
when(mockPlatform.environment).thenReturn(<String, String>{'FLUTTER_MACOS': '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');
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');
testConfig.setValue('enable-macos-desktop', 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');
when(mockPlatform.environment).thenReturn(<String, String>{'FLUTTER_MACOS': 'true'});
@ -288,80 +288,80 @@ void main() {
});
/// 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');
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');
testConfig.setValue('enable-linux-desktop', 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');
when(mockPlatform.environment).thenReturn(<String, String>{'FLUTTER_LINUX': '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');
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');
testConfig.setValue('enable-linux-desktop', 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');
when(mockPlatform.environment).thenReturn(<String, String>{'FLUTTER_LINUX': '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');
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');
testConfig.setValue('enable-linux-desktop', 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');
when(mockPlatform.environment).thenReturn(<String, String>{'FLUTTER_LINUX': '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');
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');
testConfig.setValue('enable-linux-desktop', 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');
when(mockPlatform.environment).thenReturn(<String, String>{'FLUTTER_LINUX': 'true'});
@ -369,85 +369,113 @@ void main() {
});
/// 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');
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');
testConfig.setValue('enable-windows-desktop', 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');
when(mockPlatform.environment).thenReturn(<String, String>{'FLUTTER_WINDOWS': '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');
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');
testConfig.setValue('enable-windows-desktop', 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');
when(mockPlatform.environment).thenReturn(<String, String>{'FLUTTER_WINDOWS': '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');
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');
testConfig.setValue('enable-windows-desktop', 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');
when(mockPlatform.environment).thenReturn(<String, String>{'FLUTTER_WINDOWS': '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');
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');
testConfig.setValue('enable-windows-desktop', 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');
when(mockPlatform.environment).thenReturn(<String, String>{'FLUTTER_WINDOWS': 'true'});
expect(featureFlags.isWindowsEnabled, true);
});
// Windows UWP desktop
testWithoutContext('Flutter Windows UWP desktop off by default on master', () {
when(mockFlutterVerion.channel).thenReturn('master');
expect(featureFlags.isWindowsUwpEnabled, false);
});
testWithoutContext('Flutter Windows UWP desktop enabled with config on master', () {
when(mockFlutterVerion.channel).thenReturn('master');
testConfig.setValue('enable-windows-uwp-desktop', true);
expect(featureFlags.isWindowsUwpEnabled, true);
});
testWithoutContext('Flutter Windows UWP desktop off by default on stable', () {
when(mockFlutterVerion.channel).thenReturn('stable');
expect(featureFlags.isWindowsUwpEnabled, false);
});
testWithoutContext('Flutter Windows UWP desktop not enabled with config on stable', () {
when(mockFlutterVerion.channel).thenReturn('stable');
testConfig.setValue('enable-windows-uwp-desktop', true);
expect(featureFlags.isWindowsUwpEnabled, false);
});
});
}

View file

@ -10,6 +10,7 @@ import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/build_info.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/windows/application_package.dart';
import 'package:flutter_tools/src/windows/windows_device.dart';
@ -43,8 +44,9 @@ void main() {
expect(await WindowsDevices(
windowsWorkflow: WindowsWorkflow(
featureFlags: TestFeatureFlags(isWindowsEnabled: false),
platform: FakePlatform(operatingSystem: 'windows')
platform: FakePlatform(operatingSystem: 'windows'),
),
featureFlags: TestFeatureFlags(isWindowsEnabled: false),
operatingSystemUtils: FakeOperatingSystemUtils(),
logger: BufferLogger.test(),
processManager: FakeProcessManager.any(),
@ -62,9 +64,25 @@ void main() {
logger: BufferLogger.test(),
processManager: FakeProcessManager.any(),
fileSystem: MemoryFileSystem.test(),
featureFlags: TestFeatureFlags(isWindowsEnabled: true),
).devices, hasLength(1));
});
testWithoutContext('WindowsDevices lists a UWP Windows device if feature is enabled', () async {
final FeatureFlags featureFlags = TestFeatureFlags(isWindowsEnabled: true, isWindowsUwpEnabled: true);
expect(await WindowsDevices(
windowsWorkflow: WindowsWorkflow(
featureFlags: featureFlags,
platform: FakePlatform(operatingSystem: 'windows')
),
operatingSystemUtils: FakeOperatingSystemUtils(),
logger: BufferLogger.test(),
processManager: FakeProcessManager.any(),
fileSystem: MemoryFileSystem.test(),
featureFlags: featureFlags,
).devices, hasLength(2));
});
testWithoutContext('WindowsDevices ignores the timeout provided to discoverDevices', () async {
final WindowsDevices windowsDevices = WindowsDevices(
windowsWorkflow: WindowsWorkflow(
@ -75,6 +93,7 @@ void main() {
logger: BufferLogger.test(),
processManager: FakeProcessManager.any(),
fileSystem: MemoryFileSystem.test(),
featureFlags: TestFeatureFlags(isWindowsEnabled: true),
);
// Timeout ignored.
final List<Device> devices = await windowsDevices.discoverDevices(timeout: const Duration(seconds: 10));

View file

@ -552,6 +552,7 @@ class TestFeatureFlags implements FeatureFlags {
this.isIOSEnabled = true,
this.isFuchsiaEnabled = false,
this.isExperimentalInvalidationStrategyEnabled = false,
this.isWindowsUwpEnabled = false,
});
@override
@ -581,6 +582,9 @@ class TestFeatureFlags implements FeatureFlags {
@override
final bool isExperimentalInvalidationStrategyEnabled;
@override
final bool isWindowsUwpEnabled;
@override
bool isEnabled(Feature feature) {
switch (feature) {
@ -602,6 +606,8 @@ class TestFeatureFlags implements FeatureFlags {
return isFuchsiaEnabled;
case experimentalInvalidationStrategy:
return isExperimentalInvalidationStrategyEnabled;
case windowsUwpEmbedding:
return isWindowsUwpEnabled;
}
return false;
}