Search in sources :

Example 11 with ViewState

use of com.hannesdorfmann.mosby3.mvp.viewstate.ViewState 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, true, 1, true, false);
    startActivity(delegate, bundle, 1, 2, 2, 1, 2, 1, true, 1, 1, 1);
    finishActivity(delegate, bundle, false, 1, false, true);
}
Also used : MvpView(com.hannesdorfmann.mosby3.mvp.MvpView) Bundle(android.os.Bundle) MvpPresenter(com.hannesdorfmann.mosby3.mvp.MvpPresenter) ViewState(com.hannesdorfmann.mosby3.mvp.viewstate.ViewState) Test(org.junit.Test)

Example 12 with ViewState

use of com.hannesdorfmann.mosby3.mvp.viewstate.ViewState 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);
}
Also used : Answer(org.mockito.stubbing.Answer) MvpView(com.hannesdorfmann.mosby3.mvp.MvpView) InvocationOnMock(org.mockito.invocation.InvocationOnMock) Bundle(android.os.Bundle) MvpPresenter(com.hannesdorfmann.mosby3.mvp.MvpPresenter) ViewState(com.hannesdorfmann.mosby3.mvp.viewstate.ViewState) Test(org.junit.Test)

Example 13 with ViewState

use of com.hannesdorfmann.mosby3.mvp.viewstate.ViewState in project mosby by sockeqwe.

the class FragmentMvpViewStateDelegateImplTest method initComponents.

@Before
public void initComponents() {
    view = new MvpView() {
    };
    viewState = Mockito.mock(ViewState.class);
    presenter = Mockito.mock(MvpPresenter.class);
    callback = Mockito.spy(PartialMvpViewStateDelegateCallbackImpl.class);
    Mockito.doCallRealMethod().when(callback).setPresenter(presenter);
    Mockito.doCallRealMethod().when(callback).getPresenter();
    Mockito.doCallRealMethod().when(callback).setViewState(viewState);
    Mockito.doCallRealMethod().when(callback).getViewState();
    fragment = PowerMockito.mock(Fragment.class);
    activity = Mockito.mock(FragmentActivity.class);
    application = Mockito.mock(Application.class);
    Mockito.when(callback.getMvpView()).thenReturn(view);
    Mockito.when(fragment.getActivity()).thenReturn(activity);
    Mockito.when(activity.getApplication()).thenReturn(application);
    Mockito.when(callback.createPresenter()).thenReturn(presenter);
    Mockito.when(callback.createViewState()).thenReturn(viewState);
    delegate = new FragmentMvpViewStateDelegateImpl<>(fragment, callback, true, true);
}
Also used : FragmentActivity(android.support.v4.app.FragmentActivity) MvpView(com.hannesdorfmann.mosby3.mvp.MvpView) MvpPresenter(com.hannesdorfmann.mosby3.mvp.MvpPresenter) ViewState(com.hannesdorfmann.mosby3.mvp.viewstate.ViewState) Fragment(android.support.v4.app.Fragment) Application(android.app.Application) Before(org.junit.Before)

Aggregations

MvpPresenter (com.hannesdorfmann.mosby3.mvp.MvpPresenter)8 MvpView (com.hannesdorfmann.mosby3.mvp.MvpView)8 ViewState (com.hannesdorfmann.mosby3.mvp.viewstate.ViewState)8 Bundle (android.os.Bundle)5 Test (org.junit.Test)5 Application (android.app.Application)3 Before (org.junit.Before)3 FragmentActivity (android.support.v4.app.FragmentActivity)2 RestorableViewState (com.hannesdorfmann.mosby3.mvp.viewstate.RestorableViewState)2 InvocationOnMock (org.mockito.invocation.InvocationOnMock)2 Answer (org.mockito.stubbing.Answer)2 Activity (android.app.Activity)1 Parcelable (android.os.Parcelable)1 Fragment (android.support.v4.app.Fragment)1 ActionBarDrawerToggle (android.support.v7.app.ActionBarDrawerToggle)1 RestorableParcelableViewState (com.hannesdorfmann.mosby3.mvp.viewstate.RestorableParcelableViewState)1 AuthViewState (com.hannesdorfmann.mosby3.sample.mail.base.view.viewstate.AuthViewState)1 DependencyInjection (com.hannesdorfmann.mosby3.sample.mvi.dependencyinjection.DependencyInjection)1 MenuViewState (com.hannesdorfmann.mosby3.sample.mvi.view.menu.MenuViewState)1 SearchFragment (com.hannesdorfmann.mosby3.sample.mvi.view.search.SearchFragment)1