Search in sources :

Example 51 with MockFormEntryPromptBuilder

use of org.odk.collect.android.support.MockFormEntryPromptBuilder in project collect by opendatakit.

the class WidgetFactoryTest method testCreatingSelectOneListNoLabelWidget.

@Test
public void testCreatingSelectOneListNoLabelWidget() {
    FormEntryPrompt prompt = new MockFormEntryPromptBuilder().withControlType(Constants.CONTROL_SELECT_ONE).withAppearance("something LisT-nOLabeL something").build();
    QuestionWidget widget = widgetFactory.createWidgetFromPrompt(prompt, null);
    assertThat(widget, instanceOf(ListWidget.class));
    assertThat(((ListWidget) widget).shouldDisplayLabel(), is(false));
}
Also used : FormEntryPrompt(org.javarosa.form.api.FormEntryPrompt) ListWidget(org.odk.collect.android.widgets.items.ListWidget) MockFormEntryPromptBuilder(org.odk.collect.android.support.MockFormEntryPromptBuilder) Test(org.junit.Test)

Example 52 with MockFormEntryPromptBuilder

use of org.odk.collect.android.support.MockFormEntryPromptBuilder in project collect by opendatakit.

the class WidgetFactoryTest method testCreatingSelectOneWidget.

@Test
public void testCreatingSelectOneWidget() {
    FormEntryPrompt prompt = new MockFormEntryPromptBuilder().withControlType(Constants.CONTROL_SELECT_ONE).withAppearance("").build();
    QuestionWidget widget = widgetFactory.createWidgetFromPrompt(prompt, null);
    assertThat(widget, instanceOf(SelectOneWidget.class));
    prompt = new MockFormEntryPromptBuilder().withControlType(Constants.CONTROL_SELECT_ONE).withAppearance("lorem ipsum").build();
    widget = widgetFactory.createWidgetFromPrompt(prompt, null);
    assertThat(widget, instanceOf(SelectOneWidget.class));
}
Also used : FormEntryPrompt(org.javarosa.form.api.FormEntryPrompt) SelectOneWidget(org.odk.collect.android.widgets.items.SelectOneWidget) MockFormEntryPromptBuilder(org.odk.collect.android.support.MockFormEntryPromptBuilder) Test(org.junit.Test)

Example 53 with MockFormEntryPromptBuilder

use of org.odk.collect.android.support.MockFormEntryPromptBuilder in project collect by opendatakit.

the class WidgetFactoryTest method testCreatingSelectOneLabelWidget.

@Test
public void testCreatingSelectOneLabelWidget() {
    FormEntryPrompt prompt = new MockFormEntryPromptBuilder().withControlType(Constants.CONTROL_SELECT_ONE).withAppearance("something lAbeL something").build();
    QuestionWidget widget = widgetFactory.createWidgetFromPrompt(prompt, null);
    assertThat(widget, instanceOf(LabelWidget.class));
}
Also used : FormEntryPrompt(org.javarosa.form.api.FormEntryPrompt) LabelWidget(org.odk.collect.android.widgets.items.LabelWidget) MockFormEntryPromptBuilder(org.odk.collect.android.support.MockFormEntryPromptBuilder) Test(org.junit.Test)

Example 54 with MockFormEntryPromptBuilder

use of org.odk.collect.android.support.MockFormEntryPromptBuilder in project collect by opendatakit.

the class WidgetFactoryTest method testCreatingSelectMultipleMinimalWidget.

@Test
public void testCreatingSelectMultipleMinimalWidget() {
    FormEntryPrompt prompt = new MockFormEntryPromptBuilder().withControlType(Constants.CONTROL_SELECT_MULTI).withAppearance("something miNimal something").build();
    QuestionWidget widget = widgetFactory.createWidgetFromPrompt(prompt, null);
    assertThat(widget, instanceOf(SelectMultiMinimalWidget.class));
}
Also used : FormEntryPrompt(org.javarosa.form.api.FormEntryPrompt) SelectMultiMinimalWidget(org.odk.collect.android.widgets.items.SelectMultiMinimalWidget) MockFormEntryPromptBuilder(org.odk.collect.android.support.MockFormEntryPromptBuilder) Test(org.junit.Test)

Example 55 with MockFormEntryPromptBuilder

use of org.odk.collect.android.support.MockFormEntryPromptBuilder in project collect by opendatakit.

the class QuestionWidgetTest method whenQuestionHasAudio_audioButtonUsesIndexAsClipID.

@Test
public void whenQuestionHasAudio_audioButtonUsesIndexAsClipID() throws Exception {
    FormEntryPrompt prompt = new MockFormEntryPromptBuilder().withIndex("i am index").withAudioURI("ref").build();
    WidgetTestActivity activity = CollectHelpers.createThemedActivity(WidgetTestActivity.class);
    TestWidget widget = new TestWidget(activity, new QuestionDetails(prompt));
    AudioButton audioButton = widget.getAudioVideoImageTextLabel().findViewById(R.id.audioButton);
    verify(audioHelper).setAudio(audioButton, new Clip("i am index", "blah.mp3"));
}
Also used : Clip(org.odk.collect.audioclips.Clip) FormEntryPrompt(org.javarosa.form.api.FormEntryPrompt) WidgetTestActivity(org.odk.collect.android.support.WidgetTestActivity) MockFormEntryPromptBuilder(org.odk.collect.android.support.MockFormEntryPromptBuilder) QuestionDetails(org.odk.collect.android.formentry.questions.QuestionDetails) AudioButton(org.odk.collect.android.audio.AudioButton) Test(org.junit.Test)

Aggregations

MockFormEntryPromptBuilder (org.odk.collect.android.support.MockFormEntryPromptBuilder)69 Test (org.junit.Test)65 FormEntryPrompt (org.javarosa.form.api.FormEntryPrompt)45 SelectChoice (org.javarosa.core.model.SelectChoice)21 Clip (org.odk.collect.audioclips.Clip)12 RandomString (net.bytebuddy.utility.RandomString)9 FileWidgetTest (org.odk.collect.android.widgets.base.FileWidgetTest)9 ImageView (android.widget.ImageView)8 AppDependencyModule (org.odk.collect.android.injection.config.AppDependencyModule)8 SynchronousImageLoader (org.odk.collect.android.widgets.support.SynchronousImageLoader)8 ImageLoader (org.odk.collect.imageloader.ImageLoader)8 BitmapDrawable (android.graphics.drawable.BitmapDrawable)7 Drawable (android.graphics.drawable.Drawable)7 GeneralSelectOneWidgetTest (org.odk.collect.android.widgets.base.GeneralSelectOneWidgetTest)7 Pair (androidx.core.util.Pair)6 TextView (android.widget.TextView)5 GeneralSelectMultiWidgetTest (org.odk.collect.android.widgets.base.GeneralSelectMultiWidgetTest)5 File (java.io.File)4 ReferenceManager (org.javarosa.core.reference.ReferenceManager)4 CollectHelpers.setupFakeReferenceManager (org.odk.collect.android.support.CollectHelpers.setupFakeReferenceManager)4