DirectoryChooserFragment extends DialogFragment { public static DirectoryChooserFragment newInstance( @Nonnull final String newDirectoryName, @Nullable final String initialDirectory) { DirectoryChooserFragment fragment = new DirectoryChooserFragment(); Bundle args = new Bundle(); args.putString(ARG_NEW_DIRECTORY_NAME, newDirectoryName); args.putString(ARG_INITIAL_DIRECTORY, initialDirectory); fragment.setArguments(args); return fragment; } DirectoryChooserFragment(); static DirectoryChooserFragment newInstance(
			@Nonnull final String newDirectoryName,
			@Nullable final String initialDirectory); @Override void onSaveInstanceState(@Nonnull Bundle outState); @Override void onCreate(Bundle savedInstanceState); @Override View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState); @Override void onAttach(Activity activity); @Override void onDetach(); @Override void onPause(); @Override void onResume(); @Override void onCreateOptionsMenu(Menu menu, MenuInflater inflater); @Override boolean onOptionsItemSelected(MenuItem item); static final String KEY_CURRENT_DIRECTORY; }
@TargetApi(Build.VERSION_CODES.HONEYCOMB) @Test public void testWithDirectory() { final DirectoryChooserFragment fragment = DirectoryChooserFragment.newInstance("mydir", null); startFragment(fragment, DirectoryChooserActivityMock.class); final View chooseBtn = fragment.getActivity().findViewById(R.id.btnConfirm); assertThat(chooseBtn).isEnabled(); assert chooseBtn.performClick(); assertNotNull(((DirectoryChooserActivityMock) fragment.getActivity()).selectedDirectory); }