Code example for DialogFragment

Methods: getDialog, show

0
 
    @Test 
    public void show_shouldShowDialogThatWasReturnedFromOnCreateDialog_whenOnCreateDialogReturnsADialog() throws Exception { 
        Dialog dialogFromOnCreateDialog = new Dialog(activity);
        dialogFragment.returnThisDialogFromOnCreateDialog(dialogFromOnCreateDialog);
        dialogFragment.show(fragmentManager, "this is a tag");
 
        Dialog dialog = ShadowDialog.getLatestDialog();
        assertSame(dialogFromOnCreateDialog, dialog);
        assertSame(dialogFromOnCreateDialog, dialogFragment.getDialog());
        assertSame(dialogFragment, fragmentManager.findFragmentByTag("this is a tag"));
    } 
     
    @Test 
    public void show_shouldShowDialogThatWasAutomaticallyCreated_whenOnCreateDialogReturnsNull() throws Exception { 
        dialogFragment.show(fragmentManager, "this is a tag");
 
        Dialog dialog = ShadowDialog.getLatestDialog();
        assertNotNull(dialog);
        assertSame(dialog, dialogFragment.getDialog());
        assertNotNull(dialog.findViewById(R.id.title));