EpisodeViewInflater { protected InflaterWith inflate(View view) { return new InflaterWith(view); } @Inject  EpisodeViewInflater(Activity activity, ImageLoader imageLoader, EpisodeDownloader episodeDownloader);   }
@Test public void itDoesNotInflateViewWhenViewIsAlreadySet() { View view = spiedLayoutInflater.inflate(R.layout.episode_list_item, parent, false); episodeViewInflater.inflate(view).with(new Episode()).from(parent); episodeViewInflater.inflate(view).with(new Episode()).from(parent); episodeViewInflater.inflate(view).with(new Episode()).from(parent); verify(spiedLayoutInflater, times(1)).inflate(R.layout.episode_list_item, parent, false); }
@Test public void itShowsDownloadButtonButtonWhenAudioFileHasNotBeenDownloadedAndLayoutIsNotVisible() { Episode episode = new Episode(); when(episodeDownloaderMock.isAlreadyDownloaded(episode)).thenReturn(true); View inflatedView = inflateView(episode); ViewGroup invisibleDownloadButtonLayout = (ViewGroup) inflatedView .findViewById(R.id.episode_download_layout); assertThat(invisibleDownloadButtonLayout.getVisibility(), is(INVISIBLE)); when(episodeDownloaderMock.isAlreadyDownloaded(episode)).thenReturn(false); View recycledView = episodeViewInflater.inflate(inflatedView).with(episode).from(parent); ViewGroup visibleDownloadButtonLayout = (ViewGroup) recycledView .findViewById(R.id.episode_download_layout); assertThat(visibleDownloadButtonLayout.getVisibility(), is(VISIBLE)); }