@Test
 public void testJustFinishIfResumedAgain() throws Exception {
   ActivityController<LauncherSettingsActivity> controller =
       Robolectric.buildActivity(LauncherSettingsActivity.class).attach().create().resume();
   ShadowActivity shadowActivity = Shadows.shadowOf(controller.get());
   Assert.assertFalse(shadowActivity.isFinishing());
   controller.pause().stop();
   Assert.assertFalse(shadowActivity.isFinishing());
   controller.restart().resume();
   Assert.assertTrue(shadowActivity.isFinishing());
 }
  @Test
  public void testOnStop() {
    ShadowActivity shadowActivity = Shadows.shadowOf(activity);

    activity.onStop();
    assertFalse(shadowActivity.isFinishing());
  }
  @Test
  public void shouldCallFinishInOnBackPressed() {
    Activity activity = new Activity();
    activity.onBackPressed();

    ShadowActivity shadowActivity = shadowOf(activity);
    assertTrue(shadowActivity.isFinishing());
  }
  @Test
  public void testBluetoothSelected_nochange() {
    ShadowActivity shadowActivity = Shadows.shadowOf(activity);
    activity.selectedItemTV.setText("No Device Selected!");

    activity.findViewById(R.id.done_selecting).performClick();
    assertEquals(
        "Unexpected toast text",
        shadowActivity.getString(R.string.no_change_to_device),
        ShadowToast.getTextOfLatestToast());
    assertTrue("finish() was not called", shadowActivity.isFinishing());
  }