use of org.robolectric.fakes.RoboMenu in project collect by opendatakit.
the class FormEntryMenuDelegateTest method onItemSelected_whenHierarchy_startsHierarchyActivity.
@Test
public void onItemSelected_whenHierarchy_startsHierarchyActivity() {
RoboMenu menu = new RoboMenu();
formEntryMenuDelegate.onCreateOptionsMenu(Robolectric.setupActivity(FragmentActivity.class).getMenuInflater(), menu);
formEntryMenuDelegate.onPrepareOptionsMenu(menu);
formEntryMenuDelegate.onOptionsItemSelected(new RoboMenuItem(R.id.menu_goto));
ShadowActivity.IntentForResult nextStartedActivity = shadowOf(activity).getNextStartedActivityForResult();
assertThat(nextStartedActivity, not(nullValue()));
assertThat(nextStartedActivity.intent.getComponent().getClassName(), is(FormHierarchyActivity.class.getName()));
assertThat(nextStartedActivity.requestCode, is(ApplicationConstants.RequestCodes.HIERARCHY_ACTIVITY));
}
use of org.robolectric.fakes.RoboMenu in project collect by opendatakit.
the class FormEntryMenuDelegateTest method onPrepare_whenFormHasBackgroundRecording_showsRecordAudio.
@Test
public void onPrepare_whenFormHasBackgroundRecording_showsRecordAudio() {
when(formEntryViewModel.hasBackgroundRecording()).thenReturn(new MutableNonNullLiveData<>(true));
RoboMenu menu = new RoboMenu();
formEntryMenuDelegate.onCreateOptionsMenu(Robolectric.setupActivity(FragmentActivity.class).getMenuInflater(), menu);
formEntryMenuDelegate.onPrepareOptionsMenu(menu);
assertThat(menu.findItem(R.id.menu_record_audio).isVisible(), equalTo(true));
}
use of org.robolectric.fakes.RoboMenu in project collect by opendatakit.
the class FormEntryMenuDelegateTest method onItemSelected_whenAddRepeat_whenRecordingInTheBackground_doesNotShowWarning.
@Test
public void onItemSelected_whenAddRepeat_whenRecordingInTheBackground_doesNotShowWarning() {
RoboMenu menu = new RoboMenu();
formEntryMenuDelegate.onCreateOptionsMenu(Robolectric.setupActivity(FragmentActivity.class).getMenuInflater(), menu);
formEntryMenuDelegate.onPrepareOptionsMenu(menu);
when(audioRecorder.isRecording()).thenReturn(true);
when(backgroundAudioViewModel.isBackgroundRecording()).thenReturn(true);
formEntryMenuDelegate.onOptionsItemSelected(new RoboMenuItem(R.id.menu_add_repeat));
verify(formEntryViewModel).promptForNewRepeat();
RecordingWarningDialogFragment dialog = getFragmentByClass(activity.getSupportFragmentManager(), RecordingWarningDialogFragment.class);
assertThat(dialog, is(nullValue()));
}
use of org.robolectric.fakes.RoboMenu in project collect by opendatakit.
the class FormEntryMenuDelegateTest method onPrepare_inRepeatQuestion_showsAddRepeat.
@Test
public void onPrepare_inRepeatQuestion_showsAddRepeat() {
when(formEntryViewModel.canAddRepeat()).thenReturn(true);
RoboMenu menu = new RoboMenu();
formEntryMenuDelegate.onCreateOptionsMenu(Robolectric.setupActivity(FragmentActivity.class).getMenuInflater(), menu);
formEntryMenuDelegate.onPrepareOptionsMenu(menu);
assertThat(menu.findItem(R.id.menu_add_repeat).isVisible(), equalTo(true));
}
use of org.robolectric.fakes.RoboMenu in project collect by opendatakit.
the class FormEntryMenuDelegateTest method onItemSelected_whenPreferences_whenRecording_showsWarning.
@Test
public void onItemSelected_whenPreferences_whenRecording_showsWarning() {
RoboMenu menu = new RoboMenu();
formEntryMenuDelegate.onCreateOptionsMenu(Robolectric.setupActivity(FragmentActivity.class).getMenuInflater(), menu);
formEntryMenuDelegate.onPrepareOptionsMenu(menu);
when(audioRecorder.isRecording()).thenReturn(true);
formEntryMenuDelegate.onOptionsItemSelected(new RoboMenuItem(R.id.menu_preferences));
assertThat(shadowOf(activity).getNextStartedActivityForResult(), is(nullValue()));
RecordingWarningDialogFragment dialog = getFragmentByClass(activity.getSupportFragmentManager(), RecordingWarningDialogFragment.class);
assertThat(dialog, is(notNullValue()));
assertThat(dialog.getDialog().isShowing(), is(true));
}
Aggregations