summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorByteHamster <ByteHamster@users.noreply.github.com>2023-07-15 16:27:12 +0200
committerGitHub <noreply@github.com>2023-07-15 16:27:12 +0200
commit8d1eb62f0bf3c5014a632acbbf98f06d07cf666e (patch)
tree05add6c82ed0e9866a4d8c07f4a6eec70322755e /app
parent75c3c4cf249b685d4c7ffc88b3db212963659df8 (diff)
downloadAntennaPod-8d1eb62f0bf3c5014a632acbbf98f06d07cf666e.zip
Delete partially downloaded file when giving up to retry (#6530)
Diffstat (limited to 'app')
-rw-r--r--app/src/androidTest/java/de/test/antennapod/service/download/HttpDownloaderTest.java20
1 files changed, 11 insertions, 9 deletions
diff --git a/app/src/androidTest/java/de/test/antennapod/service/download/HttpDownloaderTest.java b/app/src/androidTest/java/de/test/antennapod/service/download/HttpDownloaderTest.java
index 76cba4706..aa55a1e59 100644
--- a/app/src/androidTest/java/de/test/antennapod/service/download/HttpDownloaderTest.java
+++ b/app/src/androidTest/java/de/test/antennapod/service/download/HttpDownloaderTest.java
@@ -72,12 +72,14 @@ public class HttpDownloaderTest {
}
private Downloader download(String url, String title, boolean expectedResult) {
- return download(url, title, expectedResult, true, null, null, true);
+ return download(url, title, expectedResult, true, null, null);
}
- private Downloader download(String url, String title, boolean expectedResult, boolean deleteExisting, String username, String password, boolean deleteOnFail) {
+ private Downloader download(String url, String title, boolean expectedResult, boolean deleteExisting,
+ String username, String password) {
FeedFile feedFile = setupFeedFile(url, title, deleteExisting);
- DownloadRequest request = new DownloadRequest(feedFile.getFile_url(), url, title, 0, feedFile.getTypeAsInt(), username, password, deleteOnFail, null, false);
+ DownloadRequest request = new DownloadRequest(feedFile.getFile_url(), url, title, 0, feedFile.getTypeAsInt(),
+ username, password, null, false);
Downloader downloader = new HttpDownloader(request);
downloader.call();
DownloadResult status = downloader.getResult();
@@ -112,7 +114,8 @@ public class HttpDownloaderTest {
public void testCancel() {
final String url = httpServer.getBaseUrl() + "/delay/3";
FeedFileImpl feedFile = setupFeedFile(url, "delay", true);
- final Downloader downloader = new HttpDownloader(new DownloadRequest(feedFile.getFile_url(), url, "delay", 0, feedFile.getTypeAsInt(), null, null, true, null, false));
+ final Downloader downloader = new HttpDownloader(new DownloadRequest(feedFile.getFile_url(), url, "delay", 0,
+ feedFile.getTypeAsInt(), null, null, null, false));
Thread t = new Thread() {
@Override
public void run() {
@@ -128,12 +131,11 @@ public class HttpDownloaderTest {
}
DownloadResult result = downloader.getResult();
assertFalse(result.isSuccessful());
- assertFalse(new File(feedFile.getFile_url()).exists());
}
@Test
public void testDeleteOnFailShouldDelete() {
- Downloader downloader = download(url404, "testDeleteOnFailShouldDelete", false, true, null, null, true);
+ Downloader downloader = download(url404, "testDeleteOnFailShouldDelete", false, true, null, null);
assertFalse(new File(downloader.getDownloadRequest().getDestination()).exists());
}
@@ -143,18 +145,18 @@ public class HttpDownloaderTest {
File dest = new File(destDir, filename);
dest.delete();
assertTrue(dest.createNewFile());
- Downloader downloader = download(url404, filename, false, false, null, null, false);
+ Downloader downloader = download(url404, filename, false, false, null, null);
assertTrue(new File(downloader.getDownloadRequest().getDestination()).exists());
}
@Test
public void testAuthenticationShouldSucceed() throws InterruptedException {
- download(urlAuth, "testAuthSuccess", true, true, "user", "passwd", true);
+ download(urlAuth, "testAuthSuccess", true, true, "user", "passwd");
}
@Test
public void testAuthenticationShouldFail() {
- Downloader downloader = download(urlAuth, "testAuthSuccess", false, true, "user", "Wrong passwd", true);
+ Downloader downloader = download(urlAuth, "testAuthSuccess", false, true, "user", "Wrong passwd");
assertEquals(DownloadError.ERROR_UNAUTHORIZED, downloader.getResult().getReason());
}