use of org.odk.collect.audioclips.Clip in project collect by opendatakit.
the class PromptAutoplayerTest method whenPromptHasAutoplayAudio_playsAudio.
@Test
public void whenPromptHasAutoplayAudio_playsAudio() {
FormEntryPrompt prompt = new MockFormEntryPromptBuilder().withAudioURI(REFERENCES.get(0).first).withAdditionalAttribute("autoplay", "audio").build();
assertThat(autoplayer.autoplayIfNeeded(prompt), equalTo(true));
verify(audioHelper).playInOrder(asList(new Clip(prompt.getIndex().toString(), REFERENCES.get(0).second)));
}
use of org.odk.collect.audioclips.Clip in project collect by opendatakit.
the class PromptAutoplayerTest method whenPromptHasAutoplayAudio_andIsSelectOne_withMinimalAppearance_playsPromptAudio.
@Test
public void whenPromptHasAutoplayAudio_andIsSelectOne_withMinimalAppearance_playsPromptAudio() throws Exception {
FormEntryPrompt prompt = new MockFormEntryPromptBuilder().withControlType(Constants.CONTROL_SELECT_ONE).withAppearance(MINIMAL).withAudioURI(REFERENCES.get(0).first).withAdditionalAttribute("autoplay", "audio").withSelectChoices(asList(new SelectChoice("1", "1"), new SelectChoice("2", "2"))).withSpecialFormSelectChoiceText(asList(new Pair<>(FormEntryCaption.TEXT_FORM_AUDIO, REFERENCES.get(1).first), new Pair<>(FormEntryCaption.TEXT_FORM_AUDIO, REFERENCES.get(2).first))).build();
assertThat(autoplayer.autoplayIfNeeded(prompt), equalTo(true));
verify(audioHelper).playInOrder(asList(new Clip(prompt.getIndex().toString(), REFERENCES.get(0).second)));
}
use of org.odk.collect.audioclips.Clip in project collect by opendatakit.
the class QuestionWidgetTest method whenQuestionHasAudio_audioButtonUsesIndexAsClipID.
@Test
public void whenQuestionHasAudio_audioButtonUsesIndexAsClipID() throws Exception {
FormEntryPrompt prompt = new MockFormEntryPromptBuilder().withIndex("i am index").withAudioURI("ref").build();
WidgetTestActivity activity = CollectHelpers.createThemedActivity(WidgetTestActivity.class);
TestWidget widget = new TestWidget(activity, new QuestionDetails(prompt));
AudioButton audioButton = widget.getAudioVideoImageTextLabel().findViewById(R.id.audioButton);
verify(audioHelper).setAudio(audioButton, new Clip("i am index", "blah.mp3"));
}
use of org.odk.collect.audioclips.Clip in project collect by opendatakit.
the class PromptAutoplayer method getSelectClips.
private List<Clip> getSelectClips(FormEntryPrompt prompt) {
if (appearanceDoesNotShowControls(Appearances.getSanitizedAppearanceHint(prompt))) {
return emptyList();
}
List<Clip> selectClips = new ArrayList<>();
int controlType = prompt.getControlType();
if (controlType == Constants.CONTROL_SELECT_ONE || controlType == Constants.CONTROL_SELECT_MULTI) {
List<SelectChoice> selectChoices = prompt.getSelectChoices();
for (SelectChoice choice : selectChoices) {
String selectURI = getPlayableAudioURI(prompt, choice, referenceManager);
if (selectURI != null) {
Clip clip = new Clip(getClipID(prompt, choice), selectURI);
selectClips.add(clip);
}
}
}
return selectClips;
}
use of org.odk.collect.audioclips.Clip in project collect by opendatakit.
the class SelectMultiWidgetTest method whenChoicesHaveAudio_audioButtonUsesIndexAsClipID.
@Test
public void whenChoicesHaveAudio_audioButtonUsesIndexAsClipID() throws Exception {
formEntryPrompt = new MockFormEntryPromptBuilder().withIndex("i am index").withSelectChoices(asList(new SelectChoice("1", "1"), new SelectChoice("2", "2"))).withSpecialFormSelectChoiceText(asList(new Pair<>(FormEntryCaption.TEXT_FORM_AUDIO, REFERENCES.get(0).first), new Pair<>(FormEntryCaption.TEXT_FORM_AUDIO, REFERENCES.get(1).first))).build();
populateRecyclerView(getWidget());
verify(audioHelper).setAudio(any(AudioButton.class), eq(new Clip("i am index 0", REFERENCES.get(0).second)));
verify(audioHelper).setAudio(any(AudioButton.class), eq(new Clip("i am index 1", REFERENCES.get(1).second)));
}
Aggregations