use of org.robolectric.fakes.RoboMenuItem in project collect by opendatakit.
the class FormEntryMenuDelegateTest method onItemSelected_whenAddRepeat_savesScreenAnswers.
@Test
public void onItemSelected_whenAddRepeat_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_add_repeat));
verify(formSaveViewModel).saveAnswersForScreen(answers);
}
use of org.robolectric.fakes.RoboMenuItem in project collect by opendatakit.
the class FormEntryMenuDelegateTest method onItemSelected_whenAddRepeat_whenRecording_showsWarning.
@Test
public void onItemSelected_whenAddRepeat_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_add_repeat));
verify(formEntryViewModel, never()).promptForNewRepeat();
RecordingWarningDialogFragment dialog = getFragmentByClass(activity.getSupportFragmentManager(), RecordingWarningDialogFragment.class);
assertThat(dialog, is(notNullValue()));
assertThat(dialog.getDialog().isShowing(), is(true));
}
use of org.robolectric.fakes.RoboMenuItem in project collect by opendatakit.
the class BlankFormListMenuDelegateTest method onOptionsSelected_forSync_showsSuccessToast.
@Test
public void onOptionsSelected_forSync_showsSuccessToast() {
when(viewModel.syncWithServer()).thenReturn(new MutableLiveData<>(true));
BlankFormListMenuDelegate menuDelegate = new BlankFormListMenuDelegate(activity, viewModel, networkStateProvider);
menuDelegate.onOptionsItemSelected(new RoboMenuItem(R.id.menu_refresh));
assertThat(ShadowToast.getTextOfLatestToast(), is(activity.getString(R.string.form_update_succeeded)));
}
use of org.robolectric.fakes.RoboMenuItem in project materialistic by hidroh.
the class WebFragmentTest method testWebControls.
@SuppressLint("NewApi")
@Test
public void testWebControls() {
ShadowLocalBroadcastManager.getInstance(activity).sendBroadcast(new Intent(WebFragment.ACTION_FULLSCREEN).putExtra(WebFragment.EXTRA_FULLSCREEN, true));
ShadowWebView shadowWebView = (ShadowWebView) ShadowExtractor.extract(activity.findViewById(R.id.web_view));
activity.findViewById(R.id.button_more).performClick();
shadowOf(ShadowPopupMenu.getLatestPopupMenu()).getOnMenuItemClickListener().onMenuItemClick(new RoboMenuItem(R.id.menu_zoom_in));
assertThat(shadowWebView.getZoomDegree()).isEqualTo(1);
activity.findViewById(R.id.button_more).performClick();
shadowOf(ShadowPopupMenu.getLatestPopupMenu()).getOnMenuItemClickListener().onMenuItemClick(new RoboMenuItem(R.id.menu_zoom_out));
assertThat(shadowWebView.getZoomDegree()).isEqualTo(0);
activity.findViewById(R.id.button_forward).performClick();
assertThat(shadowWebView.getPageIndex()).isEqualTo(1);
activity.findViewById(R.id.button_back).performClick();
assertThat(shadowWebView.getPageIndex()).isEqualTo(0);
}
use of org.robolectric.fakes.RoboMenuItem in project materialistic by hidroh.
the class WebFragmentTest method testReadabilityToggle.
@Test
public void testReadabilityToggle() {
activity.fragment.onOptionsItemSelected(new RoboMenuItem(R.id.menu_readability));
verify(readabilityClient).parse(any(), eq("http://example.com"), any());
}
Aggregations