fragment/src/androidTest/java/androidx/fragment/app/FragmentAnimationTest.java
@Test
    public void popPostponed() throws Throwable {
        final FragmentManager fm = mActivityRule.getActivity().getSupportFragmentManager();

        final AnimatorFragment fragment1 = new AnimatorFragment();
        fm.beginTransaction()
                .add(R.id.fragmentContainer, fragment1)
                .setReorderingAllowed(true)
                .commit();
        FragmentTestUtil.waitForExecution(mActivityRule);
        assertEquals(0, fragment1.numAnimators);

        final AnimatorFragment fragment2 = new AnimatorFragment();
        fragment2.postponeEnterTransition();

        fm.beginTransaction()
                .setCustomAnimations(ENTER, EXIT, POP_ENTER, POP_EXIT)
                .replace(R.id.fragmentContainer, fragment2)
                .addToBackStack(null)
                .setReorderingAllowed(true)
                .commit();

        FragmentTestUtil.waitForExecution(mActivityRule);

        assertPostponed(fragment2, 0);

        // Now pop the postponed transaction
        FragmentTestUtil.popBackStackImmediate(mActivityRule);

        assertNotNull(fragment1.getView());
        assertEquals(View.VISIBLE, fragment1.getView().getVisibility());
        assertEquals(1f, fragment1.getView().getAlpha(), 0f);
        assertTrue(ViewCompat.isAttachedToWindow(fragment1.getView()));
        assertTrue(fragment1.isAdded());

        assertNull(fragment2.getView());
        assertFalse(fragment2.isAdded());

        assertEquals(0, fragment1.numAnimators);
        assertEquals(0, fragment2.numAnimators);
        assertNull(fragment1.animation);
        assertNull(fragment2.animation);
    }
// Popping a postponed transaction should result in no animators
Popping a postponed transaction should result in no animators
Popping a postponed transaction should result in no animators
@Test
    public void popPostponed() throws Throwable {
        final FragmentManager fm = mActivityRule.getActivity().getSupportFragmentManager();
        final AnimatorFragment fragment1 = new AnimatorFragment();
        fm.beginTransaction()
                .add(R.id.fragmentContainer, fragment1)
                .setReorderingAllowed(true)
                .commit();
        FragmentTestUtil.waitForExecution(mActivityRule);
        assertEquals(0, fragment1.numAnimators);
        final AnimatorFragment fragment2 = new AnimatorFragment();
        fragment2.postponeEnterTransition();
        fm.beginTransaction()
                .setCustomAnimations(ENTER, EXIT, POP_ENTER, POP_EXIT)
                .replace(R.id.fragmentContainer, fragment2)
                .addToBackStack(null)
                .setReorderingAllowed(true)
                .commit();
        FragmentTestUtil.waitForExecution(mActivityRule);
        assertPostponed(fragment2, 0);
        FragmentTestUtil.popBackStackImmediate(mActivityRule);
        assertNotNull(fragment1.getView());
        assertEquals(View.VISIBLE, fragment1.getView().getVisibility());
        assertEquals(1f, fragment1.getView().getAlpha(), 0f);
        assertTrue(ViewCompat.isAttachedToWindow(fragment1.getView()));
        assertTrue(fragment1.isAdded());
        assertNull(fragment2.getView());
        assertFalse(fragment2.isAdded());
        assertEquals(0, fragment1.numAnimators);
        assertEquals(0, fragment2.numAnimators);
        assertNull(fragment1.animation);
        assertNull(fragment2.animation);
    }
@ Test public void popPostponed ( ) throws Throwable { final FragmentManager fm = mActivityRule . getActivity ( ) . getSupportFragmentManager ( ) ; final AnimatorFragment fragment1 = new AnimatorFragment ( ) ; fm . beginTransaction ( ) . add ( R . id . fragmentContainer , fragment1 ) . setReorderingAllowed ( true ) . commit ( ) ; FragmentTestUtil . waitForExecution ( mActivityRule ) ; assertEquals ( 0 , fragment1 . numAnimators ) ; final AnimatorFragment fragment2 = new AnimatorFragment ( ) ; fragment2 . postponeEnterTransition ( ) ; fm . beginTransaction ( ) . setCustomAnimations ( ENTER , EXIT , POP_ENTER , POP_EXIT ) . replace ( R . id . fragmentContainer , fragment2 ) . addToBackStack ( null ) . setReorderingAllowed ( true ) . commit ( ) ; FragmentTestUtil . waitForExecution ( mActivityRule ) ; assertPostponed ( fragment2 , 0 ) ; FragmentTestUtil . popBackStackImmediate ( mActivityRule ) ; assertNotNull ( fragment1 . getView ( ) ) ; assertEquals ( View . VISIBLE , fragment1 . getView ( ) . getVisibility ( ) ) ; assertEquals ( 1f , fragment1 . getView ( ) . getAlpha ( ) , 0f ) ; assertTrue ( ViewCompat . isAttachedToWindow ( fragment1 . getView ( ) ) ) ; assertTrue ( fragment1 . isAdded ( ) ) ; assertNull ( fragment2 . getView ( ) ) ; assertFalse ( fragment2 . isAdded ( ) ) ; assertEquals ( 0 , fragment1 . numAnimators ) ; assertEquals ( 0 , fragment2 . numAnimators ) ; assertNull ( fragment1 . animation ) ; assertNull ( fragment2 . animation ) ; }
Popping a postponed transaction should result in no animators
Popping a postponed transaction should result in no animators
// Now pop the postponed transaction