@Test public void downloadedFilePathIsNull() throws Exception { File targetFile = mTemporaryFolder.newFile(); when(mDownloader.getTargetFile()).thenReturn(targetFile); when(mDownloader.getDownloadedReleaseFilePath()).thenReturn(null); mCheckTask.doInBackground(); verify(mDownloader).onStart(targetFile); verifyNoMoreInteractions(ignoreStubs(mDownloader)); }
@Override protected Void doInBackground(Void... params) { File targetFile = mDownloader.getTargetFile(); if (targetFile == null) { mDownloader.onDownloadError("Cannot access to downloads folder. Shared storage is not currently available."); return null; } String downloadedReleaseFilePath = mDownloader.getDownloadedReleaseFilePath(); if (downloadedReleaseFilePath != null) { File downloadedReleaseFile = new File(downloadedReleaseFilePath); if (downloadedReleaseFilePath.equals(targetFile.getAbsolutePath())) { if (downloadedReleaseFile.exists()) { mDownloader.onDownloadComplete(targetFile); return null; } } else { downloadedReleaseFile.delete(); mDownloader.setDownloadedReleaseFilePath(null); } } if (isCancelled()) { return null; } mDownloader.onStart(targetFile); return null; }
HttpConnectionCheckTask extends AsyncTask<Void, Void, Void> { @Override protected Void doInBackground(Void... params) { File targetFile = mDownloader.getTargetFile(); if (targetFile == null) { mDownloader.onDownloadError("Cannot access to downloads folder. Shared storage is not currently available."); return null; } String downloadedReleaseFilePath = mDownloader.getDownloadedReleaseFilePath(); if (downloadedReleaseFilePath != null) { File downloadedReleaseFile = new File(downloadedReleaseFilePath); if (downloadedReleaseFilePath.equals(targetFile.getAbsolutePath())) { if (downloadedReleaseFile.exists()) { mDownloader.onDownloadComplete(targetFile); return null; } } else { downloadedReleaseFile.delete(); mDownloader.setDownloadedReleaseFilePath(null); } } if (isCancelled()) { return null; } mDownloader.onStart(targetFile); return null; } }
HttpConnectionCheckTask extends AsyncTask<Void, Void, Void> { @Override protected Void doInBackground(Void... params) { File targetFile = mDownloader.getTargetFile(); if (targetFile == null) { mDownloader.onDownloadError("Cannot access to downloads folder. Shared storage is not currently available."); return null; } String downloadedReleaseFilePath = mDownloader.getDownloadedReleaseFilePath(); if (downloadedReleaseFilePath != null) { File downloadedReleaseFile = new File(downloadedReleaseFilePath); if (downloadedReleaseFilePath.equals(targetFile.getAbsolutePath())) { if (downloadedReleaseFile.exists()) { mDownloader.onDownloadComplete(targetFile); return null; } } else { downloadedReleaseFile.delete(); mDownloader.setDownloadedReleaseFilePath(null); } } if (isCancelled()) { return null; } mDownloader.onStart(targetFile); return null; } HttpConnectionCheckTask(HttpConnectionReleaseDownloader downloader); }
HttpConnectionCheckTask extends AsyncTask<Void, Void, Void> { @Override protected Void doInBackground(Void... params) { File targetFile = mDownloader.getTargetFile(); if (targetFile == null) { mDownloader.onDownloadError("Cannot access to downloads folder. Shared storage is not currently available."); return null; } String downloadedReleaseFilePath = mDownloader.getDownloadedReleaseFilePath(); if (downloadedReleaseFilePath != null) { File downloadedReleaseFile = new File(downloadedReleaseFilePath); if (downloadedReleaseFilePath.equals(targetFile.getAbsolutePath())) { if (downloadedReleaseFile.exists()) { mDownloader.onDownloadComplete(targetFile); return null; } } else { downloadedReleaseFile.delete(); mDownloader.setDownloadedReleaseFilePath(null); } } if (isCancelled()) { return null; } mDownloader.onStart(targetFile); return null; } HttpConnectionCheckTask(HttpConnectionReleaseDownloader downloader);  }
HttpConnectionCheckTask extends AsyncTask<Void, Void, Void> { @Override protected Void doInBackground(Void... params) { File targetFile = mDownloader.getTargetFile(); if (targetFile == null) { mDownloader.onDownloadError("Cannot access to downloads folder. Shared storage is not currently available."); return null; } String downloadedReleaseFilePath = mDownloader.getDownloadedReleaseFilePath(); if (downloadedReleaseFilePath != null) { File downloadedReleaseFile = new File(downloadedReleaseFilePath); if (downloadedReleaseFilePath.equals(targetFile.getAbsolutePath())) { if (downloadedReleaseFile.exists()) { mDownloader.onDownloadComplete(targetFile); return null; } } else { downloadedReleaseFile.delete(); mDownloader.setDownloadedReleaseFilePath(null); } } if (isCancelled()) { return null; } mDownloader.onStart(targetFile); return null; } HttpConnectionCheckTask(HttpConnectionReleaseDownloader downloader);   }