[app] pass App object into installers, so it is available everywhere where needed

This commit is contained in:
Torsten Grote
2022-11-10 11:19:42 -03:00
committed by Hans-Christoph Steiner
parent a8d210e487
commit 6603781652
18 changed files with 110 additions and 53 deletions

View File

@@ -4,6 +4,7 @@ import android.content.ContextWrapper;
import org.fdroid.fdroid.Preferences;
import org.fdroid.fdroid.data.Apk;
import org.fdroid.fdroid.data.App;
import org.fdroid.index.v2.FileV1;
import org.junit.Before;
import org.junit.Test;
@@ -30,12 +31,14 @@ public class FileInstallerTest {
@Test
public void testInstallOtaZip() {
App app = new App();
app.packageName = "org.fdroid.fdroid.privileged.ota";
Apk apk = new Apk();
apk.apkFile = new FileV1("org.fdroid.fdroid.privileged.ota_2010.zip", "hash", null, null);
apk.packageName = "org.fdroid.fdroid.privileged.ota";
apk.versionCode = 2010;
assertFalse(apk.isApk());
Installer installer = InstallerFactory.create(context, apk);
Installer installer = InstallerFactory.create(context, app, apk);
assertEquals("should be a FileInstaller",
FileInstaller.class,
installer.getClass());

View File

@@ -4,6 +4,7 @@ import android.content.ContextWrapper;
import org.fdroid.fdroid.Preferences;
import org.fdroid.fdroid.data.Apk;
import org.fdroid.fdroid.data.App;
import org.fdroid.index.v2.FileV1;
import org.junit.Before;
import org.junit.Test;
@@ -28,10 +29,12 @@ public class InstallerFactoryTest {
@Test
public void testApkInstallerInstance() {
for (String filename : new String[]{"test.apk", "A.APK", "b.ApK"}) {
App app = new App();
app.packageName = "test";
Apk apk = new Apk();
apk.apkFile = new FileV1(filename, "hash", null, null);
apk.packageName = "test";
Installer installer = InstallerFactory.create(context, apk);
Installer installer = InstallerFactory.create(context, app, apk);
assertEquals(filename + " should use a DefaultInstaller",
DefaultInstaller.class,
installer.getClass());
@@ -41,10 +44,12 @@ public class InstallerFactoryTest {
@Test
public void testFileInstallerInstance() {
for (String filename : new String[]{"org.fdroid.fdroid.privileged.ota_2110.zip", "test.ZIP"}) {
App app = new App();
app.packageName = "cafe0088";
Apk apk = new Apk();
apk.apkFile = new FileV1(filename, "hash", null, null);
apk.packageName = "cafe0088";
Installer installer = InstallerFactory.create(context, apk);
Installer installer = InstallerFactory.create(context, app, apk);
assertEquals("should be a FileInstaller",
FileInstaller.class,
installer.getClass());