Add a new PrebuiltFlutterApplicationPackage interface. (#95290)

* Add a new PrebuiltFlutterApplicationPackage interface.

* Review feedback

* Rename bundleDir to uncompressedBundle
This commit is contained in:
Lau Ching Jun
2022-01-05 07:54:57 -08:00
committed by GitHub
parent 7444ad8da4
commit 7f0050f5b3
13 changed files with 166 additions and 80 deletions

View File

@@ -68,7 +68,7 @@ void main() {
final File apkFile = fileSystem.file('app.apk')..createSync();
final AndroidApk apk = AndroidApk(
id: 'FlutterApp',
file: apkFile,
applicationPackage: apkFile,
launchActivity: 'FlutterActivity',
versionCode: 1,
);
@@ -133,7 +133,7 @@ void main() {
final File apkFile = fileSystem.file('app.apk')..createSync();
final AndroidApk apk = AndroidApk(
id: 'FlutterApp',
file: apkFile,
applicationPackage: apkFile,
launchActivity: 'FlutterActivity',
versionCode: 1,
);
@@ -171,7 +171,7 @@ void main() {
final File apkFile = fileSystem.file('app.apk')..createSync();
final AndroidApk apk = AndroidApk(
id: 'FlutterApp',
file: apkFile,
applicationPackage: apkFile,
launchActivity: 'FlutterActivity',
versionCode: 1,
);

View File

@@ -73,7 +73,7 @@ void main() {
]);
final File apk = fileSystem.file('app.apk')..createSync();
final AndroidApk androidApk = AndroidApk(
file: apk,
applicationPackage: apk,
id: 'app',
versionCode: 22,
launchActivity: 'Main',
@@ -89,7 +89,7 @@ void main() {
testWithoutContext('Cannot install app if APK file is missing', () async {
final File apk = fileSystem.file('app.apk');
final AndroidApk androidApk = AndroidApk(
file: apk,
applicationPackage: apk,
id: 'app',
versionCode: 22,
launchActivity: 'Main',
@@ -117,7 +117,7 @@ void main() {
]);
final File apk = fileSystem.file('app.apk')..createSync();
final AndroidApk androidApk = AndroidApk(
file: apk,
applicationPackage: apk,
id: 'app',
versionCode: 22,
launchActivity: 'Main',
@@ -146,7 +146,7 @@ void main() {
]);
final File apk = fileSystem.file('app.apk')..createSync();
final AndroidApk androidApk = AndroidApk(
file: apk,
applicationPackage: apk,
id: 'app',
versionCode: 22,
launchActivity: 'Main',
@@ -190,7 +190,7 @@ void main() {
]);
final File apk = fileSystem.file('app.apk')..createSync();
final AndroidApk androidApk = AndroidApk(
file: apk,
applicationPackage: apk,
id: 'app',
versionCode: 22,
launchActivity: 'Main',
@@ -224,7 +224,7 @@ void main() {
final File apk = fileSystem.file('app.apk')..createSync();
fileSystem.file('app.apk.sha1').writeAsStringSync('example_sha');
final AndroidApk androidApk = AndroidApk(
file: apk,
applicationPackage: apk,
id: 'app',
versionCode: 22,
launchActivity: 'Main',
@@ -265,7 +265,7 @@ void main() {
final File apk = fileSystem.file('app.apk')..createSync();
fileSystem.file('app.apk.sha1').writeAsStringSync('example_sha');
final AndroidApk androidApk = AndroidApk(
file: apk,
applicationPackage: apk,
id: 'app',
versionCode: 22,
launchActivity: 'Main',
@@ -298,7 +298,7 @@ void main() {
]);
final File apk = fileSystem.file('app.apk')..createSync();
final AndroidApk androidApk = AndroidApk(
file: apk,
applicationPackage: apk,
id: 'app',
versionCode: 22,
launchActivity: 'Main',

View File

@@ -84,6 +84,8 @@ void main() {
applicationBinary: apkFile,
);
expect(applicationPackage.name, 'app.apk');
expect(applicationPackage, isA<PrebuiltApplicationPackage>());
expect((applicationPackage as PrebuiltApplicationPackage).applicationPackage.path, apkFile.path);
expect(fakeProcessManager.hasRemainingExpectations, isFalse);
}, overrides: overrides);
@@ -298,9 +300,10 @@ void main() {
testPlistParser.setProperty('CFBundleIdentifier', 'fooBundleId');
final PrebuiltIOSApp iosApp = IOSApp.fromPrebuiltApp(globals.fs.file('bundle.app')) as PrebuiltIOSApp;
expect(testLogger.errorText, isEmpty);
expect(iosApp.bundleDir.path, 'bundle.app');
expect(iosApp.uncompressedBundle.path, 'bundle.app');
expect(iosApp.id, 'fooBundleId');
expect(iosApp.bundleName, 'bundle.app');
expect(iosApp.applicationPackage.path, globals.fs.directory('bundle.app').path);
}, overrides: overrides);
testUsingContext('Bad ipa zip-file, no payload dir', () {
@@ -348,9 +351,10 @@ void main() {
};
final PrebuiltIOSApp iosApp = IOSApp.fromPrebuiltApp(globals.fs.file('app.ipa')) as PrebuiltIOSApp;
expect(testLogger.errorText, isEmpty);
expect(iosApp.bundleDir.path, endsWith('bundle.app'));
expect(iosApp.uncompressedBundle.path, endsWith('bundle.app'));
expect(iosApp.id, 'fooBundleId');
expect(iosApp.bundleName, 'bundle.app');
expect(iosApp.applicationPackage.path, globals.fs.file('app.ipa').path);
}, overrides: overrides);
testUsingContext('returns null when there is no ios or .ios directory', () async {
@@ -427,6 +431,7 @@ void main() {
final PrebuiltFuchsiaApp fuchsiaApp = FuchsiaApp.fromPrebuiltApp(globals.fs.file('bundle.far')) as PrebuiltFuchsiaApp;
expect(testLogger.errorText, isEmpty);
expect(fuchsiaApp.id, 'bundle.far');
expect(fuchsiaApp.applicationPackage.path, globals.fs.file('bundle.far').path);
}, overrides: overrides);
testUsingContext('returns null when there is no fuchsia', () async {

View File

@@ -43,7 +43,8 @@ void main() {
testWithoutContext('IOSDevice.installApp calls ios-deploy correctly with USB', () async {
final IOSApp iosApp = PrebuiltIOSApp(
projectBundleId: 'app',
bundleDir: fileSystem.currentDirectory,
uncompressedBundle: fileSystem.currentDirectory,
applicationPackage: bundleDirectory,
);
final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
FakeCommand(command: <String>[
@@ -73,7 +74,8 @@ void main() {
testWithoutContext('IOSDevice.installApp calls ios-deploy correctly with network', () async {
final IOSApp iosApp = PrebuiltIOSApp(
projectBundleId: 'app',
bundleDir: fileSystem.currentDirectory,
uncompressedBundle: fileSystem.currentDirectory,
applicationPackage: bundleDirectory,
);
final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
FakeCommand(command: <String>[
@@ -100,7 +102,11 @@ void main() {
});
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>[
FakeCommand(command: <String>[
iosDeployPath,
@@ -123,7 +129,11 @@ void main() {
group('isAppInstalled', () {
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>[
FakeCommand(command: <String>[
iosDeployPath,
@@ -147,7 +157,11 @@ void main() {
});
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>[
FakeCommand(command: <String>[
iosDeployPath,
@@ -171,7 +185,11 @@ void main() {
});
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>[
FakeCommand(command: <String>[
iosDeployPath,
@@ -197,7 +215,11 @@ void main() {
});
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';
final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
FakeCommand(command: <String>[
@@ -228,7 +250,8 @@ void main() {
testWithoutContext('IOSDevice.installApp catches ProcessException from ios-deploy', () async {
final IOSApp iosApp = PrebuiltIOSApp(
projectBundleId: 'app',
bundleDir: fileSystem.currentDirectory,
uncompressedBundle: fileSystem.currentDirectory,
applicationPackage: bundleDirectory,
);
final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
FakeCommand(command: <String>[
@@ -250,7 +273,11 @@ void main() {
});
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>[
FakeCommand(command: <String>[
iosDeployPath,

View File

@@ -93,7 +93,8 @@ void main() {
final IOSApp iosApp = PrebuiltIOSApp(
projectBundleId: 'app',
bundleName: 'Runner',
bundleDir: MemoryFileSystem.test().directory('bundle'),
uncompressedBundle: MemoryFileSystem.test().directory('bundle'),
applicationPackage: MemoryFileSystem.test().directory('bundle'),
);
device.portForwarder = devicePortForwarder;
@@ -116,7 +117,8 @@ void main() {
final IOSApp iosApp = PrebuiltIOSApp(
projectBundleId: 'app',
bundleName: 'Runner',
bundleDir: fileSystem.currentDirectory,
uncompressedBundle: fileSystem.currentDirectory,
applicationPackage: fileSystem.currentDirectory,
);
final FakeDeviceLogReader deviceLogReader = FakeDeviceLogReader();
@@ -153,7 +155,8 @@ void main() {
final IOSApp iosApp = PrebuiltIOSApp(
projectBundleId: 'app',
bundleName: 'Runner',
bundleDir: fileSystem.currentDirectory,
uncompressedBundle: fileSystem.currentDirectory,
applicationPackage: fileSystem.currentDirectory,
);
final FakeDeviceLogReader deviceLogReader = FakeDeviceLogReader();
@@ -191,7 +194,8 @@ void main() {
final IOSApp iosApp = PrebuiltIOSApp(
projectBundleId: 'app',
bundleName: 'Runner',
bundleDir: fileSystem.currentDirectory,
uncompressedBundle: fileSystem.currentDirectory,
applicationPackage: fileSystem.currentDirectory,
);
final FakeDeviceLogReader deviceLogReader = FakeDeviceLogReader();
@@ -230,7 +234,8 @@ void main() {
final IOSApp iosApp = PrebuiltIOSApp(
projectBundleId: 'app',
bundleName: 'Runner',
bundleDir: fileSystem.currentDirectory,
uncompressedBundle: fileSystem.currentDirectory,
applicationPackage: fileSystem.currentDirectory,
);
final LaunchResult launchResult = await device.startApp(iosApp,
@@ -296,7 +301,8 @@ void main() {
final IOSApp iosApp = PrebuiltIOSApp(
projectBundleId: 'app',
bundleName: 'Runner',
bundleDir: fileSystem.currentDirectory,
uncompressedBundle: fileSystem.currentDirectory,
applicationPackage: fileSystem.currentDirectory,
);
final FakeDeviceLogReader deviceLogReader = FakeDeviceLogReader();

View File

@@ -917,7 +917,12 @@ Dec 20 17:04:32 md32-11-vm1 Another App[88374]: Ignore this text'''
testPlistParser.setProperty('CFBundleIdentifier', 'correct');
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);
final DebuggingOptions mockOptions = DebuggingOptions.disabled(mockInfo);
@@ -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 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);
final DebuggingOptions mockOptions = DebuggingOptions.disabled(mockInfo);
@@ -967,7 +977,12 @@ Dec 20 17:04:32 md32-11-vm1 Another App[88374]: Ignore this text'''
testPlistParser.setProperty('CFBundleIdentifier', 'correct');
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);
final DebuggingOptions mockOptions = DebuggingOptions.enabled(mockInfo, enableSoftwareRendering: true);

View File

@@ -100,7 +100,7 @@ group('PrebuiltMacOSApp', () {
final PrebuiltMacOSApp macosApp = MacOSApp.fromPrebuiltApp(fileSystem.file('bundle.app')) as PrebuiltMacOSApp;
expect(logger.errorText, isEmpty);
expect(macosApp.bundleDir.path, 'bundle.app');
expect(macosApp.uncompressedBundle.path, 'bundle.app');
expect(macosApp.id, 'fooBundleId');
expect(macosApp.bundleName, 'bundle.app');
}, overrides: overrides);
@@ -152,7 +152,7 @@ group('PrebuiltMacOSApp', () {
final PrebuiltMacOSApp macosApp = MacOSApp.fromPrebuiltApp(fileSystem.file('app.zip')) as PrebuiltMacOSApp;
expect(logger.errorText, isEmpty);
expect(macosApp.bundleDir.path, endsWith('bundle.app'));
expect(macosApp.uncompressedBundle.path, endsWith('bundle.app'));
expect(macosApp.id, 'fooBundleId');
expect(macosApp.bundleName, endsWith('bundle.app'));
}, overrides: overrides);