use of org.odk.collect.android.audio.AudioHelper in project collect by opendatakit.
the class ChoicesRecyclerViewTest method whenChoiceSelectedInSelectOneNoButtonsMode_shouldTryToPlayAudio.
@Test
public void whenChoiceSelectedInSelectOneNoButtonsMode_shouldTryToPlayAudio() {
List<SelectChoice> items = getTestChoices();
setUpFormEntryPrompt(items, "no-buttons");
SelectItemClickListener listener = mock(SelectItemClickListener.class);
AudioHelper audioHelper = mock(AudioHelper.class);
SelectOneListAdapter adapter = spy(new SelectOneListAdapter(null, listener, activityController.get(), items, formEntryPrompt, null, audioHelper, 0, 1, true, mock(MediaUtils.class)));
initRecyclerView(adapter, false);
// Select AAA
clickChoice(0);
verify(adapter).playAudio(any());
}
use of org.odk.collect.android.audio.AudioHelper in project collect by opendatakit.
the class ChoicesRecyclerViewTest method whenChoiceSelectedInSelectMultiNoButtonsMode_shouldTryToPlayAudio.
@Test
public void whenChoiceSelectedInSelectMultiNoButtonsMode_shouldTryToPlayAudio() {
List<SelectChoice> items = getTestChoices();
setUpFormEntryPrompt(items, "no-buttons");
SelectItemClickListener listener = mock(SelectItemClickListener.class);
AudioHelper audioHelper = mock(AudioHelper.class);
SelectMultipleListAdapter adapter = spy(new SelectMultipleListAdapter(new ArrayList<>(), listener, activityController.get(), items, formEntryPrompt, null, audioHelper, 0, 1, true, mock(MediaUtils.class)));
initRecyclerView(adapter, false);
// Select AAA
clickChoice(0);
verify(adapter).playAudio(any());
}
use of org.odk.collect.android.audio.AudioHelper in project collect by opendatakit.
the class ChoicesRecyclerViewTest method setUp.
@Before
public void setUp() throws InvalidReferenceException {
audioHelper = mock(AudioHelper.class);
activityController = CollectHelpers.buildThemedActivity(WidgetTestActivity.class);
Activity activity = activityController.get();
FrameLayout frameLayout = new FrameLayout(activity);
activity.setContentView(frameLayout);
activityController.create().start().visible();
recyclerView = new ChoicesRecyclerView(activity);
frameLayout.addView(recyclerView);
populateRecyclerView(recyclerView);
setUpReferenceManager();
}
use of org.odk.collect.android.audio.AudioHelper 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