NavigatingMvvmActivity extends MvvmActivity<S, U> implements ActivityDelegateCallback<S, U>, NavigatingDelegateCallback<T> { @NonNull @Override protected ActivityDelegate<S, U> getMvvmDelegate() { if (delegate == null) { delegate = new NavigatingActivityDelegate<>(this, this, this); } return delegate; }    }
@Test public void testActivityReturnsNavigatingDelegate() { final NavigatingMvvmActivity activity = Robolectric.buildActivity(TestNavigatingMvvmActivity.class).get(); final ActivityDelegate mvvmDelegate = activity.getMvvmDelegate(); assertTrue(mvvmDelegate instanceof NavigatingActivityDelegate); }
@Test public void testCreateNewDelegateOnceOnly() { final NavigatingMvvmActivity activity = Robolectric.buildActivity(TestNavigatingMvvmActivity.class).get(); final ActivityDelegate firstDelegate = activity.getMvvmDelegate(); final ActivityDelegate secondDelegate = activity.getMvvmDelegate(); assertSame(firstDelegate, secondDelegate); }