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

        final PostponedFragment2 fragment = new PostponedFragment2();
        fm.beginTransaction()
                .addSharedElement(startBlue, "blueSquare")
                .replace(R.id.fragmentContainer, fragment)
                .addToBackStack(null)
                .setReorderingAllowed(true)
                .commit();

        FragmentTestUtil.waitForExecution(mActivityRule);

        // should be postponed now
        assertPostponedTransition(mBeginningFragment, fragment, null);

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

        // make sure it ran
        assertForwardTransition(mBeginningFragment, fragment);

        FragmentTestUtil.popBackStackImmediate(mActivityRule);

        // should be postponed going back, too
        assertPostponedTransition(fragment, mBeginningFragment, null);

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

        // make sure it ran
        assertBackTransition(fragment, mBeginningFragment);
    }
// will properly postpone it, both adding and popping.
will properly postpone it, both adding and popping.
will properly postpone it both adding and popping .
@Test
    public void replaceTransition() throws Throwable {
        final FragmentManager fm = mActivityRule.getActivity().getSupportFragmentManager();
        final View startBlue = mActivityRule.getActivity().findViewById(R.id.blueSquare);
        final PostponedFragment2 fragment = new PostponedFragment2();
        fm.beginTransaction()
                .addSharedElement(startBlue, "blueSquare")
                .replace(R.id.fragmentContainer, fragment)
                .addToBackStack(null)
                .setReorderingAllowed(true)
                .commit();
        FragmentTestUtil.waitForExecution(mActivityRule);
        assertPostponedTransition(mBeginningFragment, fragment, null);
        fragment.startPostponedEnterTransition();
        assertForwardTransition(mBeginningFragment, fragment);
        FragmentTestUtil.popBackStackImmediate(mActivityRule);
        assertPostponedTransition(fragment, mBeginningFragment, null);
        mBeginningFragment.startPostponedEnterTransition();
        assertBackTransition(fragment, mBeginningFragment);
    }
@ Test public void replaceTransition ( ) throws Throwable { final FragmentManager fm = mActivityRule . getActivity ( ) . getSupportFragmentManager ( ) ; final View startBlue = mActivityRule . getActivity ( ) . findViewById ( R . id . blueSquare ) ; final PostponedFragment2 fragment = new PostponedFragment2 ( ) ; fm . beginTransaction ( ) . addSharedElement ( startBlue , "blueSquare" ) . replace ( R . id . fragmentContainer , fragment ) . addToBackStack ( null ) . setReorderingAllowed ( true ) . commit ( ) ; FragmentTestUtil . waitForExecution ( mActivityRule ) ; assertPostponedTransition ( mBeginningFragment , fragment , null ) ; fragment . startPostponedEnterTransition ( ) ; assertForwardTransition ( mBeginningFragment , fragment ) ; FragmentTestUtil . popBackStackImmediate ( mActivityRule ) ; assertPostponedTransition ( fragment , mBeginningFragment , null ) ; mBeginningFragment . startPostponedEnterTransition ( ) ; assertBackTransition ( fragment , mBeginningFragment ) ; }
will properly postpone it, both adding and popping.
will properly postpone it both adding and popping .
// should be postponed now // start the postponed transition // make sure it ran // should be postponed going back, too // start the postponed transition // make sure it ran