MainPresenter extends AbstractMvpPresenter<Main.View, Void> implements Main.Presenter<Main.View, Void> { @Override public void onBackPressed(boolean isDrawerOpen, boolean isDetailFragment, int backStackEntryCount) { if (isDrawerOpen) { mView.closeDrawer(); } else { if (isDetailFragment) { if (backStackEntryCount == 0) { onNavigationItemSelected(R.id.nav_all); mView.updateManualFetchFabStatus(true); return; } } mView.onSuperBackPressed(); } } MainPresenter();  MainPresenter(UseCaseHandler useCaseHandler, ManuallyFetchTodaysSentenceUC fetchTodaysSentenceUseCase); @Override void fetchTodaysSentence(); @Override void onCreate(long widgetSentenceId); @Override void onStart(); @Override void updateManualFetchFabStatus(boolean isDisplayingList, boolean isFavoriteList); @Subscribe(threadMode = ThreadMode.MAIN) void updateManualFetchFabStatus(UpdateManualFetchFabEvent event); @Override void onResume(); @Override void onStop(); @Override void onBackPressed(boolean isDrawerOpen, boolean isDetailFragment, int backStackEntryCount); @Override @Subscribe(threadMode = ThreadMode.MAIN) void refreshFetchingStatus(FetchingEvent fetchingEvent); @Override void onNavigationItemSelected(int menuId); @VisibleForTesting EventBus getEventBus();  }
@Test public void testOnBackPressed_DrawerClosed_List() { mMainPresenter.onBackPressed(false, false, 0); verify(mView).onSuperBackPressed(); }
@Test public void testOnBackPressed_DrawerClosed_Detail_NoNeedOpenAllList() { mMainPresenter.onBackPressed(false, true, 1); verify(mView).onSuperBackPressed(); }
@Test public void testOnBackPressed_DrawerOpened() { mMainPresenter.onBackPressed(true, false, 0); mMainPresenter.onBackPressed(true, true, 0); verify(mView, times(2)).closeDrawer(); verify(mView, times(0)).onSuperBackPressed(); }