use of android.app.Application 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 android.app.Application 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 android.app.Application in project mosby by sockeqwe.
the class PresenterManagerTest method getViewStateThrowsNullPointerException.
@Test
public void getViewStateThrowsNullPointerException() {
try {
PresenterManager.getViewState(null, "123");
Assert.fail("Exception expected");
} catch (NullPointerException e) {
}
try {
Activity activity = Mockito.mock(Activity.class);
Application application = Mockito.mock(Application.class);
Mockito.when(activity.getApplication()).thenReturn(application);
PresenterManager.getViewState(activity, null);
Assert.fail("Exception expected");
} catch (NullPointerException e) {
}
}
use of android.app.Application in project mosby by sockeqwe.
the class PresenterManagerTest method returnsSameScopedCacheAndRegisterLifecycleListener.
@Test
public void returnsSameScopedCacheAndRegisterLifecycleListener() {
Activity activity = Mockito.mock(Activity.class);
Application application = Mockito.mock(Application.class);
Mockito.when(activity.getApplication()).thenReturn(application);
ActivityScopedCache scopedCache1 = PresenterManager.getOrCreateActivityScopedCache(activity);
ActivityScopedCache scopedCache2 = PresenterManager.getOrCreateActivityScopedCache(activity);
Assert.assertTrue(scopedCache1 == scopedCache2);
Mockito.verify(application, Mockito.times(1)).registerActivityLifecycleCallbacks(PresenterManager.activityLifecycleCallbacks);
}
use of android.app.Application in project mosby by sockeqwe.
the class PresenterManagerTest method putGetRemoveViewState.
@Test
public void putGetRemoveViewState() {
Activity activity = Mockito.mock(Activity.class);
Application application = Mockito.mock(Application.class);
Mockito.when(activity.getApplication()).thenReturn(application);
Object viewState = new Object();
String viewId = "123";
Assert.assertNull(PresenterManager.getViewState(activity, viewId));
PresenterManager.putViewState(activity, viewId, viewState);
Assert.assertTrue(viewState == PresenterManager.getViewState(activity, viewId));
PresenterManager.remove(activity, viewId);
Assert.assertNull(PresenterManager.getPresenter(activity, viewId));
}
Aggregations