@Test
  public void onOptionsItemSelected_shouldDoNothing() {
    presenter.onCreate(mockGraph, view);
    presenter.onPrepareOptionsMenu();
    assertThat(presenter.onOptionsItemSelected(0)).isFalse();

    verify(view, never()).showAboutScreen();
  }
  @Test
  public void onOptionsItemSelected_shouldShowAboutScreen() {
    presenter.onCreate(mockGraph, view);
    presenter.onPrepareOptionsMenu();
    assertThat(presenter.onOptionsItemSelected(R.id.action_about)).isTrue();

    verify(view).showAboutScreen();
  }
  @Test
  public void onPrepareOptionsMenu_shouldSetToolbarTitle() {
    presenter.onCreate(mockGraph, view);
    presenter.onPrepareOptionsMenu();

    verify(view).setToolbarTitle(toolbarTitleStringResCaptor.capture());

    assertThat(toolbarTitleStringResCaptor.getValue()).isEqualTo(R.string.movies);
  }
  @Test
  public void onStop_shouldUnregisterEventBus() {
    presenter.onCreate(mockGraph, view);
    presenter.onStop();

    verify(mockGraph.eventBus()).unregister(objectCaptor.capture());

    assertThat(objectCaptor.getValue()).isEqualTo(presenter);
  }
  @Test
  public void onStart_shouldRegisterEventBus() throws IOException {
    presenter.onCreate(mockGraph, view);
    presenter.onStart();

    verify(mockGraph.eventBus()).register(objectCaptor.capture());

    assertThat(objectCaptor.getValue()).isEqualTo(presenter);
  }
  @Test
  public void onMovieSelectEvent_shouldShowMovieSummaryScreen() throws IOException {
    MoviesList.Movie movie = generateMoviesList().movies().get(0);

    presenter.onCreate(mockGraph, view);
    presenter.onEvent(new MoviesListScreenEvents.OnMovieSelect(movie));

    verify(view).showMovieSummaryScreen(movieCaptor.capture());

    assertThat(movieCaptor.getValue()).isEqualTo(movie);
  }
  @Test
  public void onMovieSummaryScreenExitAnimationEvent_shouldDeBlurPrimaryContainer() {
    long expectDuration = 250L;

    presenter.onCreate(mockGraph, view);
    presenter.onEvent(
        new MovieSummaryScreenEvents.OnMovieSummaryScreenExitAnimation(expectDuration));

    verify(view).deBlurContainerPrimary(durationCaptor.capture());

    assertThat(durationCaptor.getValue()).isEqualTo(expectDuration);
  }
  @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);
  }
  @Test
  public void onCreate_shouldDoNothing() {
    presenter.onCreate(mockGraph, view);

    verifyZeroInteractions(view);
  }
 @Test(expected = NullPointerException.class)
 public void onDestroy_shouldRaiseExceptionIfTouchedAfter() {
   presenter.onCreate(mockGraph, view);
   presenter.onDestroy();
   presenter.onEvent(new MoviesListScreenEvents.OnMovieSelect(null));
 }