DrawerPresenter extends BaseActivityPresenter<DrawerMvp.View> implements DrawerMvp.Presenter { @Override public void onNavigationItemSelected(@IdRes int itemId) { if (itemId != selectedItemId) { switch (itemId) { case R.id.drawer_nav_schedule: view.showFragment(new SchedulePagerFragmentBuilder(false).build()); toolbarTitle = R.string.drawer_nav_schedule; break; case R.id.drawer_nav_agenda: view.showFragment(new SchedulePagerFragmentBuilder(true).build()); toolbarTitle = R.string.drawer_nav_agenda; break; case R.id.drawer_nav_speakers: view.showFragment(new SpeakersListFragment()); toolbarTitle = R.string.drawer_nav_speakers; break; case R.id.drawer_nav_venue: view.showFragment(new VenueFragment()); toolbarTitle = R.string.drawer_nav_venue; break; case R.id.drawer_nav_settings: view.showFragment(new SettingsFragment()); toolbarTitle = R.string.drawer_nav_settings; break; default: throw new IllegalArgumentException(); } view.hideTabLayout(); view.updateToolbarTitle(toolbarTitle); selectedItemId = itemId; } view.closeNavigationDrawer(); } DrawerPresenter(DrawerMvp.View view); @Override void onPostCreate(Bundle savedInstanceState); @Override void onRestoreInstanceState(Bundle savedInstanceState); @Override void onNavigationItemSelected(@IdRes int itemId); @Override boolean onBackPressed();  }
@Test public void should_do_nothing_when_selecting_a_category_which_is_already_selected() { presenter.selectedItemId = R.id.drawer_nav_speakers; presenter.onNavigationItemSelected(R.id.drawer_nav_speakers); verify(view, never()).showFragment(any()); }
@Test public void should_show_speakers_fragment_when_selecting_speakers_from_the_navigation() { presenter.selectedItemId = 0; presenter.onNavigationItemSelected(R.id.drawer_nav_speakers); verify(view).showFragment(any(SpeakersListFragment.class)); }