fragment/src/androidTest/java/androidx/fragment/app/FragmentReorderingTest.java
@Test
    public void noReordering() throws Throwable {
        final CountCallsFragment fragment1 = new CountCallsFragment();
        final CountCallsFragment fragment2 = new CountCallsFragment();
        mInstrumentation.runOnMainSync(new Runnable() {
            @Override
            public void run() {
                mFM.beginTransaction()
                        .add(R.id.fragmentContainer, fragment1)
                        .addToBackStack(null)
                        .setReorderingAllowed(true)
                        .commit();
                mFM.beginTransaction()
                        .replace(R.id.fragmentContainer, fragment2)
                        .addToBackStack(null)
                        .setReorderingAllowed(false)
                        .commit();
                mFM.executePendingTransactions();
            }
        });
        FragmentTestUtil.assertChildren(mContainer, fragment2);

        // No reordering, so fragment1 should have created its View
        assertEquals(1, fragment1.onCreateViewCount);
    }
// transaction should all be run prior to running the ordered transaction.
transaction should all be run prior to running the ordered transaction.
transaction should all be run prior to running the ordered transaction .
@Test
    public void noReordering() throws Throwable {
        final CountCallsFragment fragment1 = new CountCallsFragment();
        final CountCallsFragment fragment2 = new CountCallsFragment();
        mInstrumentation.runOnMainSync(new Runnable() {
            @Override
            public void run() {
                mFM.beginTransaction()
                        .add(R.id.fragmentContainer, fragment1)
                        .addToBackStack(null)
                        .setReorderingAllowed(true)
                        .commit();
                mFM.beginTransaction()
                        .replace(R.id.fragmentContainer, fragment2)
                        .addToBackStack(null)
                        .setReorderingAllowed(false)
                        .commit();
                mFM.executePendingTransactions();
            }
        });
        FragmentTestUtil.assertChildren(mContainer, fragment2);
        assertEquals(1, fragment1.onCreateViewCount);
    }
@ Test public void noReordering ( ) throws Throwable { final CountCallsFragment fragment1 = new CountCallsFragment ( ) ; final CountCallsFragment fragment2 = new CountCallsFragment ( ) ; mInstrumentation . runOnMainSync ( new Runnable ( ) { @ Override public void run ( ) { mFM . beginTransaction ( ) . add ( R . id . fragmentContainer , fragment1 ) . addToBackStack ( null ) . setReorderingAllowed ( true ) . commit ( ) ; mFM . beginTransaction ( ) . replace ( R . id . fragmentContainer , fragment2 ) . addToBackStack ( null ) . setReorderingAllowed ( false ) . commit ( ) ; mFM . executePendingTransactions ( ) ; } } ) ; FragmentTestUtil . assertChildren ( mContainer , fragment2 ) ; assertEquals ( 1 , fragment1 . onCreateViewCount ) ; }
transaction should all be run prior to running the ordered transaction.
transaction should all be run prior to running the ordered transaction .
// No reordering, so fragment1 should have created its View