summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorHerbert Reiter <46045854+damoasda@users.noreply.github.com>2021-02-07 17:57:09 +0100
committerGitHub <noreply@github.com>2021-02-07 17:57:09 +0100
commit60968089ae4afe13ba48d64346ea39c542ad457b (patch)
tree6a8d9bbf36d1e9aced4fcf533a6b47c4c565fdbf /app
parentded779d0c9b884fae3b78347f7b8a09069730785 (diff)
downloadAntennaPod-60968089ae4afe13ba48d64346ea39c542ad457b.zip
Refactoring: Remove ClientConfig.automaticDownloadAlgorithm (#4924)
Diffstat (limited to 'app')
-rw-r--r--app/src/androidTest/java/de/test/antennapod/storage/AutoDownloadTest.java24
-rw-r--r--app/src/main/java/de/danoeh/antennapod/config/ClientConfigurator.java5
2 files changed, 12 insertions, 17 deletions
diff --git a/app/src/androidTest/java/de/test/antennapod/storage/AutoDownloadTest.java b/app/src/androidTest/java/de/test/antennapod/storage/AutoDownloadTest.java
index 1d2e3d9e8..e74cf49b7 100644
--- a/app/src/androidTest/java/de/test/antennapod/storage/AutoDownloadTest.java
+++ b/app/src/androidTest/java/de/test/antennapod/storage/AutoDownloadTest.java
@@ -3,13 +3,13 @@ package de.test.antennapod.storage;
import android.content.Context;
import androidx.annotation.NonNull;
import androidx.test.core.app.ApplicationProvider;
-import de.danoeh.antennapod.core.ClientConfig;
import de.danoeh.antennapod.core.feed.FeedItem;
import de.danoeh.antennapod.core.feed.FeedMedia;
import de.danoeh.antennapod.core.preferences.PlaybackPreferences;
import de.danoeh.antennapod.core.preferences.UserPreferences;
import de.danoeh.antennapod.core.storage.AutomaticDownloadAlgorithm;
import de.danoeh.antennapod.core.storage.DBReader;
+import de.danoeh.antennapod.core.storage.DBTasks;
import de.danoeh.antennapod.core.util.playback.PlaybackServiceStarter;
import de.test.antennapod.EspressoTestUtils;
import de.test.antennapod.ui.UITestUtils;
@@ -29,8 +29,7 @@ public class AutoDownloadTest {
private Context context;
private UITestUtils stubFeedsServer;
-
- private AutomaticDownloadAlgorithm automaticDownloadAlgorithmOrig;
+ private StubDownloadAlgorithm stubDownloadAlgorithm;
@Before
public void setUp() throws Exception {
@@ -39,16 +38,19 @@ public class AutoDownloadTest {
stubFeedsServer = new UITestUtils(context);
stubFeedsServer.setup();
- automaticDownloadAlgorithmOrig = ClientConfig.automaticDownloadAlgorithm;
-
EspressoTestUtils.clearPreferences();
EspressoTestUtils.clearDatabase();
UserPreferences.setAllowMobileStreaming(true);
+
+ // Setup: enable automatic download
+ // it is not needed, as the actual automatic download is stubbed.
+ stubDownloadAlgorithm = new StubDownloadAlgorithm();
+ DBTasks.setDownloadAlgorithm(stubDownloadAlgorithm);
}
@After
public void tearDown() throws Exception {
- ClientConfig.automaticDownloadAlgorithm = automaticDownloadAlgorithmOrig;
+ DBTasks.setDownloadAlgorithm(new AutomaticDownloadAlgorithm());
EspressoTestUtils.tryKillPlaybackService();
stubFeedsServer.tearDown();
}
@@ -74,11 +76,6 @@ public class AutoDownloadTest {
FeedItem item0 = queue.get(0);
FeedItem item1 = queue.get(1);
- // Setup: enable automatic download
- // it is not needed, as the actual automatic download is stubbed.
- StubDownloadAlgorithm stubDownloadAlgorithm = new StubDownloadAlgorithm();
- ClientConfig.automaticDownloadAlgorithm = stubDownloadAlgorithm;
-
// Actual test
// Play the first one in the queue
playEpisode(item0);
@@ -92,11 +89,10 @@ public class AutoDownloadTest {
} catch (ConditionTimeoutException cte) {
long actual = stubDownloadAlgorithm.getCurrentlyPlayingAtDownload();
fail("when auto download is triggered, the next episode should be playing: ("
- + item1.getId() + ", " + item1.getTitle() + ") . "
+ + item1.getId() + ", " + item1.getTitle() + ") . "
+ "Actual playing: (" + actual + ")"
);
}
-
}
private void playEpisode(@NonNull FeedItem item) {
@@ -111,7 +107,7 @@ public class AutoDownloadTest {
.until(() -> item.getMedia().getId() == PlaybackPreferences.getCurrentlyPlayingFeedMediaId());
}
- private static class StubDownloadAlgorithm implements AutomaticDownloadAlgorithm {
+ private static class StubDownloadAlgorithm extends AutomaticDownloadAlgorithm {
private long currentlyPlaying = -1;
@Override
diff --git a/app/src/main/java/de/danoeh/antennapod/config/ClientConfigurator.java b/app/src/main/java/de/danoeh/antennapod/config/ClientConfigurator.java
index 7a5cf431f..f01047705 100644
--- a/app/src/main/java/de/danoeh/antennapod/config/ClientConfigurator.java
+++ b/app/src/main/java/de/danoeh/antennapod/config/ClientConfigurator.java
@@ -2,21 +2,20 @@ package de.danoeh.antennapod.config;
import de.danoeh.antennapod.BuildConfig;
import de.danoeh.antennapod.core.ClientConfig;
-import de.danoeh.antennapod.core.storage.APDownloadAlgorithm;
/**
* Configures the ClientConfig class of the core package.
*/
class ClientConfigurator {
- private ClientConfigurator(){}
+ private ClientConfigurator() {
+ }
static {
ClientConfig.USER_AGENT = "AntennaPod/" + BuildConfig.VERSION_NAME;
ClientConfig.applicationCallbacks = new ApplicationCallbacksImpl();
ClientConfig.downloadServiceCallbacks = new DownloadServiceCallbacksImpl();
ClientConfig.playbackServiceCallbacks = new PlaybackServiceCallbacksImpl();
- ClientConfig.automaticDownloadAlgorithm = new APDownloadAlgorithm();
ClientConfig.castCallbacks = new CastCallbackImpl();
}
}