Unverified Commit 7f0050f5 authored by Lau Ching Jun's avatar Lau Ching Jun Committed by GitHub

Add a new PrebuiltFlutterApplicationPackage interface. (#95290)

* Add a new PrebuiltFlutterApplicationPackage interface.

* Review feedback

* Rename bundleDir to uncompressedBundle
parent 7444ad8d
...@@ -362,7 +362,7 @@ class AndroidDevice extends Device { ...@@ -362,7 +362,7 @@ class AndroidDevice extends Device {
} }
String _getSourceSha1(AndroidApk apk) { String _getSourceSha1(AndroidApk apk) {
final File shaFile = _fileSystem.file('${apk.file.path}.sha1'); final File shaFile = _fileSystem.file('${apk.applicationPackage.path}.sha1');
return shaFile.existsSync() ? shaFile.readAsStringSync() : ''; return shaFile.existsSync() ? shaFile.readAsStringSync() : '';
} }
...@@ -435,13 +435,13 @@ class AndroidDevice extends Device { ...@@ -435,13 +435,13 @@ class AndroidDevice extends Device {
AndroidApk app, { AndroidApk app, {
String? userIdentifier, String? userIdentifier,
}) async { }) async {
if (!app.file.existsSync()) { if (!app.applicationPackage.existsSync()) {
_logger.printError('"${_fileSystem.path.relative(app.file.path)}" does not exist.'); _logger.printError('"${_fileSystem.path.relative(app.applicationPackage.path)}" does not exist.');
return false; return false;
} }
final Status status = _logger.startProgress( final Status status = _logger.startProgress(
'Installing ${_fileSystem.path.relative(app.file.path)}...', 'Installing ${_fileSystem.path.relative(app.applicationPackage.path)}...',
); );
final RunResult installResult = await _processUtils.run( final RunResult installResult = await _processUtils.run(
adbCommandForDevice(<String>[ adbCommandForDevice(<String>[
...@@ -450,7 +450,7 @@ class AndroidDevice extends Device { ...@@ -450,7 +450,7 @@ class AndroidDevice extends Device {
'-r', '-r',
if (userIdentifier != null) if (userIdentifier != null)
...<String>['--user', userIdentifier], ...<String>['--user', userIdentifier],
app.file.path app.applicationPackage.path
])); ]));
status.stop(); status.stop();
// Some versions of adb exit with exit code 0 even on failure :( // Some versions of adb exit with exit code 0 even on failure :(
......
...@@ -21,13 +21,13 @@ import 'android_sdk.dart'; ...@@ -21,13 +21,13 @@ import 'android_sdk.dart';
import 'gradle.dart'; import 'gradle.dart';
/// An application package created from an already built Android APK. /// An application package created from an already built Android APK.
class AndroidApk extends ApplicationPackage { class AndroidApk extends ApplicationPackage implements PrebuiltApplicationPackage {
AndroidApk({ AndroidApk({
required String id, required String id,
required this.file, required this.applicationPackage,
required this.versionCode, required this.versionCode,
required this.launchActivity, required this.launchActivity,
}) : assert(file != null), }) : assert(applicationPackage != null),
assert(launchActivity != null), assert(launchActivity != null),
super(id: id); super(id: id);
...@@ -80,14 +80,14 @@ class AndroidApk extends ApplicationPackage { ...@@ -80,14 +80,14 @@ class AndroidApk extends ApplicationPackage {
return AndroidApk( return AndroidApk(
id: packageName, id: packageName,
file: apk, applicationPackage: apk,
versionCode: data.versionCode == null ? null : int.tryParse(data.versionCode!), versionCode: data.versionCode == null ? null : int.tryParse(data.versionCode!),
launchActivity: '${data.packageName}/${data.launchableActivityName}', launchActivity: '${data.packageName}/${data.launchableActivityName}',
); );
} }
/// Path to the actual apk file. @override
final File file; final FileSystemEntity applicationPackage;
/// The path to the activity that should be launched. /// The path to the activity that should be launched.
final String launchActivity; final String launchActivity;
...@@ -197,14 +197,14 @@ class AndroidApk extends ApplicationPackage { ...@@ -197,14 +197,14 @@ class AndroidApk extends ApplicationPackage {
return AndroidApk( return AndroidApk(
id: packageId, id: packageId,
file: apkFile, applicationPackage: apkFile,
versionCode: null, versionCode: null,
launchActivity: launchActivity, launchActivity: launchActivity,
); );
} }
@override @override
String get name => file.basename; String get name => applicationPackage.basename;
} }
abstract class _Entry { abstract class _Entry {
......
...@@ -31,3 +31,12 @@ abstract class ApplicationPackage { ...@@ -31,3 +31,12 @@ abstract class ApplicationPackage {
@override @override
String toString() => displayName ?? id; String toString() => displayName ?? id;
} }
/// An interface for application package that is created from prebuilt binary.
abstract class PrebuiltApplicationPackage implements ApplicationPackage {
/// The application bundle of the prebuilt application.
///
/// The same ApplicationPackage should be able to be recreated by passing
/// the file to [FlutterApplicationPackageFactory.getPackageForPlatform].
FileSystemEntity get applicationPackage;
}
...@@ -33,7 +33,7 @@ abstract class FuchsiaApp extends ApplicationPackage { ...@@ -33,7 +33,7 @@ abstract class FuchsiaApp extends ApplicationPackage {
return null; return null;
} }
return PrebuiltFuchsiaApp( return PrebuiltFuchsiaApp(
farArchive: applicationBinary.path, applicationPackage: applicationBinary,
); );
} }
...@@ -44,20 +44,20 @@ abstract class FuchsiaApp extends ApplicationPackage { ...@@ -44,20 +44,20 @@ abstract class FuchsiaApp extends ApplicationPackage {
File farArchive(BuildMode buildMode); File farArchive(BuildMode buildMode);
} }
class PrebuiltFuchsiaApp extends FuchsiaApp { class PrebuiltFuchsiaApp extends FuchsiaApp implements PrebuiltApplicationPackage {
PrebuiltFuchsiaApp({ PrebuiltFuchsiaApp({
required String farArchive, required this.applicationPackage,
}) : _farArchive = farArchive, }) : // TODO(zanderso): Extract the archive and extract the id from meta/package.
// TODO(zanderso): Extract the archive and extract the id from meta/package. super(projectBundleId: applicationPackage.path);
super(projectBundleId: farArchive);
final String _farArchive; @override
File farArchive(BuildMode buildMode) => globals.fs.file(applicationPackage);
@override @override
File farArchive(BuildMode buildMode) => globals.fs.file(_farArchive); String get name => applicationPackage.path;
@override @override
String get name => _farArchive; final FileSystemEntity applicationPackage;
} }
class BuildableFuchsiaApp extends FuchsiaApp { class BuildableFuchsiaApp extends FuchsiaApp {
......
...@@ -23,14 +23,14 @@ abstract class IOSApp extends ApplicationPackage { ...@@ -23,14 +23,14 @@ abstract class IOSApp extends ApplicationPackage {
'File "${applicationBinary.path}" does not exist. Use an app bundle or an ipa.'); 'File "${applicationBinary.path}" does not exist. Use an app bundle or an ipa.');
return null; return null;
} }
Directory bundleDir; Directory uncompressedBundle;
if (entityType == FileSystemEntityType.directory) { if (entityType == FileSystemEntityType.directory) {
final Directory directory = globals.fs.directory(applicationBinary); final Directory directory = globals.fs.directory(applicationBinary);
if (!_isBundleDirectory(directory)) { if (!_isBundleDirectory(directory)) {
globals.printError('Folder "${applicationBinary.path}" is not an app bundle.'); globals.printError('Folder "${applicationBinary.path}" is not an app bundle.');
return null; return null;
} }
bundleDir = globals.fs.directory(applicationBinary); uncompressedBundle = globals.fs.directory(applicationBinary);
} else { } else {
// Try to unpack as an ipa. // Try to unpack as an ipa.
final Directory tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_app.'); final Directory tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_app.');
...@@ -44,14 +44,14 @@ abstract class IOSApp extends ApplicationPackage { ...@@ -44,14 +44,14 @@ abstract class IOSApp extends ApplicationPackage {
return null; return null;
} }
try { try {
bundleDir = payloadDir.listSync().whereType<Directory>().singleWhere(_isBundleDirectory); uncompressedBundle = payloadDir.listSync().whereType<Directory>().singleWhere(_isBundleDirectory);
} on StateError { } on StateError {
globals.printError( globals.printError(
'Invalid prebuilt iOS ipa. Does not contain a single app bundle.'); 'Invalid prebuilt iOS ipa. Does not contain a single app bundle.');
return null; return null;
} }
} }
final String plistPath = globals.fs.path.join(bundleDir.path, 'Info.plist'); final String plistPath = globals.fs.path.join(uncompressedBundle.path, 'Info.plist');
if (!globals.fs.file(plistPath).existsSync()) { if (!globals.fs.file(plistPath).existsSync()) {
globals.printError('Invalid prebuilt iOS app. Does not contain Info.plist.'); globals.printError('Invalid prebuilt iOS app. Does not contain Info.plist.');
return null; return null;
...@@ -66,9 +66,10 @@ abstract class IOSApp extends ApplicationPackage { ...@@ -66,9 +66,10 @@ abstract class IOSApp extends ApplicationPackage {
} }
return PrebuiltIOSApp( return PrebuiltIOSApp(
bundleDir: bundleDir, uncompressedBundle: uncompressedBundle,
bundleName: globals.fs.path.basename(bundleDir.path), bundleName: globals.fs.path.basename(uncompressedBundle.path),
projectBundleId: id, projectBundleId: id,
applicationPackage: applicationBinary,
); );
} }
...@@ -152,14 +153,19 @@ class BuildableIOSApp extends IOSApp { ...@@ -152,14 +153,19 @@ class BuildableIOSApp extends IOSApp {
} }
} }
class PrebuiltIOSApp extends IOSApp { class PrebuiltIOSApp extends IOSApp implements PrebuiltApplicationPackage {
PrebuiltIOSApp({ PrebuiltIOSApp({
required this.bundleDir, required this.uncompressedBundle,
this.bundleName, this.bundleName,
required String projectBundleId, required String projectBundleId,
required this.applicationPackage,
}) : super(projectBundleId: projectBundleId); }) : super(projectBundleId: projectBundleId);
final Directory bundleDir; /// The uncompressed bundle of the application.
///
/// [IOSApp.fromPrebuiltApp] will uncompress the application into a temporary
/// directory even when an `.ipa` file was used to create the [IOSApp] instance.
final Directory uncompressedBundle;
final String? bundleName; final String? bundleName;
@override @override
...@@ -174,5 +180,11 @@ class PrebuiltIOSApp extends IOSApp { ...@@ -174,5 +180,11 @@ class PrebuiltIOSApp extends IOSApp {
@override @override
String get deviceBundlePath => _bundlePath; String get deviceBundlePath => _bundlePath;
String get _bundlePath => bundleDir.path; String get _bundlePath => uncompressedBundle.path;
/// A [File] or [Directory] pointing to the application bundle.
///
/// This can be either an `.ipa` file or an uncompressed `.app` directory.
@override
final FileSystemEntity applicationPackage;
} }
...@@ -38,10 +38,11 @@ abstract class MacOSApp extends ApplicationPackage { ...@@ -38,10 +38,11 @@ abstract class MacOSApp extends ApplicationPackage {
} }
return PrebuiltMacOSApp( return PrebuiltMacOSApp(
bundleDir: bundleInfo.bundle, uncompressedBundle: bundleInfo.uncompressedBundle,
bundleName: bundleInfo.bundle.path, bundleName: bundleInfo.uncompressedBundle.path,
projectBundleId: bundleInfo.id, projectBundleId: bundleInfo.id,
executable: bundleInfo.executable, executable: bundleInfo.executable,
applicationPackage: applicationBinary,
); );
} }
...@@ -52,14 +53,14 @@ abstract class MacOSApp extends ApplicationPackage { ...@@ -52,14 +53,14 @@ abstract class MacOSApp extends ApplicationPackage {
globals.printError('File "${applicationBundle.path}" does not exist.'); globals.printError('File "${applicationBundle.path}" does not exist.');
return null; return null;
} }
Directory bundleDir; Directory uncompressedBundle;
if (entityType == FileSystemEntityType.directory) { if (entityType == FileSystemEntityType.directory) {
final Directory directory = globals.fs.directory(applicationBundle); final Directory directory = globals.fs.directory(applicationBundle);
if (!_isBundleDirectory(directory)) { if (!_isBundleDirectory(directory)) {
globals.printError('Folder "${applicationBundle.path}" is not an app bundle.'); globals.printError('Folder "${applicationBundle.path}" is not an app bundle.');
return null; return null;
} }
bundleDir = globals.fs.directory(applicationBundle); uncompressedBundle = globals.fs.directory(applicationBundle);
} else { } else {
// Try to unpack as a zip. // Try to unpack as a zip.
final Directory tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_app.'); final Directory tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_app.');
...@@ -70,7 +71,7 @@ abstract class MacOSApp extends ApplicationPackage { ...@@ -70,7 +71,7 @@ abstract class MacOSApp extends ApplicationPackage {
return null; return null;
} }
try { try {
bundleDir = tempDir uncompressedBundle = tempDir
.listSync() .listSync()
.whereType<Directory>() .whereType<Directory>()
.singleWhere(_isBundleDirectory); .singleWhere(_isBundleDirectory);
...@@ -79,7 +80,7 @@ abstract class MacOSApp extends ApplicationPackage { ...@@ -79,7 +80,7 @@ abstract class MacOSApp extends ApplicationPackage {
return null; return null;
} }
} }
final String plistPath = globals.fs.path.join(bundleDir.path, 'Contents', 'Info.plist'); final String plistPath = globals.fs.path.join(uncompressedBundle.path, 'Contents', 'Info.plist');
if (!globals.fs.file(plistPath).existsSync()) { if (!globals.fs.file(plistPath).existsSync()) {
globals.printError('Invalid prebuilt macOS app. Does not contain Info.plist.'); globals.printError('Invalid prebuilt macOS app. Does not contain Info.plist.');
return null; return null;
...@@ -95,11 +96,11 @@ abstract class MacOSApp extends ApplicationPackage { ...@@ -95,11 +96,11 @@ abstract class MacOSApp extends ApplicationPackage {
globals.printError('Invalid prebuilt macOS app. Info.plist does not contain bundle executable'); globals.printError('Invalid prebuilt macOS app. Info.plist does not contain bundle executable');
return null; return null;
} }
final String executable = globals.fs.path.join(bundleDir.path, 'Contents', 'MacOS', executableName); final String executable = globals.fs.path.join(uncompressedBundle.path, 'Contents', 'MacOS', executableName);
if (!globals.fs.file(executable).existsSync()) { if (!globals.fs.file(executable).existsSync()) {
globals.printError('Could not find macOS binary at $executable'); globals.printError('Could not find macOS binary at $executable');
} }
return _BundleInfo(executable, id, bundleDir); return _BundleInfo(executable, id, uncompressedBundle);
} }
@override @override
...@@ -110,16 +111,21 @@ abstract class MacOSApp extends ApplicationPackage { ...@@ -110,16 +111,21 @@ abstract class MacOSApp extends ApplicationPackage {
String? executable(BuildMode buildMode); String? executable(BuildMode buildMode);
} }
class PrebuiltMacOSApp extends MacOSApp { class PrebuiltMacOSApp extends MacOSApp implements PrebuiltApplicationPackage {
PrebuiltMacOSApp({ PrebuiltMacOSApp({
required this.bundleDir, required this.uncompressedBundle,
required this.bundleName, required this.bundleName,
required this.projectBundleId, required this.projectBundleId,
required String executable, required String executable,
required this.applicationPackage,
}) : _executable = executable, }) : _executable = executable,
super(projectBundleId: projectBundleId); super(projectBundleId: projectBundleId);
final Directory bundleDir; /// The uncompressed bundle of the application.
///
/// [MacOSApp.fromPrebuiltApp] will uncompress the application into a temporary
/// directory even when an `.zip` file was used to create the [MacOSApp] instance.
final Directory uncompressedBundle;
final String bundleName; final String bundleName;
final String projectBundleId; final String projectBundleId;
...@@ -129,10 +135,16 @@ class PrebuiltMacOSApp extends MacOSApp { ...@@ -129,10 +135,16 @@ class PrebuiltMacOSApp extends MacOSApp {
String get name => bundleName; String get name => bundleName;
@override @override
String? applicationBundle(BuildMode buildMode) => bundleDir.path; String? applicationBundle(BuildMode buildMode) => uncompressedBundle.path;
@override @override
String? executable(BuildMode buildMode) => _executable; String? executable(BuildMode buildMode) => _executable;
/// A [File] or [Directory] pointing to the application bundle.
///
/// This can be either a `.zip` file or an uncompressed `.app` directory.
@override
final FileSystemEntity applicationPackage;
} }
class BuildableMacOSApp extends MacOSApp { class BuildableMacOSApp extends MacOSApp {
...@@ -170,9 +182,9 @@ class BuildableMacOSApp extends MacOSApp { ...@@ -170,9 +182,9 @@ class BuildableMacOSApp extends MacOSApp {
} }
class _BundleInfo { class _BundleInfo {
_BundleInfo(this.executable, this.id, this.bundle); _BundleInfo(this.executable, this.id, this.uncompressedBundle);
final Directory bundle; final Directory uncompressedBundle;
final String executable; final String executable;
final String id; final String id;
} }
...@@ -68,7 +68,7 @@ void main() { ...@@ -68,7 +68,7 @@ void main() {
final File apkFile = fileSystem.file('app.apk')..createSync(); final File apkFile = fileSystem.file('app.apk')..createSync();
final AndroidApk apk = AndroidApk( final AndroidApk apk = AndroidApk(
id: 'FlutterApp', id: 'FlutterApp',
file: apkFile, applicationPackage: apkFile,
launchActivity: 'FlutterActivity', launchActivity: 'FlutterActivity',
versionCode: 1, versionCode: 1,
); );
...@@ -133,7 +133,7 @@ void main() { ...@@ -133,7 +133,7 @@ void main() {
final File apkFile = fileSystem.file('app.apk')..createSync(); final File apkFile = fileSystem.file('app.apk')..createSync();
final AndroidApk apk = AndroidApk( final AndroidApk apk = AndroidApk(
id: 'FlutterApp', id: 'FlutterApp',
file: apkFile, applicationPackage: apkFile,
launchActivity: 'FlutterActivity', launchActivity: 'FlutterActivity',
versionCode: 1, versionCode: 1,
); );
...@@ -171,7 +171,7 @@ void main() { ...@@ -171,7 +171,7 @@ void main() {
final File apkFile = fileSystem.file('app.apk')..createSync(); final File apkFile = fileSystem.file('app.apk')..createSync();
final AndroidApk apk = AndroidApk( final AndroidApk apk = AndroidApk(
id: 'FlutterApp', id: 'FlutterApp',
file: apkFile, applicationPackage: apkFile,
launchActivity: 'FlutterActivity', launchActivity: 'FlutterActivity',
versionCode: 1, versionCode: 1,
); );
......
...@@ -73,7 +73,7 @@ void main() { ...@@ -73,7 +73,7 @@ void main() {
]); ]);
final File apk = fileSystem.file('app.apk')..createSync(); final File apk = fileSystem.file('app.apk')..createSync();
final AndroidApk androidApk = AndroidApk( final AndroidApk androidApk = AndroidApk(
file: apk, applicationPackage: apk,
id: 'app', id: 'app',
versionCode: 22, versionCode: 22,
launchActivity: 'Main', launchActivity: 'Main',
...@@ -89,7 +89,7 @@ void main() { ...@@ -89,7 +89,7 @@ void main() {
testWithoutContext('Cannot install app if APK file is missing', () async { testWithoutContext('Cannot install app if APK file is missing', () async {
final File apk = fileSystem.file('app.apk'); final File apk = fileSystem.file('app.apk');
final AndroidApk androidApk = AndroidApk( final AndroidApk androidApk = AndroidApk(
file: apk, applicationPackage: apk,
id: 'app', id: 'app',
versionCode: 22, versionCode: 22,
launchActivity: 'Main', launchActivity: 'Main',
...@@ -117,7 +117,7 @@ void main() { ...@@ -117,7 +117,7 @@ void main() {
]); ]);
final File apk = fileSystem.file('app.apk')..createSync(); final File apk = fileSystem.file('app.apk')..createSync();
final AndroidApk androidApk = AndroidApk( final AndroidApk androidApk = AndroidApk(
file: apk, applicationPackage: apk,
id: 'app', id: 'app',
versionCode: 22, versionCode: 22,
launchActivity: 'Main', launchActivity: 'Main',
...@@ -146,7 +146,7 @@ void main() { ...@@ -146,7 +146,7 @@ void main() {
]); ]);
final File apk = fileSystem.file('app.apk')..createSync(); final File apk = fileSystem.file('app.apk')..createSync();
final AndroidApk androidApk = AndroidApk( final AndroidApk androidApk = AndroidApk(
file: apk, applicationPackage: apk,
id: 'app', id: 'app',
versionCode: 22, versionCode: 22,
launchActivity: 'Main', launchActivity: 'Main',
...@@ -190,7 +190,7 @@ void main() { ...@@ -190,7 +190,7 @@ void main() {
]); ]);
final File apk = fileSystem.file('app.apk')..createSync(); final File apk = fileSystem.file('app.apk')..createSync();
final AndroidApk androidApk = AndroidApk( final AndroidApk androidApk = AndroidApk(
file: apk, applicationPackage: apk,
id: 'app', id: 'app',
versionCode: 22, versionCode: 22,
launchActivity: 'Main', launchActivity: 'Main',
...@@ -224,7 +224,7 @@ void main() { ...@@ -224,7 +224,7 @@ void main() {
final File apk = fileSystem.file('app.apk')..createSync(); final File apk = fileSystem.file('app.apk')..createSync();
fileSystem.file('app.apk.sha1').writeAsStringSync('example_sha'); fileSystem.file('app.apk.sha1').writeAsStringSync('example_sha');
final AndroidApk androidApk = AndroidApk( final AndroidApk androidApk = AndroidApk(
file: apk, applicationPackage: apk,
id: 'app', id: 'app',
versionCode: 22, versionCode: 22,
launchActivity: 'Main', launchActivity: 'Main',
...@@ -265,7 +265,7 @@ void main() { ...@@ -265,7 +265,7 @@ void main() {
final File apk = fileSystem.file('app.apk')..createSync(); final File apk = fileSystem.file('app.apk')..createSync();
fileSystem.file('app.apk.sha1').writeAsStringSync('example_sha'); fileSystem.file('app.apk.sha1').writeAsStringSync('example_sha');
final AndroidApk androidApk = AndroidApk( final AndroidApk androidApk = AndroidApk(
file: apk, applicationPackage: apk,
id: 'app', id: 'app',
versionCode: 22, versionCode: 22,
launchActivity: 'Main', launchActivity: 'Main',
...@@ -298,7 +298,7 @@ void main() { ...@@ -298,7 +298,7 @@ void main() {
]); ]);
final File apk = fileSystem.file('app.apk')..createSync(); final File apk = fileSystem.file('app.apk')..createSync();
final AndroidApk androidApk = AndroidApk( final AndroidApk androidApk = AndroidApk(
file: apk, applicationPackage: apk,
id: 'app', id: 'app',
versionCode: 22, versionCode: 22,
launchActivity: 'Main', launchActivity: 'Main',
......
...@@ -84,6 +84,8 @@ void main() { ...@@ -84,6 +84,8 @@ void main() {
applicationBinary: apkFile, applicationBinary: apkFile,
); );
expect(applicationPackage.name, 'app.apk'); expect(applicationPackage.name, 'app.apk');
expect(applicationPackage, isA<PrebuiltApplicationPackage>());
expect((applicationPackage as PrebuiltApplicationPackage).applicationPackage.path, apkFile.path);
expect(fakeProcessManager.hasRemainingExpectations, isFalse); expect(fakeProcessManager.hasRemainingExpectations, isFalse);
}, overrides: overrides); }, overrides: overrides);
...@@ -298,9 +300,10 @@ void main() { ...@@ -298,9 +300,10 @@ void main() {
testPlistParser.setProperty('CFBundleIdentifier', 'fooBundleId'); testPlistParser.setProperty('CFBundleIdentifier', 'fooBundleId');
final PrebuiltIOSApp iosApp = IOSApp.fromPrebuiltApp(globals.fs.file('bundle.app')) as PrebuiltIOSApp; final PrebuiltIOSApp iosApp = IOSApp.fromPrebuiltApp(globals.fs.file('bundle.app')) as PrebuiltIOSApp;
expect(testLogger.errorText, isEmpty); expect(testLogger.errorText, isEmpty);
expect(iosApp.bundleDir.path, 'bundle.app'); expect(iosApp.uncompressedBundle.path, 'bundle.app');
expect(iosApp.id, 'fooBundleId'); expect(iosApp.id, 'fooBundleId');
expect(iosApp.bundleName, 'bundle.app'); expect(iosApp.bundleName, 'bundle.app');
expect(iosApp.applicationPackage.path, globals.fs.directory('bundle.app').path);
}, overrides: overrides); }, overrides: overrides);
testUsingContext('Bad ipa zip-file, no payload dir', () { testUsingContext('Bad ipa zip-file, no payload dir', () {
...@@ -348,9 +351,10 @@ void main() { ...@@ -348,9 +351,10 @@ void main() {
}; };
final PrebuiltIOSApp iosApp = IOSApp.fromPrebuiltApp(globals.fs.file('app.ipa')) as PrebuiltIOSApp; final PrebuiltIOSApp iosApp = IOSApp.fromPrebuiltApp(globals.fs.file('app.ipa')) as PrebuiltIOSApp;
expect(testLogger.errorText, isEmpty); expect(testLogger.errorText, isEmpty);
expect(iosApp.bundleDir.path, endsWith('bundle.app')); expect(iosApp.uncompressedBundle.path, endsWith('bundle.app'));
expect(iosApp.id, 'fooBundleId'); expect(iosApp.id, 'fooBundleId');
expect(iosApp.bundleName, 'bundle.app'); expect(iosApp.bundleName, 'bundle.app');
expect(iosApp.applicationPackage.path, globals.fs.file('app.ipa').path);
}, overrides: overrides); }, overrides: overrides);
testUsingContext('returns null when there is no ios or .ios directory', () async { testUsingContext('returns null when there is no ios or .ios directory', () async {
...@@ -427,6 +431,7 @@ void main() { ...@@ -427,6 +431,7 @@ void main() {
final PrebuiltFuchsiaApp fuchsiaApp = FuchsiaApp.fromPrebuiltApp(globals.fs.file('bundle.far')) as PrebuiltFuchsiaApp; final PrebuiltFuchsiaApp fuchsiaApp = FuchsiaApp.fromPrebuiltApp(globals.fs.file('bundle.far')) as PrebuiltFuchsiaApp;
expect(testLogger.errorText, isEmpty); expect(testLogger.errorText, isEmpty);
expect(fuchsiaApp.id, 'bundle.far'); expect(fuchsiaApp.id, 'bundle.far');
expect(fuchsiaApp.applicationPackage.path, globals.fs.file('bundle.far').path);
}, overrides: overrides); }, overrides: overrides);
testUsingContext('returns null when there is no fuchsia', () async { testUsingContext('returns null when there is no fuchsia', () async {
......
...@@ -43,7 +43,8 @@ void main() { ...@@ -43,7 +43,8 @@ void main() {
testWithoutContext('IOSDevice.installApp calls ios-deploy correctly with USB', () async { testWithoutContext('IOSDevice.installApp calls ios-deploy correctly with USB', () async {
final IOSApp iosApp = PrebuiltIOSApp( final IOSApp iosApp = PrebuiltIOSApp(
projectBundleId: 'app', projectBundleId: 'app',
bundleDir: fileSystem.currentDirectory, uncompressedBundle: fileSystem.currentDirectory,
applicationPackage: bundleDirectory,
); );
final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[ final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
FakeCommand(command: <String>[ FakeCommand(command: <String>[
...@@ -73,7 +74,8 @@ void main() { ...@@ -73,7 +74,8 @@ void main() {
testWithoutContext('IOSDevice.installApp calls ios-deploy correctly with network', () async { testWithoutContext('IOSDevice.installApp calls ios-deploy correctly with network', () async {
final IOSApp iosApp = PrebuiltIOSApp( final IOSApp iosApp = PrebuiltIOSApp(
projectBundleId: 'app', projectBundleId: 'app',
bundleDir: fileSystem.currentDirectory, uncompressedBundle: fileSystem.currentDirectory,
applicationPackage: bundleDirectory,
); );
final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[ final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
FakeCommand(command: <String>[ FakeCommand(command: <String>[
...@@ -100,7 +102,11 @@ void main() { ...@@ -100,7 +102,11 @@ void main() {
}); });
testWithoutContext('IOSDevice.uninstallApp calls ios-deploy correctly', () async { testWithoutContext('IOSDevice.uninstallApp calls ios-deploy correctly', () async {
final IOSApp iosApp = PrebuiltIOSApp(projectBundleId: 'app', bundleDir: bundleDirectory); final IOSApp iosApp = PrebuiltIOSApp(
projectBundleId: 'app',
uncompressedBundle: bundleDirectory,
applicationPackage: bundleDirectory,
);
final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[ final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
FakeCommand(command: <String>[ FakeCommand(command: <String>[
iosDeployPath, iosDeployPath,
...@@ -123,7 +129,11 @@ void main() { ...@@ -123,7 +129,11 @@ void main() {
group('isAppInstalled', () { group('isAppInstalled', () {
testWithoutContext('catches ProcessException from ios-deploy', () async { testWithoutContext('catches ProcessException from ios-deploy', () async {
final IOSApp iosApp = PrebuiltIOSApp(projectBundleId: 'app', bundleDir: bundleDirectory); final IOSApp iosApp = PrebuiltIOSApp(
projectBundleId: 'app',
uncompressedBundle: bundleDirectory,
applicationPackage: bundleDirectory,
);
final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[ final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
FakeCommand(command: <String>[ FakeCommand(command: <String>[
iosDeployPath, iosDeployPath,
...@@ -147,7 +157,11 @@ void main() { ...@@ -147,7 +157,11 @@ void main() {
}); });
testWithoutContext('returns true when app is installed', () async { testWithoutContext('returns true when app is installed', () async {
final IOSApp iosApp = PrebuiltIOSApp(projectBundleId: 'app', bundleDir: bundleDirectory); final IOSApp iosApp = PrebuiltIOSApp(
projectBundleId: 'app',
uncompressedBundle: bundleDirectory,
applicationPackage: bundleDirectory,
);
final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[ final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
FakeCommand(command: <String>[ FakeCommand(command: <String>[
iosDeployPath, iosDeployPath,
...@@ -171,7 +185,11 @@ void main() { ...@@ -171,7 +185,11 @@ void main() {
}); });
testWithoutContext('returns false when app is not installed', () async { testWithoutContext('returns false when app is not installed', () async {
final IOSApp iosApp = PrebuiltIOSApp(projectBundleId: 'app', bundleDir: bundleDirectory); final IOSApp iosApp = PrebuiltIOSApp(
projectBundleId: 'app',
uncompressedBundle: bundleDirectory,
applicationPackage: bundleDirectory,
);
final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[ final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
FakeCommand(command: <String>[ FakeCommand(command: <String>[
iosDeployPath, iosDeployPath,
...@@ -197,7 +215,11 @@ void main() { ...@@ -197,7 +215,11 @@ void main() {
}); });
testWithoutContext('returns false on command timeout or other error', () async { testWithoutContext('returns false on command timeout or other error', () async {
final IOSApp iosApp = PrebuiltIOSApp(projectBundleId: 'app', bundleDir: bundleDirectory); final IOSApp iosApp = PrebuiltIOSApp(
projectBundleId: 'app',
uncompressedBundle: bundleDirectory,
applicationPackage: bundleDirectory,
);
const String stderr = '2020-03-26 17:48:43.484 ios-deploy[21518:5501783] [ !! ] Timed out waiting for device'; const String stderr = '2020-03-26 17:48:43.484 ios-deploy[21518:5501783] [ !! ] Timed out waiting for device';
final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[ final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
FakeCommand(command: <String>[ FakeCommand(command: <String>[
...@@ -228,7 +250,8 @@ void main() { ...@@ -228,7 +250,8 @@ void main() {
testWithoutContext('IOSDevice.installApp catches ProcessException from ios-deploy', () async { testWithoutContext('IOSDevice.installApp catches ProcessException from ios-deploy', () async {
final IOSApp iosApp = PrebuiltIOSApp( final IOSApp iosApp = PrebuiltIOSApp(
projectBundleId: 'app', projectBundleId: 'app',
bundleDir: fileSystem.currentDirectory, uncompressedBundle: fileSystem.currentDirectory,
applicationPackage: bundleDirectory,
); );
final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[ final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
FakeCommand(command: <String>[ FakeCommand(command: <String>[
...@@ -250,7 +273,11 @@ void main() { ...@@ -250,7 +273,11 @@ void main() {
}); });
testWithoutContext('IOSDevice.uninstallApp catches ProcessException from ios-deploy', () async { testWithoutContext('IOSDevice.uninstallApp catches ProcessException from ios-deploy', () async {
final IOSApp iosApp = PrebuiltIOSApp(projectBundleId: 'app', bundleDir: bundleDirectory); final IOSApp iosApp = PrebuiltIOSApp(
projectBundleId: 'app',
uncompressedBundle: bundleDirectory,
applicationPackage: bundleDirectory,
);
final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[ final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
FakeCommand(command: <String>[ FakeCommand(command: <String>[
iosDeployPath, iosDeployPath,
......
...@@ -93,7 +93,8 @@ void main() { ...@@ -93,7 +93,8 @@ void main() {
final IOSApp iosApp = PrebuiltIOSApp( final IOSApp iosApp = PrebuiltIOSApp(
projectBundleId: 'app', projectBundleId: 'app',
bundleName: 'Runner', bundleName: 'Runner',
bundleDir: MemoryFileSystem.test().directory('bundle'), uncompressedBundle: MemoryFileSystem.test().directory('bundle'),
applicationPackage: MemoryFileSystem.test().directory('bundle'),
); );
device.portForwarder = devicePortForwarder; device.portForwarder = devicePortForwarder;
...@@ -116,7 +117,8 @@ void main() { ...@@ -116,7 +117,8 @@ void main() {
final IOSApp iosApp = PrebuiltIOSApp( final IOSApp iosApp = PrebuiltIOSApp(
projectBundleId: 'app', projectBundleId: 'app',
bundleName: 'Runner', bundleName: 'Runner',
bundleDir: fileSystem.currentDirectory, uncompressedBundle: fileSystem.currentDirectory,
applicationPackage: fileSystem.currentDirectory,
); );
final FakeDeviceLogReader deviceLogReader = FakeDeviceLogReader(); final FakeDeviceLogReader deviceLogReader = FakeDeviceLogReader();
...@@ -153,7 +155,8 @@ void main() { ...@@ -153,7 +155,8 @@ void main() {
final IOSApp iosApp = PrebuiltIOSApp( final IOSApp iosApp = PrebuiltIOSApp(
projectBundleId: 'app', projectBundleId: 'app',
bundleName: 'Runner', bundleName: 'Runner',
bundleDir: fileSystem.currentDirectory, uncompressedBundle: fileSystem.currentDirectory,
applicationPackage: fileSystem.currentDirectory,
); );
final FakeDeviceLogReader deviceLogReader = FakeDeviceLogReader(); final FakeDeviceLogReader deviceLogReader = FakeDeviceLogReader();
...@@ -191,7 +194,8 @@ void main() { ...@@ -191,7 +194,8 @@ void main() {
final IOSApp iosApp = PrebuiltIOSApp( final IOSApp iosApp = PrebuiltIOSApp(
projectBundleId: 'app', projectBundleId: 'app',
bundleName: 'Runner', bundleName: 'Runner',
bundleDir: fileSystem.currentDirectory, uncompressedBundle: fileSystem.currentDirectory,
applicationPackage: fileSystem.currentDirectory,
); );
final FakeDeviceLogReader deviceLogReader = FakeDeviceLogReader(); final FakeDeviceLogReader deviceLogReader = FakeDeviceLogReader();
...@@ -230,7 +234,8 @@ void main() { ...@@ -230,7 +234,8 @@ void main() {
final IOSApp iosApp = PrebuiltIOSApp( final IOSApp iosApp = PrebuiltIOSApp(
projectBundleId: 'app', projectBundleId: 'app',
bundleName: 'Runner', bundleName: 'Runner',
bundleDir: fileSystem.currentDirectory, uncompressedBundle: fileSystem.currentDirectory,
applicationPackage: fileSystem.currentDirectory,
); );
final LaunchResult launchResult = await device.startApp(iosApp, final LaunchResult launchResult = await device.startApp(iosApp,
...@@ -296,7 +301,8 @@ void main() { ...@@ -296,7 +301,8 @@ void main() {
final IOSApp iosApp = PrebuiltIOSApp( final IOSApp iosApp = PrebuiltIOSApp(
projectBundleId: 'app', projectBundleId: 'app',
bundleName: 'Runner', bundleName: 'Runner',
bundleDir: fileSystem.currentDirectory, uncompressedBundle: fileSystem.currentDirectory,
applicationPackage: fileSystem.currentDirectory,
); );
final FakeDeviceLogReader deviceLogReader = FakeDeviceLogReader(); final FakeDeviceLogReader deviceLogReader = FakeDeviceLogReader();
......
...@@ -917,7 +917,12 @@ Dec 20 17:04:32 md32-11-vm1 Another App[88374]: Ignore this text''' ...@@ -917,7 +917,12 @@ Dec 20 17:04:32 md32-11-vm1 Another App[88374]: Ignore this text'''
testPlistParser.setProperty('CFBundleIdentifier', 'correct'); testPlistParser.setProperty('CFBundleIdentifier', 'correct');
final Directory mockDir = globals.fs.currentDirectory; final Directory mockDir = globals.fs.currentDirectory;
final IOSApp package = PrebuiltIOSApp(projectBundleId: 'incorrect', bundleName: 'name', bundleDir: mockDir); final IOSApp package = PrebuiltIOSApp(
projectBundleId: 'incorrect',
bundleName: 'name',
uncompressedBundle: mockDir,
applicationPackage: mockDir,
);
const BuildInfo mockInfo = BuildInfo(BuildMode.debug, 'flavor', treeShakeIcons: false); const BuildInfo mockInfo = BuildInfo(BuildMode.debug, 'flavor', treeShakeIcons: false);
final DebuggingOptions mockOptions = DebuggingOptions.disabled(mockInfo); final DebuggingOptions mockOptions = DebuggingOptions.disabled(mockInfo);
...@@ -940,7 +945,12 @@ Dec 20 17:04:32 md32-11-vm1 Another App[88374]: Ignore this text''' ...@@ -940,7 +945,12 @@ Dec 20 17:04:32 md32-11-vm1 Another App[88374]: Ignore this text'''
); );
final Directory mockDir = globals.fs.currentDirectory; final Directory mockDir = globals.fs.currentDirectory;
final IOSApp package = PrebuiltIOSApp(projectBundleId: 'incorrect', bundleName: 'name', bundleDir: mockDir); final IOSApp package = PrebuiltIOSApp(
projectBundleId: 'incorrect',
bundleName: 'name',
uncompressedBundle: mockDir,
applicationPackage: mockDir,
);
const BuildInfo mockInfo = BuildInfo(BuildMode.debug, 'flavor', treeShakeIcons: false); const BuildInfo mockInfo = BuildInfo(BuildMode.debug, 'flavor', treeShakeIcons: false);
final DebuggingOptions mockOptions = DebuggingOptions.disabled(mockInfo); final DebuggingOptions mockOptions = DebuggingOptions.disabled(mockInfo);
...@@ -967,7 +977,12 @@ Dec 20 17:04:32 md32-11-vm1 Another App[88374]: Ignore this text''' ...@@ -967,7 +977,12 @@ Dec 20 17:04:32 md32-11-vm1 Another App[88374]: Ignore this text'''
testPlistParser.setProperty('CFBundleIdentifier', 'correct'); testPlistParser.setProperty('CFBundleIdentifier', 'correct');
final Directory mockDir = globals.fs.currentDirectory; final Directory mockDir = globals.fs.currentDirectory;
final IOSApp package = PrebuiltIOSApp(projectBundleId: 'correct', bundleName: 'name', bundleDir: mockDir); final IOSApp package = PrebuiltIOSApp(
projectBundleId: 'correct',
bundleName: 'name',
uncompressedBundle: mockDir,
applicationPackage: mockDir,
);
const BuildInfo mockInfo = BuildInfo(BuildMode.debug, 'flavor', treeShakeIcons: false); const BuildInfo mockInfo = BuildInfo(BuildMode.debug, 'flavor', treeShakeIcons: false);
final DebuggingOptions mockOptions = DebuggingOptions.enabled(mockInfo, enableSoftwareRendering: true); final DebuggingOptions mockOptions = DebuggingOptions.enabled(mockInfo, enableSoftwareRendering: true);
......
...@@ -100,7 +100,7 @@ group('PrebuiltMacOSApp', () { ...@@ -100,7 +100,7 @@ group('PrebuiltMacOSApp', () {
final PrebuiltMacOSApp macosApp = MacOSApp.fromPrebuiltApp(fileSystem.file('bundle.app')) as PrebuiltMacOSApp; final PrebuiltMacOSApp macosApp = MacOSApp.fromPrebuiltApp(fileSystem.file('bundle.app')) as PrebuiltMacOSApp;
expect(logger.errorText, isEmpty); expect(logger.errorText, isEmpty);
expect(macosApp.bundleDir.path, 'bundle.app'); expect(macosApp.uncompressedBundle.path, 'bundle.app');
expect(macosApp.id, 'fooBundleId'); expect(macosApp.id, 'fooBundleId');
expect(macosApp.bundleName, 'bundle.app'); expect(macosApp.bundleName, 'bundle.app');
}, overrides: overrides); }, overrides: overrides);
...@@ -152,7 +152,7 @@ group('PrebuiltMacOSApp', () { ...@@ -152,7 +152,7 @@ group('PrebuiltMacOSApp', () {
final PrebuiltMacOSApp macosApp = MacOSApp.fromPrebuiltApp(fileSystem.file('app.zip')) as PrebuiltMacOSApp; final PrebuiltMacOSApp macosApp = MacOSApp.fromPrebuiltApp(fileSystem.file('app.zip')) as PrebuiltMacOSApp;
expect(logger.errorText, isEmpty); expect(logger.errorText, isEmpty);
expect(macosApp.bundleDir.path, endsWith('bundle.app')); expect(macosApp.uncompressedBundle.path, endsWith('bundle.app'));
expect(macosApp.id, 'fooBundleId'); expect(macosApp.id, 'fooBundleId');
expect(macosApp.bundleName, endsWith('bundle.app')); expect(macosApp.bundleName, endsWith('bundle.app'));
}, overrides: overrides); }, overrides: overrides);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment