class NimbleFrameLayout extends FrameLayout implements NimbleView {

  @Override
  protected void onDetachedFromWindow() {
    super.onDetachedFromWindow();
    presenter().dropView(getMvpView());
    if (getActivity().isFinishing()) {
      presenter().onDestroy();
    }
  }

}

class TestNimbleFrameLayout {

  @Mock NimblePresenter<NimbleView> presenter;
  @Mock Bundle bundle;
   NimbleFrameLayout<NimbleView> layout;
  @Mock Context context;

  @Test
  public void testOnDetachedFromWindow() throws Exception {

    prepareForOnDetachedFromWindows(false);
    layout.onDetachedFromWindow();
    verify(presenter).dropView(layout);
  }

}