NavigationalCompatTransition extends BaseNavigationalTransition<NavigationalCompatTransition> { public void start(@NonNull final Fragment caller) { configureOutgoingTransitions(caller.requireActivity()); onStart(caller); } NavigationalCompatTransition();  NavigationalCompatTransition(@NonNull final Class<? extends Activity> classOfTransitionActivity); void start(@NonNull final Fragment caller); void finish(@NonNull final Fragment caller);  }
@Config(sdk = Build.VERSION_CODES.KITKAT) @Test public void testStartForFragmentAtKitKatApiLevel() { final FragmentActivity activity = Robolectric.buildActivity(TestCompatActivity.class).create().start().resume().get(); final FragmentManager fragmentManager = activity.getSupportFragmentManager(); final TestFragment fragment = new TestFragment(); fragmentManager.beginTransaction().add(fragment, null).commit(); fragmentManager.executePendingTransactions(); final NavigationalCompatTransition navTransition = new TestTransition(SecondaryTestActivity.class).exitTransition(null); navTransition.start(fragment); assertThat(activity.isFinishing(), is(false)); assertThat(fragment.hasBeenStartActivityCalled(TestFragment.START_ACTIVITY_WITH_OPTIONS), is(true)); assertThat(fragment.hasBeenStartActivityCalled( TestFragment.START_ACTIVITY | TestFragment.START_ACTIVITY_FOR_RESULT | TestFragment.START_ACTIVITY_FOR_RESULT_WITH_OPTIONS ), is(false)); }
@Config(sdk = Build.VERSION_CODES.LOLLIPOP) @Test public void testStartForFragmentAtLollipopApiLevel() { final FragmentActivity activity = Robolectric.buildActivity(TestCompatActivity.class).create().start().resume().get(); final FragmentManager fragmentManager = activity.getSupportFragmentManager(); final TestFragment fragment = new TestFragment(); fragmentManager.beginTransaction().add(fragment, null).commit(); fragmentManager.executePendingTransactions(); final Transition transition = new Fade(); final NavigationalCompatTransition navTransition = new TestTransition(SecondaryTestActivity.class).exitTransition(transition); navTransition.start(fragment); assertThat(activity.getWindow().getExitTransition(), is(transition)); assertThat(activity.isFinishing(), is(false)); assertThat(fragment.hasBeenStartActivityCalled(TestFragment.START_ACTIVITY_WITH_OPTIONS), is(true)); assertThat(fragment.hasBeenStartActivityCalled( TestFragment.START_ACTIVITY | TestFragment.START_ACTIVITY_FOR_RESULT | TestFragment.START_ACTIVITY_FOR_RESULT_WITH_OPTIONS ), is(false)); }