@Test public void doInBackgroundResumeDownloaded() { long downloadedId = 2L; when(SharedPreferencesManager.getLong(anyString(), anyLong())).thenReturn(downloadedId); ResumeFromBackgroundTask task = new ResumeFromBackgroundTask(mContext, downloadedId); task.doInBackground(); verify(mDistribute).startFromBackground(mContext); verify(mDistribute).resumeDownload(); }
@Override protected Void doInBackground(Void... args) { Distribute distribute = Distribute.getInstance(); distribute.startFromBackground(mContext); AppCenterLog.debug(LOG_TAG, "Check download id=" + mDownloadedId); long expectedDownloadId = SharedPreferencesManager.getLong(PREFERENCE_KEY_DOWNLOAD_ID, INVALID_DOWNLOAD_IDENTIFIER); if (expectedDownloadId == INVALID_DOWNLOAD_IDENTIFIER || expectedDownloadId != mDownloadedId) { AppCenterLog.debug(LOG_TAG, "Ignoring download identifier we didn't expect, id=" + mDownloadedId); return null; } distribute.resumeDownload(); return null; }
ResumeFromBackgroundTask extends AsyncTask<Void, Void, Void> { @Override protected Void doInBackground(Void... args) { Distribute distribute = Distribute.getInstance(); distribute.startFromBackground(mContext); AppCenterLog.debug(LOG_TAG, "Check download id=" + mDownloadedId); long expectedDownloadId = SharedPreferencesManager.getLong(PREFERENCE_KEY_DOWNLOAD_ID, INVALID_DOWNLOAD_IDENTIFIER); if (expectedDownloadId == INVALID_DOWNLOAD_IDENTIFIER || expectedDownloadId != mDownloadedId) { AppCenterLog.debug(LOG_TAG, "Ignoring download identifier we didn't expect, id=" + mDownloadedId); return null; } distribute.resumeDownload(); return null; } }
ResumeFromBackgroundTask extends AsyncTask<Void, Void, Void> { @Override protected Void doInBackground(Void... args) { Distribute distribute = Distribute.getInstance(); distribute.startFromBackground(mContext); AppCenterLog.debug(LOG_TAG, "Check download id=" + mDownloadedId); long expectedDownloadId = SharedPreferencesManager.getLong(PREFERENCE_KEY_DOWNLOAD_ID, INVALID_DOWNLOAD_IDENTIFIER); if (expectedDownloadId == INVALID_DOWNLOAD_IDENTIFIER || expectedDownloadId != mDownloadedId) { AppCenterLog.debug(LOG_TAG, "Ignoring download identifier we didn't expect, id=" + mDownloadedId); return null; } distribute.resumeDownload(); return null; } ResumeFromBackgroundTask(@NonNull Context context, long downloadedId); }
ResumeFromBackgroundTask extends AsyncTask<Void, Void, Void> { @Override protected Void doInBackground(Void... args) { Distribute distribute = Distribute.getInstance(); distribute.startFromBackground(mContext); AppCenterLog.debug(LOG_TAG, "Check download id=" + mDownloadedId); long expectedDownloadId = SharedPreferencesManager.getLong(PREFERENCE_KEY_DOWNLOAD_ID, INVALID_DOWNLOAD_IDENTIFIER); if (expectedDownloadId == INVALID_DOWNLOAD_IDENTIFIER || expectedDownloadId != mDownloadedId) { AppCenterLog.debug(LOG_TAG, "Ignoring download identifier we didn't expect, id=" + mDownloadedId); return null; } distribute.resumeDownload(); return null; } ResumeFromBackgroundTask(@NonNull Context context, long downloadedId);  }
ResumeFromBackgroundTask extends AsyncTask<Void, Void, Void> { @Override protected Void doInBackground(Void... args) { Distribute distribute = Distribute.getInstance(); distribute.startFromBackground(mContext); AppCenterLog.debug(LOG_TAG, "Check download id=" + mDownloadedId); long expectedDownloadId = SharedPreferencesManager.getLong(PREFERENCE_KEY_DOWNLOAD_ID, INVALID_DOWNLOAD_IDENTIFIER); if (expectedDownloadId == INVALID_DOWNLOAD_IDENTIFIER || expectedDownloadId != mDownloadedId) { AppCenterLog.debug(LOG_TAG, "Ignoring download identifier we didn't expect, id=" + mDownloadedId); return null; } distribute.resumeDownload(); return null; } ResumeFromBackgroundTask(@NonNull Context context, long downloadedId);   }