TravelTimePicker extends DialogFragment { public void open(final android.app.FragmentManager manager, final Date date) { }  static TravelTimePicker newInstance(); static TravelTimePicker newInstance(Variety type); @Override Dialog onCreateDialog(final Bundle savedInstanceState); void open(final android.app.FragmentManager manager, final Date date); void open(final android.app.FragmentManager manager); void open(final FragmentManager manager, final Date date); void open(final FragmentManager manager); Date getTime(); void setTime(final Date time); RouteOptions.TimeType getTimeType(); void setTimeType(final RouteOptions.TimeType type); DatePicker getDatePicker(); TimePicker getTimePicker(); TravelTimePicker setMinDate(long minDate); TravelTimePicker setMaxDate(long maxDate); long getMaxDate(); long getMinDate(); Variety getVariety(); @Override void onSaveInstanceState(Bundle outState); void setOnTimePickedListener(final OnTimePickedListener listener); static final String HOUR; static final String MINUTE; static final String YEAR; static final String MONTH; static final String DAY; static final String TYPE; static final String TAB_SELECTED; static final String MIN_DAY; static final String MAX_DAY; static final String TIME_DIALOG_OPEN; }
@Test public void tesInitUI() { mTravelTimePicker.open(getSupportFragmentManager()); final Dialog dialog = mTravelTimePicker.getDialog(); assertNotNull(dialog.findViewById(R.id.picker_tab)); assertNotNull(dialog.findViewById(R.id.travel_date)); assertNotNull(dialog.findViewById(R.id.travel_time)); }
@Test public void cancelShouldDismissDialog() { mTravelTimePicker.open(getSupportFragmentManager()); final Dialog dialog = mTravelTimePicker.getDialog(); assertThat(dialog.isShowing(), is(true)); ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_NEGATIVE).performClick(); assertThat(dialog.isShowing(), is(false)); }
@Test public void openShouldOpenDialogWithCurrentDateAndTime() { mTravelTimePicker.open(getSupportFragmentManager()); final Dialog dialog = mTravelTimePicker.getDialog(); final DatePicker picker = dialog.findViewById(R.id.travel_date); final Calendar calendar = Calendar.getInstance(); assertThat(picker.getYear(), equalTo(calendar.get(Calendar.YEAR))); assertThat(picker.getMonth(), equalTo(calendar.get(Calendar.MONTH))); assertThat(picker.getDayOfMonth(), equalTo(calendar.get(Calendar.DAY_OF_MONTH))); final TimePicker timePicker = dialog.findViewById(R.id.travel_time); assertThat(timePicker.getCurrentHour(), equalTo(calendar.get(Calendar.HOUR_OF_DAY))); assertThat(timePicker.getCurrentMinute(), equalTo(calendar.get(Calendar.MINUTE))); }