IntentStarters { @NonNull public static IntentStarter activityStarter(@NonNull final Activity activity) { return new ActivityStarter(activity); } private  IntentStarters(); @NonNull static IntentStarter activityStarter(@NonNull final Activity activity); static IntentStarter fragmentStarter(@NonNull final Fragment fragment); static IntentStarter supportFragmentStarter(@NonNull final androidx.fragment.app.Fragment fragment);  }
@Test public void testActivityStarter() { final Activity activity = Robolectric.buildActivity(TestActivity.class).create().get(); final IntentStarter starter = IntentStarters.activityStarter(activity); assertThat(starter, is(notNullValue())); assertThat(starter.getContext(), is((Context) activity)); }
@Test public void testActivityStarterStartIntent() { final Activity mockActivity = mock(Activity.class); final Intent intent = new Intent(); final IntentStarter starter = IntentStarters.activityStarter(mockActivity); starter.startIntent(intent); verify(mockActivity).startActivity(intent); }
@Config(sdk = Build.VERSION_CODES.JELLY_BEAN) @Test public void testActivityStarterStartIntentWithOptions() { final Activity mockActivity = mock(Activity.class); final Intent intent = new Intent(); final IntentStarter starter = IntentStarters.activityStarter(mockActivity); starter.startIntent(intent, Bundle.EMPTY); verify(mockActivity).startActivity(intent, Bundle.EMPTY); }
@Test public void testActivityStarterStartIntentForResult() { final Activity mockActivity = mock(Activity.class); final Intent intent = new Intent(); final IntentStarter starter = IntentStarters.activityStarter(mockActivity); starter.startIntentForResult(intent, 1000); verify(mockActivity).startActivityForResult(intent, 1000); }
@Config(sdk = Build.VERSION_CODES.JELLY_BEAN) @Test public void testActivityStarterStartIntentForResultWithOptions() { final Activity mockActivity = mock(Activity.class); final Intent intent = new Intent(); final IntentStarter starter = IntentStarters.activityStarter(mockActivity); starter.startIntentForResult(intent, 1000, Bundle.EMPTY); verify(mockActivity).startActivityForResult(intent, 1000, Bundle.EMPTY); }
@Test public void testActivityStarterOverridePendingTransition() { final Activity mockActivity = mock(Activity.class); final IntentStarter starter = IntentStarters.activityStarter(mockActivity); starter.overridePendingTransition( android.R.anim.fade_in, android.R.anim.fade_out ); }