Search in sources :

Example 6 with MvpPresenter

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

the class ActivityMvpViewStateDelegateImplTestNew method appStartWithViewStateFromMemoryAndBundleButPreferViewStateFromMemory.

@Test
public void appStartWithViewStateFromMemoryAndBundleButPreferViewStateFromMemory() {
    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();
    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 : 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 7 with MvpPresenter

use of com.hannesdorfmann.mosby3.mvp.MvpPresenter 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) {
        }
    };
    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));
}
Also used : MvpView(com.hannesdorfmann.mosby3.mvp.MvpView) MvpPresenter(com.hannesdorfmann.mosby3.mvp.MvpPresenter) Activity(android.app.Activity) Application(android.app.Application) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 8 with MvpPresenter

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

Example 9 with MvpPresenter

use of com.hannesdorfmann.mosby3.mvp.MvpPresenter 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 10 with MvpPresenter

use of com.hannesdorfmann.mosby3.mvp.MvpPresenter 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)

Aggregations

MvpPresenter (com.hannesdorfmann.mosby3.mvp.MvpPresenter)10 Test (org.junit.Test)10 MvpView (com.hannesdorfmann.mosby3.mvp.MvpView)9 Bundle (android.os.Bundle)8 ViewState (com.hannesdorfmann.mosby3.mvp.viewstate.ViewState)5 Activity (android.app.Activity)2 Application (android.app.Application)2 InvocationOnMock (org.mockito.invocation.InvocationOnMock)2 Answer (org.mockito.stubbing.Answer)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2