use of org.odk.collect.android.formentry.questions.AudioVideoImageTextLabel in project collect by opendatakit.
the class AudioVideoImageTextLabelTest method bothClickingLabelAndImageView_shouldSelectOptionInSelectOneMode.
@Test
public void bothClickingLabelAndImageView_shouldSelectOptionInSelectOneMode() {
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));
// clear answer
((RadioButton) audioVideoImageTextLabel.getLabelTextView()).setChecked(false);
assertThat(((RadioButton) audioVideoImageTextLabel.getLabelTextView()).isChecked(), is(false));
// click on image
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 AudioVideoImageTextLabelTest method whenImageFileDoesNotExist_ShouldAnAppropriateMessageBeDisplayed.
@Test
public void whenImageFileDoesNotExist_ShouldAnAppropriateMessageBeDisplayed() {
File imageFile = new File("file://image.png");
AudioVideoImageTextLabel audioVideoImageTextLabel = new AudioVideoImageTextLabel(activity);
audioVideoImageTextLabel.setImage(imageFile, mock(ImageLoader.class));
assertThat(audioVideoImageTextLabel.getMissingImage().getVisibility(), is(VISIBLE));
assertThat(audioVideoImageTextLabel.getMissingImage().getText().toString(), is("File: file:/image.png is missing."));
}
use of org.odk.collect.android.formentry.questions.AudioVideoImageTextLabel in project collect by opendatakit.
the class AudioVideoImageTextLabelTest method withNullText_hidesTextLabel.
@Test
public void withNullText_hidesTextLabel() {
AudioVideoImageTextLabel audioVideoImageTextLabel = new AudioVideoImageTextLabel(activity);
audioVideoImageTextLabel.setText(null, false, 16);
assertThat(audioVideoImageTextLabel.getLabelTextView().getVisibility(), equalTo(View.GONE));
}
use of org.odk.collect.android.formentry.questions.AudioVideoImageTextLabel in project collect by opendatakit.
the class SelectMultiWidgetTest 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());
SelectMultiWidget a = getSpyWidget();
AudioVideoImageTextLabel avitLabel = (AudioVideoImageTextLabel) a.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));
}
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));
}
Aggregations