Search in sources :

Example 11 with AudioVideoImageTextLabel

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));
}
Also used : RadioButton(android.widget.RadioButton) AudioVideoImageTextLabel(org.odk.collect.android.formentry.questions.AudioVideoImageTextLabel) ImageLoader(org.odk.collect.imageloader.ImageLoader) File(java.io.File) Test(org.junit.Test)

Example 12 with AudioVideoImageTextLabel

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));
}
Also used : SelectChoice(org.javarosa.core.model.SelectChoice) MediaUtils(org.odk.collect.android.utilities.MediaUtils) SelectItemClickListener(org.odk.collect.android.listeners.SelectItemClickListener) AudioHelper(org.odk.collect.android.audio.AudioHelper) SelectMultipleListAdapter(org.odk.collect.android.adapters.SelectMultipleListAdapter) MutableLiveData(androidx.lifecycle.MutableLiveData) AudioButton(org.odk.collect.android.audio.AudioButton) AudioVideoImageTextLabel(org.odk.collect.android.formentry.questions.AudioVideoImageTextLabel) ImageLoader(org.odk.collect.imageloader.ImageLoader) File(java.io.File) Test(org.junit.Test)

Example 13 with AudioVideoImageTextLabel

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));
}
Also used : SelectChoice(org.javarosa.core.model.SelectChoice) FrameLayout(android.widget.FrameLayout) MockFormEntryPromptBuilder(org.odk.collect.android.support.MockFormEntryPromptBuilder) AudioVideoImageTextLabel(org.odk.collect.android.formentry.questions.AudioVideoImageTextLabel) GeneralSelectOneWidgetTest(org.odk.collect.android.widgets.base.GeneralSelectOneWidgetTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)13 AudioVideoImageTextLabel (org.odk.collect.android.formentry.questions.AudioVideoImageTextLabel)13 File (java.io.File)7 ImageLoader (org.odk.collect.imageloader.ImageLoader)6 MutableLiveData (androidx.lifecycle.MutableLiveData)3 SelectChoice (org.javarosa.core.model.SelectChoice)3 AudioButton (org.odk.collect.android.audio.AudioButton)3 CheckBox (android.widget.CheckBox)2 FrameLayout (android.widget.FrameLayout)2 RadioButton (android.widget.RadioButton)2 MockFormEntryPromptBuilder (org.odk.collect.android.support.MockFormEntryPromptBuilder)2 MediaUtils (org.odk.collect.android.utilities.MediaUtils)2 SelectMultipleListAdapter (org.odk.collect.android.adapters.SelectMultipleListAdapter)1 AudioHelper (org.odk.collect.android.audio.AudioHelper)1 SelectItemClickListener (org.odk.collect.android.listeners.SelectItemClickListener)1 GeneralSelectMultiWidgetTest (org.odk.collect.android.widgets.base.GeneralSelectMultiWidgetTest)1 GeneralSelectOneWidgetTest (org.odk.collect.android.widgets.base.GeneralSelectOneWidgetTest)1