Search in sources :

Example 6 with ReferenceManager

use of org.javarosa.core.reference.ReferenceManager 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));
}
Also used : SynchronousImageLoader(org.odk.collect.android.widgets.support.SynchronousImageLoader) Drawable(android.graphics.drawable.Drawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) RandomString(net.bytebuddy.utility.RandomString) AppDependencyModule(org.odk.collect.android.injection.config.AppDependencyModule) MockFormEntryPromptBuilder(org.odk.collect.android.support.MockFormEntryPromptBuilder) ImageView(android.widget.ImageView) BitmapDrawable(android.graphics.drawable.BitmapDrawable) ImageLoader(org.odk.collect.imageloader.ImageLoader) SynchronousImageLoader(org.odk.collect.android.widgets.support.SynchronousImageLoader) CollectHelpers.setupFakeReferenceManager(org.odk.collect.android.support.CollectHelpers.setupFakeReferenceManager) ReferenceManager(org.javarosa.core.reference.ReferenceManager) Pair(androidx.core.util.Pair) Test(org.junit.Test) FileWidgetTest(org.odk.collect.android.widgets.base.FileWidgetTest)

Example 7 with ReferenceManager

use of org.javarosa.core.reference.ReferenceManager in project collect by opendatakit.

the class PromptAutoplayerTest method setup.

@Before
public void setup() throws Exception {
    ReferenceManager referenceManager = setupFakeReferenceManager(REFERENCES);
    autoplayer = new PromptAutoplayer(audioHelper, referenceManager);
}
Also used : PromptAutoplayer(org.odk.collect.android.formentry.media.PromptAutoplayer) CollectHelpers.setupFakeReferenceManager(org.odk.collect.android.support.CollectHelpers.setupFakeReferenceManager) ReferenceManager(org.javarosa.core.reference.ReferenceManager) Before(org.junit.Before)

Example 8 with ReferenceManager

use of org.javarosa.core.reference.ReferenceManager in project collect by opendatakit.

the class ChoicesRecyclerViewTest method setUpReferenceManager.

private void setUpReferenceManager() throws InvalidReferenceException {
    referenceManager = mock(ReferenceManager.class);
    Reference reference = mock(Reference.class);
    when(reference.getLocalURI()).thenReturn("");
    when(referenceManager.deriveReference(any())).thenReturn(reference);
}
Also used : Reference(org.javarosa.core.reference.Reference) ReferenceManager(org.javarosa.core.reference.ReferenceManager)

Example 9 with ReferenceManager

use of org.javarosa.core.reference.ReferenceManager 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());
}
Also used : SynchronousImageLoader(org.odk.collect.android.widgets.support.SynchronousImageLoader) RandomString(net.bytebuddy.utility.RandomString) AppDependencyModule(org.odk.collect.android.injection.config.AppDependencyModule) MockFormEntryPromptBuilder(org.odk.collect.android.support.MockFormEntryPromptBuilder) ImageView(android.widget.ImageView) ImageLoader(org.odk.collect.imageloader.ImageLoader) SynchronousImageLoader(org.odk.collect.android.widgets.support.SynchronousImageLoader) CollectHelpers.setupFakeReferenceManager(org.odk.collect.android.support.CollectHelpers.setupFakeReferenceManager) ReferenceManager(org.javarosa.core.reference.ReferenceManager) Pair(androidx.core.util.Pair) Test(org.junit.Test) FileWidgetTest(org.odk.collect.android.widgets.base.FileWidgetTest)

Example 10 with ReferenceManager

use of org.javarosa.core.reference.ReferenceManager in project collect by opendatakit.

the class SelectImageMapWidgetTest method overrideDependencyModule.

private void overrideDependencyModule() throws Exception {
    ReferenceManager referenceManager = setupFakeReferenceManager(asList(new Pair<>("jr://images/body.svg", "body.svg")));
    CollectHelpers.overrideAppDependencyModule(new AppDependencyModule() {

        @Override
        public ReferenceManager providesReferenceManager() {
            return referenceManager;
        }
    });
}
Also used : AppDependencyModule(org.odk.collect.android.injection.config.AppDependencyModule) CollectHelpers.setupFakeReferenceManager(org.odk.collect.android.support.CollectHelpers.setupFakeReferenceManager) ReferenceManager(org.javarosa.core.reference.ReferenceManager) Pair(androidx.core.util.Pair)

Aggregations

ReferenceManager (org.javarosa.core.reference.ReferenceManager)10 CollectHelpers.setupFakeReferenceManager (org.odk.collect.android.support.CollectHelpers.setupFakeReferenceManager)9 AppDependencyModule (org.odk.collect.android.injection.config.AppDependencyModule)8 Pair (androidx.core.util.Pair)6 ImageView (android.widget.ImageView)4 RandomString (net.bytebuddy.utility.RandomString)4 Test (org.junit.Test)4 MockFormEntryPromptBuilder (org.odk.collect.android.support.MockFormEntryPromptBuilder)4 FileWidgetTest (org.odk.collect.android.widgets.base.FileWidgetTest)4 SynchronousImageLoader (org.odk.collect.android.widgets.support.SynchronousImageLoader)4 ImageLoader (org.odk.collect.imageloader.ImageLoader)4 Application (android.app.Application)3 BitmapDrawable (android.graphics.drawable.BitmapDrawable)3 Drawable (android.graphics.drawable.Drawable)3 Analytics (org.odk.collect.analytics.Analytics)3 AudioHelperFactory (org.odk.collect.android.formentry.media.AudioHelperFactory)3 Scheduler (org.odk.collect.async.Scheduler)3 SoftKeyboardController (org.odk.collect.android.utilities.SoftKeyboardController)2 Reference (org.javarosa.core.reference.Reference)1 Before (org.junit.Before)1