예제 #1
0
 @Test
 public void signalsCompletionToPostProcessor() throws Exception {
   DownloadManager.CompletionInfo info = DownloadManager.CompletionInfo.success(TITLE, LOCAL_PATH);
   when(downloadManager.query(1)).thenReturn(info);
   downloader.finishDownload(1);
   verify(processor).downloadComplete(TITLE, LOCAL_PATH);
 }
예제 #2
0
 @Test
 public void signalsErrorToPostProcessor() throws Exception {
   final int errorCode = 1006;
   DownloadManager.CompletionInfo info = DownloadManager.CompletionInfo.failure(TITLE, errorCode);
   when(downloadManager.query(1)).thenReturn(info);
   downloader.finishDownload(1);
   verify(processor).downloadError(TITLE, errorCode);
 }
예제 #3
0
 @Test
 public void skipsCancelledTasks() throws Exception {
   when(downloadManager.query(1)).thenReturn(null);
   downloader.finishDownload(1);
   verifyZeroInteractions(processor);
 }
예제 #4
0
 @Test
 public void ensuresDownloadFolderExists() throws Exception {
   downloader.startDownloading(request);
   verify(downloadFolder).mkdirs();
 }
예제 #5
0
 @Test
 public void constructsLocalPathForTaskFromSourceUrl() throws Exception {
   when(downloadFolder.makePathForUrl(SOURCE_URL)).thenReturn(LOCAL_PATH);
   downloader.startDownloading(request);
   assertEquals(request.localPath, LOCAL_PATH);
 }
예제 #6
0
 @Test
 public void submitsTaskToDownloader() throws Exception {
   downloader.startDownloading(request);
   verify(downloadManager).submit(request);
 }