AssignThumbnailAsyncTask extends AsyncTask<String, Void, Bitmap> { @Override protected void onPostExecute(Bitmap bitmap) { AssignThumbnailAsyncTask bitmapDownloaderTask = getBitmapDownloaderTask(imageView); if (this == bitmapDownloaderTask) { imageView.setImageBitmap(bitmap); } } AssignThumbnailAsyncTask(ImageView imageView, PhotoCaptureHelper photoCaptureHelper); String getImageName();  }
@Test public void shouldAssignImageToViewOnPostExecute(){ AssignThumbnailAsyncTask task = new AssignThumbnailAsyncTask(imageView, photoCaptureHelper); ThumbnailDrawable thumbnailDrawable = mock(ThumbnailDrawable.class); given(imageView.getDrawable()).willReturn(thumbnailDrawable); given(thumbnailDrawable.getAssignThumbnailAsyncTask()).willReturn(task); Bitmap bitmap = mock(Bitmap.class); task.onPostExecute(bitmap); verify(imageView).setImageBitmap(bitmap); }