fragment/src/androidTest/java/androidx/fragment/app/FragmentLifecycleTest.java
@Test
    @UiThreadTest
    public void fragmentLifecycleCallbacks() throws Throwable {
        FragmentController fc = FragmentController.createController(
                new HostCallbacks(mActivityRule.getActivity()));
        fc.attachHost(null);
        fc.dispatchCreate();

        FragmentManager fm = fc.getSupportFragmentManager();

        ChildFragmentManagerFragment fragment = new ChildFragmentManagerFragment();
        fm.beginTransaction()
                .add(android.R.id.content, fragment)
                .commitNow();

        fc.dispatchActivityCreated();

        fc.dispatchStart();
        fc.dispatchResume();

        // Confirm that the parent fragment received onAttachFragment
        assertTrue("parent fragment did not receive onAttachFragment",
                fragment.mCalledOnAttachFragment);

        fc.dispatchStop();
        fc.dispatchDestroy();
    }
/**
     * This test checks that FragmentLifecycleCallbacks are invoked when expected.
     */
This test checks that FragmentLifecycleCallbacks are invoked when expected.
This test checks that FragmentLifecycleCallbacks are invoked when expected .
@Test
    @UiThreadTest
    public void fragmentLifecycleCallbacks() throws Throwable {
        FragmentController fc = FragmentController.createController(
                new HostCallbacks(mActivityRule.getActivity()));
        fc.attachHost(null);
        fc.dispatchCreate();
        FragmentManager fm = fc.getSupportFragmentManager();
        ChildFragmentManagerFragment fragment = new ChildFragmentManagerFragment();
        fm.beginTransaction()
                .add(android.R.id.content, fragment)
                .commitNow();
        fc.dispatchActivityCreated();
        fc.dispatchStart();
        fc.dispatchResume();
        assertTrue("parent fragment did not receive onAttachFragment",
                fragment.mCalledOnAttachFragment);
        fc.dispatchStop();
        fc.dispatchDestroy();
    }
@ Test @ UiThreadTest public void fragmentLifecycleCallbacks ( ) throws Throwable { FragmentController fc = FragmentController . createController ( new HostCallbacks ( mActivityRule . getActivity ( ) ) ) ; fc . attachHost ( null ) ; fc . dispatchCreate ( ) ; FragmentManager fm = fc . getSupportFragmentManager ( ) ; ChildFragmentManagerFragment fragment = new ChildFragmentManagerFragment ( ) ; fm . beginTransaction ( ) . add ( android . R . id . content , fragment ) . commitNow ( ) ; fc . dispatchActivityCreated ( ) ; fc . dispatchStart ( ) ; fc . dispatchResume ( ) ; assertTrue ( "parent fragment did not receive onAttachFragment" , fragment . mCalledOnAttachFragment ) ; fc . dispatchStop ( ) ; fc . dispatchDestroy ( ) ; }
This test checks that FragmentLifecycleCallbacks are invoked when expected.
This test checks that FragmentLifecycleCallbacks are invoked when expected .
// Confirm that the parent fragment received onAttachFragment