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);
}
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);
}
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);
}
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);
}
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());
}
Aggregations