summaryrefslogtreecommitdiff
path: root/app/src/androidTest/java/de
diff options
context:
space:
mode:
authorByteHamster <ByteHamster@users.noreply.github.com>2022-01-06 14:36:11 +0100
committerGitHub <noreply@github.com>2022-01-06 14:36:11 +0100
commit849bf4ad854973d39698613c3a356c09c87e687c (patch)
treefbd07d17fe5f26b8c91f9ce4ff8020046070431f /app/src/androidTest/java/de
parent8252eb2183c6a478fdfd9317586c8800a24054ca (diff)
downloadAntennaPod-849bf4ad854973d39698613c3a356c09c87e687c.zip
Rewrite download request creation (#5530)
Android has a limit on the size of Intent parameters. When enqueuing a huge number of items, it just ignored the argument and did not call onNewIntent. We now load the list over in DownloadService.
Diffstat (limited to 'app/src/androidTest/java/de')
-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)