Search in sources :

Example 6 with AudioVideoImageTextLabel

use of org.odk.collect.android.formentry.questions.AudioVideoImageTextLabel in project collect by opendatakit.

the class AudioVideoImageTextLabelTest method withBlankText_hidesTextLabel.

@Test
public void withBlankText_hidesTextLabel() {
    AudioVideoImageTextLabel audioVideoImageTextLabel = new AudioVideoImageTextLabel(activity);
    audioVideoImageTextLabel.setText("", false, 16);
    assertThat(audioVideoImageTextLabel.getLabelTextView().getVisibility(), equalTo(View.GONE));
}
Also used : AudioVideoImageTextLabel(org.odk.collect.android.formentry.questions.AudioVideoImageTextLabel) Test(org.junit.Test)

Example 7 with AudioVideoImageTextLabel

use of org.odk.collect.android.formentry.questions.AudioVideoImageTextLabel in project collect by opendatakit.

the class AudioVideoImageTextLabelTest method bothClickingLabelAndImageView_shouldSelectOptionInSelectMultiMode.

@Test
public void bothClickingLabelAndImageView_shouldSelectOptionInSelectMultiMode() {
    File imageFile = mock(File.class);
    when(imageFile.exists()).thenReturn(true);
    AudioVideoImageTextLabel audioVideoImageTextLabel = new AudioVideoImageTextLabel(activity);
    audioVideoImageTextLabel.setImage(imageFile, mock(ImageLoader.class));
    audioVideoImageTextLabel.setTextView(new CheckBox(activity));
    assertThat(((CheckBox) audioVideoImageTextLabel.getLabelTextView()).isChecked(), is(false));
    // click on label
    audioVideoImageTextLabel.getLabelTextView().performClick();
    assertThat(((CheckBox) audioVideoImageTextLabel.getLabelTextView()).isChecked(), is(true));
    // click on image
    audioVideoImageTextLabel.getImageView().performClick();
    assertThat(((CheckBox) audioVideoImageTextLabel.getLabelTextView()).isChecked(), is(false));
}
Also used : CheckBox(android.widget.CheckBox) AudioVideoImageTextLabel(org.odk.collect.android.formentry.questions.AudioVideoImageTextLabel) ImageLoader(org.odk.collect.imageloader.ImageLoader) File(java.io.File) Test(org.junit.Test)

Example 8 with AudioVideoImageTextLabel

use of org.odk.collect.android.formentry.questions.AudioVideoImageTextLabel in project collect by opendatakit.

the class AudioVideoImageTextLabelTest method withText_andAudio_playingAudio_highlightsText.

@Test
public void withText_andAudio_playingAudio_highlightsText() {
    MutableLiveData<Boolean> isPlaying = new MutableLiveData<>();
    when(audioHelper.setAudio(any(AudioButton.class), any())).thenReturn(isPlaying);
    AudioVideoImageTextLabel audioVideoImageTextLabel = new AudioVideoImageTextLabel(activity);
    audioVideoImageTextLabel.setText("blah", false, 16);
    audioVideoImageTextLabel.setAudio("file://audio.mp3", audioHelper);
    int originalTextColor = audioVideoImageTextLabel.getLabelTextView().getCurrentTextColor();
    isPlaying.setValue(true);
    int textColor = audioVideoImageTextLabel.getLabelTextView().getCurrentTextColor();
    assertThat(textColor, not(equalTo(originalTextColor)));
    isPlaying.setValue(false);
    textColor = audioVideoImageTextLabel.getLabelTextView().getCurrentTextColor();
    assertThat(textColor, equalTo(originalTextColor));
}
Also used : MutableLiveData(androidx.lifecycle.MutableLiveData) AudioButton(org.odk.collect.android.audio.AudioButton) AudioVideoImageTextLabel(org.odk.collect.android.formentry.questions.AudioVideoImageTextLabel) Test(org.junit.Test)

Example 9 with AudioVideoImageTextLabel

use of org.odk.collect.android.formentry.questions.AudioVideoImageTextLabel in project collect by opendatakit.

the class AudioVideoImageTextLabelTest method whenClickOneElementTwiceInSelectMultiMode_shouldThatElementBeUnSelected.

@Test
public void whenClickOneElementTwiceInSelectMultiMode_shouldThatElementBeUnSelected() {
    File imageFile = mock(File.class);
    when(imageFile.exists()).thenReturn(true);
    AudioVideoImageTextLabel audioVideoImageTextLabel = new AudioVideoImageTextLabel(activity);
    audioVideoImageTextLabel.setImage(imageFile, mock(ImageLoader.class));
    audioVideoImageTextLabel.setTextView(new CheckBox(activity));
    assertThat(((CheckBox) audioVideoImageTextLabel.getLabelTextView()).isChecked(), is(false));
    // click on label
    audioVideoImageTextLabel.getLabelTextView().performClick();
    assertThat(((CheckBox) audioVideoImageTextLabel.getLabelTextView()).isChecked(), is(true));
    // click on label again
    audioVideoImageTextLabel.getLabelTextView().performClick();
    assertThat(((CheckBox) audioVideoImageTextLabel.getLabelTextView()).isChecked(), is(false));
    // click on image
    audioVideoImageTextLabel.getImageView().performClick();
    assertThat(((CheckBox) audioVideoImageTextLabel.getLabelTextView()).isChecked(), is(true));
    // click on image again
    audioVideoImageTextLabel.getImageView().performClick();
    assertThat(((CheckBox) audioVideoImageTextLabel.getLabelTextView()).isChecked(), is(false));
}
Also used : CheckBox(android.widget.CheckBox) AudioVideoImageTextLabel(org.odk.collect.android.formentry.questions.AudioVideoImageTextLabel) ImageLoader(org.odk.collect.imageloader.ImageLoader) File(java.io.File) Test(org.junit.Test)

Example 10 with AudioVideoImageTextLabel

use of org.odk.collect.android.formentry.questions.AudioVideoImageTextLabel in project collect by opendatakit.

the class AudioVideoImageTextLabelTest method withText_andAudio_showsTextAndAudioButton.

@Test
public void withText_andAudio_showsTextAndAudioButton() {
    MutableLiveData<Boolean> isPlaying = new MutableLiveData<>(false);
    when(audioHelper.setAudio(any(AudioButton.class), any())).thenReturn(isPlaying);
    AudioVideoImageTextLabel label = new AudioVideoImageTextLabel(activity);
    label.setText("blah", false, 16);
    label.setAudio("file://audio.mp3", audioHelper);
    assertThat(label.getLabelTextView().getVisibility(), equalTo(VISIBLE));
    assertThat(label.getLabelTextView().getText().toString(), equalTo("blah"));
    assertThat(label.findViewById(R.id.audioButton).getVisibility(), equalTo(VISIBLE));
}
Also used : MutableLiveData(androidx.lifecycle.MutableLiveData) AudioButton(org.odk.collect.android.audio.AudioButton) AudioVideoImageTextLabel(org.odk.collect.android.formentry.questions.AudioVideoImageTextLabel) 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