use of org.odk.collect.android.formentry.questions.AudioVideoImageTextLabel in project collect by opendatakit.
the class AudioVideoImageTextLabelTest method whenClickOneElementTwiceInSelectOneMode_shouldThatElementRemainSelected.
@Test
public void whenClickOneElementTwiceInSelectOneMode_shouldThatElementRemainSelected() {
File imageFile = mock(File.class);
when(imageFile.exists()).thenReturn(true);
AudioVideoImageTextLabel audioVideoImageTextLabel = new AudioVideoImageTextLabel(activity);
audioVideoImageTextLabel.setImage(imageFile, mock(ImageLoader.class));
audioVideoImageTextLabel.setTextView(new RadioButton(activity));
assertThat(((RadioButton) audioVideoImageTextLabel.getLabelTextView()).isChecked(), is(false));
// click on label
audioVideoImageTextLabel.getLabelTextView().performClick();
assertThat(((RadioButton) audioVideoImageTextLabel.getLabelTextView()).isChecked(), is(true));
// click on label again
audioVideoImageTextLabel.getLabelTextView().performClick();
assertThat(((RadioButton) audioVideoImageTextLabel.getLabelTextView()).isChecked(), is(true));
// click on image
audioVideoImageTextLabel.getImageView().performClick();
assertThat(((RadioButton) audioVideoImageTextLabel.getLabelTextView()).isChecked(), is(true));
// click on image again
audioVideoImageTextLabel.getImageView().performClick();
assertThat(((RadioButton) audioVideoImageTextLabel.getLabelTextView()).isChecked(), is(true));
}
use of org.odk.collect.android.formentry.questions.AudioVideoImageTextLabel in project collect by opendatakit.
the class ChoicesRecyclerViewTest method whenButtonsModeIsUsed_shouldViewAndItsElementsBeLongClickableToSupportRemovingAnswers.
@Test
public void whenButtonsModeIsUsed_shouldViewAndItsElementsBeLongClickableToSupportRemovingAnswers() {
List<SelectChoice> items = getTestChoices();
setUpFormEntryPrompt(items, "");
SelectItemClickListener listener = mock(SelectItemClickListener.class);
SelectMultipleListAdapter adapter = new SelectMultipleListAdapter(new ArrayList<>(), listener, activityController.get(), items, formEntryPrompt, null, null, 0, 1, false, mock(MediaUtils.class));
initRecyclerView(adapter, false);
AudioVideoImageTextLabel view = (AudioVideoImageTextLabel) getChoiceView(0);
File file = mock(File.class);
when(file.exists()).thenReturn(true);
view.setImage(file, mock(ImageLoader.class));
view.setVideo(file);
AudioHelper audioHelper = mock(AudioHelper.class);
MutableLiveData<Boolean> isPlaying = new MutableLiveData<>(false);
when(audioHelper.setAudio(any(AudioButton.class), any())).thenReturn(isPlaying);
view.setAudio("file://audio.mp3", audioHelper);
assertThat(view.isLongClickable(), is(true));
assertThat(view.getImageView().isLongClickable(), is(true));
assertThat(view.getVideoButton().isLongClickable(), is(true));
assertThat(view.getAudioButton().isLongClickable(), is(true));
assertThat(view.getLabelTextView().isLongClickable(), is(true));
}
use of org.odk.collect.android.formentry.questions.AudioVideoImageTextLabel in project collect by opendatakit.
the class SelectOneWidgetTest method usingReadOnlyOptionShouldMakeAllClickableElementsDisabled.
@Test
public void usingReadOnlyOptionShouldMakeAllClickableElementsDisabled() {
// No appearance
formEntryPrompt = new MockFormEntryPromptBuilder().withIndex("i am index").withSelectChoices(asList(new SelectChoice("1", "1"), new SelectChoice("2", "2"))).withReadOnly(true).build();
populateRecyclerView(getWidget());
AudioVideoImageTextLabel avitLabel = (AudioVideoImageTextLabel) getSpyWidget().binding.choicesRecyclerView.getLayoutManager().getChildAt(0);
assertThat(avitLabel.isEnabled(), is(Boolean.FALSE));
resetWidget();
// No-buttons appearance
formEntryPrompt = new MockFormEntryPromptBuilder(formEntryPrompt).withAppearance(Appearances.NO_BUTTONS).build();
populateRecyclerView(getWidget());
FrameLayout view = (FrameLayout) getSpyWidget().binding.choicesRecyclerView.getLayoutManager().getChildAt(0);
assertThat(view.isEnabled(), is(Boolean.FALSE));
}
Aggregations