Search in sources :

Example 91 with FormEntryPrompt

use of org.javarosa.form.api.FormEntryPrompt 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)

Example 92 with FormEntryPrompt

use of org.javarosa.form.api.FormEntryPrompt in project collect by opendatakit.

the class TimeWidgetTest method clickingButton_callsDisplayTimePickerDialogWithCurrentTime_whenPromptDoesNotHaveAnswer.

@Test
public void clickingButton_callsDisplayTimePickerDialogWithCurrentTime_whenPromptDoesNotHaveAnswer() {
    FormEntryPrompt prompt = promptWithQuestionDefAndAnswer(questionDef, null);
    TimeWidget widget = createWidget(prompt);
    widget.binding.timeButton.performClick();
    verify(widgetUtils).showTimePickerDialog(widgetActivity, DateTimeUtils.getCurrentDateTime());
}
Also used : FormEntryPrompt(org.javarosa.form.api.FormEntryPrompt) Test(org.junit.Test)

Example 93 with FormEntryPrompt

use of org.javarosa.form.api.FormEntryPrompt 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));
}
Also used : FormEntryPrompt(org.javarosa.form.api.FormEntryPrompt) MockFormEntryPromptBuilder(org.odk.collect.android.support.MockFormEntryPromptBuilder) ListMultiWidget(org.odk.collect.android.widgets.items.ListMultiWidget) Test(org.junit.Test)

Example 94 with FormEntryPrompt

use of org.javarosa.form.api.FormEntryPrompt 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));
}
Also used : FormEntryPrompt(org.javarosa.form.api.FormEntryPrompt) SelectMultiWidget(org.odk.collect.android.widgets.items.SelectMultiWidget) MockFormEntryPromptBuilder(org.odk.collect.android.support.MockFormEntryPromptBuilder) Test(org.junit.Test)

Example 95 with FormEntryPrompt

use of org.javarosa.form.api.FormEntryPrompt 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)

Aggregations

FormEntryPrompt (org.javarosa.form.api.FormEntryPrompt)114 Test (org.junit.Test)92 MockFormEntryPromptBuilder (org.odk.collect.android.support.MockFormEntryPromptBuilder)45 Clip (org.odk.collect.audioclips.Clip)13 FormIndex (org.javarosa.core.model.FormIndex)10 File (java.io.File)9 SelectChoice (org.javarosa.core.model.SelectChoice)7 StringData (org.javarosa.core.model.data.StringData)7 IFormElement (org.javarosa.core.model.IFormElement)5 QuestionDef (org.javarosa.core.model.QuestionDef)5 FormController (org.odk.collect.android.javarosawrapper.FormController)5 GroupDef (org.javarosa.core.model.GroupDef)4 QuestionDetails (org.odk.collect.android.formentry.questions.QuestionDetails)4 DatePickerDetails (org.odk.collect.android.logic.DatePickerDetails)4 ArrayList (java.util.ArrayList)3 DateData (org.javarosa.core.model.data.DateData)3 IAnswerData (org.javarosa.core.model.data.IAnswerData)3 TreeReference (org.javarosa.core.model.instance.TreeReference)3 LocalDateTime (org.joda.time.LocalDateTime)3 AudioControllerView (org.odk.collect.android.audio.AudioControllerView)3