@Test public void startFragment_shouldInsertTheFragmentViewIntoTheContainerView() throws Exception { manager.addFragment(CONTAINER_VIEW_ID, null, fragment, false); manager.startFragment(fragment); View fragmentViewParent = (View) activity.findViewById(TestFragment.FRAGMENT_VIEW_ID).getParent(); assertThat( activity.findViewById(TestFragment.FRAGMENT_VIEW_ID), sameInstance(fragment.onCreateViewReturnValue)); assertThat(fragmentViewParent, sameInstance((View) containerView)); }
@Before public void setUp() throws Exception { activity = new TestFragmentActivity(); activity.onCreate(null); manager = (TestFragmentManager) activity.getSupportFragmentManager(); fragment = new TestFragment(); containerView = (ViewGroup) activity.findViewById(CONTAINER_VIEW_ID); }