use of org.fdroid.fdroid.data.Apk in project fdroidclient by f-droid.
the class ProperMultiIndexUpdaterTest method assertMainRepo.
/**
* + 2048 (com.uberspot.a2048)
* - Version 1.96 (19)
* - Version 1.95 (18)
* + AdAway (org.adaway)
* - Version 3.0.2 (54)
* - Version 3.0.1 (53)
* - Version 3.0 (52)
* + adbWireless (siir.es.adbWireless)
* - Version 1.5.4 (12)
*/
private void assertMainRepo(List<Repo> allRepos) {
Repo repo = findRepo(REPO_MAIN, allRepos);
List<Apk> apks = ApkProvider.Helper.findByRepo(context, repo, Schema.ApkTable.Cols.ALL);
assertEquals("Apks for main repo", apks.size(), 6);
assertApksExist(apks, "com.uberspot.a2048", new int[] { 18, 19 });
assertApksExist(apks, "org.adaway", new int[] { 52, 53, 54 });
assertApksExist(apks, "siir.es.adbWireless", new int[] { 12 });
assert2048Metadata(repo, "Normal");
assertAdAwayMetadata(repo, "Normal");
assertAdbMetadata(repo, "Normal");
}
use of org.fdroid.fdroid.data.Apk in project fdroidclient by f-droid.
the class ProperMultiIndexUpdaterTest method assertConflictingRepo.
/**
* + AdAway (org.adaway)
* - Version 3.0.1 (53) *
* - Version 3.0 (52) *
* - Version 2.9.2 (51) *
* - Version 2.2.1 (50) *
* + Add to calendar (org.dgtale.icsimport)
* - Version 1.2 (3)
* - Version 1.1 (2)
*/
private void assertConflictingRepo(List<Repo> allRepos) {
Repo repo = findRepo(REPO_CONFLICTING, allRepos);
List<Apk> apks = ApkProvider.Helper.findByRepo(context, repo, Schema.ApkTable.Cols.ALL);
assertEquals("Apks for conflicting repo", 6, apks.size());
assertApksExist(apks, "org.adaway", new int[] { 50, 51, 52, 53 });
assertApksExist(apks, "org.dgtale.icsimport", new int[] { 2, 3 });
assertAdAwayMetadata(repo, "Conflicting");
assertCalendarMetadata(repo, "Conflicting");
}
use of org.fdroid.fdroid.data.Apk in project fdroidclient by f-droid.
the class SwapRepoTest method testSwap.
/**
* @see WifiStateChangeService.WifiInfoThread#run()
*/
@Test
public void testSwap() throws IOException, LocalRepoKeyStore.InitException, IndexUpdater.UpdateException, InterruptedException {
PackageManager packageManager = context.getPackageManager();
ApplicationInfo appInfo = new ApplicationInfo();
appInfo.flags = 0;
appInfo.packageName = context.getPackageName();
appInfo.minSdkVersion = 10;
appInfo.targetSdkVersion = 23;
appInfo.sourceDir = getClass().getClassLoader().getResource("F-Droid.apk").getPath();
appInfo.publicSourceDir = getClass().getClassLoader().getResource("F-Droid.apk").getPath();
System.out.println("appInfo.sourceDir " + appInfo.sourceDir);
appInfo.name = "F-Droid";
PackageInfo packageInfo = new PackageInfo();
packageInfo.packageName = appInfo.packageName;
packageInfo.applicationInfo = appInfo;
packageInfo.versionCode = 1002001;
packageInfo.versionName = "1.2-fake";
shadowOf(packageManager).addPackage(packageInfo);
try {
FDroidApp.initWifiSettings();
FDroidApp.ipAddressString = "127.0.0.1";
FDroidApp.subnetInfo = new SubnetUtils("127.0.0.0/8").getInfo();
FDroidApp.repo.name = "test";
FDroidApp.repo.address = "http://" + FDroidApp.ipAddressString + ":" + FDroidApp.port + "/fdroid/repo";
LocalRepoService.runProcess(context, new String[] { context.getPackageName() });
File indexJarFile = LocalRepoManager.get(context).getIndexJar();
System.out.println("indexJarFile:" + indexJarFile);
assertTrue(indexJarFile.isFile());
localHttpd = new LocalHTTPD(context, FDroidApp.ipAddressString, FDroidApp.port, LocalRepoManager.get(context).getWebRoot(), false);
localHttpd.start();
// give the server some tine to start.
Thread.sleep(100);
assertTrue(localHttpd.isAlive());
LocalRepoKeyStore localRepoKeyStore = LocalRepoKeyStore.get(context);
Certificate localCert = localRepoKeyStore.getCertificate();
String signingCert = Hasher.hex(localCert);
assertFalse(TextUtils.isEmpty(signingCert));
assertFalse(TextUtils.isEmpty(Utils.calcFingerprint(localCert)));
Repo repo = MultiIndexUpdaterTest.createRepo(FDroidApp.repo.name, FDroidApp.repo.address, context, signingCert);
IndexUpdater updater = new IndexUpdater(context, repo);
updater.update();
assertTrue(updater.hasChanged());
updater.processDownloadedFile(indexJarFile);
boolean foundRepo = false;
for (Repo repoFromDb : RepoProvider.Helper.all(context)) {
if (TextUtils.equals(repo.address, repoFromDb.address)) {
foundRepo = true;
repo = repoFromDb;
}
}
assertTrue(foundRepo);
assertNotEquals(-1, repo.getId());
List<Apk> apks = ApkProvider.Helper.findByRepo(context, repo, Schema.ApkTable.Cols.ALL);
assertEquals(1, apks.size());
for (Apk apk : apks) {
System.out.println(apk);
}
// MultiIndexUpdaterTest.assertApksExist(apks, context.getPackageName(), new int[]{BuildConfig.VERSION_CODE});
Thread.sleep(10000);
} finally {
if (localHttpd != null) {
localHttpd.stop();
}
}
}
Aggregations