fix tests after icon changes

This commit is contained in:
Marcus Hoffmann 2020-02-21 17:16:07 +01:00
parent 941d8a0b8b
commit 7b5d7f8fed
4 changed files with 14 additions and 9 deletions

View File

@ -169,7 +169,8 @@ dependencies {
testImplementation 'org.robolectric:robolectric:3.8'
testImplementation "com.android.support.test:monitor:1.0.2"
testImplementation 'org.bouncycastle:bcprov-jdk15on:1.60'
testImplementation 'junit:junit:4.12'
testImplementation 'junit:junit:4.13'
testImplementation 'org.hamcrest:hamcrest:2.2'
testImplementation 'org.mockito:mockito-core:2.7.22'
androidTestImplementation 'com.android.support:support-annotations:27.1.1'

View File

@ -118,6 +118,7 @@ public class App extends ValueObject implements Comparable<App>, Parcelable {
public String name = "Unknown";
public String summary = "Unknown application";
@JsonProperty("icon")
public String iconFromApk;
public String description;

View File

@ -1,6 +1,7 @@
package org.fdroid.fdroid.updater;
import android.content.ContentValues;
import org.fdroid.fdroid.BuildConfig;
import org.fdroid.fdroid.IndexUpdater;
import org.fdroid.fdroid.data.App;
@ -14,7 +15,8 @@ import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import static org.junit.Assert.assertEquals;
import static org.hamcrest.MatcherAssert.assertThat;
import org.hamcrest.text.MatchesPattern;
/**
* Check whether app icons are loaded from the correct repository. The repository with the
@ -42,7 +44,7 @@ public class AppIconsTest extends MultiIndexUpdaterTest {
updateMain();
updateArchive();
assertIconUrl("https://f-droid.org/repo/icons/org.adaway.54.png");
assertIconUrl("^https://f-droid.org/repo/icons-[0-9]{3}/org.adaway.54.png$");
}
@Test
@ -53,7 +55,7 @@ public class AppIconsTest extends MultiIndexUpdaterTest {
updateMain();
updateArchive();
assertIconUrl("https://f-droid.org/archive/icons/org.adaway.54.png");
assertIconUrl("^https://f-droid.org/archive/icons-[0-9]{3}/org.adaway.54.png$");
}
private void setRepoPriority(String repoUri, int priority) {
@ -66,9 +68,10 @@ public class AppIconsTest extends MultiIndexUpdaterTest {
private void assertIconUrl(String expectedUrl) {
App app = AppProvider.Helper.findHighestPriorityMetadata(context.getContentResolver(),
"org.adaway", new String[]{Schema.AppMetadataTable.Cols.ICON_URL});
assertEquals(app.getIconUrl(context), expectedUrl);
"org.adaway", new String[]{
Schema.AppMetadataTable.Cols.ICON_URL,
Schema.AppMetadataTable.Cols.ICON,
Schema.AppMetadataTable.Cols.REPO_ID});
assertThat(app.getIconUrl(context), MatchesPattern.matchesPattern(expectedUrl));
}
}

View File

@ -312,7 +312,7 @@ public class IndexV1UpdaterTest extends FDroidProviderTest {
"donate",
"featureGraphic",
"flattrID",
"icon",
"iconFromApk",
"iconUrl",
"issueTracker",
"lastUpdated",