fragment/src/androidTest/java/androidx/fragment/app/PostponedTransitionTest.java
@Test
    public void noAccidentalRemoval() throws Throwable {
        final FragmentManager fm = mActivityRule.getActivity().getSupportFragmentManager();
        fm.beginTransaction()
                .remove(mBeginningFragment)
                .setReorderingAllowed(true)
                .commit();
        FragmentTestUtil.waitForExecution(mActivityRule);
        FragmentTestUtil.setContentView(mActivityRule, R.layout.double_container);

        TransitionFragment fragment1 = new PostponedFragment1();

        fm.beginTransaction()
                .add(R.id.fragmentContainer1, fragment1)
                .setReorderingAllowed(true)
                .commit();
        FragmentTestUtil.waitForExecution(mActivityRule);
        fragment1.startPostponedEnterTransition();
        fragment1.waitForTransition();
        clearTargets(fragment1);

        TransitionFragment fragment2 = new PostponedFragment2();
        // Create a postponed transaction that removes a view
        fm.beginTransaction()
                .replace(R.id.fragmentContainer1, fragment2)
                .setReorderingAllowed(true)
                .commit();
        FragmentTestUtil.waitForExecution(mActivityRule);
        assertPostponedTransition(fragment1, fragment2, null);

        TransitionFragment fragment3 = new PostponedFragment1();
        // Create a transaction that doesn't interfere with the previously postponed one
        fm.beginTransaction()
                .replace(R.id.fragmentContainer2, fragment3)
                .setReorderingAllowed(true)
                .commit();
        FragmentTestUtil.waitForExecution(mActivityRule);

        assertPostponedTransition(fragment1, fragment2, null);

        fragment3.startPostponedEnterTransition();
        fragment3.waitForTransition();
        clearTargets(fragment3);

        assertPostponedTransition(fragment1, fragment2, null);
    }
// another transaction doesn't accidentally remove the view early.
another transaction doesn't accidentally remove the view early.
another transaction doesn ' t accidentally remove the view early .
@Test
    public void noAccidentalRemoval() throws Throwable {
        final FragmentManager fm = mActivityRule.getActivity().getSupportFragmentManager();
        fm.beginTransaction()
                .remove(mBeginningFragment)
                .setReorderingAllowed(true)
                .commit();
        FragmentTestUtil.waitForExecution(mActivityRule);
        FragmentTestUtil.setContentView(mActivityRule, R.layout.double_container);
        TransitionFragment fragment1 = new PostponedFragment1();
        fm.beginTransaction()
                .add(R.id.fragmentContainer1, fragment1)
                .setReorderingAllowed(true)
                .commit();
        FragmentTestUtil.waitForExecution(mActivityRule);
        fragment1.startPostponedEnterTransition();
        fragment1.waitForTransition();
        clearTargets(fragment1);
        TransitionFragment fragment2 = new PostponedFragment2();
        fm.beginTransaction()
                .replace(R.id.fragmentContainer1, fragment2)
                .setReorderingAllowed(true)
                .commit();
        FragmentTestUtil.waitForExecution(mActivityRule);
        assertPostponedTransition(fragment1, fragment2, null);
        TransitionFragment fragment3 = new PostponedFragment1();
        fm.beginTransaction()
                .replace(R.id.fragmentContainer2, fragment3)
                .setReorderingAllowed(true)
                .commit();
        FragmentTestUtil.waitForExecution(mActivityRule);
        assertPostponedTransition(fragment1, fragment2, null);
        fragment3.startPostponedEnterTransition();
        fragment3.waitForTransition();
        clearTargets(fragment3);
        assertPostponedTransition(fragment1, fragment2, null);
    }
@ Test public void noAccidentalRemoval ( ) throws Throwable { final FragmentManager fm = mActivityRule . getActivity ( ) . getSupportFragmentManager ( ) ; fm . beginTransaction ( ) . remove ( mBeginningFragment ) . setReorderingAllowed ( true ) . commit ( ) ; FragmentTestUtil . waitForExecution ( mActivityRule ) ; FragmentTestUtil . setContentView ( mActivityRule , R . layout . double_container ) ; TransitionFragment fragment1 = new PostponedFragment1 ( ) ; fm . beginTransaction ( ) . add ( R . id . fragmentContainer1 , fragment1 ) . setReorderingAllowed ( true ) . commit ( ) ; FragmentTestUtil . waitForExecution ( mActivityRule ) ; fragment1 . startPostponedEnterTransition ( ) ; fragment1 . waitForTransition ( ) ; clearTargets ( fragment1 ) ; TransitionFragment fragment2 = new PostponedFragment2 ( ) ; fm . beginTransaction ( ) . replace ( R . id . fragmentContainer1 , fragment2 ) . setReorderingAllowed ( true ) . commit ( ) ; FragmentTestUtil . waitForExecution ( mActivityRule ) ; assertPostponedTransition ( fragment1 , fragment2 , null ) ; TransitionFragment fragment3 = new PostponedFragment1 ( ) ; fm . beginTransaction ( ) . replace ( R . id . fragmentContainer2 , fragment3 ) . setReorderingAllowed ( true ) . commit ( ) ; FragmentTestUtil . waitForExecution ( mActivityRule ) ; assertPostponedTransition ( fragment1 , fragment2 , null ) ; fragment3 . startPostponedEnterTransition ( ) ; fragment3 . waitForTransition ( ) ; clearTargets ( fragment3 ) ; assertPostponedTransition ( fragment1 , fragment2 , null ) ; }
another transaction doesn't accidentally remove the view early.
another transaction doesn ' t accidentally remove the view early .
// Create a postponed transaction that removes a view // Create a transaction that doesn't interfere with the previously postponed one