Search in sources :

Example 96 with FormEntryPrompt

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

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

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

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

the class ODKView method autoplayIfNeeded.

private void autoplayIfNeeded(boolean advancingPage) {
    // Only execute it during forward swipes through the form
    if (advancingPage && widgets.size() == 1) {
        FormEntryPrompt firstPrompt = widgets.get(0).getFormEntryPrompt();
        Boolean autoplayedAudio = autoplayAudio(firstPrompt);
        if (!autoplayedAudio) {
            autoplayVideo(firstPrompt);
        }
    }
}
Also used : FormEntryPrompt(org.javarosa.form.api.FormEntryPrompt)

Example 100 with FormEntryPrompt

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

the class FormSaveViewModelTest method whenFormSaverFinishes_saved_andFormIsCurrentlyOnQuestion_logsSaveAndQuestionAuditEventsAfterFlush.

@Test
public void whenFormSaverFinishes_saved_andFormIsCurrentlyOnQuestion_logsSaveAndQuestionAuditEventsAfterFlush() throws RepeatsInFieldListException {
    when(formController.getEvent()).thenReturn(EVENT_QUESTION);
    FormEntryPrompt prompt = new MockFormEntryPromptBuilder().withIndex("index1").withAnswerDisplayText("answer").build();
    when(formController.getQuestionPrompts()).thenReturn(Arrays.asList(prompt).toArray(new FormEntryPrompt[] {}));
    viewModel.saveForm(Uri.parse("file://form"), true, "", false);
    whenFormSaverFinishes(SaveFormToDisk.SAVED);
    InOrder verifier = inOrder(logger);
    verifier.verify(logger).flush();
    verifier.verify(logger).logEvent(AuditEvent.AuditEventType.FORM_SAVE, false, CURRENT_TIME);
    verifier.verify(logger).logEvent(AuditEvent.AuditEventType.QUESTION, prompt.getIndex(), true, prompt.getAnswerValue().getDisplayText(), CURRENT_TIME, null);
}
Also used : FormEntryPrompt(org.javarosa.form.api.FormEntryPrompt) InOrder(org.mockito.InOrder) 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