mirror of
https://github.com/flutter/packages.git
synced 2025-05-24 04:06:40 +08:00
[tools] adds 'android' alias for build-example script (#3656)
[tools] adds 'android' alias for build-example script
This commit is contained in:
@ -39,6 +39,8 @@ const String _flutterBuildTypeMacOS = 'macos';
|
|||||||
const String _flutterBuildTypeWeb = 'web';
|
const String _flutterBuildTypeWeb = 'web';
|
||||||
const String _flutterBuildTypeWindows = 'windows';
|
const String _flutterBuildTypeWindows = 'windows';
|
||||||
|
|
||||||
|
const String _flutterBuildTypeAndroidAlias = 'android';
|
||||||
|
|
||||||
/// 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 {
|
||||||
/// Creates an instance of the build command.
|
/// Creates an instance of the build command.
|
||||||
@ -52,7 +54,8 @@ class BuildExamplesCommand extends PackageLoopingCommand {
|
|||||||
argParser.addFlag(platformWeb);
|
argParser.addFlag(platformWeb);
|
||||||
argParser.addFlag(platformWindows);
|
argParser.addFlag(platformWindows);
|
||||||
argParser.addFlag(platformIOS);
|
argParser.addFlag(platformIOS);
|
||||||
argParser.addFlag(_platformFlagApk);
|
argParser.addFlag(_platformFlagApk,
|
||||||
|
aliases: const <String>[_flutterBuildTypeAndroidAlias]);
|
||||||
argParser.addOption(
|
argParser.addOption(
|
||||||
kEnableExperiment,
|
kEnableExperiment,
|
||||||
defaultsTo: '',
|
defaultsTo: '',
|
||||||
|
@ -13,6 +13,9 @@ typedef Print = void Function(Object? object);
|
|||||||
/// Key for APK (Android) platform.
|
/// Key for APK (Android) platform.
|
||||||
const String platformAndroid = 'android';
|
const String platformAndroid = 'android';
|
||||||
|
|
||||||
|
/// Alias for APK (Android) platform.
|
||||||
|
const String platformAndroidAlias = 'apk';
|
||||||
|
|
||||||
/// Key for IPA (iOS) platform.
|
/// Key for IPA (iOS) platform.
|
||||||
const String platformIOS = 'ios';
|
const String platformIOS = 'ios';
|
||||||
|
|
||||||
|
@ -26,7 +26,8 @@ class DriveExamplesCommand extends PackageLoopingCommand {
|
|||||||
Platform platform = const LocalPlatform(),
|
Platform platform = const LocalPlatform(),
|
||||||
}) : super(packagesDir, processRunner: processRunner, platform: platform) {
|
}) : super(packagesDir, processRunner: processRunner, platform: platform) {
|
||||||
argParser.addFlag(platformAndroid,
|
argParser.addFlag(platformAndroid,
|
||||||
help: 'Runs the Android implementation of the examples');
|
help: 'Runs the Android implementation of the examples',
|
||||||
|
aliases: const <String>[platformAndroidAlias]);
|
||||||
argParser.addFlag(platformIOS,
|
argParser.addFlag(platformIOS,
|
||||||
help: 'Runs the iOS implementation of the examples');
|
help: 'Runs the iOS implementation of the examples');
|
||||||
argParser.addFlag(platformLinux,
|
argParser.addFlag(platformLinux,
|
||||||
|
@ -406,6 +406,34 @@ void main() {
|
|||||||
]));
|
]));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('building for Android with alias', () async {
|
||||||
|
final RepositoryPackage plugin = createFakePlugin('plugin', packagesDir,
|
||||||
|
platformSupport: <String, PlatformDetails>{
|
||||||
|
platformAndroid: const PlatformDetails(PlatformSupport.inline),
|
||||||
|
});
|
||||||
|
|
||||||
|
final Directory pluginExampleDirectory = getExampleDir(plugin);
|
||||||
|
|
||||||
|
final List<String> output = await runCapturingPrint(runner, <String>[
|
||||||
|
'build-examples',
|
||||||
|
'--android',
|
||||||
|
]);
|
||||||
|
|
||||||
|
expect(
|
||||||
|
output,
|
||||||
|
containsAllInOrder(<String>[
|
||||||
|
'\nBUILDING plugin/example for Android (apk)',
|
||||||
|
]),
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(
|
||||||
|
processRunner.recordedCalls,
|
||||||
|
orderedEquals(<ProcessCall>[
|
||||||
|
ProcessCall(getFlutterCommand(mockPlatform),
|
||||||
|
const <String>['build', 'apk'], pluginExampleDirectory.path),
|
||||||
|
]));
|
||||||
|
});
|
||||||
|
|
||||||
test('enable-experiment flag for Android', () async {
|
test('enable-experiment flag for Android', () async {
|
||||||
final RepositoryPackage plugin = createFakePlugin('plugin', packagesDir,
|
final RepositoryPackage plugin = createFakePlugin('plugin', packagesDir,
|
||||||
platformSupport: <String, PlatformDetails>{
|
platformSupport: <String, PlatformDetails>{
|
||||||
|
@ -808,6 +808,56 @@ void main() {
|
|||||||
]));
|
]));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('driving on an Android plugin with alias', () async {
|
||||||
|
final RepositoryPackage plugin = createFakePlugin(
|
||||||
|
'plugin',
|
||||||
|
packagesDir,
|
||||||
|
extraFiles: <String>[
|
||||||
|
'example/test_driver/plugin_test.dart',
|
||||||
|
'example/test_driver/plugin.dart',
|
||||||
|
'example/android/android.java',
|
||||||
|
],
|
||||||
|
platformSupport: <String, PlatformDetails>{
|
||||||
|
platformAndroid: const PlatformDetails(PlatformSupport.inline),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
final Directory pluginExampleDirectory = getExampleDir(plugin);
|
||||||
|
|
||||||
|
setMockFlutterDevicesOutput();
|
||||||
|
final List<String> output = await runCapturingPrint(runner, <String>[
|
||||||
|
'drive-examples',
|
||||||
|
'--apk',
|
||||||
|
]);
|
||||||
|
|
||||||
|
expect(
|
||||||
|
output,
|
||||||
|
containsAllInOrder(<Matcher>[
|
||||||
|
contains('Running for plugin'),
|
||||||
|
contains('No issues found!'),
|
||||||
|
]),
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(
|
||||||
|
processRunner.recordedCalls,
|
||||||
|
orderedEquals(<ProcessCall>[
|
||||||
|
ProcessCall(getFlutterCommand(mockPlatform),
|
||||||
|
const <String>['devices', '--machine'], null),
|
||||||
|
ProcessCall(
|
||||||
|
getFlutterCommand(mockPlatform),
|
||||||
|
const <String>[
|
||||||
|
'drive',
|
||||||
|
'-d',
|
||||||
|
_fakeAndroidDevice,
|
||||||
|
'--driver',
|
||||||
|
'test_driver/plugin_test.dart',
|
||||||
|
'--target',
|
||||||
|
'test_driver/plugin.dart'
|
||||||
|
],
|
||||||
|
pluginExampleDirectory.path),
|
||||||
|
]));
|
||||||
|
});
|
||||||
|
|
||||||
test('driving when plugin does not support Android is no-op', () async {
|
test('driving when plugin does not support Android is no-op', () async {
|
||||||
createFakePlugin(
|
createFakePlugin(
|
||||||
'plugin',
|
'plugin',
|
||||||
|
Reference in New Issue
Block a user