use of com.hannesdorfmann.mosby3.mvp.MvpView in project mosby by sockeqwe.
the class ActivityMvpViewStateDelegateImplTestNew method appStartAfterProcessDeathAndViewStateRecreationFromBundle.
@Test
public void appStartAfterProcessDeathAndViewStateRecreationFromBundle() {
ActivityMvpViewStateDelegateImpl<MvpView, MvpPresenter<MvpView>, ViewState<MvpView>> delegate = new ActivityMvpViewStateDelegateImpl<>(activity, callback, true);
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(ActivityMvpViewStateDelegateImpl.KEY_MOSBY_VIEW_ID, "123456789");
startActivity(delegate, bundle, 1, 1, 1, 1, 1, 1, false, 1, 0, 1);
}
use of com.hannesdorfmann.mosby3.mvp.MvpView in project mosby by sockeqwe.
the class ActivityMvpViewStateDelegateImplTestNew method appStartWithScreenOrientationChangeAndFinallyFinishing.
@Test
public void appStartWithScreenOrientationChangeAndFinallyFinishing() {
ActivityMvpViewStateDelegateImpl<MvpView, MvpPresenter<MvpView>, ViewState<MvpView>> delegate = new ActivityMvpViewStateDelegateImpl<>(activity, callback, true);
startActivity(delegate, null, 1, 1, 1, 1, 1, 0, null, 0, 1, 0);
Bundle bundle = BundleMocker.create();
finishActivity(delegate, bundle, 1, 0, true, false);
startActivity(delegate, bundle, 1, 2, 2, 1, 2, 1, true, 1, 1, 1);
finishActivity(delegate, bundle, 2, 1, false, true);
}
use of com.hannesdorfmann.mosby3.mvp.MvpView in project mosby by sockeqwe.
the class FragmentMvpViewStateDelegateImplTest method dontKeepPresenterWithSecondFragmentInPresenterManager.
/**
* Checks if two Fragments one that keeps presenter, the other who doesn't keep presenter during
* screen orientation changes work properly
*
* https://github.com/sockeqwe/mosby/issues/231
*/
@Test
public void dontKeepPresenterWithSecondFragmentInPresenterManager() {
MvpView view1 = new MvpView() {
};
ViewState<MvpView> viewState1 = Mockito.mock(ViewState.class);
MvpPresenter<MvpView> presenter1 = Mockito.mock(MvpPresenter.class);
PartialMvpViewStateDelegateCallbackImpl callback1 = Mockito.spy(PartialMvpViewStateDelegateCallbackImpl.class);
Fragment fragment1 = PowerMockito.mock(Fragment.class);
Mockito.doCallRealMethod().when(callback1).setPresenter(presenter1);
Mockito.doCallRealMethod().when(callback1).getPresenter();
Mockito.doCallRealMethod().when(callback1).setViewState(viewState1);
Mockito.doCallRealMethod().when(callback1).getViewState();
Mockito.when(callback1.getMvpView()).thenReturn(view1);
Mockito.when(fragment1.getActivity()).thenReturn(activity);
Mockito.when(callback1.createPresenter()).thenReturn(presenter1);
Mockito.when(callback1.createViewState()).thenReturn(viewState1);
FragmentMvpViewStateDelegateImpl<MvpView, MvpPresenter<MvpView>, ViewState<MvpView>> keepDelegate = new FragmentMvpViewStateDelegateImpl<>(fragment1, callback1, true, false);
startFragment(keepDelegate, null);
delegate = new FragmentMvpViewStateDelegateImpl<>(fragment, callback, false, false);
startFragment(null, 1, 1, 1, 1, 1, 0, null, 0, 1, 0);
Bundle bundle = BundleMocker.create();
finishFragment(bundle, 1, 1, true, false);
startFragment(null, 2, 2, 2, 2, 2, 0, null, 0, 2, 0);
finishFragment(bundle, 2, 2, false, true);
finishFragment(keepDelegate, BundleMocker.create());
}
use of com.hannesdorfmann.mosby3.mvp.MvpView in project mosby by sockeqwe.
the class ActivityMvpDelegateImplTest method appStartFinishing.
@Test
public void appStartFinishing() {
ActivityMvpDelegateImpl<MvpView, MvpPresenter<MvpView>> delegate = new ActivityMvpDelegateImpl<>(activity, callback, true);
startActivity(delegate, null, 1, 1, 1);
Bundle bundle = BundleMocker.create();
finishActivity(delegate, bundle, false, 1, 1, false, true);
}
use of com.hannesdorfmann.mosby3.mvp.MvpView in project mosby by sockeqwe.
the class PresenterManagerTest method putGetRemovePresenter.
@Test
public void putGetRemovePresenter() {
Activity activity = Mockito.mock(Activity.class);
Application application = Mockito.mock(Application.class);
Mockito.when(activity.getApplication()).thenReturn(application);
MvpPresenter<MvpView> presenter = new MvpPresenter<MvpView>() {
@Override
public void attachView(MvpView view) {
}
@Override
public void detachView(boolean retainInstance) {
}
@Override
public void detachView() {
}
@Override
public void destroy() {
}
};
String viewId = "123";
Assert.assertNull(PresenterManager.getPresenter(activity, viewId));
PresenterManager.putPresenter(activity, viewId, presenter);
Assert.assertTrue(presenter == PresenterManager.getPresenter(activity, viewId));
PresenterManager.remove(activity, viewId);
Assert.assertNull(PresenterManager.getPresenter(activity, viewId));
}
Aggregations