Updated tests to work with flipped repo priorities.
This commit is contained in:
parent
c6efdbb20c
commit
1aea1c9302
@ -44,8 +44,7 @@ public class CategoryProviderTest extends FDroidProviderTest {
|
|||||||
insertAppWithCategory("com.dog.rock.apple", "Dog-Rock-Apple", "Animal,Mineral,Vegetable", mainRepo);
|
insertAppWithCategory("com.dog.rock.apple", "Dog-Rock-Apple", "Animal,Mineral,Vegetable", mainRepo);
|
||||||
insertAppWithCategory("com.banana.apple", "Banana", "Vegetable,Vegetable", mainRepo);
|
insertAppWithCategory("com.banana.apple", "Banana", "Vegetable,Vegetable", mainRepo);
|
||||||
|
|
||||||
List<String> categories = CategoryProvider.Helper.categories(context);
|
String[] expectedFDroid = new String[] {
|
||||||
String[] expected = new String[] {
|
|
||||||
context.getResources().getString(R.string.category_Whats_New),
|
context.getResources().getString(R.string.category_Whats_New),
|
||||||
context.getResources().getString(R.string.category_Recently_Updated),
|
context.getResources().getString(R.string.category_Recently_Updated),
|
||||||
context.getResources().getString(R.string.category_All),
|
context.getResources().getString(R.string.category_All),
|
||||||
@ -56,13 +55,8 @@ public class CategoryProviderTest extends FDroidProviderTest {
|
|||||||
"Vegetable",
|
"Vegetable",
|
||||||
"Writing",
|
"Writing",
|
||||||
};
|
};
|
||||||
assertContainsOnly(categories, expected);
|
|
||||||
|
|
||||||
insertAppWithCategory("info.guardianproject.notepadbot", "NoteCipher", "Office,GuardianProject", gpRepo);
|
String[] expectedGP = new String[] {
|
||||||
assertContainsOnly(CategoryProvider.Helper.categories(context), expected);
|
|
||||||
|
|
||||||
RepoProvider.Helper.purgeApps(context, new MockRepo(mainRepo));
|
|
||||||
String[] expectedGp = new String[] {
|
|
||||||
context.getResources().getString(R.string.category_Whats_New),
|
context.getResources().getString(R.string.category_Whats_New),
|
||||||
context.getResources().getString(R.string.category_Recently_Updated),
|
context.getResources().getString(R.string.category_Recently_Updated),
|
||||||
context.getResources().getString(R.string.category_All),
|
context.getResources().getString(R.string.category_All),
|
||||||
@ -70,8 +64,29 @@ public class CategoryProviderTest extends FDroidProviderTest {
|
|||||||
"GuardianProject",
|
"GuardianProject",
|
||||||
"Office",
|
"Office",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// We overwrite "Security" + "Writing" with "GuardianProject" + "Office"
|
||||||
|
String[] expectedBoth = new String[] {
|
||||||
|
context.getResources().getString(R.string.category_Whats_New),
|
||||||
|
context.getResources().getString(R.string.category_Recently_Updated),
|
||||||
|
context.getResources().getString(R.string.category_All),
|
||||||
|
|
||||||
|
"Animal",
|
||||||
|
"Mineral",
|
||||||
|
"Vegetable",
|
||||||
|
|
||||||
|
"GuardianProject",
|
||||||
|
"Office",
|
||||||
|
};
|
||||||
|
|
||||||
|
assertContainsOnly(CategoryProvider.Helper.categories(context), expectedFDroid);
|
||||||
|
|
||||||
|
insertAppWithCategory("info.guardianproject.notepadbot", "NoteCipher", "Office,GuardianProject", gpRepo);
|
||||||
|
assertContainsOnly(CategoryProvider.Helper.categories(context), expectedBoth);
|
||||||
|
|
||||||
|
RepoProvider.Helper.purgeApps(context, new MockRepo(mainRepo));
|
||||||
List<String> categoriesAfterPurge = CategoryProvider.Helper.categories(context);
|
List<String> categoriesAfterPurge = CategoryProvider.Helper.categories(context);
|
||||||
assertContainsOnly(categoriesAfterPurge, expectedGp);
|
assertContainsOnly(categoriesAfterPurge, expectedGP);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -95,15 +95,15 @@ public class ProperMultiRepoUpdaterTest extends MultiRepoUpdaterTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void metadataWithRepoPriority() throws RepoUpdater.UpdateException {
|
public void metadataWithRepoPriority() throws RepoUpdater.UpdateException {
|
||||||
updateConflicting();
|
|
||||||
updateMain();
|
updateMain();
|
||||||
updateArchive();
|
updateArchive();
|
||||||
|
updateConflicting();
|
||||||
|
|
||||||
Repo conflictingRepo = RepoProvider.Helper.findByAddress(context, REPO_CONFLICTING_URI);
|
Repo mainRepo = RepoProvider.Helper.findByAddress(context, REPO_MAIN_URI);
|
||||||
|
|
||||||
assertEquals(1, conflictingRepo.priority);
|
assertEquals(1, mainRepo.priority);
|
||||||
assertEquals(2, RepoProvider.Helper.findByAddress(context, REPO_MAIN_URI).priority);
|
assertEquals(2, RepoProvider.Helper.findByAddress(context, REPO_ARCHIVE_URI).priority);
|
||||||
assertEquals(3, RepoProvider.Helper.findByAddress(context, REPO_ARCHIVE_URI).priority);
|
assertEquals(3, RepoProvider.Helper.findByAddress(context, REPO_CONFLICTING_URI).priority);
|
||||||
|
|
||||||
assertMainRepo();
|
assertMainRepo();
|
||||||
assertMainArchiveRepoMetadata();
|
assertMainArchiveRepoMetadata();
|
||||||
@ -114,9 +114,9 @@ public class ProperMultiRepoUpdaterTest extends MultiRepoUpdaterTest {
|
|||||||
// Make the conflicting repo less important than the main repo.
|
// Make the conflicting repo less important than the main repo.
|
||||||
ContentValues values = new ContentValues(1);
|
ContentValues values = new ContentValues(1);
|
||||||
values.put(Cols.PRIORITY, 5);
|
values.put(Cols.PRIORITY, 5);
|
||||||
RepoProvider.Helper.update(context, conflictingRepo, values);
|
RepoProvider.Helper.update(context, mainRepo, values);
|
||||||
Repo updatedConflictingRepo = RepoProvider.Helper.findByAddress(context, REPO_CONFLICTING_URI);
|
Repo updatedMainRepo = RepoProvider.Helper.findByAddress(context, REPO_MAIN_URI);
|
||||||
assertEquals(5, updatedConflictingRepo.priority);
|
assertEquals(5, updatedMainRepo.priority);
|
||||||
|
|
||||||
assertRepoTakesPriority("Normal");
|
assertRepoTakesPriority("Normal");
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user