fragment/src/androidTest/java/androidx/fragment/app/FragmentViewTests.java
@Test
    public void childFragmentManager() throws Throwable {
        FragmentTestUtil.setContentView(mActivityRule, R.layout.simple_container);
        ViewGroup container = (ViewGroup)
                mActivityRule.getActivity().findViewById(R.id.fragmentContainer);
        final FragmentManager fm = mActivityRule.getActivity().getSupportFragmentManager();

        final StrictViewFragment fragment1 = new ParentFragment();
        fragment1.setLayoutId(R.layout.double_container);

        fm.beginTransaction()
                .add(R.id.fragmentContainer, fragment1)
                .addToBackStack(null)
                .commit();

        FragmentTestUtil.executePendingTransactions(mActivityRule);

        FragmentTestUtil.assertChildren(container, fragment1);
        ViewGroup innerContainer = (ViewGroup)
                fragment1.getView().findViewById(R.id.fragmentContainer1);

        Fragment fragment2 = fragment1.getChildFragmentManager().findFragmentByTag("inner");
        FragmentTestUtil.assertChildren(innerContainer, fragment2);
    }
// the View has been added.
the View has been added.
the View has been added .
@Test
    public void childFragmentManager() throws Throwable {
        FragmentTestUtil.setContentView(mActivityRule, R.layout.simple_container);
        ViewGroup container = (ViewGroup)
                mActivityRule.getActivity().findViewById(R.id.fragmentContainer);
        final FragmentManager fm = mActivityRule.getActivity().getSupportFragmentManager();
        final StrictViewFragment fragment1 = new ParentFragment();
        fragment1.setLayoutId(R.layout.double_container);
        fm.beginTransaction()
                .add(R.id.fragmentContainer, fragment1)
                .addToBackStack(null)
                .commit();
        FragmentTestUtil.executePendingTransactions(mActivityRule);
        FragmentTestUtil.assertChildren(container, fragment1);
        ViewGroup innerContainer = (ViewGroup)
                fragment1.getView().findViewById(R.id.fragmentContainer1);
        Fragment fragment2 = fragment1.getChildFragmentManager().findFragmentByTag("inner");
        FragmentTestUtil.assertChildren(innerContainer, fragment2);
    }
@ Test public void childFragmentManager ( ) throws Throwable { FragmentTestUtil . setContentView ( mActivityRule , R . layout . simple_container ) ; ViewGroup container = ( ViewGroup ) mActivityRule . getActivity ( ) . findViewById ( R . id . fragmentContainer ) ; final FragmentManager fm = mActivityRule . getActivity ( ) . getSupportFragmentManager ( ) ; final StrictViewFragment fragment1 = new ParentFragment ( ) ; fragment1 . setLayoutId ( R . layout . double_container ) ; fm . beginTransaction ( ) . add ( R . id . fragmentContainer , fragment1 ) . addToBackStack ( null ) . commit ( ) ; FragmentTestUtil . executePendingTransactions ( mActivityRule ) ; FragmentTestUtil . assertChildren ( container , fragment1 ) ; ViewGroup innerContainer = ( ViewGroup ) fragment1 . getView ( ) . findViewById ( R . id . fragmentContainer1 ) ; Fragment fragment2 = fragment1 . getChildFragmentManager ( ) . findFragmentByTag ( "inner" ) ; FragmentTestUtil . assertChildren ( innerContainer , fragment2 ) ; }
the View has been added.
the View has been added .