FragmentMvpViewStateDelegateImpl implements FragmentMvpDelegate<V, P> { private VS createViewState() { VS viewState = delegateCallback.createViewState(); if (viewState == null) { throw new NullPointerException( "ViewState returned from createViewState() is null. Fragment is " + fragment); } if (keepPresenterInstanceDuringScreenOrientationChanges) { PresenterManager.putViewState(getActivity(), mosbyViewId, viewState); } return viewState; } FragmentMvpViewStateDelegateImpl(Fragment fragment,
      MvpViewStateDelegateCallback<V, P, VS> delegateCallback,
      boolean keepPresenterAndViewStateDuringScreenOrientationChange,
      boolean keepPresenterAndViewStateOnBackstack); @Override void onCreate(Bundle bundle); @Override void onViewCreated(View view, Bundle bundle); @Override void onStart(); @Override void onStop(); @Override void onDestroy(); @Override void onSaveInstanceState(Bundle outState); @Override void onDestroyView(); @Override void onPause(); @Override void onResume(); @Override void onActivityCreated(Bundle savedInstanceState); @Override void onAttach(Activity activity); @Override void onAttach(Context context); @Override void onDetach(); static boolean DEBUG; }
@Test public void appStartAfterProcessDeathAndViewStateRecreationFromBundle() { Mockito.doAnswer(new Answer() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { viewState = Mockito.spy(new SimpleRestorableViewState()); return viewState; } }).when(callback).createViewState(); Bundle bundle = BundleMocker.create(); bundle.putString(FragmentMvpViewStateDelegateImpl.KEY_MOSBY_VIEW_ID, "123456789"); startFragment(bundle, 1, 1, 1, 1, 1, 1, false, 1, 0, 1); }
@Test public void appStartWithViewStateFromMemoryAndBundleShouldPreferViewStateFromMemory() { Mockito.doAnswer(new Answer() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { viewState = Mockito.spy(new SimpleRestorableViewState()); return viewState; } }).when(callback).createViewState(); startFragment(null, 1, 1, 1, 1, 1, 0, null, 0, 1, 0); Bundle bundle = BundleMocker.create(); finishFragment(bundle, 1, 0, true, false); startFragment(bundle, 1, 2, 2, 1, 2, 1, true, 1, 1, 1); finishFragment(bundle, 2, 1, false, true); }