Search in sources :

Example 1 with MvpView

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

the class ActivityMvpDelegateImplTest method dontKeepPresenter.

@Test
public void dontKeepPresenter() {
    ActivityMvpDelegateImpl<MvpView, MvpPresenter<MvpView>> delegate = new ActivityMvpDelegateImpl<>(activity, callback, false);
    startActivity(delegate, null, 1, 1, 1);
    Bundle bundle = BundleMocker.create();
    finishActivity(delegate, bundle, false, 1, true, false);
    startActivity(delegate, bundle, 2, 2, 2);
    finishActivity(delegate, bundle, false, 2, 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 2 with MvpView

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

the class ActivityMvpDelegateImplTest method appStartWithScreenOrientationChangeAndFinallyFinishing.

@Test
public void appStartWithScreenOrientationChangeAndFinallyFinishing() {
    ActivityMvpDelegateImpl<MvpView, MvpPresenter<MvpView>> delegate = new ActivityMvpDelegateImpl<>(activity, callback, true);
    startActivity(delegate, null, 1, 1, 1);
    Bundle bundle = BundleMocker.create();
    finishActivity(delegate, bundle, true, 1, true, false);
    startActivity(delegate, bundle, 1, 2, 2);
    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 3 with MvpView

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

the class FragmentMvpDelegateImplTest method initComponents.

@Before
public void initComponents() {
    view = new MvpView() {
    };
    presenter = Mockito.mock(MvpPresenter.class);
    callback = Mockito.mock(PartialMvpDelegateCallbackImpl.class);
    Mockito.doCallRealMethod().when(callback).setPresenter(presenter);
    Mockito.doCallRealMethod().when(callback).getPresenter();
    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);
    delegate = new FragmentMvpDelegateImpl<>(fragment, callback, true, true);
}
Also used : FragmentActivity(android.support.v4.app.FragmentActivity) MvpView(com.hannesdorfmann.mosby3.mvp.MvpView) MvpPresenter(com.hannesdorfmann.mosby3.mvp.MvpPresenter) Fragment(android.support.v4.app.Fragment) Application(android.app.Application) Before(org.junit.Before)

Example 4 with MvpView

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

the class ViewGroupMvpDelegateImplTest method initComponents.

@Before
public void initComponents() {
    view = new MvpView() {
    };
    presenter = Mockito.mock(MvpPresenter.class);
    callback = Mockito.mock(PartialViewGroupMvpDelegateCallbackImpl.class);
    Mockito.doCallRealMethod().when(callback).setPresenter(presenter);
    Mockito.doCallRealMethod().when(callback).getPresenter();
    activity = Mockito.mock(FragmentActivity.class);
    application = Mockito.mock(Application.class);
    Mockito.when(callback.getMvpView()).thenReturn(view);
    Mockito.when(callback.getContext()).thenReturn(activity);
    Mockito.when(activity.getApplication()).thenReturn(application);
    delegate = new ViewGroupMvpDelegateImpl<>(callback, true);
}
Also used : FragmentActivity(android.support.v4.app.FragmentActivity) MvpView(com.hannesdorfmann.mosby3.mvp.MvpView) MvpPresenter(com.hannesdorfmann.mosby3.mvp.MvpPresenter) Application(android.app.Application) Before(org.junit.Before)

Example 5 with MvpView

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

the class MviBasePresenterTest method bindIntentsAndUnbindIntentsOnlyOnce.

@Test
public void bindIntentsAndUnbindIntentsOnlyOnce() {
    final AtomicInteger bindInvocations = new AtomicInteger(0);
    final AtomicInteger unbindInvocations = new AtomicInteger(0);
    MvpView view = new MvpView() {
    };
    MviBasePresenter<MvpView, Object> presenter = new MviBasePresenter<MvpView, Object>() {

        @Override
        protected void bindIntents() {
            bindInvocations.incrementAndGet();
        }

        @Override
        protected void unbindIntents() {
            super.unbindIntents();
            unbindInvocations.incrementAndGet();
        }
    };
    presenter.attachView(view);
    presenter.detachView(true);
    presenter.attachView(view);
    presenter.detachView(true);
    presenter.attachView(view);
    presenter.detachView(false);
    Assert.assertEquals(1, bindInvocations.get());
    Assert.assertEquals(1, unbindInvocations.get());
}
Also used : MvpView(com.hannesdorfmann.mosby3.mvp.MvpView) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Object(org.omg.CORBA.Object) Test(org.junit.Test)

Aggregations

MvpView (com.hannesdorfmann.mosby3.mvp.MvpView)17 MvpPresenter (com.hannesdorfmann.mosby3.mvp.MvpPresenter)15 Test (org.junit.Test)11 Bundle (android.os.Bundle)8 ViewState (com.hannesdorfmann.mosby3.mvp.viewstate.ViewState)8 Application (android.app.Application)7 Before (org.junit.Before)6 FragmentActivity (android.support.v4.app.FragmentActivity)4 Activity (android.app.Activity)3 Fragment (android.support.v4.app.Fragment)2 RestorableViewState (com.hannesdorfmann.mosby3.mvp.viewstate.RestorableViewState)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 InvocationOnMock (org.mockito.invocation.InvocationOnMock)2 Answer (org.mockito.stubbing.Answer)2 Object (org.omg.CORBA.Object)2 Parcelable (android.os.Parcelable)1 RestorableParcelableViewState (com.hannesdorfmann.mosby3.mvp.viewstate.RestorableParcelableViewState)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1