@Test public void getPageType() { MoviesListScreenListType expectPageTypes[] = { MoviesListScreenListType.NOW_PLAYING, MoviesListScreenListType.POPULAR, MoviesListScreenListType.TOP_RATED, MoviesListScreenListType.UPCOMING }; MoviesListScreenListType resultPageTypes[] = { presenter.getPageType(0), presenter.getPageType(1), presenter.getPageType(2), presenter.getPageType(3) }; assertThat(resultPageTypes).isEqualTo(expectPageTypes); }
@Test public void onResumeOnPause_shouldReportPageViewTime() throws Exception { int expectPage = 0; long expectPageDuration = 1000; when(view.getCurrentPage()).thenReturn(expectPage); presenter.onCreate(mockGraph, view); presenter.onResume(); Thread.sleep(expectPageDuration); presenter.onPause(); verify(mockGraph.analytics()) .onMoviesListPageChanged( pageNameCaptor.capture(), durationCaptor.capture(), timeUnitCaptor.capture()); assertThat(pageNameCaptor.getValue()).isEqualTo(presenter.getPageType(expectPage).toString()); assertThat(durationCaptor.getValue()).isIn(Range.open(990L, 1010L)); assertThat(timeUnitCaptor.getValue()).isEqualTo(TimeUnit.MILLISECONDS); }