### Question:
MainActivity extends RoboFragmentActivity { @Override public void onBackPressed() { if (mChronoFragment.isBackPressReset) { mChronoFragment.isBackPressReset = false; mBackPressedOnce = false; } if (mBackPressedOnce) { super.onBackPressed(); } else { mBackPressedOnce = true; Toast toast = Toast.makeText(this, R.string.press_back_again, Toast.LENGTH_SHORT); toast.show(); } } MainActivity(); @Override void onBackPressed(); void endMeeting(); void restartMeeting();  }### Answer:
@Test public void whenTwoBackPressesThenExit() { out.onBackPressed(); assertEquals(out.getString(R.string.press_back_again), ShadowToast.getTextOfLatestToast()); assertFalse(out.isFinishing()); out.onBackPressed(); assertTrue(out.isFinishing()); }
@Test public void whenTwoBackPressesInResultsThenExit() { mPagerListener.onPageSelected(1); out.onBackPressed(); assertEquals(out.getString(R.string.press_back_again), ShadowToast.getTextOfLatestToast()); assertFalse(out.isFinishing()); out.onBackPressed(); assertTrue(out.isFinishing()); assertNull(shadowOut.getNextStartedActivity()); }