fragment/src/androidTest/java/androidx/fragment/app/PostponedTransitionTest.java
@Test
    public void commitNowStartsPostponed() throws Throwable {
        final FragmentManager fm = mActivityRule.getActivity().getSupportFragmentManager();
        final View startBlue1 = mBeginningFragment.getView().findViewById(R.id.blueSquare);

        final TransitionFragment fragment2 = new PostponedFragment2();
        final TransitionFragment fragment1 = new PostponedFragment1();

        fm.beginTransaction()
                .addSharedElement(startBlue1, "blueSquare")
                .replace(R.id.fragmentContainer, fragment2)
                .addToBackStack(null)
                .setReorderingAllowed(true)
                .commit();
        FragmentTestUtil.waitForExecution(mActivityRule);

        final View startBlue2 = fragment2.getView().findViewById(R.id.blueSquare);

        mInstrumentation.runOnMainSync(new Runnable() {
            @Override
            public void run() {
                fm.beginTransaction()
                        .addSharedElement(startBlue2, "blueSquare")
                        .replace(R.id.fragmentContainer, fragment1)
                        .setReorderingAllowed(true)
                        .commitNow();
            }
        });

        assertPostponedTransition(fragment2, fragment1, mBeginningFragment);

        // start the postponed transition
        fragment1.startPostponedEnterTransition();

        assertForwardTransition(fragment2, fragment1);
    }
// container forces the postponed transition to start.
container forces the postponed transition to start.
container forces the postponed transition to start .
@Test
    public void commitNowStartsPostponed() throws Throwable {
        final FragmentManager fm = mActivityRule.getActivity().getSupportFragmentManager();
        final View startBlue1 = mBeginningFragment.getView().findViewById(R.id.blueSquare);
        final TransitionFragment fragment2 = new PostponedFragment2();
        final TransitionFragment fragment1 = new PostponedFragment1();
        fm.beginTransaction()
                .addSharedElement(startBlue1, "blueSquare")
                .replace(R.id.fragmentContainer, fragment2)
                .addToBackStack(null)
                .setReorderingAllowed(true)
                .commit();
        FragmentTestUtil.waitForExecution(mActivityRule);
        final View startBlue2 = fragment2.getView().findViewById(R.id.blueSquare);
        mInstrumentation.runOnMainSync(new Runnable() {
            @Override
            public void run() {
                fm.beginTransaction()
                        .addSharedElement(startBlue2, "blueSquare")
                        .replace(R.id.fragmentContainer, fragment1)
                        .setReorderingAllowed(true)
                        .commitNow();
            }
        });
        assertPostponedTransition(fragment2, fragment1, mBeginningFragment);
        fragment1.startPostponedEnterTransition();
        assertForwardTransition(fragment2, fragment1);
    }
@ Test public void commitNowStartsPostponed ( ) throws Throwable { final FragmentManager fm = mActivityRule . getActivity ( ) . getSupportFragmentManager ( ) ; final View startBlue1 = mBeginningFragment . getView ( ) . findViewById ( R . id . blueSquare ) ; final TransitionFragment fragment2 = new PostponedFragment2 ( ) ; final TransitionFragment fragment1 = new PostponedFragment1 ( ) ; fm . beginTransaction ( ) . addSharedElement ( startBlue1 , "blueSquare" ) . replace ( R . id . fragmentContainer , fragment2 ) . addToBackStack ( null ) . setReorderingAllowed ( true ) . commit ( ) ; FragmentTestUtil . waitForExecution ( mActivityRule ) ; final View startBlue2 = fragment2 . getView ( ) . findViewById ( R . id . blueSquare ) ; mInstrumentation . runOnMainSync ( new Runnable ( ) { @ Override public void run ( ) { fm . beginTransaction ( ) . addSharedElement ( startBlue2 , "blueSquare" ) . replace ( R . id . fragmentContainer , fragment1 ) . setReorderingAllowed ( true ) . commitNow ( ) ; } } ) ; assertPostponedTransition ( fragment2 , fragment1 , mBeginningFragment ) ; fragment1 . startPostponedEnterTransition ( ) ; assertForwardTransition ( fragment2 , fragment1 ) ; }
container forces the postponed transition to start.
container forces the postponed transition to start .
// start the postponed transition