Code example for FragmentTransaction

Methods: commit, remove

0
    @Test 
    public void removeUsingTransaction_shouldDismissTheDialog() throws Exception { 
        dialogFragment.show(fragmentManager, null);
 
        FragmentTransaction t = fragmentManager.beginTransaction();
        t.remove(dialogFragment);
        t.commit();
 
        Dialog dialog = ShadowDialog.getLatestDialog();
        assertFalse(dialog.isShowing());
        assertTrue(shadowOf(dialog).hasBeenDismissed());
    } 
     
    private class TestDialogFragment extends DialogFragment {
        final Transcript transcript = new Transcript();
        Activity onAttachActivity;
        private Dialog returnThisDialogFromOnCreateDialog;
 
        @Override 
        public void onAttach(Activity activity) {
            transcript.add("onAttach");