mirror of
https://github.com/flutter/packages.git
synced 2025-06-06 03:19:27 +08:00
[flutter_plugin_tool] Add support for building UWP plugins (#4047)
This allows building UWP plugin examples with `build-examples --winuwp`. As with previous pre-stable-template desktop support, this avoids the issue of unstable app templates by running `flutter create` on the fly before trying to build, so a template that will bitrot doesn't need to be checked in. Also adds no-op "support" for `drive-examples --winuwp`, with warnings about it not doing anything. This is to handle the fact that the LUCI recipe is shared between Win32 and UWP, and didn't conditionalize `drive`. Rather than change that, then change it back later, this just adds the no-op support now (since changing the tooling is much easier than changing LUCI recipes currently). This required some supporting tool changes: - Adds the ability to check for the new platform variants in a pubspec - Adds the ability to write test pubspecs that include variants, for testing Part of https://github.com/flutter/flutter/issues/82817
This commit is contained in:
@ -4,6 +4,7 @@
|
|||||||
- Added a new `android-lint` command to lint Android plugin native code.
|
- Added a new `android-lint` command to lint Android plugin native code.
|
||||||
- Pubspec validation now checks for `implements` in implementation packages.
|
- Pubspec validation now checks for `implements` in implementation packages.
|
||||||
- Pubspec valitation now checks the full relative path of `repository` entries.
|
- Pubspec valitation now checks the full relative path of `repository` entries.
|
||||||
|
- `build-examples` now supports UWP plugins via a `--winuwp` flag.
|
||||||
|
|
||||||
## 0.5.0
|
## 0.5.0
|
||||||
|
|
||||||
|
@ -16,7 +16,16 @@ import 'common/repository_package.dart';
|
|||||||
/// Key for APK.
|
/// Key for APK.
|
||||||
const String _platformFlagApk = 'apk';
|
const String _platformFlagApk = 'apk';
|
||||||
|
|
||||||
const int _exitNoPlatformFlags = 2;
|
const int _exitNoPlatformFlags = 3;
|
||||||
|
|
||||||
|
// Flutter build types. These are the values passed to `flutter build <foo>`.
|
||||||
|
const String _flutterBuildTypeAndroid = 'apk';
|
||||||
|
const String _flutterBuildTypeIos = 'ios';
|
||||||
|
const String _flutterBuildTypeLinux = 'linux';
|
||||||
|
const String _flutterBuildTypeMacOS = 'macos';
|
||||||
|
const String _flutterBuildTypeWeb = 'web';
|
||||||
|
const String _flutterBuildTypeWin32 = 'windows';
|
||||||
|
const String _flutterBuildTypeWinUwp = 'winuwp';
|
||||||
|
|
||||||
/// A command to build the example applications for packages.
|
/// A command to build the example applications for packages.
|
||||||
class BuildExamplesCommand extends PackageLoopingCommand {
|
class BuildExamplesCommand extends PackageLoopingCommand {
|
||||||
@ -30,6 +39,7 @@ class BuildExamplesCommand extends PackageLoopingCommand {
|
|||||||
argParser.addFlag(kPlatformMacos);
|
argParser.addFlag(kPlatformMacos);
|
||||||
argParser.addFlag(kPlatformWeb);
|
argParser.addFlag(kPlatformWeb);
|
||||||
argParser.addFlag(kPlatformWindows);
|
argParser.addFlag(kPlatformWindows);
|
||||||
|
argParser.addFlag(kPlatformWinUwp);
|
||||||
argParser.addFlag(kPlatformIos);
|
argParser.addFlag(kPlatformIos);
|
||||||
argParser.addFlag(_platformFlagApk);
|
argParser.addFlag(_platformFlagApk);
|
||||||
argParser.addOption(
|
argParser.addOption(
|
||||||
@ -46,33 +56,40 @@ class BuildExamplesCommand extends PackageLoopingCommand {
|
|||||||
_platformFlagApk: const _PlatformDetails(
|
_platformFlagApk: const _PlatformDetails(
|
||||||
'Android',
|
'Android',
|
||||||
pluginPlatform: kPlatformAndroid,
|
pluginPlatform: kPlatformAndroid,
|
||||||
flutterBuildType: 'apk',
|
flutterBuildType: _flutterBuildTypeAndroid,
|
||||||
),
|
),
|
||||||
kPlatformIos: const _PlatformDetails(
|
kPlatformIos: const _PlatformDetails(
|
||||||
'iOS',
|
'iOS',
|
||||||
pluginPlatform: kPlatformIos,
|
pluginPlatform: kPlatformIos,
|
||||||
flutterBuildType: 'ios',
|
flutterBuildType: _flutterBuildTypeIos,
|
||||||
extraBuildFlags: <String>['--no-codesign'],
|
extraBuildFlags: <String>['--no-codesign'],
|
||||||
),
|
),
|
||||||
kPlatformLinux: const _PlatformDetails(
|
kPlatformLinux: const _PlatformDetails(
|
||||||
'Linux',
|
'Linux',
|
||||||
pluginPlatform: kPlatformLinux,
|
pluginPlatform: kPlatformLinux,
|
||||||
flutterBuildType: 'linux',
|
flutterBuildType: _flutterBuildTypeLinux,
|
||||||
),
|
),
|
||||||
kPlatformMacos: const _PlatformDetails(
|
kPlatformMacos: const _PlatformDetails(
|
||||||
'macOS',
|
'macOS',
|
||||||
pluginPlatform: kPlatformMacos,
|
pluginPlatform: kPlatformMacos,
|
||||||
flutterBuildType: 'macos',
|
flutterBuildType: _flutterBuildTypeMacOS,
|
||||||
),
|
),
|
||||||
kPlatformWeb: const _PlatformDetails(
|
kPlatformWeb: const _PlatformDetails(
|
||||||
'web',
|
'web',
|
||||||
pluginPlatform: kPlatformWeb,
|
pluginPlatform: kPlatformWeb,
|
||||||
flutterBuildType: 'web',
|
flutterBuildType: _flutterBuildTypeWeb,
|
||||||
),
|
),
|
||||||
kPlatformWindows: const _PlatformDetails(
|
kPlatformWindows: const _PlatformDetails(
|
||||||
'Windows',
|
'Win32',
|
||||||
pluginPlatform: kPlatformWindows,
|
pluginPlatform: kPlatformWindows,
|
||||||
flutterBuildType: 'windows',
|
pluginPlatformVariant: platformVariantWin32,
|
||||||
|
flutterBuildType: _flutterBuildTypeWin32,
|
||||||
|
),
|
||||||
|
kPlatformWinUwp: const _PlatformDetails(
|
||||||
|
'UWP',
|
||||||
|
pluginPlatform: kPlatformWindows,
|
||||||
|
pluginPlatformVariant: platformVariantWinUwp,
|
||||||
|
flutterBuildType: _flutterBuildTypeWinUwp,
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -107,7 +124,8 @@ class BuildExamplesCommand extends PackageLoopingCommand {
|
|||||||
final Set<_PlatformDetails> buildPlatforms = <_PlatformDetails>{};
|
final Set<_PlatformDetails> buildPlatforms = <_PlatformDetails>{};
|
||||||
final Set<_PlatformDetails> unsupportedPlatforms = <_PlatformDetails>{};
|
final Set<_PlatformDetails> unsupportedPlatforms = <_PlatformDetails>{};
|
||||||
for (final _PlatformDetails platform in requestedPlatforms) {
|
for (final _PlatformDetails platform in requestedPlatforms) {
|
||||||
if (pluginSupportsPlatform(platform.pluginPlatform, package)) {
|
if (pluginSupportsPlatform(platform.pluginPlatform, package,
|
||||||
|
variant: platform.pluginPlatformVariant)) {
|
||||||
buildPlatforms.add(platform);
|
buildPlatforms.add(platform);
|
||||||
} else {
|
} else {
|
||||||
unsupportedPlatforms.add(platform);
|
unsupportedPlatforms.add(platform);
|
||||||
@ -156,6 +174,22 @@ class BuildExamplesCommand extends PackageLoopingCommand {
|
|||||||
}) async {
|
}) async {
|
||||||
final String enableExperiment = getStringArg(kEnableExperiment);
|
final String enableExperiment = getStringArg(kEnableExperiment);
|
||||||
|
|
||||||
|
// The UWP template is not yet stable, so the UWP directory
|
||||||
|
// needs to be created on the fly with 'flutter create .'
|
||||||
|
Directory? temporaryPlatformDirectory;
|
||||||
|
if (flutterBuildType == _flutterBuildTypeWinUwp) {
|
||||||
|
final Directory uwpDirectory = example.directory.childDirectory('winuwp');
|
||||||
|
if (!uwpDirectory.existsSync()) {
|
||||||
|
print('Creating temporary winuwp folder');
|
||||||
|
final int exitCode = await processRunner.runAndStream(flutterCommand,
|
||||||
|
<String>['create', '--platforms=$kPlatformWinUwp', '.'],
|
||||||
|
workingDir: example.directory);
|
||||||
|
if (exitCode == 0) {
|
||||||
|
temporaryPlatformDirectory = uwpDirectory;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
final int exitCode = await processRunner.runAndStream(
|
final int exitCode = await processRunner.runAndStream(
|
||||||
flutterCommand,
|
flutterCommand,
|
||||||
<String>[
|
<String>[
|
||||||
@ -167,6 +201,13 @@ class BuildExamplesCommand extends PackageLoopingCommand {
|
|||||||
],
|
],
|
||||||
workingDir: example.directory,
|
workingDir: example.directory,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (temporaryPlatformDirectory != null &&
|
||||||
|
temporaryPlatformDirectory.existsSync()) {
|
||||||
|
print('Cleaning up ${temporaryPlatformDirectory.path}');
|
||||||
|
temporaryPlatformDirectory.deleteSync(recursive: true);
|
||||||
|
}
|
||||||
|
|
||||||
return exitCode == 0;
|
return exitCode == 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -176,6 +217,7 @@ class _PlatformDetails {
|
|||||||
const _PlatformDetails(
|
const _PlatformDetails(
|
||||||
this.label, {
|
this.label, {
|
||||||
required this.pluginPlatform,
|
required this.pluginPlatform,
|
||||||
|
this.pluginPlatformVariant,
|
||||||
required this.flutterBuildType,
|
required this.flutterBuildType,
|
||||||
this.extraBuildFlags = const <String>[],
|
this.extraBuildFlags = const <String>[],
|
||||||
});
|
});
|
||||||
@ -186,6 +228,10 @@ class _PlatformDetails {
|
|||||||
/// The key in a pubspec's platform: entry.
|
/// The key in a pubspec's platform: entry.
|
||||||
final String pluginPlatform;
|
final String pluginPlatform;
|
||||||
|
|
||||||
|
/// The supportedVariants key under a plugin's [pluginPlatform] entry, if
|
||||||
|
/// applicable.
|
||||||
|
final String? pluginPlatformVariant;
|
||||||
|
|
||||||
/// The `flutter build` build type.
|
/// The `flutter build` build type.
|
||||||
final String flutterBuildType;
|
final String flutterBuildType;
|
||||||
|
|
||||||
|
@ -10,24 +10,43 @@ import 'package:yaml/yaml.dart';
|
|||||||
/// print destination.
|
/// print destination.
|
||||||
typedef Print = void Function(Object? object);
|
typedef Print = void Function(Object? object);
|
||||||
|
|
||||||
/// Key for windows platform.
|
/// Key for APK (Android) platform.
|
||||||
const String kPlatformWindows = 'windows';
|
const String kPlatformAndroid = 'android';
|
||||||
|
|
||||||
/// Key for macos platform.
|
|
||||||
const String kPlatformMacos = 'macos';
|
|
||||||
|
|
||||||
/// Key for linux platform.
|
|
||||||
const String kPlatformLinux = 'linux';
|
|
||||||
|
|
||||||
/// Key for IPA (iOS) platform.
|
/// Key for IPA (iOS) platform.
|
||||||
const String kPlatformIos = 'ios';
|
const String kPlatformIos = 'ios';
|
||||||
|
|
||||||
/// Key for APK (Android) platform.
|
/// Key for linux platform.
|
||||||
const String kPlatformAndroid = 'android';
|
const String kPlatformLinux = 'linux';
|
||||||
|
|
||||||
|
/// Key for macos platform.
|
||||||
|
const String kPlatformMacos = 'macos';
|
||||||
|
|
||||||
/// Key for Web platform.
|
/// Key for Web platform.
|
||||||
const String kPlatformWeb = 'web';
|
const String kPlatformWeb = 'web';
|
||||||
|
|
||||||
|
/// Key for windows platform.
|
||||||
|
///
|
||||||
|
/// Note that this corresponds to the Win32 variant for flutter commands like
|
||||||
|
/// `build` and `run`, but is a general platform containing all Windows
|
||||||
|
/// variants for purposes of the `platform` section of a plugin pubspec).
|
||||||
|
const String kPlatformWindows = 'windows';
|
||||||
|
|
||||||
|
/// Key for WinUWP platform.
|
||||||
|
///
|
||||||
|
/// Note that UWP is a platform for the purposes of flutter commands like
|
||||||
|
/// `build` and `run`, but a variant of the `windows` platform for the purposes
|
||||||
|
/// of plugin pubspecs).
|
||||||
|
const String kPlatformWinUwp = 'winuwp';
|
||||||
|
|
||||||
|
/// Key for Win32 variant of the Windows platform.
|
||||||
|
const String platformVariantWin32 = 'win32';
|
||||||
|
|
||||||
|
/// Key for UWP variant of the Windows platform.
|
||||||
|
///
|
||||||
|
/// See the note on [kPlatformWinUwp].
|
||||||
|
const String platformVariantWinUwp = 'uwp';
|
||||||
|
|
||||||
/// Key for enable experiment.
|
/// Key for enable experiment.
|
||||||
const String kEnableExperiment = 'enable-experiment';
|
const String kEnableExperiment = 'enable-experiment';
|
||||||
|
|
||||||
|
@ -28,8 +28,12 @@ enum PlatformSupport {
|
|||||||
///
|
///
|
||||||
/// If [requiredMode] is provided, the plugin must have the given type of
|
/// If [requiredMode] is provided, the plugin must have the given type of
|
||||||
/// implementation in order to return true.
|
/// implementation in order to return true.
|
||||||
bool pluginSupportsPlatform(String platform, RepositoryPackage package,
|
bool pluginSupportsPlatform(
|
||||||
{PlatformSupport? requiredMode}) {
|
String platform,
|
||||||
|
RepositoryPackage package, {
|
||||||
|
PlatformSupport? requiredMode,
|
||||||
|
String? variant,
|
||||||
|
}) {
|
||||||
assert(platform == kPlatformIos ||
|
assert(platform == kPlatformIos ||
|
||||||
platform == kPlatformAndroid ||
|
platform == kPlatformAndroid ||
|
||||||
platform == kPlatformWeb ||
|
platform == kPlatformWeb ||
|
||||||
@ -65,9 +69,34 @@ bool pluginSupportsPlatform(String platform, RepositoryPackage package,
|
|||||||
}
|
}
|
||||||
// If the platform entry is present, then it supports the platform. Check
|
// If the platform entry is present, then it supports the platform. Check
|
||||||
// for required mode if specified.
|
// for required mode if specified.
|
||||||
|
if (requiredMode != null) {
|
||||||
final bool federated = platformEntry.containsKey('default_package');
|
final bool federated = platformEntry.containsKey('default_package');
|
||||||
return requiredMode == null ||
|
if (federated != (requiredMode == PlatformSupport.federated)) {
|
||||||
federated == (requiredMode == PlatformSupport.federated);
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If a variant is specified, check for that variant.
|
||||||
|
if (variant != null) {
|
||||||
|
const String variantsKey = 'supportedVariants';
|
||||||
|
if (platformEntry.containsKey(variantsKey)) {
|
||||||
|
if (!(platformEntry['supportedVariants']! as YamlList)
|
||||||
|
.contains(variant)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Platforms with variants have a default variant when unspecified for
|
||||||
|
// backward compatibility. Must match the flutter tool logic.
|
||||||
|
const Map<String, String> defaultVariants = <String, String>{
|
||||||
|
kPlatformWindows: platformVariantWin32,
|
||||||
|
};
|
||||||
|
if (variant != defaultVariants[platform]) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
} on FileSystemException {
|
} on FileSystemException {
|
||||||
return false;
|
return false;
|
||||||
} on YamlException {
|
} on YamlException {
|
||||||
|
@ -36,7 +36,10 @@ class DriveExamplesCommand extends PackageLoopingCommand {
|
|||||||
argParser.addFlag(kPlatformWeb,
|
argParser.addFlag(kPlatformWeb,
|
||||||
help: 'Runs the web implementation of the examples');
|
help: 'Runs the web implementation of the examples');
|
||||||
argParser.addFlag(kPlatformWindows,
|
argParser.addFlag(kPlatformWindows,
|
||||||
help: 'Runs the Windows implementation of the examples');
|
help: 'Runs the Windows (Win32) implementation of the examples');
|
||||||
|
argParser.addFlag(kPlatformWinUwp,
|
||||||
|
help:
|
||||||
|
'Runs the UWP implementation of the examples [currently a no-op]');
|
||||||
argParser.addOption(
|
argParser.addOption(
|
||||||
kEnableExperiment,
|
kEnableExperiment,
|
||||||
defaultsTo: '',
|
defaultsTo: '',
|
||||||
@ -67,6 +70,7 @@ class DriveExamplesCommand extends PackageLoopingCommand {
|
|||||||
kPlatformMacos,
|
kPlatformMacos,
|
||||||
kPlatformWeb,
|
kPlatformWeb,
|
||||||
kPlatformWindows,
|
kPlatformWindows,
|
||||||
|
kPlatformWinUwp,
|
||||||
];
|
];
|
||||||
final int platformCount = platformSwitches
|
final int platformCount = platformSwitches
|
||||||
.where((String platform) => getBoolArg(platform))
|
.where((String platform) => getBoolArg(platform))
|
||||||
@ -81,6 +85,10 @@ class DriveExamplesCommand extends PackageLoopingCommand {
|
|||||||
throw ToolExit(_exitNoPlatformFlags);
|
throw ToolExit(_exitNoPlatformFlags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (getBoolArg(kPlatformWinUwp)) {
|
||||||
|
logWarning('Driving UWP applications is not yet supported');
|
||||||
|
}
|
||||||
|
|
||||||
String? androidDevice;
|
String? androidDevice;
|
||||||
if (getBoolArg(kPlatformAndroid)) {
|
if (getBoolArg(kPlatformAndroid)) {
|
||||||
final List<String> devices = await _getDevicesForPlatform('android');
|
final List<String> devices = await _getDevicesForPlatform('android');
|
||||||
@ -116,6 +124,10 @@ class DriveExamplesCommand extends PackageLoopingCommand {
|
|||||||
],
|
],
|
||||||
if (getBoolArg(kPlatformWindows))
|
if (getBoolArg(kPlatformWindows))
|
||||||
kPlatformWindows: <String>['-d', 'windows'],
|
kPlatformWindows: <String>['-d', 'windows'],
|
||||||
|
// TODO(stuartmorgan): Check these flags once drive supports UWP:
|
||||||
|
// https://github.com/flutter/flutter/issues/82821
|
||||||
|
if (getBoolArg(kPlatformWinUwp))
|
||||||
|
kPlatformWinUwp: <String>['-d', 'winuwp'],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,7 +144,17 @@ class DriveExamplesCommand extends PackageLoopingCommand {
|
|||||||
final List<String> deviceFlags = <String>[];
|
final List<String> deviceFlags = <String>[];
|
||||||
for (final MapEntry<String, List<String>> entry
|
for (final MapEntry<String, List<String>> entry
|
||||||
in _targetDeviceFlags.entries) {
|
in _targetDeviceFlags.entries) {
|
||||||
if (pluginSupportsPlatform(entry.key, package)) {
|
final String platform = entry.key;
|
||||||
|
String? variant;
|
||||||
|
if (platform == kPlatformWindows) {
|
||||||
|
variant = platformVariantWin32;
|
||||||
|
} else if (platform == kPlatformWinUwp) {
|
||||||
|
variant = platformVariantWinUwp;
|
||||||
|
// TODO(stuartmorgan): Remove this once drive supports UWP.
|
||||||
|
// https://github.com/flutter/flutter/issues/82821
|
||||||
|
return PackageResult.skip('Drive does not yet support UWP');
|
||||||
|
}
|
||||||
|
if (pluginSupportsPlatform(platform, package, variant: variant)) {
|
||||||
deviceFlags.addAll(entry.value);
|
deviceFlags.addAll(entry.value);
|
||||||
} else {
|
} else {
|
||||||
print('Skipping unsupported platform ${entry.key}...');
|
print('Skipping unsupported platform ${entry.key}...');
|
||||||
|
@ -56,8 +56,8 @@ void main() {
|
|||||||
|
|
||||||
test('fails if building fails', () async {
|
test('fails if building fails', () async {
|
||||||
createFakePlugin('plugin', packagesDir,
|
createFakePlugin('plugin', packagesDir,
|
||||||
platformSupport: <String, PlatformSupport>{
|
platformSupport: <String, PlatformDetails>{
|
||||||
kPlatformIos: PlatformSupport.inline
|
kPlatformIos: const PlatformDetails(PlatformSupport.inline),
|
||||||
});
|
});
|
||||||
|
|
||||||
processRunner
|
processRunner
|
||||||
@ -106,8 +106,8 @@ void main() {
|
|||||||
test('building for iOS', () async {
|
test('building for iOS', () async {
|
||||||
mockPlatform.isMacOS = true;
|
mockPlatform.isMacOS = true;
|
||||||
final Directory pluginDirectory = createFakePlugin('plugin', packagesDir,
|
final Directory pluginDirectory = createFakePlugin('plugin', packagesDir,
|
||||||
platformSupport: <String, PlatformSupport>{
|
platformSupport: <String, PlatformDetails>{
|
||||||
kPlatformIos: PlatformSupport.inline
|
kPlatformIos: const PlatformDetails(PlatformSupport.inline),
|
||||||
});
|
});
|
||||||
|
|
||||||
final Directory pluginExampleDirectory =
|
final Directory pluginExampleDirectory =
|
||||||
@ -163,8 +163,8 @@ void main() {
|
|||||||
test('building for Linux', () async {
|
test('building for Linux', () async {
|
||||||
mockPlatform.isLinux = true;
|
mockPlatform.isLinux = true;
|
||||||
final Directory pluginDirectory = createFakePlugin('plugin', packagesDir,
|
final Directory pluginDirectory = createFakePlugin('plugin', packagesDir,
|
||||||
platformSupport: <String, PlatformSupport>{
|
platformSupport: <String, PlatformDetails>{
|
||||||
kPlatformLinux: PlatformSupport.inline,
|
kPlatformLinux: const PlatformDetails(PlatformSupport.inline),
|
||||||
});
|
});
|
||||||
|
|
||||||
final Directory pluginExampleDirectory =
|
final Directory pluginExampleDirectory =
|
||||||
@ -212,8 +212,8 @@ void main() {
|
|||||||
test('building for macOS', () async {
|
test('building for macOS', () async {
|
||||||
mockPlatform.isMacOS = true;
|
mockPlatform.isMacOS = true;
|
||||||
final Directory pluginDirectory = createFakePlugin('plugin', packagesDir,
|
final Directory pluginDirectory = createFakePlugin('plugin', packagesDir,
|
||||||
platformSupport: <String, PlatformSupport>{
|
platformSupport: <String, PlatformDetails>{
|
||||||
kPlatformMacos: PlatformSupport.inline,
|
kPlatformMacos: const PlatformDetails(PlatformSupport.inline),
|
||||||
});
|
});
|
||||||
|
|
||||||
final Directory pluginExampleDirectory =
|
final Directory pluginExampleDirectory =
|
||||||
@ -258,8 +258,8 @@ void main() {
|
|||||||
|
|
||||||
test('building for web', () async {
|
test('building for web', () async {
|
||||||
final Directory pluginDirectory = createFakePlugin('plugin', packagesDir,
|
final Directory pluginDirectory = createFakePlugin('plugin', packagesDir,
|
||||||
platformSupport: <String, PlatformSupport>{
|
platformSupport: <String, PlatformDetails>{
|
||||||
kPlatformWeb: PlatformSupport.inline,
|
kPlatformWeb: const PlatformDetails(PlatformSupport.inline),
|
||||||
});
|
});
|
||||||
|
|
||||||
final Directory pluginExampleDirectory =
|
final Directory pluginExampleDirectory =
|
||||||
@ -284,7 +284,7 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test(
|
test(
|
||||||
'building for Windows when plugin is not set up for Windows results in no-op',
|
'building for win32 when plugin is not set up for Windows results in no-op',
|
||||||
() async {
|
() async {
|
||||||
mockPlatform.isWindows = true;
|
mockPlatform.isWindows = true;
|
||||||
createFakePlugin('plugin', packagesDir);
|
createFakePlugin('plugin', packagesDir);
|
||||||
@ -296,7 +296,7 @@ void main() {
|
|||||||
output,
|
output,
|
||||||
containsAllInOrder(<Matcher>[
|
containsAllInOrder(<Matcher>[
|
||||||
contains('Running for plugin'),
|
contains('Running for plugin'),
|
||||||
contains('Windows is not supported by this plugin'),
|
contains('Win32 is not supported by this plugin'),
|
||||||
]),
|
]),
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -305,11 +305,11 @@ void main() {
|
|||||||
expect(processRunner.recordedCalls, orderedEquals(<ProcessCall>[]));
|
expect(processRunner.recordedCalls, orderedEquals(<ProcessCall>[]));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('building for Windows', () async {
|
test('building for win32', () async {
|
||||||
mockPlatform.isWindows = true;
|
mockPlatform.isWindows = true;
|
||||||
final Directory pluginDirectory = createFakePlugin('plugin', packagesDir,
|
final Directory pluginDirectory = createFakePlugin('plugin', packagesDir,
|
||||||
platformSupport: <String, PlatformSupport>{
|
platformSupport: <String, PlatformDetails>{
|
||||||
kPlatformWindows: PlatformSupport.inline
|
kPlatformWindows: const PlatformDetails(PlatformSupport.inline),
|
||||||
});
|
});
|
||||||
|
|
||||||
final Directory pluginExampleDirectory =
|
final Directory pluginExampleDirectory =
|
||||||
@ -321,7 +321,7 @@ void main() {
|
|||||||
expect(
|
expect(
|
||||||
output,
|
output,
|
||||||
containsAllInOrder(<String>[
|
containsAllInOrder(<String>[
|
||||||
'\nBUILDING plugin/example for Windows',
|
'\nBUILDING plugin/example for Win32 (windows)',
|
||||||
]),
|
]),
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -335,6 +335,91 @@ void main() {
|
|||||||
]));
|
]));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('building for UWP when plugin does not support UWP is a no-op',
|
||||||
|
() async {
|
||||||
|
createFakePlugin('plugin', packagesDir);
|
||||||
|
|
||||||
|
final List<String> output = await runCapturingPrint(
|
||||||
|
runner, <String>['build-examples', '--winuwp']);
|
||||||
|
|
||||||
|
expect(
|
||||||
|
output,
|
||||||
|
containsAllInOrder(<Matcher>[
|
||||||
|
contains('Running for plugin'),
|
||||||
|
contains('UWP is not supported by this plugin'),
|
||||||
|
]),
|
||||||
|
);
|
||||||
|
|
||||||
|
print(processRunner.recordedCalls);
|
||||||
|
// Output should be empty since running build-examples --macos with no macos
|
||||||
|
// implementation is a no-op.
|
||||||
|
expect(processRunner.recordedCalls, orderedEquals(<ProcessCall>[]));
|
||||||
|
});
|
||||||
|
|
||||||
|
test('building for UWP', () async {
|
||||||
|
final Directory pluginDirectory =
|
||||||
|
createFakePlugin('plugin', packagesDir, extraFiles: <String>[
|
||||||
|
'example/test',
|
||||||
|
], platformSupport: <String, PlatformDetails>{
|
||||||
|
kPlatformWindows: const PlatformDetails(PlatformSupport.federated,
|
||||||
|
variants: <String>[platformVariantWinUwp]),
|
||||||
|
});
|
||||||
|
|
||||||
|
final Directory pluginExampleDirectory =
|
||||||
|
pluginDirectory.childDirectory('example');
|
||||||
|
|
||||||
|
final List<String> output = await runCapturingPrint(
|
||||||
|
runner, <String>['build-examples', '--winuwp']);
|
||||||
|
|
||||||
|
expect(
|
||||||
|
output,
|
||||||
|
containsAllInOrder(<Matcher>[
|
||||||
|
contains('BUILDING plugin/example for UWP (winuwp)'),
|
||||||
|
]),
|
||||||
|
);
|
||||||
|
|
||||||
|
print(processRunner.recordedCalls);
|
||||||
|
expect(
|
||||||
|
processRunner.recordedCalls,
|
||||||
|
containsAll(<ProcessCall>[
|
||||||
|
ProcessCall(getFlutterCommand(mockPlatform),
|
||||||
|
const <String>['build', 'winuwp'], pluginExampleDirectory.path),
|
||||||
|
]));
|
||||||
|
});
|
||||||
|
|
||||||
|
test('building for UWP creates a folder if necessary', () async {
|
||||||
|
final Directory pluginDirectory =
|
||||||
|
createFakePlugin('plugin', packagesDir, extraFiles: <String>[
|
||||||
|
'example/test',
|
||||||
|
], platformSupport: <String, PlatformDetails>{
|
||||||
|
kPlatformWindows: const PlatformDetails(PlatformSupport.federated,
|
||||||
|
variants: <String>[platformVariantWinUwp]),
|
||||||
|
});
|
||||||
|
|
||||||
|
final Directory pluginExampleDirectory =
|
||||||
|
pluginDirectory.childDirectory('example');
|
||||||
|
|
||||||
|
final List<String> output = await runCapturingPrint(
|
||||||
|
runner, <String>['build-examples', '--winuwp']);
|
||||||
|
|
||||||
|
expect(
|
||||||
|
output,
|
||||||
|
contains('Creating temporary winuwp folder'),
|
||||||
|
);
|
||||||
|
|
||||||
|
print(processRunner.recordedCalls);
|
||||||
|
expect(
|
||||||
|
processRunner.recordedCalls,
|
||||||
|
orderedEquals(<ProcessCall>[
|
||||||
|
ProcessCall(
|
||||||
|
getFlutterCommand(mockPlatform),
|
||||||
|
const <String>['create', '--platforms=winuwp', '.'],
|
||||||
|
pluginExampleDirectory.path),
|
||||||
|
ProcessCall(getFlutterCommand(mockPlatform),
|
||||||
|
const <String>['build', 'winuwp'], pluginExampleDirectory.path),
|
||||||
|
]));
|
||||||
|
});
|
||||||
|
|
||||||
test(
|
test(
|
||||||
'building for Android when plugin is not set up for Android results in no-op',
|
'building for Android when plugin is not set up for Android results in no-op',
|
||||||
() async {
|
() async {
|
||||||
@ -358,8 +443,8 @@ void main() {
|
|||||||
|
|
||||||
test('building for Android', () async {
|
test('building for Android', () async {
|
||||||
final Directory pluginDirectory = createFakePlugin('plugin', packagesDir,
|
final Directory pluginDirectory = createFakePlugin('plugin', packagesDir,
|
||||||
platformSupport: <String, PlatformSupport>{
|
platformSupport: <String, PlatformDetails>{
|
||||||
kPlatformAndroid: PlatformSupport.inline
|
kPlatformAndroid: const PlatformDetails(PlatformSupport.inline),
|
||||||
});
|
});
|
||||||
|
|
||||||
final Directory pluginExampleDirectory =
|
final Directory pluginExampleDirectory =
|
||||||
@ -387,8 +472,8 @@ void main() {
|
|||||||
|
|
||||||
test('enable-experiment flag for Android', () async {
|
test('enable-experiment flag for Android', () async {
|
||||||
final Directory pluginDirectory = createFakePlugin('plugin', packagesDir,
|
final Directory pluginDirectory = createFakePlugin('plugin', packagesDir,
|
||||||
platformSupport: <String, PlatformSupport>{
|
platformSupport: <String, PlatformDetails>{
|
||||||
kPlatformAndroid: PlatformSupport.inline
|
kPlatformAndroid: const PlatformDetails(PlatformSupport.inline),
|
||||||
});
|
});
|
||||||
|
|
||||||
final Directory pluginExampleDirectory =
|
final Directory pluginExampleDirectory =
|
||||||
@ -409,8 +494,8 @@ void main() {
|
|||||||
|
|
||||||
test('enable-experiment flag for ios', () async {
|
test('enable-experiment flag for ios', () async {
|
||||||
final Directory pluginDirectory = createFakePlugin('plugin', packagesDir,
|
final Directory pluginDirectory = createFakePlugin('plugin', packagesDir,
|
||||||
platformSupport: <String, PlatformSupport>{
|
platformSupport: <String, PlatformDetails>{
|
||||||
kPlatformIos: PlatformSupport.inline
|
kPlatformIos: const PlatformDetails(PlatformSupport.inline),
|
||||||
});
|
});
|
||||||
|
|
||||||
final Directory pluginExampleDirectory =
|
final Directory pluginExampleDirectory =
|
||||||
|
@ -36,13 +36,13 @@ void main() {
|
|||||||
test('all platforms', () async {
|
test('all platforms', () async {
|
||||||
final RepositoryPackage plugin = RepositoryPackage(createFakePlugin(
|
final RepositoryPackage plugin = RepositoryPackage(createFakePlugin(
|
||||||
'plugin', packagesDir,
|
'plugin', packagesDir,
|
||||||
platformSupport: <String, PlatformSupport>{
|
platformSupport: <String, PlatformDetails>{
|
||||||
kPlatformAndroid: PlatformSupport.inline,
|
kPlatformAndroid: const PlatformDetails(PlatformSupport.inline),
|
||||||
kPlatformIos: PlatformSupport.inline,
|
kPlatformIos: const PlatformDetails(PlatformSupport.inline),
|
||||||
kPlatformLinux: PlatformSupport.inline,
|
kPlatformLinux: const PlatformDetails(PlatformSupport.inline),
|
||||||
kPlatformMacos: PlatformSupport.inline,
|
kPlatformMacos: const PlatformDetails(PlatformSupport.inline),
|
||||||
kPlatformWeb: PlatformSupport.inline,
|
kPlatformWeb: const PlatformDetails(PlatformSupport.inline),
|
||||||
kPlatformWindows: PlatformSupport.inline,
|
kPlatformWindows: const PlatformDetails(PlatformSupport.inline),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
expect(pluginSupportsPlatform(kPlatformAndroid, plugin), isTrue);
|
expect(pluginSupportsPlatform(kPlatformAndroid, plugin), isTrue);
|
||||||
@ -55,14 +55,12 @@ void main() {
|
|||||||
|
|
||||||
test('some platforms', () async {
|
test('some platforms', () async {
|
||||||
final RepositoryPackage plugin = RepositoryPackage(createFakePlugin(
|
final RepositoryPackage plugin = RepositoryPackage(createFakePlugin(
|
||||||
'plugin',
|
'plugin', packagesDir,
|
||||||
packagesDir,
|
platformSupport: <String, PlatformDetails>{
|
||||||
platformSupport: <String, PlatformSupport>{
|
kPlatformAndroid: const PlatformDetails(PlatformSupport.inline),
|
||||||
kPlatformAndroid: PlatformSupport.inline,
|
kPlatformLinux: const PlatformDetails(PlatformSupport.inline),
|
||||||
kPlatformLinux: PlatformSupport.inline,
|
kPlatformWeb: const PlatformDetails(PlatformSupport.inline),
|
||||||
kPlatformWeb: PlatformSupport.inline,
|
}));
|
||||||
},
|
|
||||||
));
|
|
||||||
|
|
||||||
expect(pluginSupportsPlatform(kPlatformAndroid, plugin), isTrue);
|
expect(pluginSupportsPlatform(kPlatformAndroid, plugin), isTrue);
|
||||||
expect(pluginSupportsPlatform(kPlatformIos, plugin), isFalse);
|
expect(pluginSupportsPlatform(kPlatformIos, plugin), isFalse);
|
||||||
@ -74,17 +72,15 @@ void main() {
|
|||||||
|
|
||||||
test('inline plugins are only detected as inline', () async {
|
test('inline plugins are only detected as inline', () async {
|
||||||
final RepositoryPackage plugin = RepositoryPackage(createFakePlugin(
|
final RepositoryPackage plugin = RepositoryPackage(createFakePlugin(
|
||||||
'plugin',
|
'plugin', packagesDir,
|
||||||
packagesDir,
|
platformSupport: <String, PlatformDetails>{
|
||||||
platformSupport: <String, PlatformSupport>{
|
kPlatformAndroid: const PlatformDetails(PlatformSupport.inline),
|
||||||
kPlatformAndroid: PlatformSupport.inline,
|
kPlatformIos: const PlatformDetails(PlatformSupport.inline),
|
||||||
kPlatformIos: PlatformSupport.inline,
|
kPlatformLinux: const PlatformDetails(PlatformSupport.inline),
|
||||||
kPlatformLinux: PlatformSupport.inline,
|
kPlatformMacos: const PlatformDetails(PlatformSupport.inline),
|
||||||
kPlatformMacos: PlatformSupport.inline,
|
kPlatformWeb: const PlatformDetails(PlatformSupport.inline),
|
||||||
kPlatformWeb: PlatformSupport.inline,
|
kPlatformWindows: const PlatformDetails(PlatformSupport.inline),
|
||||||
kPlatformWindows: PlatformSupport.inline,
|
}));
|
||||||
},
|
|
||||||
));
|
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
pluginSupportsPlatform(kPlatformAndroid, plugin,
|
pluginSupportsPlatform(kPlatformAndroid, plugin,
|
||||||
@ -137,19 +133,16 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('federated plugins are only detected as federated', () async {
|
test('federated plugins are only detected as federated', () async {
|
||||||
const String pluginName = 'plugin';
|
|
||||||
final RepositoryPackage plugin = RepositoryPackage(createFakePlugin(
|
final RepositoryPackage plugin = RepositoryPackage(createFakePlugin(
|
||||||
pluginName,
|
'plugin', packagesDir,
|
||||||
packagesDir,
|
platformSupport: <String, PlatformDetails>{
|
||||||
platformSupport: <String, PlatformSupport>{
|
kPlatformAndroid: const PlatformDetails(PlatformSupport.federated),
|
||||||
kPlatformAndroid: PlatformSupport.federated,
|
kPlatformIos: const PlatformDetails(PlatformSupport.federated),
|
||||||
kPlatformIos: PlatformSupport.federated,
|
kPlatformLinux: const PlatformDetails(PlatformSupport.federated),
|
||||||
kPlatformLinux: PlatformSupport.federated,
|
kPlatformMacos: const PlatformDetails(PlatformSupport.federated),
|
||||||
kPlatformMacos: PlatformSupport.federated,
|
kPlatformWeb: const PlatformDetails(PlatformSupport.federated),
|
||||||
kPlatformWeb: PlatformSupport.federated,
|
kPlatformWindows: const PlatformDetails(PlatformSupport.federated),
|
||||||
kPlatformWindows: PlatformSupport.federated,
|
}));
|
||||||
},
|
|
||||||
));
|
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
pluginSupportsPlatform(kPlatformAndroid, plugin,
|
pluginSupportsPlatform(kPlatformAndroid, plugin,
|
||||||
@ -200,5 +193,84 @@ void main() {
|
|||||||
requiredMode: PlatformSupport.inline),
|
requiredMode: PlatformSupport.inline),
|
||||||
isFalse);
|
isFalse);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('windows without variants is only win32', () async {
|
||||||
|
final RepositoryPackage plugin = RepositoryPackage(createFakePlugin(
|
||||||
|
'plugin',
|
||||||
|
packagesDir,
|
||||||
|
platformSupport: <String, PlatformDetails>{
|
||||||
|
kPlatformWindows: const PlatformDetails(PlatformSupport.inline),
|
||||||
|
},
|
||||||
|
));
|
||||||
|
|
||||||
|
expect(
|
||||||
|
pluginSupportsPlatform(kPlatformWindows, plugin,
|
||||||
|
variant: platformVariantWin32),
|
||||||
|
isTrue);
|
||||||
|
expect(
|
||||||
|
pluginSupportsPlatform(kPlatformWindows, plugin,
|
||||||
|
variant: platformVariantWinUwp),
|
||||||
|
isFalse);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('windows with both variants matches win32 and winuwp', () async {
|
||||||
|
final RepositoryPackage plugin = RepositoryPackage(createFakePlugin(
|
||||||
|
'plugin', packagesDir,
|
||||||
|
platformSupport: <String, PlatformDetails>{
|
||||||
|
kPlatformWindows: const PlatformDetails(
|
||||||
|
PlatformSupport.federated,
|
||||||
|
variants: <String>[platformVariantWin32, platformVariantWinUwp],
|
||||||
|
),
|
||||||
|
}));
|
||||||
|
|
||||||
|
expect(
|
||||||
|
pluginSupportsPlatform(kPlatformWindows, plugin,
|
||||||
|
variant: platformVariantWin32),
|
||||||
|
isTrue);
|
||||||
|
expect(
|
||||||
|
pluginSupportsPlatform(kPlatformWindows, plugin,
|
||||||
|
variant: platformVariantWinUwp),
|
||||||
|
isTrue);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('win32 plugin is only win32', () async {
|
||||||
|
final RepositoryPackage plugin = RepositoryPackage(createFakePlugin(
|
||||||
|
'plugin', packagesDir,
|
||||||
|
platformSupport: <String, PlatformDetails>{
|
||||||
|
kPlatformWindows: const PlatformDetails(
|
||||||
|
PlatformSupport.federated,
|
||||||
|
variants: <String>[platformVariantWin32],
|
||||||
|
),
|
||||||
|
}));
|
||||||
|
|
||||||
|
expect(
|
||||||
|
pluginSupportsPlatform(kPlatformWindows, plugin,
|
||||||
|
variant: platformVariantWin32),
|
||||||
|
isTrue);
|
||||||
|
expect(
|
||||||
|
pluginSupportsPlatform(kPlatformWindows, plugin,
|
||||||
|
variant: platformVariantWinUwp),
|
||||||
|
isFalse);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('winup plugin is only winuwp', () async {
|
||||||
|
final RepositoryPackage plugin = RepositoryPackage(createFakePlugin(
|
||||||
|
'plugin',
|
||||||
|
packagesDir,
|
||||||
|
platformSupport: <String, PlatformDetails>{
|
||||||
|
kPlatformWindows: const PlatformDetails(PlatformSupport.federated,
|
||||||
|
variants: <String>[platformVariantWinUwp]),
|
||||||
|
},
|
||||||
|
));
|
||||||
|
|
||||||
|
expect(
|
||||||
|
pluginSupportsPlatform(kPlatformWindows, plugin,
|
||||||
|
variant: platformVariantWin32),
|
||||||
|
isFalse);
|
||||||
|
expect(
|
||||||
|
pluginSupportsPlatform(kPlatformWindows, plugin,
|
||||||
|
variant: platformVariantWinUwp),
|
||||||
|
isTrue);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ void main() {
|
|||||||
setUp(() {
|
setUp(() {
|
||||||
// Since the core of this command is a call to 'flutter create', the test
|
// Since the core of this command is a call to 'flutter create', the test
|
||||||
// has to use the real filesystem. Put everything possible in a unique
|
// has to use the real filesystem. Put everything possible in a unique
|
||||||
// temporary to minimize affect on the host system.
|
// temporary to minimize effect on the host system.
|
||||||
fileSystem = const LocalFileSystem();
|
fileSystem = const LocalFileSystem();
|
||||||
testRoot = fileSystem.systemTempDirectory.createTempSync();
|
testRoot = fileSystem.systemTempDirectory.createTempSync();
|
||||||
packagesDir = testRoot.childDirectory('packages');
|
packagesDir = testRoot.childDirectory('packages');
|
||||||
|
@ -127,8 +127,8 @@ void main() {
|
|||||||
'example/test_driver/integration_test.dart',
|
'example/test_driver/integration_test.dart',
|
||||||
'example/integration_test/foo_test.dart',
|
'example/integration_test/foo_test.dart',
|
||||||
],
|
],
|
||||||
platformSupport: <String, PlatformSupport>{
|
platformSupport: <String, PlatformDetails>{
|
||||||
kPlatformIos: PlatformSupport.inline,
|
kPlatformIos: const PlatformDetails(PlatformSupport.inline),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -192,9 +192,9 @@ void main() {
|
|||||||
'example/test_driver/plugin_test.dart',
|
'example/test_driver/plugin_test.dart',
|
||||||
'example/test_driver/plugin.dart',
|
'example/test_driver/plugin.dart',
|
||||||
],
|
],
|
||||||
platformSupport: <String, PlatformSupport>{
|
platformSupport: <String, PlatformDetails>{
|
||||||
kPlatformAndroid: PlatformSupport.inline,
|
kPlatformAndroid: const PlatformDetails(PlatformSupport.inline),
|
||||||
kPlatformIos: PlatformSupport.inline,
|
kPlatformIos: const PlatformDetails(PlatformSupport.inline),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -242,9 +242,9 @@ void main() {
|
|||||||
extraFiles: <String>[
|
extraFiles: <String>[
|
||||||
'example/test_driver/plugin_test.dart',
|
'example/test_driver/plugin_test.dart',
|
||||||
],
|
],
|
||||||
platformSupport: <String, PlatformSupport>{
|
platformSupport: <String, PlatformDetails>{
|
||||||
kPlatformAndroid: PlatformSupport.inline,
|
kPlatformAndroid: const PlatformDetails(PlatformSupport.inline),
|
||||||
kPlatformIos: PlatformSupport.inline,
|
kPlatformIos: const PlatformDetails(PlatformSupport.inline),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -275,9 +275,9 @@ void main() {
|
|||||||
extraFiles: <String>[
|
extraFiles: <String>[
|
||||||
'example/lib/main.dart',
|
'example/lib/main.dart',
|
||||||
],
|
],
|
||||||
platformSupport: <String, PlatformSupport>{
|
platformSupport: <String, PlatformDetails>{
|
||||||
kPlatformAndroid: PlatformSupport.inline,
|
kPlatformAndroid: const PlatformDetails(PlatformSupport.inline),
|
||||||
kPlatformIos: PlatformSupport.inline,
|
kPlatformIos: const PlatformDetails(PlatformSupport.inline),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -311,9 +311,9 @@ void main() {
|
|||||||
'example/integration_test/foo_test.dart',
|
'example/integration_test/foo_test.dart',
|
||||||
'example/integration_test/ignore_me.dart',
|
'example/integration_test/ignore_me.dart',
|
||||||
],
|
],
|
||||||
platformSupport: <String, PlatformSupport>{
|
platformSupport: <String, PlatformDetails>{
|
||||||
kPlatformAndroid: PlatformSupport.inline,
|
kPlatformAndroid: const PlatformDetails(PlatformSupport.inline),
|
||||||
kPlatformIos: PlatformSupport.inline,
|
kPlatformIos: const PlatformDetails(PlatformSupport.inline),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -397,8 +397,8 @@ void main() {
|
|||||||
'example/test_driver/plugin_test.dart',
|
'example/test_driver/plugin_test.dart',
|
||||||
'example/test_driver/plugin.dart',
|
'example/test_driver/plugin.dart',
|
||||||
],
|
],
|
||||||
platformSupport: <String, PlatformSupport>{
|
platformSupport: <String, PlatformDetails>{
|
||||||
kPlatformLinux: PlatformSupport.inline,
|
kPlatformLinux: const PlatformDetails(PlatformSupport.inline),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -470,8 +470,8 @@ void main() {
|
|||||||
'example/test_driver/plugin.dart',
|
'example/test_driver/plugin.dart',
|
||||||
'example/macos/macos.swift',
|
'example/macos/macos.swift',
|
||||||
],
|
],
|
||||||
platformSupport: <String, PlatformSupport>{
|
platformSupport: <String, PlatformDetails>{
|
||||||
kPlatformMacos: PlatformSupport.inline,
|
kPlatformMacos: const PlatformDetails(PlatformSupport.inline),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -541,8 +541,8 @@ void main() {
|
|||||||
'example/test_driver/plugin_test.dart',
|
'example/test_driver/plugin_test.dart',
|
||||||
'example/test_driver/plugin.dart',
|
'example/test_driver/plugin.dart',
|
||||||
],
|
],
|
||||||
platformSupport: <String, PlatformSupport>{
|
platformSupport: <String, PlatformDetails>{
|
||||||
kPlatformWeb: PlatformSupport.inline,
|
kPlatformWeb: const PlatformDetails(PlatformSupport.inline),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -615,8 +615,8 @@ void main() {
|
|||||||
'example/test_driver/plugin_test.dart',
|
'example/test_driver/plugin_test.dart',
|
||||||
'example/test_driver/plugin.dart',
|
'example/test_driver/plugin.dart',
|
||||||
],
|
],
|
||||||
platformSupport: <String, PlatformSupport>{
|
platformSupport: <String, PlatformDetails>{
|
||||||
kPlatformWindows: PlatformSupport.inline
|
kPlatformWindows: const PlatformDetails(PlatformSupport.inline),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -654,6 +654,40 @@ void main() {
|
|||||||
]));
|
]));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('driving UWP is a no-op', () async {
|
||||||
|
createFakePlugin(
|
||||||
|
'plugin',
|
||||||
|
packagesDir,
|
||||||
|
extraFiles: <String>[
|
||||||
|
'example/test_driver/plugin_test.dart',
|
||||||
|
'example/test_driver/plugin.dart',
|
||||||
|
],
|
||||||
|
platformSupport: <String, PlatformDetails>{
|
||||||
|
kPlatformWindows: const PlatformDetails(PlatformSupport.inline,
|
||||||
|
variants: <String>[platformVariantWinUwp]),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
final List<String> output = await runCapturingPrint(runner, <String>[
|
||||||
|
'drive-examples',
|
||||||
|
'--winuwp',
|
||||||
|
]);
|
||||||
|
|
||||||
|
expect(
|
||||||
|
output,
|
||||||
|
containsAllInOrder(<Matcher>[
|
||||||
|
contains('Driving UWP applications is not yet supported'),
|
||||||
|
contains('Running for plugin'),
|
||||||
|
contains('SKIPPING: Drive does not yet support UWP'),
|
||||||
|
contains('No issues found!'),
|
||||||
|
]),
|
||||||
|
);
|
||||||
|
|
||||||
|
// Output should be empty since running drive-examples --windows on a
|
||||||
|
// non-Windows plugin is a no-op.
|
||||||
|
expect(processRunner.recordedCalls, <ProcessCall>[]);
|
||||||
|
});
|
||||||
|
|
||||||
test('driving on an Android plugin', () async {
|
test('driving on an Android plugin', () async {
|
||||||
final Directory pluginDirectory = createFakePlugin(
|
final Directory pluginDirectory = createFakePlugin(
|
||||||
'plugin',
|
'plugin',
|
||||||
@ -662,8 +696,8 @@ void main() {
|
|||||||
'example/test_driver/plugin_test.dart',
|
'example/test_driver/plugin_test.dart',
|
||||||
'example/test_driver/plugin.dart',
|
'example/test_driver/plugin.dart',
|
||||||
],
|
],
|
||||||
platformSupport: <String, PlatformSupport>{
|
platformSupport: <String, PlatformDetails>{
|
||||||
kPlatformAndroid: PlatformSupport.inline,
|
kPlatformAndroid: const PlatformDetails(PlatformSupport.inline),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -712,8 +746,8 @@ void main() {
|
|||||||
'example/test_driver/plugin_test.dart',
|
'example/test_driver/plugin_test.dart',
|
||||||
'example/test_driver/plugin.dart',
|
'example/test_driver/plugin.dart',
|
||||||
],
|
],
|
||||||
platformSupport: <String, PlatformSupport>{
|
platformSupport: <String, PlatformDetails>{
|
||||||
kPlatformMacos: PlatformSupport.inline,
|
kPlatformMacos: const PlatformDetails(PlatformSupport.inline),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -745,8 +779,8 @@ void main() {
|
|||||||
'example/test_driver/plugin_test.dart',
|
'example/test_driver/plugin_test.dart',
|
||||||
'example/test_driver/plugin.dart',
|
'example/test_driver/plugin.dart',
|
||||||
],
|
],
|
||||||
platformSupport: <String, PlatformSupport>{
|
platformSupport: <String, PlatformDetails>{
|
||||||
kPlatformMacos: PlatformSupport.inline,
|
kPlatformMacos: const PlatformDetails(PlatformSupport.inline),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -800,9 +834,9 @@ void main() {
|
|||||||
'example/test_driver/plugin_test.dart',
|
'example/test_driver/plugin_test.dart',
|
||||||
'example/test_driver/plugin.dart',
|
'example/test_driver/plugin.dart',
|
||||||
],
|
],
|
||||||
platformSupport: <String, PlatformSupport>{
|
platformSupport: <String, PlatformDetails>{
|
||||||
kPlatformAndroid: PlatformSupport.inline,
|
kPlatformAndroid: const PlatformDetails(PlatformSupport.inline),
|
||||||
kPlatformIos: PlatformSupport.inline,
|
kPlatformIos: const PlatformDetails(PlatformSupport.inline),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -842,8 +876,8 @@ void main() {
|
|||||||
'plugin',
|
'plugin',
|
||||||
packagesDir,
|
packagesDir,
|
||||||
examples: <String>[],
|
examples: <String>[],
|
||||||
platformSupport: <String, PlatformSupport>{
|
platformSupport: <String, PlatformDetails>{
|
||||||
kPlatformWeb: PlatformSupport.inline,
|
kPlatformWeb: const PlatformDetails(PlatformSupport.inline),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -874,8 +908,8 @@ void main() {
|
|||||||
'example/integration_test/bar_test.dart',
|
'example/integration_test/bar_test.dart',
|
||||||
'example/integration_test/foo_test.dart',
|
'example/integration_test/foo_test.dart',
|
||||||
],
|
],
|
||||||
platformSupport: <String, PlatformSupport>{
|
platformSupport: <String, PlatformDetails>{
|
||||||
kPlatformWeb: PlatformSupport.inline,
|
kPlatformWeb: const PlatformDetails(PlatformSupport.inline),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -906,8 +940,8 @@ void main() {
|
|||||||
extraFiles: <String>[
|
extraFiles: <String>[
|
||||||
'example/test_driver/integration_test.dart',
|
'example/test_driver/integration_test.dart',
|
||||||
],
|
],
|
||||||
platformSupport: <String, PlatformSupport>{
|
platformSupport: <String, PlatformDetails>{
|
||||||
kPlatformWeb: PlatformSupport.inline,
|
kPlatformWeb: const PlatformDetails(PlatformSupport.inline),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -942,8 +976,8 @@ void main() {
|
|||||||
'example/integration_test/bar_test.dart',
|
'example/integration_test/bar_test.dart',
|
||||||
'example/integration_test/foo_test.dart',
|
'example/integration_test/foo_test.dart',
|
||||||
],
|
],
|
||||||
platformSupport: <String, PlatformSupport>{
|
platformSupport: <String, PlatformDetails>{
|
||||||
kPlatformMacos: PlatformSupport.inline,
|
kPlatformMacos: const PlatformDetails(PlatformSupport.inline),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -43,8 +43,8 @@ void main() {
|
|||||||
final Directory pluginDir =
|
final Directory pluginDir =
|
||||||
createFakePlugin('plugin1', packagesDir, extraFiles: <String>[
|
createFakePlugin('plugin1', packagesDir, extraFiles: <String>[
|
||||||
'example/android/gradlew',
|
'example/android/gradlew',
|
||||||
], platformSupport: <String, PlatformSupport>{
|
], platformSupport: <String, PlatformDetails>{
|
||||||
kPlatformAndroid: PlatformSupport.inline
|
kPlatformAndroid: const PlatformDetails(PlatformSupport.inline)
|
||||||
});
|
});
|
||||||
|
|
||||||
final Directory androidDir =
|
final Directory androidDir =
|
||||||
@ -74,8 +74,8 @@ void main() {
|
|||||||
|
|
||||||
test('fails if gradlew is missing', () async {
|
test('fails if gradlew is missing', () async {
|
||||||
createFakePlugin('plugin1', packagesDir,
|
createFakePlugin('plugin1', packagesDir,
|
||||||
platformSupport: <String, PlatformSupport>{
|
platformSupport: <String, PlatformDetails>{
|
||||||
kPlatformAndroid: PlatformSupport.inline
|
kPlatformAndroid: const PlatformDetails(PlatformSupport.inline)
|
||||||
});
|
});
|
||||||
|
|
||||||
Error? commandError;
|
Error? commandError;
|
||||||
@ -96,8 +96,8 @@ void main() {
|
|||||||
|
|
||||||
test('fails if linting finds issues', () async {
|
test('fails if linting finds issues', () async {
|
||||||
createFakePlugin('plugin1', packagesDir,
|
createFakePlugin('plugin1', packagesDir,
|
||||||
platformSupport: <String, PlatformSupport>{
|
platformSupport: <String, PlatformDetails>{
|
||||||
kPlatformAndroid: PlatformSupport.inline
|
kPlatformAndroid: const PlatformDetails(PlatformSupport.inline)
|
||||||
});
|
});
|
||||||
|
|
||||||
processRunner.mockProcessesForExecutable['gradlew'] = <io.Process>[
|
processRunner.mockProcessesForExecutable['gradlew'] = <io.Process>[
|
||||||
@ -138,8 +138,8 @@ void main() {
|
|||||||
|
|
||||||
test('skips non-inline plugins', () async {
|
test('skips non-inline plugins', () async {
|
||||||
createFakePlugin('plugin1', packagesDir,
|
createFakePlugin('plugin1', packagesDir,
|
||||||
platformSupport: <String, PlatformSupport>{
|
platformSupport: <String, PlatformDetails>{
|
||||||
kPlatformAndroid: PlatformSupport.federated
|
kPlatformAndroid: const PlatformDetails(PlatformSupport.federated)
|
||||||
});
|
});
|
||||||
|
|
||||||
final List<String> output =
|
final List<String> output =
|
||||||
|
@ -115,8 +115,8 @@ void main() {
|
|||||||
|
|
||||||
test('reports skips with no tests', () async {
|
test('reports skips with no tests', () async {
|
||||||
final Directory pluginDirectory1 = createFakePlugin('plugin', packagesDir,
|
final Directory pluginDirectory1 = createFakePlugin('plugin', packagesDir,
|
||||||
platformSupport: <String, PlatformSupport>{
|
platformSupport: <String, PlatformDetails>{
|
||||||
kPlatformMacos: PlatformSupport.inline,
|
kPlatformMacos: const PlatformDetails(PlatformSupport.inline),
|
||||||
});
|
});
|
||||||
|
|
||||||
final Directory pluginExampleDirectory =
|
final Directory pluginExampleDirectory =
|
||||||
@ -154,8 +154,8 @@ void main() {
|
|||||||
group('iOS', () {
|
group('iOS', () {
|
||||||
test('skip if iOS is not supported', () async {
|
test('skip if iOS is not supported', () async {
|
||||||
createFakePlugin('plugin', packagesDir,
|
createFakePlugin('plugin', packagesDir,
|
||||||
platformSupport: <String, PlatformSupport>{
|
platformSupport: <String, PlatformDetails>{
|
||||||
kPlatformMacos: PlatformSupport.inline,
|
kPlatformMacos: const PlatformDetails(PlatformSupport.inline),
|
||||||
});
|
});
|
||||||
|
|
||||||
final List<String> output = await runCapturingPrint(runner,
|
final List<String> output = await runCapturingPrint(runner,
|
||||||
@ -171,8 +171,8 @@ void main() {
|
|||||||
|
|
||||||
test('skip if iOS is implemented in a federated package', () async {
|
test('skip if iOS is implemented in a federated package', () async {
|
||||||
createFakePlugin('plugin', packagesDir,
|
createFakePlugin('plugin', packagesDir,
|
||||||
platformSupport: <String, PlatformSupport>{
|
platformSupport: <String, PlatformDetails>{
|
||||||
kPlatformIos: PlatformSupport.federated
|
kPlatformIos: const PlatformDetails(PlatformSupport.federated)
|
||||||
});
|
});
|
||||||
|
|
||||||
final List<String> output = await runCapturingPrint(runner,
|
final List<String> output = await runCapturingPrint(runner,
|
||||||
@ -188,8 +188,8 @@ void main() {
|
|||||||
|
|
||||||
test('running with correct destination', () async {
|
test('running with correct destination', () async {
|
||||||
final Directory pluginDirectory = createFakePlugin(
|
final Directory pluginDirectory = createFakePlugin(
|
||||||
'plugin', packagesDir, platformSupport: <String, PlatformSupport>{
|
'plugin', packagesDir, platformSupport: <String, PlatformDetails>{
|
||||||
kPlatformIos: PlatformSupport.inline
|
kPlatformIos: const PlatformDetails(PlatformSupport.inline)
|
||||||
});
|
});
|
||||||
|
|
||||||
final Directory pluginExampleDirectory =
|
final Directory pluginExampleDirectory =
|
||||||
@ -234,8 +234,8 @@ void main() {
|
|||||||
test('Not specifying --ios-destination assigns an available simulator',
|
test('Not specifying --ios-destination assigns an available simulator',
|
||||||
() async {
|
() async {
|
||||||
final Directory pluginDirectory = createFakePlugin(
|
final Directory pluginDirectory = createFakePlugin(
|
||||||
'plugin', packagesDir, platformSupport: <String, PlatformSupport>{
|
'plugin', packagesDir, platformSupport: <String, PlatformDetails>{
|
||||||
kPlatformIos: PlatformSupport.inline
|
kPlatformIos: const PlatformDetails(PlatformSupport.inline)
|
||||||
});
|
});
|
||||||
final Directory pluginExampleDirectory =
|
final Directory pluginExampleDirectory =
|
||||||
pluginDirectory.childDirectory('example');
|
pluginDirectory.childDirectory('example');
|
||||||
@ -298,8 +298,8 @@ void main() {
|
|||||||
|
|
||||||
test('skip if macOS is implemented in a federated package', () async {
|
test('skip if macOS is implemented in a federated package', () async {
|
||||||
createFakePlugin('plugin', packagesDir,
|
createFakePlugin('plugin', packagesDir,
|
||||||
platformSupport: <String, PlatformSupport>{
|
platformSupport: <String, PlatformDetails>{
|
||||||
kPlatformMacos: PlatformSupport.federated,
|
kPlatformMacos: const PlatformDetails(PlatformSupport.federated),
|
||||||
});
|
});
|
||||||
|
|
||||||
final List<String> output =
|
final List<String> output =
|
||||||
@ -317,8 +317,8 @@ void main() {
|
|||||||
test('runs for macOS plugin', () async {
|
test('runs for macOS plugin', () async {
|
||||||
final Directory pluginDirectory1 = createFakePlugin(
|
final Directory pluginDirectory1 = createFakePlugin(
|
||||||
'plugin', packagesDir,
|
'plugin', packagesDir,
|
||||||
platformSupport: <String, PlatformSupport>{
|
platformSupport: <String, PlatformDetails>{
|
||||||
kPlatformMacos: PlatformSupport.inline,
|
kPlatformMacos: const PlatformDetails(PlatformSupport.inline),
|
||||||
});
|
});
|
||||||
|
|
||||||
final Directory pluginExampleDirectory =
|
final Directory pluginExampleDirectory =
|
||||||
@ -360,8 +360,8 @@ void main() {
|
|||||||
final Directory plugin = createFakePlugin(
|
final Directory plugin = createFakePlugin(
|
||||||
'plugin',
|
'plugin',
|
||||||
packagesDir,
|
packagesDir,
|
||||||
platformSupport: <String, PlatformSupport>{
|
platformSupport: <String, PlatformDetails>{
|
||||||
kPlatformAndroid: PlatformSupport.inline
|
kPlatformAndroid: const PlatformDetails(PlatformSupport.inline)
|
||||||
},
|
},
|
||||||
extraFiles: <String>[
|
extraFiles: <String>[
|
||||||
'example/android/gradlew',
|
'example/android/gradlew',
|
||||||
@ -390,8 +390,8 @@ void main() {
|
|||||||
final Directory plugin = createFakePlugin(
|
final Directory plugin = createFakePlugin(
|
||||||
'plugin',
|
'plugin',
|
||||||
packagesDir,
|
packagesDir,
|
||||||
platformSupport: <String, PlatformSupport>{
|
platformSupport: <String, PlatformDetails>{
|
||||||
kPlatformAndroid: PlatformSupport.inline
|
kPlatformAndroid: const PlatformDetails(PlatformSupport.inline)
|
||||||
},
|
},
|
||||||
extraFiles: <String>[
|
extraFiles: <String>[
|
||||||
'example/android/gradlew',
|
'example/android/gradlew',
|
||||||
@ -420,8 +420,8 @@ void main() {
|
|||||||
final Directory plugin = createFakePlugin(
|
final Directory plugin = createFakePlugin(
|
||||||
'plugin',
|
'plugin',
|
||||||
packagesDir,
|
packagesDir,
|
||||||
platformSupport: <String, PlatformSupport>{
|
platformSupport: <String, PlatformDetails>{
|
||||||
kPlatformAndroid: PlatformSupport.inline
|
kPlatformAndroid: const PlatformDetails(PlatformSupport.inline)
|
||||||
},
|
},
|
||||||
extraFiles: <String>[
|
extraFiles: <String>[
|
||||||
'example/android/gradlew',
|
'example/android/gradlew',
|
||||||
@ -455,8 +455,8 @@ void main() {
|
|||||||
createFakePlugin(
|
createFakePlugin(
|
||||||
'plugin',
|
'plugin',
|
||||||
packagesDir,
|
packagesDir,
|
||||||
platformSupport: <String, PlatformSupport>{
|
platformSupport: <String, PlatformDetails>{
|
||||||
kPlatformAndroid: PlatformSupport.inline
|
kPlatformAndroid: const PlatformDetails(PlatformSupport.inline)
|
||||||
},
|
},
|
||||||
extraFiles: <String>[
|
extraFiles: <String>[
|
||||||
'example/android/gradlew',
|
'example/android/gradlew',
|
||||||
@ -480,8 +480,8 @@ void main() {
|
|||||||
final Directory plugin = createFakePlugin(
|
final Directory plugin = createFakePlugin(
|
||||||
'plugin',
|
'plugin',
|
||||||
packagesDir,
|
packagesDir,
|
||||||
platformSupport: <String, PlatformSupport>{
|
platformSupport: <String, PlatformDetails>{
|
||||||
kPlatformAndroid: PlatformSupport.inline
|
kPlatformAndroid: const PlatformDetails(PlatformSupport.inline)
|
||||||
},
|
},
|
||||||
extraFiles: <String>[
|
extraFiles: <String>[
|
||||||
'android/src/test/example_test.java',
|
'android/src/test/example_test.java',
|
||||||
@ -519,8 +519,8 @@ void main() {
|
|||||||
final Directory plugin = createFakePlugin(
|
final Directory plugin = createFakePlugin(
|
||||||
'plugin',
|
'plugin',
|
||||||
packagesDir,
|
packagesDir,
|
||||||
platformSupport: <String, PlatformSupport>{
|
platformSupport: <String, PlatformDetails>{
|
||||||
kPlatformAndroid: PlatformSupport.inline
|
kPlatformAndroid: const PlatformDetails(PlatformSupport.inline)
|
||||||
},
|
},
|
||||||
extraFiles: <String>[
|
extraFiles: <String>[
|
||||||
'android/src/test/example_test.java',
|
'android/src/test/example_test.java',
|
||||||
@ -554,8 +554,8 @@ void main() {
|
|||||||
final Directory plugin = createFakePlugin(
|
final Directory plugin = createFakePlugin(
|
||||||
'plugin',
|
'plugin',
|
||||||
packagesDir,
|
packagesDir,
|
||||||
platformSupport: <String, PlatformSupport>{
|
platformSupport: <String, PlatformDetails>{
|
||||||
kPlatformAndroid: PlatformSupport.inline
|
kPlatformAndroid: const PlatformDetails(PlatformSupport.inline)
|
||||||
},
|
},
|
||||||
extraFiles: <String>[
|
extraFiles: <String>[
|
||||||
'android/src/test/example_test.java',
|
'android/src/test/example_test.java',
|
||||||
@ -586,8 +586,8 @@ void main() {
|
|||||||
createFakePlugin(
|
createFakePlugin(
|
||||||
'plugin',
|
'plugin',
|
||||||
packagesDir,
|
packagesDir,
|
||||||
platformSupport: <String, PlatformSupport>{
|
platformSupport: <String, PlatformDetails>{
|
||||||
kPlatformAndroid: PlatformSupport.inline
|
kPlatformAndroid: const PlatformDetails(PlatformSupport.inline)
|
||||||
},
|
},
|
||||||
extraFiles: <String>[
|
extraFiles: <String>[
|
||||||
'example/android/app/src/test/example_test.java',
|
'example/android/app/src/test/example_test.java',
|
||||||
@ -618,8 +618,8 @@ void main() {
|
|||||||
createFakePlugin(
|
createFakePlugin(
|
||||||
'plugin1',
|
'plugin1',
|
||||||
packagesDir,
|
packagesDir,
|
||||||
platformSupport: <String, PlatformSupport>{
|
platformSupport: <String, PlatformDetails>{
|
||||||
kPlatformAndroid: PlatformSupport.inline
|
kPlatformAndroid: const PlatformDetails(PlatformSupport.inline)
|
||||||
},
|
},
|
||||||
extraFiles: <String>[
|
extraFiles: <String>[
|
||||||
'example/android/gradlew',
|
'example/android/gradlew',
|
||||||
@ -630,8 +630,8 @@ void main() {
|
|||||||
createFakePlugin(
|
createFakePlugin(
|
||||||
'plugin2',
|
'plugin2',
|
||||||
packagesDir,
|
packagesDir,
|
||||||
platformSupport: <String, PlatformSupport>{
|
platformSupport: <String, PlatformDetails>{
|
||||||
kPlatformAndroid: PlatformSupport.inline
|
kPlatformAndroid: const PlatformDetails(PlatformSupport.inline)
|
||||||
},
|
},
|
||||||
extraFiles: <String>[
|
extraFiles: <String>[
|
||||||
'android/src/test/example_test.java',
|
'android/src/test/example_test.java',
|
||||||
@ -657,8 +657,8 @@ void main() {
|
|||||||
final Directory pluginDir = createFakePlugin(
|
final Directory pluginDir = createFakePlugin(
|
||||||
'plugin',
|
'plugin',
|
||||||
packagesDir,
|
packagesDir,
|
||||||
platformSupport: <String, PlatformSupport>{
|
platformSupport: <String, PlatformDetails>{
|
||||||
kPlatformAndroid: PlatformSupport.inline
|
kPlatformAndroid: const PlatformDetails(PlatformSupport.inline)
|
||||||
},
|
},
|
||||||
extraFiles: <String>[
|
extraFiles: <String>[
|
||||||
'example/android/gradlew',
|
'example/android/gradlew',
|
||||||
@ -716,8 +716,8 @@ void main() {
|
|||||||
createFakePlugin(
|
createFakePlugin(
|
||||||
'plugin',
|
'plugin',
|
||||||
packagesDir,
|
packagesDir,
|
||||||
platformSupport: <String, PlatformSupport>{
|
platformSupport: <String, PlatformDetails>{
|
||||||
kPlatformAndroid: PlatformSupport.inline
|
kPlatformAndroid: const PlatformDetails(PlatformSupport.inline)
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -739,8 +739,8 @@ void main() {
|
|||||||
group('iOS/macOS', () {
|
group('iOS/macOS', () {
|
||||||
test('fails if xcrun fails', () async {
|
test('fails if xcrun fails', () async {
|
||||||
createFakePlugin('plugin', packagesDir,
|
createFakePlugin('plugin', packagesDir,
|
||||||
platformSupport: <String, PlatformSupport>{
|
platformSupport: <String, PlatformDetails>{
|
||||||
kPlatformMacos: PlatformSupport.inline,
|
kPlatformMacos: const PlatformDetails(PlatformSupport.inline),
|
||||||
});
|
});
|
||||||
|
|
||||||
processRunner.mockProcessesForExecutable['xcrun'] = <io.Process>[
|
processRunner.mockProcessesForExecutable['xcrun'] = <io.Process>[
|
||||||
@ -767,8 +767,8 @@ void main() {
|
|||||||
test('honors unit-only', () async {
|
test('honors unit-only', () async {
|
||||||
final Directory pluginDirectory1 = createFakePlugin(
|
final Directory pluginDirectory1 = createFakePlugin(
|
||||||
'plugin', packagesDir,
|
'plugin', packagesDir,
|
||||||
platformSupport: <String, PlatformSupport>{
|
platformSupport: <String, PlatformDetails>{
|
||||||
kPlatformMacos: PlatformSupport.inline,
|
kPlatformMacos: const PlatformDetails(PlatformSupport.inline),
|
||||||
});
|
});
|
||||||
|
|
||||||
final Directory pluginExampleDirectory =
|
final Directory pluginExampleDirectory =
|
||||||
@ -832,8 +832,8 @@ void main() {
|
|||||||
test('honors integration-only', () async {
|
test('honors integration-only', () async {
|
||||||
final Directory pluginDirectory1 = createFakePlugin(
|
final Directory pluginDirectory1 = createFakePlugin(
|
||||||
'plugin', packagesDir,
|
'plugin', packagesDir,
|
||||||
platformSupport: <String, PlatformSupport>{
|
platformSupport: <String, PlatformDetails>{
|
||||||
kPlatformMacos: PlatformSupport.inline,
|
kPlatformMacos: const PlatformDetails(PlatformSupport.inline),
|
||||||
});
|
});
|
||||||
|
|
||||||
final Directory pluginExampleDirectory =
|
final Directory pluginExampleDirectory =
|
||||||
@ -897,8 +897,8 @@ void main() {
|
|||||||
test('skips when the requested target is not present', () async {
|
test('skips when the requested target is not present', () async {
|
||||||
final Directory pluginDirectory1 = createFakePlugin(
|
final Directory pluginDirectory1 = createFakePlugin(
|
||||||
'plugin', packagesDir,
|
'plugin', packagesDir,
|
||||||
platformSupport: <String, PlatformSupport>{
|
platformSupport: <String, PlatformDetails>{
|
||||||
kPlatformMacos: PlatformSupport.inline,
|
kPlatformMacos: const PlatformDetails(PlatformSupport.inline),
|
||||||
});
|
});
|
||||||
|
|
||||||
final Directory pluginExampleDirectory =
|
final Directory pluginExampleDirectory =
|
||||||
@ -950,8 +950,8 @@ void main() {
|
|||||||
test('fails if unable to check for requested target', () async {
|
test('fails if unable to check for requested target', () async {
|
||||||
final Directory pluginDirectory1 = createFakePlugin(
|
final Directory pluginDirectory1 = createFakePlugin(
|
||||||
'plugin', packagesDir,
|
'plugin', packagesDir,
|
||||||
platformSupport: <String, PlatformSupport>{
|
platformSupport: <String, PlatformDetails>{
|
||||||
kPlatformMacos: PlatformSupport.inline,
|
kPlatformMacos: const PlatformDetails(PlatformSupport.inline),
|
||||||
});
|
});
|
||||||
|
|
||||||
final Directory pluginExampleDirectory =
|
final Directory pluginExampleDirectory =
|
||||||
@ -1007,10 +1007,10 @@ void main() {
|
|||||||
'example/android/gradlew',
|
'example/android/gradlew',
|
||||||
'android/src/test/example_test.java',
|
'android/src/test/example_test.java',
|
||||||
],
|
],
|
||||||
platformSupport: <String, PlatformSupport>{
|
platformSupport: <String, PlatformDetails>{
|
||||||
kPlatformAndroid: PlatformSupport.inline,
|
kPlatformAndroid: const PlatformDetails(PlatformSupport.inline),
|
||||||
kPlatformIos: PlatformSupport.inline,
|
kPlatformIos: const PlatformDetails(PlatformSupport.inline),
|
||||||
kPlatformMacos: PlatformSupport.inline,
|
kPlatformMacos: const PlatformDetails(PlatformSupport.inline),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -1077,8 +1077,8 @@ void main() {
|
|||||||
test('runs only macOS for a macOS plugin', () async {
|
test('runs only macOS for a macOS plugin', () async {
|
||||||
final Directory pluginDirectory1 = createFakePlugin(
|
final Directory pluginDirectory1 = createFakePlugin(
|
||||||
'plugin', packagesDir,
|
'plugin', packagesDir,
|
||||||
platformSupport: <String, PlatformSupport>{
|
platformSupport: <String, PlatformDetails>{
|
||||||
kPlatformMacos: PlatformSupport.inline,
|
kPlatformMacos: const PlatformDetails(PlatformSupport.inline),
|
||||||
});
|
});
|
||||||
|
|
||||||
final Directory pluginExampleDirectory =
|
final Directory pluginExampleDirectory =
|
||||||
@ -1121,8 +1121,8 @@ void main() {
|
|||||||
|
|
||||||
test('runs only iOS for a iOS plugin', () async {
|
test('runs only iOS for a iOS plugin', () async {
|
||||||
final Directory pluginDirectory = createFakePlugin(
|
final Directory pluginDirectory = createFakePlugin(
|
||||||
'plugin', packagesDir, platformSupport: <String, PlatformSupport>{
|
'plugin', packagesDir, platformSupport: <String, PlatformDetails>{
|
||||||
kPlatformIos: PlatformSupport.inline
|
kPlatformIos: const PlatformDetails(PlatformSupport.inline)
|
||||||
});
|
});
|
||||||
|
|
||||||
final Directory pluginExampleDirectory =
|
final Directory pluginExampleDirectory =
|
||||||
@ -1193,9 +1193,9 @@ void main() {
|
|||||||
final Directory pluginDir = createFakePlugin(
|
final Directory pluginDir = createFakePlugin(
|
||||||
'plugin',
|
'plugin',
|
||||||
packagesDir,
|
packagesDir,
|
||||||
platformSupport: <String, PlatformSupport>{
|
platformSupport: <String, PlatformDetails>{
|
||||||
kPlatformAndroid: PlatformSupport.inline,
|
kPlatformAndroid: const PlatformDetails(PlatformSupport.inline),
|
||||||
kPlatformIos: PlatformSupport.inline,
|
kPlatformIos: const PlatformDetails(PlatformSupport.inline),
|
||||||
},
|
},
|
||||||
extraFiles: <String>[
|
extraFiles: <String>[
|
||||||
'example/android/gradlew',
|
'example/android/gradlew',
|
||||||
@ -1244,9 +1244,9 @@ void main() {
|
|||||||
final Directory pluginDir = createFakePlugin(
|
final Directory pluginDir = createFakePlugin(
|
||||||
'plugin',
|
'plugin',
|
||||||
packagesDir,
|
packagesDir,
|
||||||
platformSupport: <String, PlatformSupport>{
|
platformSupport: <String, PlatformDetails>{
|
||||||
kPlatformAndroid: PlatformSupport.inline,
|
kPlatformAndroid: const PlatformDetails(PlatformSupport.inline),
|
||||||
kPlatformIos: PlatformSupport.inline,
|
kPlatformIos: const PlatformDetails(PlatformSupport.inline),
|
||||||
},
|
},
|
||||||
extraFiles: <String>[
|
extraFiles: <String>[
|
||||||
'example/android/gradlew',
|
'example/android/gradlew',
|
||||||
|
@ -180,8 +180,8 @@ void main() {
|
|||||||
'plugin',
|
'plugin',
|
||||||
packagesDir,
|
packagesDir,
|
||||||
extraFiles: <String>['test/empty_test.dart'],
|
extraFiles: <String>['test/empty_test.dart'],
|
||||||
platformSupport: <String, PlatformSupport>{
|
platformSupport: <String, PlatformDetails>{
|
||||||
kPlatformWeb: PlatformSupport.inline,
|
kPlatformWeb: const PlatformDetails(PlatformSupport.inline),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -41,6 +41,21 @@ Directory createPackagesDirectory(
|
|||||||
return packagesDir;
|
return packagesDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Details for platform support in a plugin.
|
||||||
|
@immutable
|
||||||
|
class PlatformDetails {
|
||||||
|
const PlatformDetails(
|
||||||
|
this.type, {
|
||||||
|
this.variants = const <String>[],
|
||||||
|
});
|
||||||
|
|
||||||
|
/// The type of support for the platform.
|
||||||
|
final PlatformSupport type;
|
||||||
|
|
||||||
|
/// Any 'supportVariants' to list in the pubspec.
|
||||||
|
final List<String> variants;
|
||||||
|
}
|
||||||
|
|
||||||
/// Creates a plugin package with the given [name] in [packagesDirectory].
|
/// Creates a plugin package with the given [name] in [packagesDirectory].
|
||||||
///
|
///
|
||||||
/// [platformSupport] is a map of platform string to the support details for
|
/// [platformSupport] is a map of platform string to the support details for
|
||||||
@ -54,8 +69,8 @@ Directory createFakePlugin(
|
|||||||
Directory parentDirectory, {
|
Directory parentDirectory, {
|
||||||
List<String> examples = const <String>['example'],
|
List<String> examples = const <String>['example'],
|
||||||
List<String> extraFiles = const <String>[],
|
List<String> extraFiles = const <String>[],
|
||||||
Map<String, PlatformSupport> platformSupport =
|
Map<String, PlatformDetails> platformSupport =
|
||||||
const <String, PlatformSupport>{},
|
const <String, PlatformDetails>{},
|
||||||
String? version = '0.0.1',
|
String? version = '0.0.1',
|
||||||
}) {
|
}) {
|
||||||
final Directory pluginDirectory = createFakePackage(name, parentDirectory,
|
final Directory pluginDirectory = createFakePackage(name, parentDirectory,
|
||||||
@ -143,8 +158,8 @@ void createFakePubspec(
|
|||||||
String name = 'fake_package',
|
String name = 'fake_package',
|
||||||
bool isFlutter = true,
|
bool isFlutter = true,
|
||||||
bool isPlugin = false,
|
bool isPlugin = false,
|
||||||
Map<String, PlatformSupport> platformSupport =
|
Map<String, PlatformDetails> platformSupport =
|
||||||
const <String, PlatformSupport>{},
|
const <String, PlatformDetails>{},
|
||||||
String publishTo = 'http://no_pub_server.com',
|
String publishTo = 'http://no_pub_server.com',
|
||||||
String? version,
|
String? version,
|
||||||
}) {
|
}) {
|
||||||
@ -160,12 +175,11 @@ flutter:
|
|||||||
plugin:
|
plugin:
|
||||||
platforms:
|
platforms:
|
||||||
''';
|
''';
|
||||||
for (final MapEntry<String, PlatformSupport> platform
|
for (final MapEntry<String, PlatformDetails> platform
|
||||||
in platformSupport.entries) {
|
in platformSupport.entries) {
|
||||||
yaml += _pluginPlatformSection(platform.key, platform.value, name);
|
yaml += _pluginPlatformSection(platform.key, platform.value, name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
yaml += '''
|
yaml += '''
|
||||||
dependencies:
|
dependencies:
|
||||||
flutter:
|
flutter:
|
||||||
@ -186,50 +200,73 @@ publish_to: $publishTo # Hardcoded safeguard to prevent this from somehow being
|
|||||||
}
|
}
|
||||||
|
|
||||||
String _pluginPlatformSection(
|
String _pluginPlatformSection(
|
||||||
String platform, PlatformSupport type, String packageName) {
|
String platform, PlatformDetails support, String packageName) {
|
||||||
if (type == PlatformSupport.federated) {
|
String entry = '';
|
||||||
return '''
|
// Build the main plugin entry.
|
||||||
|
if (support.type == PlatformSupport.federated) {
|
||||||
|
entry = '''
|
||||||
$platform:
|
$platform:
|
||||||
default_package: ${packageName}_$platform
|
default_package: ${packageName}_$platform
|
||||||
''';
|
''';
|
||||||
}
|
} else {
|
||||||
switch (platform) {
|
switch (platform) {
|
||||||
case kPlatformAndroid:
|
case kPlatformAndroid:
|
||||||
return '''
|
entry = '''
|
||||||
android:
|
android:
|
||||||
package: io.flutter.plugins.fake
|
package: io.flutter.plugins.fake
|
||||||
pluginClass: FakePlugin
|
pluginClass: FakePlugin
|
||||||
''';
|
''';
|
||||||
|
break;
|
||||||
case kPlatformIos:
|
case kPlatformIos:
|
||||||
return '''
|
entry = '''
|
||||||
ios:
|
ios:
|
||||||
pluginClass: FLTFakePlugin
|
pluginClass: FLTFakePlugin
|
||||||
''';
|
''';
|
||||||
|
break;
|
||||||
case kPlatformLinux:
|
case kPlatformLinux:
|
||||||
return '''
|
entry = '''
|
||||||
linux:
|
linux:
|
||||||
pluginClass: FakePlugin
|
pluginClass: FakePlugin
|
||||||
''';
|
''';
|
||||||
|
break;
|
||||||
case kPlatformMacos:
|
case kPlatformMacos:
|
||||||
return '''
|
entry = '''
|
||||||
macos:
|
macos:
|
||||||
pluginClass: FakePlugin
|
pluginClass: FakePlugin
|
||||||
''';
|
''';
|
||||||
|
break;
|
||||||
case kPlatformWeb:
|
case kPlatformWeb:
|
||||||
return '''
|
entry = '''
|
||||||
web:
|
web:
|
||||||
pluginClass: FakePlugin
|
pluginClass: FakePlugin
|
||||||
fileName: ${packageName}_web.dart
|
fileName: ${packageName}_web.dart
|
||||||
''';
|
''';
|
||||||
|
break;
|
||||||
case kPlatformWindows:
|
case kPlatformWindows:
|
||||||
return '''
|
entry = '''
|
||||||
windows:
|
windows:
|
||||||
pluginClass: FakePlugin
|
pluginClass: FakePlugin
|
||||||
''';
|
''';
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
assert(false);
|
assert(false, 'Unrecognized platform: $platform');
|
||||||
return '';
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add any variants.
|
||||||
|
if (support.variants.isNotEmpty) {
|
||||||
|
entry += '''
|
||||||
|
supportedVariants:
|
||||||
|
''';
|
||||||
|
for (final String variant in support.variants) {
|
||||||
|
entry += '''
|
||||||
|
- $variant
|
||||||
|
''';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef _ErrorHandler = void Function(Error error);
|
typedef _ErrorHandler = void Function(Error error);
|
||||||
|
@ -57,8 +57,8 @@ void main() {
|
|||||||
group('iOS', () {
|
group('iOS', () {
|
||||||
test('skip if iOS is not supported', () async {
|
test('skip if iOS is not supported', () async {
|
||||||
createFakePlugin('plugin', packagesDir,
|
createFakePlugin('plugin', packagesDir,
|
||||||
platformSupport: <String, PlatformSupport>{
|
platformSupport: <String, PlatformDetails>{
|
||||||
kPlatformMacos: PlatformSupport.inline,
|
kPlatformMacos: const PlatformDetails(PlatformSupport.inline),
|
||||||
});
|
});
|
||||||
|
|
||||||
final List<String> output =
|
final List<String> output =
|
||||||
@ -70,8 +70,8 @@ void main() {
|
|||||||
|
|
||||||
test('skip if iOS is implemented in a federated package', () async {
|
test('skip if iOS is implemented in a federated package', () async {
|
||||||
createFakePlugin('plugin', packagesDir,
|
createFakePlugin('plugin', packagesDir,
|
||||||
platformSupport: <String, PlatformSupport>{
|
platformSupport: <String, PlatformDetails>{
|
||||||
kPlatformIos: PlatformSupport.federated
|
kPlatformIos: const PlatformDetails(PlatformSupport.federated)
|
||||||
});
|
});
|
||||||
|
|
||||||
final List<String> output =
|
final List<String> output =
|
||||||
@ -83,8 +83,8 @@ void main() {
|
|||||||
|
|
||||||
test('runs for iOS plugin', () async {
|
test('runs for iOS plugin', () async {
|
||||||
final Directory pluginDirectory = createFakePlugin(
|
final Directory pluginDirectory = createFakePlugin(
|
||||||
'plugin', packagesDir, platformSupport: <String, PlatformSupport>{
|
'plugin', packagesDir, platformSupport: <String, PlatformDetails>{
|
||||||
kPlatformIos: PlatformSupport.inline
|
kPlatformIos: const PlatformDetails(PlatformSupport.inline)
|
||||||
});
|
});
|
||||||
|
|
||||||
final Directory pluginExampleDirectory =
|
final Directory pluginExampleDirectory =
|
||||||
@ -126,8 +126,8 @@ void main() {
|
|||||||
|
|
||||||
test('fails if xcrun fails', () async {
|
test('fails if xcrun fails', () async {
|
||||||
createFakePlugin('plugin', packagesDir,
|
createFakePlugin('plugin', packagesDir,
|
||||||
platformSupport: <String, PlatformSupport>{
|
platformSupport: <String, PlatformDetails>{
|
||||||
kPlatformIos: PlatformSupport.inline
|
kPlatformIos: const PlatformDetails(PlatformSupport.inline)
|
||||||
});
|
});
|
||||||
|
|
||||||
processRunner.mockProcessesForExecutable['xcrun'] = <io.Process>[
|
processRunner.mockProcessesForExecutable['xcrun'] = <io.Process>[
|
||||||
@ -172,8 +172,8 @@ void main() {
|
|||||||
|
|
||||||
test('skip if macOS is implemented in a federated package', () async {
|
test('skip if macOS is implemented in a federated package', () async {
|
||||||
createFakePlugin('plugin', packagesDir,
|
createFakePlugin('plugin', packagesDir,
|
||||||
platformSupport: <String, PlatformSupport>{
|
platformSupport: <String, PlatformDetails>{
|
||||||
kPlatformMacos: PlatformSupport.federated,
|
kPlatformMacos: const PlatformDetails(PlatformSupport.federated),
|
||||||
});
|
});
|
||||||
|
|
||||||
final List<String> output = await runCapturingPrint(
|
final List<String> output = await runCapturingPrint(
|
||||||
@ -186,8 +186,8 @@ void main() {
|
|||||||
test('runs for macOS plugin', () async {
|
test('runs for macOS plugin', () async {
|
||||||
final Directory pluginDirectory1 = createFakePlugin(
|
final Directory pluginDirectory1 = createFakePlugin(
|
||||||
'plugin', packagesDir,
|
'plugin', packagesDir,
|
||||||
platformSupport: <String, PlatformSupport>{
|
platformSupport: <String, PlatformDetails>{
|
||||||
kPlatformMacos: PlatformSupport.inline,
|
kPlatformMacos: const PlatformDetails(PlatformSupport.inline),
|
||||||
});
|
});
|
||||||
|
|
||||||
final Directory pluginExampleDirectory =
|
final Directory pluginExampleDirectory =
|
||||||
@ -223,8 +223,8 @@ void main() {
|
|||||||
|
|
||||||
test('fails if xcrun fails', () async {
|
test('fails if xcrun fails', () async {
|
||||||
createFakePlugin('plugin', packagesDir,
|
createFakePlugin('plugin', packagesDir,
|
||||||
platformSupport: <String, PlatformSupport>{
|
platformSupport: <String, PlatformDetails>{
|
||||||
kPlatformMacos: PlatformSupport.inline,
|
kPlatformMacos: const PlatformDetails(PlatformSupport.inline),
|
||||||
});
|
});
|
||||||
|
|
||||||
processRunner.mockProcessesForExecutable['xcrun'] = <io.Process>[
|
processRunner.mockProcessesForExecutable['xcrun'] = <io.Process>[
|
||||||
@ -253,9 +253,9 @@ void main() {
|
|||||||
test('runs both iOS and macOS when supported', () async {
|
test('runs both iOS and macOS when supported', () async {
|
||||||
final Directory pluginDirectory1 = createFakePlugin(
|
final Directory pluginDirectory1 = createFakePlugin(
|
||||||
'plugin', packagesDir,
|
'plugin', packagesDir,
|
||||||
platformSupport: <String, PlatformSupport>{
|
platformSupport: <String, PlatformDetails>{
|
||||||
kPlatformIos: PlatformSupport.inline,
|
kPlatformIos: const PlatformDetails(PlatformSupport.inline),
|
||||||
kPlatformMacos: PlatformSupport.inline,
|
kPlatformMacos: const PlatformDetails(PlatformSupport.inline),
|
||||||
});
|
});
|
||||||
|
|
||||||
final Directory pluginExampleDirectory =
|
final Directory pluginExampleDirectory =
|
||||||
@ -313,8 +313,8 @@ void main() {
|
|||||||
test('runs only macOS for a macOS plugin', () async {
|
test('runs only macOS for a macOS plugin', () async {
|
||||||
final Directory pluginDirectory1 = createFakePlugin(
|
final Directory pluginDirectory1 = createFakePlugin(
|
||||||
'plugin', packagesDir,
|
'plugin', packagesDir,
|
||||||
platformSupport: <String, PlatformSupport>{
|
platformSupport: <String, PlatformDetails>{
|
||||||
kPlatformMacos: PlatformSupport.inline,
|
kPlatformMacos: const PlatformDetails(PlatformSupport.inline),
|
||||||
});
|
});
|
||||||
|
|
||||||
final Directory pluginExampleDirectory =
|
final Directory pluginExampleDirectory =
|
||||||
@ -354,8 +354,8 @@ void main() {
|
|||||||
|
|
||||||
test('runs only iOS for a iOS plugin', () async {
|
test('runs only iOS for a iOS plugin', () async {
|
||||||
final Directory pluginDirectory = createFakePlugin(
|
final Directory pluginDirectory = createFakePlugin(
|
||||||
'plugin', packagesDir, platformSupport: <String, PlatformSupport>{
|
'plugin', packagesDir, platformSupport: <String, PlatformDetails>{
|
||||||
kPlatformIos: PlatformSupport.inline
|
kPlatformIos: const PlatformDetails(PlatformSupport.inline)
|
||||||
});
|
});
|
||||||
|
|
||||||
final Directory pluginExampleDirectory =
|
final Directory pluginExampleDirectory =
|
||||||
|
Reference in New Issue
Block a user