use of de.danoeh.antennapod.core.service.download.Downloader in project AntennaPod by AntennaPod.
the class PostDownloaderTask method run.
@Override
public void run() {
List<Downloader> runningDownloads = new ArrayList<>();
for (Downloader downloader : downloads) {
if (!downloader.cancelled) {
runningDownloads.add(downloader);
}
}
List<Downloader> list = Collections.unmodifiableList(runningDownloads);
EventBus.getDefault().postSticky(DownloadEvent.refresh(list));
}
use of de.danoeh.antennapod.core.service.download.Downloader in project AntennaPod by AntennaPod.
the class HttpDownloaderTest method testDeleteOnFailShouldNotDelete.
@Test
public void testDeleteOnFailShouldNotDelete() throws IOException {
String filename = "testDeleteOnFailShouldDelete";
File dest = new File(destDir, filename);
dest.delete();
assertTrue(dest.createNewFile());
Downloader downloader = download(url404, filename, false, false, null, null, false);
assertTrue(new File(downloader.getDownloadRequest().getDestination()).exists());
}
use of de.danoeh.antennapod.core.service.download.Downloader in project AntennaPod by AntennaPod.
the class HttpDownloaderTest method testAuthenticationShouldFail.
@Test
public void testAuthenticationShouldFail() {
Downloader downloader = download(urlAuth, "testAuthSuccess", false, true, "user", "Wrong passwd", true);
assertEquals(DownloadError.ERROR_UNAUTHORIZED, downloader.getResult().getReason());
}
use of de.danoeh.antennapod.core.service.download.Downloader in project AntennaPod by AntennaPod.
the class HttpDownloaderTest method download.
private Downloader download(String url, String title, boolean expectedResult, boolean deleteExisting, String username, String password, boolean deleteOnFail) {
FeedFile feedFile = setupFeedFile(url, title, deleteExisting);
DownloadRequest request = new DownloadRequest(feedFile.getFile_url(), url, title, 0, feedFile.getTypeAsInt(), username, password, deleteOnFail, null, false);
Downloader downloader = new HttpDownloader(request);
downloader.call();
DownloadStatus status = downloader.getResult();
assertNotNull(status);
assertEquals(expectedResult, status.isSuccessful());
assertTrue(status.isDone());
// the file should not exist if the download has failed and deleteExisting was true
assertTrue(!deleteExisting || new File(feedFile.getFile_url()).exists() == expectedResult);
return downloader;
}
use of de.danoeh.antennapod.core.service.download.Downloader in project AntennaPod by AntennaPod.
the class HttpDownloaderTest method testDeleteOnFailShouldDelete.
@Test
public void testDeleteOnFailShouldDelete() {
Downloader downloader = download(url404, "testDeleteOnFailShouldDelete", false, true, null, null, true);
assertFalse(new File(downloader.getDownloadRequest().getDestination()).exists());
}
Aggregations