Add test for repo priorities + app metadata. Not passing yet.
This commit is contained in:
parent
e25d26aca0
commit
1d1c1ebb74
@ -301,7 +301,7 @@ public class RepoProvider extends FDroidProvider {
|
|||||||
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
|
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
|
||||||
|
|
||||||
if (TextUtils.isEmpty(sortOrder)) {
|
if (TextUtils.isEmpty(sortOrder)) {
|
||||||
sortOrder = "_ID ASC";
|
sortOrder = Cols.PRIORITY + " ASC";
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (MATCHER.match(uri)) {
|
switch (MATCHER.match(uri)) {
|
||||||
|
@ -165,7 +165,7 @@ public abstract class MultiRepoUpdaterTest extends FDroidProviderTest {
|
|||||||
repo.address = uri;
|
repo.address = uri;
|
||||||
repo.name = name;
|
repo.name = name;
|
||||||
|
|
||||||
ContentValues values = new ContentValues(2);
|
ContentValues values = new ContentValues(3);
|
||||||
values.put(Schema.RepoTable.Cols.SIGNING_CERT, repo.signingCertificate);
|
values.put(Schema.RepoTable.Cols.SIGNING_CERT, repo.signingCertificate);
|
||||||
values.put(Schema.RepoTable.Cols.ADDRESS, repo.address);
|
values.put(Schema.RepoTable.Cols.ADDRESS, repo.address);
|
||||||
values.put(Schema.RepoTable.Cols.NAME, repo.name);
|
values.put(Schema.RepoTable.Cols.NAME, repo.name);
|
||||||
|
@ -39,21 +39,53 @@ public class ProperMultiRepoUpdaterTest extends MultiRepoUpdaterTest {
|
|||||||
public void mainRepo() throws RepoUpdater.UpdateException {
|
public void mainRepo() throws RepoUpdater.UpdateException {
|
||||||
assertEmpty();
|
assertEmpty();
|
||||||
updateMain();
|
updateMain();
|
||||||
assertMainRepo(RepoProvider.Helper.all(context));
|
assertMainRepo();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void archiveRepo() throws RepoUpdater.UpdateException {
|
public void archiveRepo() throws RepoUpdater.UpdateException {
|
||||||
assertEmpty();
|
assertEmpty();
|
||||||
updateArchive();
|
updateArchive();
|
||||||
assertMainArchiveRepo(RepoProvider.Helper.all(context));
|
assertMainArchiveRepoMetadata();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void conflictingRepo() throws RepoUpdater.UpdateException {
|
public void conflictingRepo() throws RepoUpdater.UpdateException {
|
||||||
assertEmpty();
|
assertEmpty();
|
||||||
updateConflicting();
|
updateConflicting();
|
||||||
assertConflictingRepo(RepoProvider.Helper.all(context));
|
assertConflictingRepo();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void conflictingMetadataTakesPriority() throws RepoUpdater.UpdateException {
|
||||||
|
updateConflicting();
|
||||||
|
updateMain();
|
||||||
|
updateArchive();
|
||||||
|
|
||||||
|
assertEquals(1, RepoProvider.Helper.findByAddress(context, REPO_CONFLICTING_URI).priority);
|
||||||
|
assertEquals(2, RepoProvider.Helper.findByAddress(context, REPO_MAIN_URI).priority);
|
||||||
|
assertEquals(3, RepoProvider.Helper.findByAddress(context, REPO_ARCHIVE_URI).priority);
|
||||||
|
|
||||||
|
assertMainRepo();
|
||||||
|
assertMainArchiveRepoMetadata();
|
||||||
|
assertConflictingRepo();
|
||||||
|
|
||||||
|
App a2048 = AppProvider.Helper.findHighestPriorityMetadata(context.getContentResolver(), "com.uberspot.a2048");
|
||||||
|
assert2048Metadata(a2048, "Conflicting");
|
||||||
|
|
||||||
|
// This is only provided by the "Conflicting" repo.
|
||||||
|
App calendar = AppProvider.Helper.findHighestPriorityMetadata(context.getContentResolver(), "org.dgtale.icsimport");
|
||||||
|
assertCalendarMetadata(calendar, "Conflicting");
|
||||||
|
|
||||||
|
// This is only provided by the "Main" or "Archive" repo. Both the main and archive repo both
|
||||||
|
// pull their metadata from the same build recipe in fdroidserver. The only difference is that
|
||||||
|
// the archive repository contains .apks from further back, but their metadata is the same.
|
||||||
|
App adAway = AppProvider.Helper.findHighestPriorityMetadata(context.getContentResolver(), "org.adaway");
|
||||||
|
assertAdAwayMetadata(adAway, "Normal");
|
||||||
|
|
||||||
|
// This is only provided by the "Main" repo.
|
||||||
|
App adb = AppProvider.Helper.findHighestPriorityMetadata(context.getContentResolver(), "siir.es.adbWireless");
|
||||||
|
assertAdAwayMetadata(adb, "Normal");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -133,10 +165,14 @@ public class ProperMultiRepoUpdaterTest extends MultiRepoUpdaterTest {
|
|||||||
assertEquals("Repos", 3, repos.size());
|
assertEquals("Repos", 3, repos.size());
|
||||||
|
|
||||||
assertMainRepo(repos);
|
assertMainRepo(repos);
|
||||||
assertMainArchiveRepo(repos);
|
assertMainArchiveRepoMetadata(repos);
|
||||||
assertConflictingRepo(repos);
|
assertConflictingRepo(repos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void assertMainRepo() {
|
||||||
|
assertMainRepo(RepoProvider.Helper.all(context));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* + 2048 (com.uberspot.a2048)
|
* + 2048 (com.uberspot.a2048)
|
||||||
* - Version 1.96 (19)
|
* - Version 1.96 (19)
|
||||||
@ -157,17 +193,21 @@ public class ProperMultiRepoUpdaterTest extends MultiRepoUpdaterTest {
|
|||||||
assertApksExist(apks, "org.adaway", new int[]{52, 53, 54});
|
assertApksExist(apks, "org.adaway", new int[]{52, 53, 54});
|
||||||
assertApksExist(apks, "siir.es.adbWireless", new int[]{12});
|
assertApksExist(apks, "siir.es.adbWireless", new int[]{12});
|
||||||
|
|
||||||
assert2048(repo, "Normal");
|
assert2048Metadata(repo, "Normal");
|
||||||
assertAdAway(repo, "Normal");
|
assertAdAwayMetadata(repo, "Normal");
|
||||||
assertAdb(repo, "Normal");
|
assertAdbMetadata(repo, "Normal");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void assert2048Metadata(Repo repo, @RepoIdentifier String id) {
|
||||||
|
App a2048 = AppProvider.Helper.findByPackageName(context.getContentResolver(), "com.uberspot.a2048", repo.getId());
|
||||||
|
assert2048Metadata(a2048, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param id An identifier that we've put in the metadata for each repo to ensure that
|
* @param id An identifier that we've put in the metadata for each repo to ensure that
|
||||||
* we can identify the metadata is coming from the correct repo.
|
* we can identify the metadata is coming from the correct repo.
|
||||||
*/
|
*/
|
||||||
private void assert2048(Repo repo, @RepoIdentifier String id) {
|
private void assert2048Metadata(App a2048, @RepoIdentifier String id) {
|
||||||
App a2048 = AppProvider.Helper.findByPackageName(context.getContentResolver(), "com.uberspot.a2048", repo.getId());
|
|
||||||
assertNotNull(a2048);
|
assertNotNull(a2048);
|
||||||
assertEquals("2048", a2048.name);
|
assertEquals("2048", a2048.name);
|
||||||
assertEquals(String.format("<p>2048 from %s repo.</p>", id), a2048.description);
|
assertEquals(String.format("<p>2048 from %s repo.</p>", id), a2048.description);
|
||||||
@ -177,9 +217,13 @@ public class ProperMultiRepoUpdaterTest extends MultiRepoUpdaterTest {
|
|||||||
assertEquals(String.format("https://github.com/uberspot/2048-android/issues?%s", id), a2048.trackerURL);
|
assertEquals(String.format("https://github.com/uberspot/2048-android/issues?%s", id), a2048.trackerURL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @see ProperMultiRepoUpdaterTest#assert2048(Repo, String) */
|
private void assertAdAwayMetadata(Repo repo, @RepoIdentifier String id) {
|
||||||
private void assertAdAway(Repo repo, @RepoIdentifier String id) {
|
|
||||||
App adaway = AppProvider.Helper.findByPackageName(context.getContentResolver(), "org.adaway", repo.getId());
|
App adaway = AppProvider.Helper.findByPackageName(context.getContentResolver(), "org.adaway", repo.getId());
|
||||||
|
assertAdAwayMetadata(adaway, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @see ProperMultiRepoUpdaterTest#assert2048Metadata(Repo, String) */
|
||||||
|
private void assertAdAwayMetadata(App adaway, @RepoIdentifier String id) {
|
||||||
assertNotNull(adaway);
|
assertNotNull(adaway);
|
||||||
assertEquals(String.format("AdAway", id), adaway.name);
|
assertEquals(String.format("AdAway", id), adaway.name);
|
||||||
assertEquals(String.format("<p>AdAway from %s repo.</p>", id), adaway.description);
|
assertEquals(String.format("<p>AdAway from %s repo.</p>", id), adaway.description);
|
||||||
@ -192,9 +236,13 @@ public class ProperMultiRepoUpdaterTest extends MultiRepoUpdaterTest {
|
|||||||
assertEquals(String.format("369138", id), adaway.flattrID);
|
assertEquals(String.format("369138", id), adaway.flattrID);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @see ProperMultiRepoUpdaterTest#assert2048(Repo, String) */
|
private void assertAdbMetadata(Repo repo, @RepoIdentifier String id) {
|
||||||
private void assertAdb(Repo repo, @RepoIdentifier String id) {
|
|
||||||
App adb = AppProvider.Helper.findByPackageName(context.getContentResolver(), "siir.es.adbWireless", repo.getId());
|
App adb = AppProvider.Helper.findByPackageName(context.getContentResolver(), "siir.es.adbWireless", repo.getId());
|
||||||
|
assertAdbMetadata(adb, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @see ProperMultiRepoUpdaterTest#assert2048Metadata(Repo, String) */
|
||||||
|
private void assertAdbMetadata(App adb, @RepoIdentifier String id) {
|
||||||
assertNotNull(adb);
|
assertNotNull(adb);
|
||||||
assertEquals("adbWireless", adb.name);
|
assertEquals("adbWireless", adb.name);
|
||||||
assertEquals(String.format("<p>adbWireless from %s repo.</p>", id), adb.description);
|
assertEquals(String.format("<p>adbWireless from %s repo.</p>", id), adb.description);
|
||||||
@ -204,9 +252,13 @@ public class ProperMultiRepoUpdaterTest extends MultiRepoUpdaterTest {
|
|||||||
assertEquals(String.format("https://adbwireless.example.com/issues?%s", id), adb.trackerURL);
|
assertEquals(String.format("https://adbwireless.example.com/issues?%s", id), adb.trackerURL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @see ProperMultiRepoUpdaterTest#assert2048(Repo, String) */
|
private void assertCalendarMetadata(Repo repo, @RepoIdentifier String id) {
|
||||||
private void assertCalendar(Repo repo, @RepoIdentifier String id) {
|
|
||||||
App calendar = AppProvider.Helper.findByPackageName(context.getContentResolver(), "org.dgtale.icsimport", repo.getId());
|
App calendar = AppProvider.Helper.findByPackageName(context.getContentResolver(), "org.dgtale.icsimport", repo.getId());
|
||||||
|
assertCalendarMetadata(calendar, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @see ProperMultiRepoUpdaterTest#assert2048Metadata(Repo, String) */
|
||||||
|
private void assertCalendarMetadata(App calendar, @RepoIdentifier String id) {
|
||||||
assertNotNull(calendar);
|
assertNotNull(calendar);
|
||||||
assertEquals("Add to calendar", calendar.name);
|
assertEquals("Add to calendar", calendar.name);
|
||||||
assertEquals(String.format("<p>Add to calendar from %s repo.</p>", id), calendar.description);
|
assertEquals(String.format("<p>Add to calendar from %s repo.</p>", id), calendar.description);
|
||||||
@ -217,6 +269,10 @@ public class ProperMultiRepoUpdaterTest extends MultiRepoUpdaterTest {
|
|||||||
assertEquals("2225390", calendar.flattrID);
|
assertEquals("2225390", calendar.flattrID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void assertMainArchiveRepoMetadata() {
|
||||||
|
assertMainArchiveRepoMetadata(RepoProvider.Helper.all(context));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* + AdAway (org.adaway)
|
* + AdAway (org.adaway)
|
||||||
* - Version 2.9.2 (51)
|
* - Version 2.9.2 (51)
|
||||||
@ -233,14 +289,18 @@ public class ProperMultiRepoUpdaterTest extends MultiRepoUpdaterTest {
|
|||||||
* - Version 1.35 (36)
|
* - Version 1.35 (36)
|
||||||
* - Version 1.34 (35)
|
* - Version 1.34 (35)
|
||||||
*/
|
*/
|
||||||
private void assertMainArchiveRepo(List<Repo> allRepos) {
|
private void assertMainArchiveRepoMetadata(List<Repo> allRepos) {
|
||||||
Repo repo = findRepo(REPO_ARCHIVE, allRepos);
|
Repo repo = findRepo(REPO_ARCHIVE, allRepos);
|
||||||
|
|
||||||
List<Apk> apks = ApkProvider.Helper.findByRepo(context, repo, Schema.ApkTable.Cols.ALL);
|
List<Apk> apks = ApkProvider.Helper.findByRepo(context, repo, Schema.ApkTable.Cols.ALL);
|
||||||
assertEquals("Apks for main archive repo", 13, apks.size());
|
assertEquals("Apks for main archive repo", 13, apks.size());
|
||||||
assertApksExist(apks, "org.adaway", new int[]{35, 36, 37, 38, 40, 42, 45, 46, 47, 48, 49, 50, 51});
|
assertApksExist(apks, "org.adaway", new int[]{35, 36, 37, 38, 40, 42, 45, 46, 47, 48, 49, 50, 51});
|
||||||
|
|
||||||
assertAdAway(repo, "Normal");
|
assertAdAwayMetadata(repo, "Normal");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void assertConflictingRepo() {
|
||||||
|
assertConflictingRepo(RepoProvider.Helper.all(context));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -261,8 +321,8 @@ public class ProperMultiRepoUpdaterTest extends MultiRepoUpdaterTest {
|
|||||||
assertApksExist(apks, "org.adaway", new int[]{50, 51, 52, 53});
|
assertApksExist(apks, "org.adaway", new int[]{50, 51, 52, 53});
|
||||||
assertApksExist(apks, "org.dgtale.icsimport", new int[]{2, 3});
|
assertApksExist(apks, "org.dgtale.icsimport", new int[]{2, 3});
|
||||||
|
|
||||||
assertAdAway(repo, "Conflicting");
|
assertAdAwayMetadata(repo, "Conflicting");
|
||||||
assertCalendar(repo, "Conflicting");
|
assertCalendarMetadata(repo, "Conflicting");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user