fragment/src/androidTest/java/androidx/fragment/app/FragmentLifecycleTest.java
@Test
    @UiThreadTest
    public void noPrematureStateChange() throws Throwable {
        FragmentController fc = startupFragmentController(null);
        FragmentManager fm = fc.getSupportFragmentManager();

        fm.beginTransaction()
                .add(new StrictFragment(), "1")
                .commitNow();

        Parcelable savedState = shutdownFragmentController(fc);
        fc = FragmentController.createController(
                new HostCallbacks(mActivityRule.getActivity()));

        fc.attachHost(null);
        fc.dispatchCreate();
        fc.dispatchActivityCreated();
        fc.noteStateNotSaved();
        fc.execPendingActions();
        fc.dispatchStart();
        fc.dispatchResume();
        fc.restoreAllState(savedState, (FragmentManagerNonConfig) null);
        fc.dispatchResume();
        fm = fc.getSupportFragmentManager();

        StrictFragment fragment1 = (StrictFragment) fm.findFragmentByTag("1");

        assertFalse(fragment1.mCalledOnResume);
    }
/**
     * Test to ensure that when dispatch* is called that the fragment manager
     * doesn't cause the contained fragment states to change even if no state changes.
     */
Test to ensure that when dispatch* is called that the fragment manager
doesn't cause the contained fragment states to change even if no state changes.
Test to ensure that when dispatch * is called that the fragment manager doesn ' t cause the contained fragment states to change even if no state changes .
@Test
    @UiThreadTest
    public void noPrematureStateChange() throws Throwable {
        FragmentController fc = startupFragmentController(null);
        FragmentManager fm = fc.getSupportFragmentManager();
        fm.beginTransaction()
                .add(new StrictFragment(), "1")
                .commitNow();
        Parcelable savedState = shutdownFragmentController(fc);
        fc = FragmentController.createController(
                new HostCallbacks(mActivityRule.getActivity()));
        fc.attachHost(null);
        fc.dispatchCreate();
        fc.dispatchActivityCreated();
        fc.noteStateNotSaved();
        fc.execPendingActions();
        fc.dispatchStart();
        fc.dispatchResume();
        fc.restoreAllState(savedState, (FragmentManagerNonConfig) null);
        fc.dispatchResume();
        fm = fc.getSupportFragmentManager();
        StrictFragment fragment1 = (StrictFragment) fm.findFragmentByTag("1");
        assertFalse(fragment1.mCalledOnResume);
    }
@ Test @ UiThreadTest public void noPrematureStateChange ( ) throws Throwable { FragmentController fc = startupFragmentController ( null ) ; FragmentManager fm = fc . getSupportFragmentManager ( ) ; fm . beginTransaction ( ) . add ( new StrictFragment ( ) , "1" ) . commitNow ( ) ; Parcelable savedState = shutdownFragmentController ( fc ) ; fc = FragmentController . createController ( new HostCallbacks ( mActivityRule . getActivity ( ) ) ) ; fc . attachHost ( null ) ; fc . dispatchCreate ( ) ; fc . dispatchActivityCreated ( ) ; fc . noteStateNotSaved ( ) ; fc . execPendingActions ( ) ; fc . dispatchStart ( ) ; fc . dispatchResume ( ) ; fc . restoreAllState ( savedState , ( FragmentManagerNonConfig ) null ) ; fc . dispatchResume ( ) ; fm = fc . getSupportFragmentManager ( ) ; StrictFragment fragment1 = ( StrictFragment ) fm . findFragmentByTag ( "1" ) ; assertFalse ( fragment1 . mCalledOnResume ) ; }
Test to ensure that when dispatch* is called that the fragment manager
 doesn't cause the contained fragment states to change even if no state changes.
Test to ensure that when dispatch * is called that the fragment manager doesn ' t cause the contained fragment states to change even if no state changes .