use of org.javarosa.core.reference.ReferenceManager in project collect by opendatakit.
the class AnnotateWidgetTest 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();
AnnotateWidget 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.javarosa.core.reference.ReferenceManager in project collect by opendatakit.
the class SelectOneWidgetTest method overrideDependencyModule.
private void overrideDependencyModule() throws Exception {
ReferenceManager referenceManager = setupFakeReferenceManager(REFERENCES);
CollectHelpers.overrideAppDependencyModule(new AppDependencyModule() {
@Override
public ReferenceManager providesReferenceManager() {
return referenceManager;
}
@Override
public AudioHelperFactory providesAudioHelperFactory(Scheduler scheduler) {
return context -> audioHelper;
}
@Override
public Analytics providesAnalytics(Application application) {
return analytics;
}
@Override
public SoftKeyboardController provideSoftKeyboardController() {
return mock(SoftKeyboardController.class);
}
});
}
use of org.javarosa.core.reference.ReferenceManager in project collect by opendatakit.
the class SelectMultiWidgetTest method overrideDependencyModule.
private void overrideDependencyModule() throws Exception {
ReferenceManager referenceManager = setupFakeReferenceManager(REFERENCES);
CollectHelpers.overrideAppDependencyModule(new AppDependencyModule() {
@Override
public ReferenceManager providesReferenceManager() {
return referenceManager;
}
@Override
public AudioHelperFactory providesAudioHelperFactory(Scheduler scheduler) {
return context -> audioHelper;
}
@Override
public Analytics providesAnalytics(Application application) {
return analytics;
}
@Override
public SoftKeyboardController provideSoftKeyboardController() {
return mock(SoftKeyboardController.class);
}
});
}
use of org.javarosa.core.reference.ReferenceManager in project collect by opendatakit.
the class DrawWidgetTest 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(DEFAULT_IMAGE_ANSWER).build();
DrawWidget 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.javarosa.core.reference.ReferenceManager in project collect by opendatakit.
the class QuestionWidgetTest method overrideDependencyModule.
private void overrideDependencyModule() throws Exception {
ReferenceManager referenceManager = setupFakeReferenceManager(asList(new Pair<>("ref", "blah.mp3")));
CollectHelpers.overrideAppDependencyModule(new AppDependencyModule() {
@Override
public ReferenceManager providesReferenceManager() {
return referenceManager;
}
@Override
public AudioHelperFactory providesAudioHelperFactory(Scheduler scheduler) {
return context -> audioHelper;
}
@Override
public Analytics providesAnalytics(Application application) {
return analytics;
}
});
}
Aggregations