Move some tests from core module to their respective module (#7059)
This commit is contained in:
parent
0288d4e51e
commit
2143ab1351
|
@ -10,12 +10,12 @@ import androidx.test.filters.LargeTest;
|
|||
import androidx.test.rule.ActivityTestRule;
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.ui.screen.preferences.PreferenceActivity;
|
||||
import de.danoeh.antennapod.core.storage.APCleanupAlgorithm;
|
||||
import de.danoeh.antennapod.core.storage.APNullCleanupAlgorithm;
|
||||
import de.danoeh.antennapod.core.storage.APQueueCleanupAlgorithm;
|
||||
import de.danoeh.antennapod.core.storage.EpisodeCleanupAlgorithm;
|
||||
import de.danoeh.antennapod.core.storage.EpisodeCleanupAlgorithmFactory;
|
||||
import de.danoeh.antennapod.core.storage.ExceptFavoriteCleanupAlgorithm;
|
||||
import de.danoeh.antennapod.net.download.service.episode.autodownload.APCleanupAlgorithm;
|
||||
import de.danoeh.antennapod.net.download.service.episode.autodownload.APNullCleanupAlgorithm;
|
||||
import de.danoeh.antennapod.net.download.service.episode.autodownload.APQueueCleanupAlgorithm;
|
||||
import de.danoeh.antennapod.net.download.service.episode.autodownload.EpisodeCleanupAlgorithm;
|
||||
import de.danoeh.antennapod.net.download.service.episode.autodownload.EpisodeCleanupAlgorithmFactory;
|
||||
import de.danoeh.antennapod.net.download.service.episode.autodownload.ExceptFavoriteCleanupAlgorithm;
|
||||
import de.danoeh.antennapod.storage.preferences.UserPreferences;
|
||||
import de.danoeh.antennapod.storage.preferences.UserPreferences.EnqueueLocation;
|
||||
import de.test.antennapod.EspressoTestUtils;
|
||||
|
|
|
@ -3,7 +3,7 @@ package de.danoeh.antennapod;
|
|||
import android.content.Context;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import de.danoeh.antennapod.core.storage.AutoDownloadManagerImpl;
|
||||
import de.danoeh.antennapod.net.download.service.episode.autodownload.AutoDownloadManagerImpl;
|
||||
import de.danoeh.antennapod.net.download.service.feed.FeedUpdateManagerImpl;
|
||||
import de.danoeh.antennapod.net.download.serviceinterface.AutoDownloadManager;
|
||||
import de.danoeh.antennapod.net.download.serviceinterface.FeedUpdateManager;
|
||||
|
|
|
@ -33,7 +33,7 @@ import com.google.android.material.bottomsheet.BottomSheetBehavior;
|
|||
import com.google.android.material.shape.MaterialShapeDrawable;
|
||||
import com.google.android.material.shape.ShapeAppearanceModel;
|
||||
|
||||
import de.danoeh.antennapod.core.storage.EpisodeCleanupAlgorithmFactory;
|
||||
import de.danoeh.antennapod.net.download.service.episode.autodownload.EpisodeCleanupAlgorithmFactory;
|
||||
import de.danoeh.antennapod.ui.screen.AddFeedFragment;
|
||||
import de.danoeh.antennapod.ui.screen.AllEpisodesFragment;
|
||||
import de.danoeh.antennapod.ui.screen.InboxFragment;
|
||||
|
|
|
@ -41,6 +41,7 @@ project.ext {
|
|||
runnerVersion = "1.5.0"
|
||||
rulesVersion = "1.5.0"
|
||||
testCoreVersion = "1.5.0"
|
||||
mockitoVersion = "5.11.0"
|
||||
}
|
||||
|
||||
checkstyle {
|
||||
|
|
|
@ -56,7 +56,7 @@ dependencies {
|
|||
testImplementation "androidx.test:core:$testCoreVersion"
|
||||
testImplementation "org.awaitility:awaitility:$awaitilityVersion"
|
||||
testImplementation "junit:junit:$junitVersion"
|
||||
testImplementation 'org.mockito:mockito-core:5.11.0'
|
||||
testImplementation "org.mockito:mockito-core:$mockitoVersion"
|
||||
testImplementation "org.robolectric:robolectric:$robolectricVersion"
|
||||
testImplementation 'javax.inject:javax.inject:1'
|
||||
androidTestImplementation "androidx.test.espresso:espresso-core:$espressoVersion"
|
||||
|
|
|
@ -18,4 +18,5 @@ dependencies {
|
|||
|
||||
testImplementation "junit:junit:$junitVersion"
|
||||
testImplementation "androidx.test:core:$testCoreVersion"
|
||||
testImplementation "org.mockito:mockito-core:$mockitoVersion"
|
||||
}
|
||||
|
|
|
@ -1,12 +1,9 @@
|
|||
package de.danoeh.antennapod.core.feed;
|
||||
|
||||
import de.danoeh.antennapod.ui.common.Converter;
|
||||
import de.danoeh.antennapod.model.feed.FeedFilter;
|
||||
import de.danoeh.antennapod.model.feed.FeedItem;
|
||||
import de.danoeh.antennapod.model.feed.FeedMedia;
|
||||
package de.danoeh.antennapod.model.feed;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
@ -133,7 +130,7 @@ public class FeedFilterTest {
|
|||
FeedItem download = new FeedItem();
|
||||
download.setTitle("Hello friend!");
|
||||
FeedMedia downloadMedia = FeedMediaMother.anyFeedMedia();
|
||||
downloadMedia.setDuration(Converter.durationStringShortToMs("05:00", false));
|
||||
downloadMedia.setDuration((int) TimeUnit.MILLISECONDS.convert(5, TimeUnit.MINUTES));
|
||||
download.setMedia(downloadMedia);
|
||||
// because duration of the media in unknown
|
||||
FeedItem download2 = new FeedItem();
|
||||
|
@ -144,7 +141,7 @@ public class FeedFilterTest {
|
|||
FeedItem doNotDownload = new FeedItem();
|
||||
doNotDownload.setTitle("Hello friend!");
|
||||
FeedMedia doNotDownloadMedia = FeedMediaMother.anyFeedMedia();
|
||||
doNotDownloadMedia.setDuration(Converter.durationStringShortToMs("02:00", false));
|
||||
doNotDownloadMedia.setDuration((int) TimeUnit.MILLISECONDS.convert(2, TimeUnit.MINUTES));
|
||||
doNotDownload.setMedia(doNotDownloadMedia);
|
||||
|
||||
int minimalDurationFilter = 3 * 60;
|
|
@ -1,10 +1,8 @@
|
|||
package de.danoeh.antennapod.core.feed;
|
||||
|
||||
import de.danoeh.antennapod.model.feed.FeedItem;
|
||||
package de.danoeh.antennapod.model.feed;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import static de.danoeh.antennapod.core.feed.FeedMother.anyFeed;
|
||||
import static de.danoeh.antennapod.model.feed.FeedMother.anyFeed;
|
||||
|
||||
class FeedItemMother {
|
||||
private static final String IMAGE_URL = "http://example.com/image";
|
|
@ -1,13 +1,12 @@
|
|||
package de.danoeh.antennapod.core.feed;
|
||||
package de.danoeh.antennapod.model.feed;
|
||||
|
||||
import de.danoeh.antennapod.model.feed.FeedItem;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import static de.danoeh.antennapod.core.feed.FeedItemMother.anyFeedItemWithImage;
|
||||
import static de.danoeh.antennapod.model.feed.FeedItemMother.anyFeedItemWithImage;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
|
@ -1,6 +1,4 @@
|
|||
package de.danoeh.antennapod.core.feed;
|
||||
|
||||
import de.danoeh.antennapod.model.feed.FeedMedia;
|
||||
package de.danoeh.antennapod.model.feed;
|
||||
|
||||
class FeedMediaMother {
|
||||
|
|
@ -1,11 +1,9 @@
|
|||
package de.danoeh.antennapod.core.feed;
|
||||
package de.danoeh.antennapod.model.feed;
|
||||
|
||||
import de.danoeh.antennapod.model.feed.FeedItem;
|
||||
import de.danoeh.antennapod.model.feed.FeedMedia;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static de.danoeh.antennapod.core.feed.FeedMediaMother.anyFeedMedia;
|
||||
import static de.danoeh.antennapod.model.feed.FeedMediaMother.anyFeedMedia;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
|
@ -1,6 +1,4 @@
|
|||
package de.danoeh.antennapod.core.feed;
|
||||
|
||||
import de.danoeh.antennapod.model.feed.Feed;
|
||||
package de.danoeh.antennapod.model.feed;
|
||||
|
||||
public class FeedMother {
|
||||
public static final String IMAGE_URL = "http://example.com/image";
|
|
@ -1,12 +1,9 @@
|
|||
package de.danoeh.antennapod.core.feed;
|
||||
package de.danoeh.antennapod.model.feed;
|
||||
|
||||
import de.danoeh.antennapod.model.feed.Feed;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import de.danoeh.antennapod.model.feed.SortOrder;
|
||||
|
||||
import static de.danoeh.antennapod.core.feed.FeedMother.anyFeed;
|
||||
import static de.danoeh.antennapod.model.feed.FeedMother.anyFeed;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThrows;
|
||||
|
|
@ -43,5 +43,6 @@ dependencies {
|
|||
testImplementation "junit:junit:$junitVersion"
|
||||
testImplementation "org.robolectric:robolectric:$robolectricVersion"
|
||||
testImplementation "org.awaitility:awaitility:$awaitilityVersion"
|
||||
testImplementation 'org.mockito:mockito-core:5.11.0'
|
||||
testImplementation "org.mockito:mockito-core:$mockitoVersion"
|
||||
testImplementation "androidx.preference:preference:$preferenceVersion"
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package de.danoeh.antennapod.core.storage;
|
||||
package de.danoeh.antennapod.net.download.service.episode.autodownload;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.annotation.NonNull;
|
|
@ -1,4 +1,4 @@
|
|||
package de.danoeh.antennapod.core.storage;
|
||||
package de.danoeh.antennapod.net.download.service.episode.autodownload;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
|
@ -1,4 +1,4 @@
|
|||
package de.danoeh.antennapod.core.storage;
|
||||
package de.danoeh.antennapod.net.download.service.episode.autodownload;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.annotation.NonNull;
|
|
@ -1,4 +1,4 @@
|
|||
package de.danoeh.antennapod.core.storage;
|
||||
package de.danoeh.antennapod.net.download.service.episode.autodownload;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
|
@ -1,4 +1,4 @@
|
|||
package de.danoeh.antennapod.core.storage;
|
||||
package de.danoeh.antennapod.net.download.service.episode.autodownload;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
|
@ -1,4 +1,4 @@
|
|||
package de.danoeh.antennapod.core.storage;
|
||||
package de.danoeh.antennapod.net.download.service.episode.autodownload;
|
||||
|
||||
import android.content.Context;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package de.danoeh.antennapod.core.storage;
|
||||
package de.danoeh.antennapod.net.download.service.episode.autodownload;
|
||||
|
||||
import de.danoeh.antennapod.storage.preferences.UserPreferences;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package de.danoeh.antennapod.core.storage;
|
||||
package de.danoeh.antennapod.net.download.service.episode.autodownload;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
|
@ -1,4 +1,4 @@
|
|||
package de.danoeh.antennapod.core.storage;
|
||||
package de.danoeh.antennapod.net.download.service.episode.autodownload;
|
||||
|
||||
import org.junit.Test;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package de.danoeh.antennapod.core.storage;
|
||||
package de.danoeh.antennapod.net.download.service.episode.autodownload;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
|
@ -28,7 +28,7 @@ import org.junit.Test;
|
|||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
|
||||
import static de.danoeh.antennapod.core.storage.DbTestUtils.saveFeedlist;
|
||||
import static de.danoeh.antennapod.net.download.service.episode.autodownload.DbTestUtils.saveFeedlist;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
|
@ -1,4 +1,4 @@
|
|||
package de.danoeh.antennapod.core.storage;
|
||||
package de.danoeh.antennapod.net.download.service.episode.autodownload;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
|
@ -1,4 +1,4 @@
|
|||
package de.danoeh.antennapod.core.storage;
|
||||
package de.danoeh.antennapod.net.download.service.episode.autodownload;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
|
@ -1,4 +1,4 @@
|
|||
package de.danoeh.antennapod.core.storage;
|
||||
package de.danoeh.antennapod.net.download.service.episode.autodownload;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
|
@ -33,7 +33,7 @@ import org.junit.runner.RunWith;
|
|||
import org.robolectric.ParameterizedRobolectricTestRunner;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
|
||||
import static de.danoeh.antennapod.core.storage.DbTestUtils.saveFeedlist;
|
||||
import static de.danoeh.antennapod.net.download.service.episode.autodownload.DbTestUtils.saveFeedlist;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
|
@ -1,4 +1,4 @@
|
|||
package de.danoeh.antennapod.core.storage;
|
||||
package de.danoeh.antennapod.net.download.service.episode.autodownload;
|
||||
|
||||
import android.content.Context;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package de.danoeh.antennapod.core.storage;
|
||||
package de.danoeh.antennapod.net.download.service.episode.autodownload;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
|
@ -1,4 +1,4 @@
|
|||
package de.danoeh.antennapod.core.storage;
|
||||
package de.danoeh.antennapod.net.download.service.episode.autodownload;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
|
@ -1,4 +1,4 @@
|
|||
package de.danoeh.antennapod.core.storage;
|
||||
package de.danoeh.antennapod.net.download.service.episode.autodownload;
|
||||
|
||||
import de.danoeh.antennapod.net.download.serviceinterface.AutoDownloadManager;
|
||||
import org.junit.Test;
|
|
@ -40,5 +40,5 @@ dependencies {
|
|||
implementation "org.apache.commons:commons-lang3:$commonslangVersion"
|
||||
|
||||
testImplementation "junit:junit:$junitVersion"
|
||||
testImplementation 'org.mockito:mockito-core:5.11.0'
|
||||
testImplementation "org.mockito:mockito-core:$mockitoVersion"
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package de.danoeh.antennapod.core.util;
|
||||
package de.danoeh.antennapod.storage.database;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
|
@ -1,4 +1,4 @@
|
|||
package de.danoeh.antennapod.core.storage;
|
||||
package de.danoeh.antennapod.storage.database;
|
||||
|
||||
import de.danoeh.antennapod.model.feed.FeedItem;
|
||||
import de.danoeh.antennapod.model.feed.FeedMedia;
|
|
@ -1,9 +1,9 @@
|
|||
package de.danoeh.antennapod.core.storage;
|
||||
package de.danoeh.antennapod.storage.database;
|
||||
|
||||
import de.danoeh.antennapod.model.feed.Feed;
|
||||
import de.danoeh.antennapod.model.playback.RemoteMedia;
|
||||
import de.danoeh.antennapod.net.download.serviceinterface.DownloadServiceInterface;
|
||||
import de.danoeh.antennapod.net.download.serviceinterface.DownloadServiceInterfaceStub;
|
||||
import de.danoeh.antennapod.storage.database.ItemEnqueuePositionCalculator;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
|
@ -19,16 +19,14 @@ import java.util.stream.Collectors;
|
|||
|
||||
import de.danoeh.antennapod.model.feed.FeedItem;
|
||||
import de.danoeh.antennapod.model.feed.FeedMedia;
|
||||
import de.danoeh.antennapod.core.feed.FeedMother;
|
||||
import de.danoeh.antennapod.storage.preferences.UserPreferences.EnqueueLocation;
|
||||
import de.danoeh.antennapod.model.playback.Playable;
|
||||
|
||||
import static de.danoeh.antennapod.storage.preferences.UserPreferences.EnqueueLocation.AFTER_CURRENTLY_PLAYING;
|
||||
import static de.danoeh.antennapod.storage.preferences.UserPreferences.EnqueueLocation.BACK;
|
||||
import static de.danoeh.antennapod.storage.preferences.UserPreferences.EnqueueLocation.FRONT;
|
||||
import static de.danoeh.antennapod.core.util.CollectionTestUtil.concat;
|
||||
import static de.danoeh.antennapod.core.util.CollectionTestUtil.list;
|
||||
import static de.danoeh.antennapod.core.util.FeedItemUtil.getIdList;
|
||||
import static de.danoeh.antennapod.storage.database.CollectionTestUtil.concat;
|
||||
import static de.danoeh.antennapod.storage.database.CollectionTestUtil.list;
|
||||
import static java.util.Collections.emptyList;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
|
@ -136,7 +134,10 @@ public class ItemEnqueuePositionCalculatorTest {
|
|||
List<Long> idsExpected) {
|
||||
int posActual = calculator.calcPosition(queue, currentlyPlaying);
|
||||
queue.add(posActual, itemToAdd);
|
||||
assertEquals(message, idsExpected, getIdList(queue));
|
||||
assertEquals(message, idsExpected.size(), queue.size());
|
||||
for (int i = 0; i < idsExpected.size(); i++) {
|
||||
assertEquals(message, (long) idsExpected.get(i), queue.get(i).getId());
|
||||
}
|
||||
}
|
||||
|
||||
static final List<FeedItem> QUEUE_EMPTY = Collections.unmodifiableList(emptyList());
|
||||
|
@ -167,8 +168,11 @@ public class ItemEnqueuePositionCalculatorTest {
|
|||
|
||||
|
||||
static FeedItem createFeedItem(long id) {
|
||||
Feed feed = new Feed(0, null, "title", "http://example.com", "This is the description",
|
||||
"http://example.com/payment", "Daniel", "en", null, "http://example.com/feed",
|
||||
"http://example.com/image", null, "http://example.com/feed", System.currentTimeMillis());
|
||||
FeedItem item = new FeedItem(id, "Item" + id, "ItemId" + id, "url",
|
||||
new Date(), FeedItem.PLAYED, FeedMother.anyFeed());
|
||||
new Date(), FeedItem.PLAYED, feed);
|
||||
FeedMedia media = new FeedMedia(item, "http://download.url.net/" + id, 1234567, "audio/mpeg");
|
||||
media.setId(item.getId());
|
||||
item.setMedia(media);
|
Loading…
Reference in New Issue