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

        final PostponedFragment2 fragment2 = new PostponedFragment2();

        fm.beginTransaction()
                .addSharedElement(startBlue, "blueSquare")
                .hide(mBeginningFragment)
                .replace(R.id.fragmentContainer, fragment2)
                .hide(fragment2)
                .detach(fragment2)
                .attach(fragment2)
                .show(fragment2)
                .addToBackStack(null)
                .setReorderingAllowed(true)
                .commit();

        FragmentTestUtil.waitForExecution(mActivityRule);

        assertPostponedTransition(mBeginningFragment, fragment2, null);

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

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

        // Pop back to fragment2, but it should be postponed
        FragmentTestUtil.popBackStackImmediate(mActivityRule);

        assertPostponedTransition(fragment2, mBeginningFragment, null);

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

        // make sure it ran
        assertBackTransition(fragment2, mBeginningFragment);
    }
// Do a bunch of things to one fragment in a transaction and see if it can screw things up.
Do a bunch of things to one fragment in a transaction and see if it can screw things up.
Do a bunch of things to one fragment in a transaction and see if it can screw things up .
@Test
    public void crazyTransition() throws Throwable {
        final FragmentManager fm = mActivityRule.getActivity().getSupportFragmentManager();
        final View startBlue = mActivityRule.getActivity().findViewById(R.id.blueSquare);
        final PostponedFragment2 fragment2 = new PostponedFragment2();
        fm.beginTransaction()
                .addSharedElement(startBlue, "blueSquare")
                .hide(mBeginningFragment)
                .replace(R.id.fragmentContainer, fragment2)
                .hide(fragment2)
                .detach(fragment2)
                .attach(fragment2)
                .show(fragment2)
                .addToBackStack(null)
                .setReorderingAllowed(true)
                .commit();
        FragmentTestUtil.waitForExecution(mActivityRule);
        assertPostponedTransition(mBeginningFragment, fragment2, null);
        fragment2.startPostponedEnterTransition();
        assertForwardTransition(mBeginningFragment, fragment2);
        FragmentTestUtil.popBackStackImmediate(mActivityRule);
        assertPostponedTransition(fragment2, mBeginningFragment, null);
        mBeginningFragment.startPostponedEnterTransition();
        assertBackTransition(fragment2, mBeginningFragment);
    }
@ Test public void crazyTransition ( ) throws Throwable { final FragmentManager fm = mActivityRule . getActivity ( ) . getSupportFragmentManager ( ) ; final View startBlue = mActivityRule . getActivity ( ) . findViewById ( R . id . blueSquare ) ; final PostponedFragment2 fragment2 = new PostponedFragment2 ( ) ; fm . beginTransaction ( ) . addSharedElement ( startBlue , "blueSquare" ) . hide ( mBeginningFragment ) . replace ( R . id . fragmentContainer , fragment2 ) . hide ( fragment2 ) . detach ( fragment2 ) . attach ( fragment2 ) . show ( fragment2 ) . addToBackStack ( null ) . setReorderingAllowed ( true ) . commit ( ) ; FragmentTestUtil . waitForExecution ( mActivityRule ) ; assertPostponedTransition ( mBeginningFragment , fragment2 , null ) ; fragment2 . startPostponedEnterTransition ( ) ; assertForwardTransition ( mBeginningFragment , fragment2 ) ; FragmentTestUtil . popBackStackImmediate ( mActivityRule ) ; assertPostponedTransition ( fragment2 , mBeginningFragment , null ) ; mBeginningFragment . startPostponedEnterTransition ( ) ; assertBackTransition ( fragment2 , mBeginningFragment ) ; }
Do a bunch of things to one fragment in a transaction and see if it can screw things up.
Do a bunch of things to one fragment in a transaction and see if it can screw things up .
// start the postponed transition // make sure it ran // Pop back to fragment2, but it should be postponed // start the postponed transition // make sure it ran