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));
}
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));
}
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));
}
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));
}
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));
}
Aggregations