use of org.robolectric.fakes.RoboMenu in project collect by opendatakit.
the class FormEntryMenuDelegateTest method onItemSelected_whenHierarchy_savesScreenAnswers.
@Test
public void onItemSelected_whenHierarchy_savesScreenAnswers() {
RoboMenu menu = new RoboMenu();
formEntryMenuDelegate.onCreateOptionsMenu(Robolectric.setupActivity(FragmentActivity.class).getMenuInflater(), menu);
formEntryMenuDelegate.onPrepareOptionsMenu(menu);
HashMap answers = new HashMap();
when(answersProvider.getAnswers()).thenReturn(answers);
formEntryMenuDelegate.onOptionsItemSelected(new RoboMenuItem(R.id.menu_goto));
verify(formSaveViewModel).saveAnswersForScreen(answers);
}
use of org.robolectric.fakes.RoboMenu in project collect by opendatakit.
the class FormEntryMenuDelegateTest method onItemSelected_whenHierarchy_callsOpenHierarchy.
@Test
public void onItemSelected_whenHierarchy_callsOpenHierarchy() {
RoboMenu menu = new RoboMenu();
formEntryMenuDelegate.onCreateOptionsMenu(Robolectric.setupActivity(FragmentActivity.class).getMenuInflater(), menu);
formEntryMenuDelegate.onPrepareOptionsMenu(menu);
formEntryMenuDelegate.onOptionsItemSelected(new RoboMenuItem(R.id.menu_goto));
verify(formEntryViewModel).openHierarchy();
}
use of org.robolectric.fakes.RoboMenu in project collect by opendatakit.
the class FormEntryMenuDelegateTest method onItemSelected_whenHierarchy_whenRecordingInBackground_doesNotShowWarning.
@Test
public void onItemSelected_whenHierarchy_whenRecordingInBackground_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_goto));
assertThat(shadowOf(activity).getNextStartedActivity(), is(notNullValue()));
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 onItemSelected_whenAddRepeat_callsPromptForNewRepeat.
@Test
public void onItemSelected_whenAddRepeat_callsPromptForNewRepeat() {
RoboMenu menu = new RoboMenu();
formEntryMenuDelegate.onCreateOptionsMenu(Robolectric.setupActivity(FragmentActivity.class).getMenuInflater(), menu);
formEntryMenuDelegate.onPrepareOptionsMenu(menu);
formEntryMenuDelegate.onOptionsItemSelected(new RoboMenuItem(R.id.menu_add_repeat));
verify(formEntryViewModel).promptForNewRepeat();
}
use of org.robolectric.fakes.RoboMenu in project collect by opendatakit.
the class FormEntryMenuDelegateTest method onPrepare_whenNotRecordingInBackground_unchecksRecordAudio.
@Test
public void onPrepare_whenNotRecordingInBackground_unchecksRecordAudio() {
when(backgroundAudioViewModel.isBackgroundRecordingEnabled()).thenReturn(new MutableNonNullLiveData<>(false));
RoboMenu menu = new RoboMenu();
formEntryMenuDelegate.onCreateOptionsMenu(Robolectric.setupActivity(FragmentActivity.class).getMenuInflater(), menu);
formEntryMenuDelegate.onPrepareOptionsMenu(menu);
assertThat(menu.findItem(R.id.menu_record_audio).isChecked(), equalTo(false));
}
Aggregations