summaryrefslogtreecommitdiff
path: root/app/src/androidTest/java/de/test/antennapod/service/download
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/androidTest/java/de/test/antennapod/service/download')
-rw-r--r--app/src/androidTest/java/de/test/antennapod/service/download/DownloadServiceTest.java13
1 files changed, 7 insertions, 6 deletions
diff --git a/app/src/androidTest/java/de/test/antennapod/service/download/DownloadServiceTest.java b/app/src/androidTest/java/de/test/antennapod/service/download/DownloadServiceTest.java
index 7645facc2..edd80b0d0 100644
--- a/app/src/androidTest/java/de/test/antennapod/service/download/DownloadServiceTest.java
+++ b/app/src/androidTest/java/de/test/antennapod/service/download/DownloadServiceTest.java
@@ -8,6 +8,7 @@ import androidx.core.util.Consumer;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;
+import de.danoeh.antennapod.core.service.download.DownloadRequestCreator;
import de.test.antennapod.EspressoTestUtils;
import org.awaitility.Awaitility;
import org.awaitility.core.ConditionTimeoutException;
@@ -33,7 +34,6 @@ import de.danoeh.antennapod.core.service.download.DownloaderFactory;
import de.danoeh.antennapod.core.service.download.StubDownloader;
import de.danoeh.antennapod.core.storage.DBReader;
import de.danoeh.antennapod.core.storage.DBWriter;
-import de.danoeh.antennapod.core.storage.DownloadRequester;
import static de.test.antennapod.util.event.DownloadEventListener.withDownloadEventListener;
import static de.test.antennapod.util.event.FeedItemEventListener.withFeedItemEventListener;
@@ -80,7 +80,7 @@ public class DownloadServiceTest {
public void tearDown() throws Exception {
DownloadService.setDownloaderFactory(origFactory);
Context context = InstrumentationRegistry.getInstrumentation().getTargetContext();
- DownloadRequester.getInstance().cancelAllDownloads(context);
+ DownloadService.cancelAll(context);
context.stopService(new Intent(context, DownloadService.class));
EspressoTestUtils.tryKillDownloadService();
}
@@ -113,8 +113,8 @@ public class DownloadServiceTest {
assertFalse("The media in test should not yet been downloaded",
DBReader.getFeedMedia(testMedia11.getId()).isDownloaded());
- DownloadRequester.getInstance().downloadMedia(false, InstrumentationRegistry
- .getInstrumentation().getTargetContext(), true, testMedia11.getItem());
+ DownloadService.download(InstrumentationRegistry.getInstrumentation().getTargetContext(), false,
+ DownloadRequestCreator.create(testMedia11).build());
Awaitility.await()
.atMost(5000, TimeUnit.MILLISECONDS)
.until(() -> feedItemEventListener.getEvents().size() >= numEventsExpected);
@@ -158,7 +158,8 @@ public class DownloadServiceTest {
}
withFeedItemEventListener(feedItemEventListener -> {
- DownloadRequester.getInstance().downloadMedia(false, context, true, testMedia11.getItem());
+ DownloadService.download(InstrumentationRegistry.getInstrumentation().getTargetContext(), false,
+ DownloadRequestCreator.create(testMedia11).build());
withDownloadEventListener(downloadEventListener ->
Awaitility.await("download is actually running")
.atMost(5000, TimeUnit.MILLISECONDS)
@@ -174,7 +175,7 @@ public class DownloadServiceTest {
.atMost(2000, TimeUnit.MILLISECONDS)
.until(() -> feedItemEventListener.getEvents().size() >= 1);
}
- DownloadRequester.getInstance().cancelDownload(context, testMedia11);
+ DownloadService.cancel(context, testMedia11.getDownload_url());
final int totalNumEventsExpected = itemAlreadyInQueue ? 1 : 3;
Awaitility.await("item dequeue event + download termination event")
.atMost(2000, TimeUnit.MILLISECONDS)