use of org.odk.collect.android.support.MockFormEntryPromptBuilder in project collect by opendatakit.
the class WidgetFactoryTest method testCreatingSelectMultipleListWidget.
@Test
public void testCreatingSelectMultipleListWidget() {
FormEntryPrompt prompt = new MockFormEntryPromptBuilder().withControlType(Constants.CONTROL_SELECT_MULTI).withAppearance("something LisT something").build();
QuestionWidget widget = widgetFactory.createWidgetFromPrompt(prompt, null);
assertThat(widget, instanceOf(ListMultiWidget.class));
assertThat(((ListMultiWidget) widget).shouldDisplayLabel(), is(true));
}
use of org.odk.collect.android.support.MockFormEntryPromptBuilder in project collect by opendatakit.
the class WidgetFactoryTest method testCreatingLikertWidget.
@Test
public void testCreatingLikertWidget() {
FormEntryPrompt prompt = new MockFormEntryPromptBuilder().withControlType(Constants.CONTROL_SELECT_ONE).withAppearance("something lIkErt something").build();
QuestionWidget widget = widgetFactory.createWidgetFromPrompt(prompt, null);
assertThat(widget, instanceOf(LikertWidget.class));
}
use of org.odk.collect.android.support.MockFormEntryPromptBuilder in project collect by opendatakit.
the class SignatureWidgetTest method whenPromptHasDefaultAnswer_showsInImageView.
@Test
public void whenPromptHasDefaultAnswer_showsInImageView() throws Exception {
String imagePath = File.createTempFile("default", ".bmp").getAbsolutePath();
ReferenceManager referenceManager = setupFakeReferenceManager(singletonList(new Pair<>(DrawWidgetTest.DEFAULT_IMAGE_ANSWER, imagePath)));
CollectHelpers.overrideAppDependencyModule(new AppDependencyModule() {
@Override
public ReferenceManager providesReferenceManager() {
return referenceManager;
}
@Override
public ImageLoader providesImageLoader() {
return new SynchronousImageLoader();
}
});
formEntryPrompt = new MockFormEntryPromptBuilder().withAnswerDisplayText(DrawWidgetTest.DEFAULT_IMAGE_ANSWER).build();
SignatureWidget widget = createWidget();
ImageView imageView = widget.getImageView();
assertThat(imageView, notNullValue());
Drawable drawable = imageView.getDrawable();
assertThat(drawable, notNullValue());
String loadedPath = shadowOf(((BitmapDrawable) drawable).getBitmap()).getCreatedFromPath();
assertThat(loadedPath, equalTo(imagePath));
}
use of org.odk.collect.android.support.MockFormEntryPromptBuilder in project collect by opendatakit.
the class PromptAutoplayerTest method whenPromptHasNoAutoplay_doesNotLogEvents.
@Test
public void whenPromptHasNoAutoplay_doesNotLogEvents() {
FormEntryPrompt prompt = new MockFormEntryPromptBuilder().withAdditionalAttribute("autoplay", null).build();
autoplayer.autoplayIfNeeded(prompt);
verify(analytics, never()).logEvent(any(), any());
verify(analytics, never()).logEvent(any(), any(), any());
}
use of org.odk.collect.android.support.MockFormEntryPromptBuilder in project collect by opendatakit.
the class PromptAutoplayerTest method whenPromptHasAutoplayAudio_andIsSelectOne_playsAudioInOrder.
@Test
public void whenPromptHasAutoplayAudio_andIsSelectOne_playsAudioInOrder() {
FormEntryPrompt prompt = new MockFormEntryPromptBuilder().withControlType(Constants.CONTROL_SELECT_ONE).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), new Clip(prompt.getIndex().toString() + " 0", REFERENCES.get(1).second), new Clip(prompt.getIndex().toString() + " 1", REFERENCES.get(2).second)));
}
Aggregations