use of org.odk.collect.android.support.MockFormEntryPromptBuilder in project collect by opendatakit.
the class ImageWidgetTest method whenPromptHasCurrentAnswer_showsInImageView.
@Test
public void whenPromptHasCurrentAnswer_showsInImageView() throws Exception {
CollectHelpers.overrideAppDependencyModule(new AppDependencyModule() {
@Override
public ImageLoader providesImageLoader() {
return new SynchronousImageLoader();
}
});
String imagePath = File.createTempFile("current", ".bmp").getAbsolutePath();
currentFile = new File(imagePath);
formEntryPrompt = new MockFormEntryPromptBuilder().withAnswerDisplayText(DrawWidgetTest.USER_SPECIFIED_IMAGE_ANSWER).build();
ImageWidget 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 ImageWidgetTest method whenPromptHasDefaultAnswer_doesNotShow.
@Test
public void whenPromptHasDefaultAnswer_doesNotShow() 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();
ImageWidget widget = createWidget();
ImageView imageView = widget.getImageView();
assertThat(imageView, nullValue());
}
use of org.odk.collect.android.support.MockFormEntryPromptBuilder in project collect by opendatakit.
the class RankingWidgetTest method whenSpacesInUnderlyingValuesExist_shouldAppropriateWarningBeDisplayed.
@Test
public void whenSpacesInUnderlyingValuesExist_shouldAppropriateWarningBeDisplayed() {
formEntryPrompt = new MockFormEntryPromptBuilder().withSelectChoices(asList(new SelectChoice("a", "a a"), new SelectChoice("a", "b b"))).build();
TextView warningTv = getWidget().findViewById(R.id.warning_text);
assertThat(warningTv.getVisibility(), is(View.VISIBLE));
assertThat(warningTv.getText(), is("Warning: underlying values a a, b b have spaces"));
}
use of org.odk.collect.android.support.MockFormEntryPromptBuilder in project collect by opendatakit.
the class WidgetFactoryTest method testCreatingSelectMultipleListNoLabelWidget.
@Test
public void testCreatingSelectMultipleListNoLabelWidget() {
FormEntryPrompt prompt = new MockFormEntryPromptBuilder().withControlType(Constants.CONTROL_SELECT_MULTI).withAppearance("something LisT-nOLabeL something").build();
QuestionWidget widget = widgetFactory.createWidgetFromPrompt(prompt, null);
assertThat(widget, instanceOf(ListMultiWidget.class));
assertThat(((ListMultiWidget) widget).shouldDisplayLabel(), is(false));
}
use of org.odk.collect.android.support.MockFormEntryPromptBuilder in project collect by opendatakit.
the class WidgetFactoryTest method testCreatingSelectMultipleWidget.
@Test
public void testCreatingSelectMultipleWidget() {
FormEntryPrompt prompt = new MockFormEntryPromptBuilder().withControlType(Constants.CONTROL_SELECT_MULTI).withAppearance("").build();
QuestionWidget widget = widgetFactory.createWidgetFromPrompt(prompt, null);
assertThat(widget, instanceOf(SelectMultiWidget.class));
prompt = new MockFormEntryPromptBuilder().withControlType(Constants.CONTROL_SELECT_MULTI).withAppearance("lorem ipsum").build();
widget = widgetFactory.createWidgetFromPrompt(prompt, null);
assertThat(widget, instanceOf(SelectMultiWidget.class));
}
Aggregations