forked from firka/flutter
[tools]build ipa validate launch image using template files (#116242)
* [tools]build ipa validate launch image using template files * reuse more code by sharing the same file key * fix space
This commit is contained in:
@@ -1476,6 +1476,162 @@ void main() {
|
||||
Platform: () => macosPlatform,
|
||||
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
|
||||
});
|
||||
|
||||
testUsingContext('Validate template launch images with conflicts', () async {
|
||||
const String projectLaunchImageContentsJsonPath = 'ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json';
|
||||
const String projectLaunchImagePath = 'ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png';
|
||||
final String templateLaunchImageContentsJsonPath = '${Cache.flutterRoot!}/packages/flutter_tools/templates/app_shared/ios.tmpl/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json';
|
||||
const String templateLaunchImagePath = '/flutter_template_images/templates/app_shared/ios.tmpl/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png';
|
||||
|
||||
fakeProcessManager.addCommands(<FakeCommand>[
|
||||
xattrCommand,
|
||||
setUpFakeXcodeBuildHandler(onRun: () {
|
||||
fileSystem.file(templateLaunchImageContentsJsonPath)
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync('''
|
||||
{
|
||||
"images": [
|
||||
{
|
||||
"idiom": "iphone",
|
||||
"filename": "LaunchImage@2x.png",
|
||||
"scale": "2x"
|
||||
}
|
||||
],
|
||||
"info": {
|
||||
"version": 1,
|
||||
"author": "xcode"
|
||||
}
|
||||
}
|
||||
''');
|
||||
fileSystem.file(templateLaunchImagePath)
|
||||
..createSync(recursive: true)
|
||||
..writeAsBytes(<int>[1, 2, 3]);
|
||||
|
||||
fileSystem.file(projectLaunchImageContentsJsonPath)
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync('''
|
||||
{
|
||||
"images": [
|
||||
{
|
||||
"idiom": "iphone",
|
||||
"filename": "LaunchImage@2x.png",
|
||||
"scale": "2x"
|
||||
}
|
||||
],
|
||||
"info": {
|
||||
"version": 1,
|
||||
"author": "xcode"
|
||||
}
|
||||
}
|
||||
''');
|
||||
fileSystem.file(projectLaunchImagePath)
|
||||
..createSync(recursive: true)
|
||||
..writeAsBytes(<int>[1, 2, 3]);
|
||||
}),
|
||||
exportArchiveCommand(exportOptionsPlist: _exportOptionsPlist),
|
||||
]);
|
||||
|
||||
createMinimalMockProjectFiles();
|
||||
|
||||
final BuildCommand command = BuildCommand(
|
||||
androidSdk: FakeAndroidSdk(),
|
||||
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
|
||||
fileSystem: MemoryFileSystem.test(),
|
||||
logger: BufferLogger.test(),
|
||||
osUtils: FakeOperatingSystemUtils(),
|
||||
);
|
||||
await createTestCommandRunner(command).run(
|
||||
<String>['build', 'ipa', '--no-pub']);
|
||||
|
||||
expect(
|
||||
testLogger.statusText,
|
||||
contains('Warning: Launch image is set to the default placeholder. Replace with unique launch images.'),
|
||||
);
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => fileSystem,
|
||||
ProcessManager: () => fakeProcessManager,
|
||||
Platform: () => macosPlatform,
|
||||
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
|
||||
});
|
||||
|
||||
|
||||
testUsingContext('Validate template launch images without conflicts', () async {
|
||||
const String projectLaunchImageContentsJsonPath = 'ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json';
|
||||
const String projectLaunchImagePath = 'ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png';
|
||||
final String templateLaunchImageContentsJsonPath = '${Cache.flutterRoot!}/packages/flutter_tools/templates/app_shared/ios.tmpl/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json';
|
||||
const String templateLaunchImagePath = '/flutter_template_images/templates/app_shared/ios.tmpl/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png';
|
||||
|
||||
fakeProcessManager.addCommands(<FakeCommand>[
|
||||
xattrCommand,
|
||||
setUpFakeXcodeBuildHandler(onRun: () {
|
||||
fileSystem.file(templateLaunchImageContentsJsonPath)
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync('''
|
||||
{
|
||||
"images": [
|
||||
{
|
||||
"idiom": "iphone",
|
||||
"filename": "LaunchImage@2x.png",
|
||||
"scale": "2x"
|
||||
}
|
||||
],
|
||||
"info": {
|
||||
"version": 1,
|
||||
"author": "xcode"
|
||||
}
|
||||
}
|
||||
''');
|
||||
fileSystem.file(templateLaunchImagePath)
|
||||
..createSync(recursive: true)
|
||||
..writeAsBytes(<int>[1, 2, 3]);
|
||||
|
||||
fileSystem.file(projectLaunchImageContentsJsonPath)
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync('''
|
||||
{
|
||||
"images": [
|
||||
{
|
||||
"idiom": "iphone",
|
||||
"filename": "LaunchImage@2x.png",
|
||||
"scale": "2x"
|
||||
}
|
||||
],
|
||||
"info": {
|
||||
"version": 1,
|
||||
"author": "xcode"
|
||||
}
|
||||
}
|
||||
''');
|
||||
fileSystem.file(projectLaunchImagePath)
|
||||
..createSync(recursive: true)
|
||||
..writeAsBytes(<int>[4, 5, 6]);
|
||||
}),
|
||||
exportArchiveCommand(exportOptionsPlist: _exportOptionsPlist),
|
||||
]);
|
||||
|
||||
createMinimalMockProjectFiles();
|
||||
|
||||
final BuildCommand command = BuildCommand(
|
||||
androidSdk: FakeAndroidSdk(),
|
||||
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
|
||||
fileSystem: MemoryFileSystem.test(),
|
||||
logger: BufferLogger.test(),
|
||||
osUtils: FakeOperatingSystemUtils(),
|
||||
);
|
||||
await createTestCommandRunner(command).run(
|
||||
<String>['build', 'ipa', '--no-pub']);
|
||||
|
||||
expect(
|
||||
testLogger.statusText,
|
||||
isNot(contains('Warning: Launch image is set to the default placeholder. Replace with unique launch images.')),
|
||||
);
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => fileSystem,
|
||||
ProcessManager: () => fakeProcessManager,
|
||||
Platform: () => macosPlatform,
|
||||
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -476,6 +476,92 @@ void main() {
|
||||
),
|
||||
);
|
||||
}, overrides: overrides);
|
||||
|
||||
testUsingContext('returns project launch image dirname', () async {
|
||||
final BuildableIOSApp iosApp = BuildableIOSApp(
|
||||
IosProject.fromFlutter(FlutterProject.fromDirectory(globals.fs.currentDirectory)),
|
||||
'com.foo.bar',
|
||||
'Runner',
|
||||
);
|
||||
final String launchImageDirSuffix = globals.fs.path.join(
|
||||
'Runner',
|
||||
'Assets.xcassets',
|
||||
'LaunchImage.imageset',
|
||||
);
|
||||
expect(iosApp.projectLaunchImageDirName, globals.fs.path.join('ios', launchImageDirSuffix));
|
||||
}, overrides: overrides);
|
||||
|
||||
testUsingContext('returns template launch image dirname for Contents.json', () async {
|
||||
final BuildableIOSApp iosApp = BuildableIOSApp(
|
||||
IosProject.fromFlutter(FlutterProject.fromDirectory(globals.fs.currentDirectory)),
|
||||
'com.foo.bar',
|
||||
'Runner',
|
||||
);
|
||||
final String launchImageDirSuffix = globals.fs.path.join(
|
||||
'Runner',
|
||||
'Assets.xcassets',
|
||||
'LaunchImage.imageset',
|
||||
);
|
||||
expect(
|
||||
iosApp.templateLaunchImageDirNameForContentsJson,
|
||||
globals.fs.path.join(
|
||||
Cache.flutterRoot!,
|
||||
'packages',
|
||||
'flutter_tools',
|
||||
'templates',
|
||||
'app_shared',
|
||||
'ios.tmpl',
|
||||
launchImageDirSuffix,
|
||||
),
|
||||
);
|
||||
}, overrides: overrides);
|
||||
|
||||
testUsingContext('returns template launch image dirname for images', () async {
|
||||
final String toolsDir = globals.fs.path.join(
|
||||
Cache.flutterRoot!,
|
||||
'packages',
|
||||
'flutter_tools',
|
||||
);
|
||||
final String packageConfigPath = globals.fs.path.join(
|
||||
toolsDir,
|
||||
'.dart_tool',
|
||||
'package_config.json'
|
||||
);
|
||||
globals.fs.file(packageConfigPath)
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync('''
|
||||
{
|
||||
"configVersion": 2,
|
||||
"packages": [
|
||||
{
|
||||
"name": "flutter_template_images",
|
||||
"rootUri": "/flutter_template_images",
|
||||
"packageUri": "lib/",
|
||||
"languageVersion": "2.12"
|
||||
}
|
||||
]
|
||||
}
|
||||
''');
|
||||
final BuildableIOSApp iosApp = BuildableIOSApp(
|
||||
IosProject.fromFlutter(FlutterProject.fromDirectory(globals.fs.currentDirectory)),
|
||||
'com.foo.bar',
|
||||
'Runner');
|
||||
final String launchImageDirSuffix = globals.fs.path.join(
|
||||
'Runner',
|
||||
'Assets.xcassets',
|
||||
'LaunchImage.imageset',
|
||||
);
|
||||
expect(
|
||||
await iosApp.templateLaunchImageDirNameForImages,
|
||||
globals.fs.path.absolute(
|
||||
'flutter_template_images',
|
||||
'templates',
|
||||
'app_shared',
|
||||
'ios.tmpl',
|
||||
launchImageDirSuffix,
|
||||
),
|
||||
);
|
||||
}, overrides: overrides);
|
||||
});
|
||||
|
||||
group('FuchsiaApp', () {
|
||||
|
||||
Reference in New Issue
Block a user