use of org.robolectric.fakes.RoboMenu in project collect by opendatakit.
the class FormEntryMenuDelegateTest method onItemSelected_whenPreferences_startsPreferencesActivityWithChangeSettingsRequest.
@Test
public void onItemSelected_whenPreferences_startsPreferencesActivityWithChangeSettingsRequest() {
RoboMenu menu = new RoboMenu();
formEntryMenuDelegate.onCreateOptionsMenu(Robolectric.setupActivity(FragmentActivity.class).getMenuInflater(), menu);
formEntryMenuDelegate.onPrepareOptionsMenu(menu);
formEntryMenuDelegate.onOptionsItemSelected(new RoboMenuItem(R.id.menu_preferences));
ShadowActivity.IntentForResult nextStartedActivity = shadowOf(activity).getNextStartedActivityForResult();
assertThat(nextStartedActivity, not(nullValue()));
assertThat(nextStartedActivity.intent.getComponent().getClassName(), is(ProjectPreferencesActivity.class.getName()));
assertThat(nextStartedActivity.requestCode, is(ApplicationConstants.RequestCodes.CHANGE_SETTINGS));
}
use of org.robolectric.fakes.RoboMenu in project collect by opendatakit.
the class FormEntryMenuDelegateTest method onPrepare_whenFormControllerIsNull_hidesAddRepeat.
@Test
public void onPrepare_whenFormControllerIsNull_hidesAddRepeat() {
formEntryMenuDelegate.formLoaded(null);
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(false));
}
use of org.robolectric.fakes.RoboMenu in project collect by opendatakit.
the class FormEntryMenuDelegateTest method onPrepare_whenFormDoesNotHaveBackgroundRecording_hidesRecordAudio.
@Test
public void onPrepare_whenFormDoesNotHaveBackgroundRecording_hidesRecordAudio() {
when(formEntryViewModel.hasBackgroundRecording()).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).isVisible(), equalTo(false));
}
use of org.robolectric.fakes.RoboMenu in project collect by opendatakit.
the class FormEntryMenuDelegateTest method onItemSelected_whenRecordAudio_whenBackgroundRecordingDisabled_enablesBackgroundRecording_andShowsDialog.
@Test
public void onItemSelected_whenRecordAudio_whenBackgroundRecordingDisabled_enablesBackgroundRecording_andShowsDialog() {
RoboMenu menu = new RoboMenu();
formEntryMenuDelegate.onCreateOptionsMenu(Robolectric.setupActivity(FragmentActivity.class).getMenuInflater(), menu);
formEntryMenuDelegate.onPrepareOptionsMenu(menu);
when(backgroundAudioViewModel.isBackgroundRecordingEnabled()).thenReturn(new MutableNonNullLiveData<>(false));
formEntryMenuDelegate.onOptionsItemSelected(new RoboMenuItem(R.id.menu_record_audio));
verify(backgroundAudioViewModel).setBackgroundRecordingEnabled(true);
}
use of org.robolectric.fakes.RoboMenu in project collect by opendatakit.
the class FormEntryMenuDelegateTest method onPrepare_whenBackgroundRecodingEnabled_checksRecordAudio.
@Test
public void onPrepare_whenBackgroundRecodingEnabled_checksRecordAudio() {
when(backgroundAudioViewModel.isBackgroundRecordingEnabled()).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).isChecked(), equalTo(true));
}
Aggregations