use of org.odk.collect.imageloader.ImageLoader 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.imageloader.ImageLoader 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.imageloader.ImageLoader in project collect by opendatakit.
the class SignatureWidgetTest 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();
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));
}
Aggregations