Search in sources :

Example 6 with MockFormEntryPromptBuilder

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

the class SelectOneWidgetTest method whenQuickAppearanceIsNotUsed_shouldNotAdvanceToNextListenerBeCalledInNoButtonsMode.

@Test
public void whenQuickAppearanceIsNotUsed_shouldNotAdvanceToNextListenerBeCalledInNoButtonsMode() {
    formEntryPrompt = new MockFormEntryPromptBuilder().withSelectChoices(asList(new SelectChoice("AAA", "AAA"), new SelectChoice("BBB", "BBB"))).withAppearance("no-buttons").build();
    SelectOneWidget widget = getWidget();
    populateRecyclerView(widget);
    // Select AAA
    clickChoice(widget, 0);
    assertThat(widget.getAnswer().getDisplayText(), is("AAA"));
    verify(listener, times(0)).advance();
}
Also used : SelectChoice(org.javarosa.core.model.SelectChoice) MockFormEntryPromptBuilder(org.odk.collect.android.support.MockFormEntryPromptBuilder) GeneralSelectOneWidgetTest(org.odk.collect.android.widgets.base.GeneralSelectOneWidgetTest) Test(org.junit.Test)

Example 7 with MockFormEntryPromptBuilder

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

the class SelectOneWidgetTest method whenQuickAppearanceIsUsed_shouldAdvanceToNextListenerBeCalledInButtonsMode.

@Test
public void whenQuickAppearanceIsUsed_shouldAdvanceToNextListenerBeCalledInButtonsMode() {
    formEntryPrompt = new MockFormEntryPromptBuilder().withSelectChoices(asList(new SelectChoice("AAA", "AAA"), new SelectChoice("BBB", "BBB"))).withAppearance("quick").build();
    SelectOneWidget widget = getWidget();
    populateRecyclerView(widget);
    // Select AAA
    clickChoice(widget, 0);
    assertThat(widget.getAnswer().getDisplayText(), is("AAA"));
    verify(listener).advance();
}
Also used : SelectChoice(org.javarosa.core.model.SelectChoice) MockFormEntryPromptBuilder(org.odk.collect.android.support.MockFormEntryPromptBuilder) GeneralSelectOneWidgetTest(org.odk.collect.android.widgets.base.GeneralSelectOneWidgetTest) Test(org.junit.Test)

Example 8 with MockFormEntryPromptBuilder

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

the class SelectOneWidgetTest method whenQuickAppearanceIsUsed_shouldAdvanceToNextListenerBeCalledInNoButtonsMode.

@Test
public void whenQuickAppearanceIsUsed_shouldAdvanceToNextListenerBeCalledInNoButtonsMode() {
    formEntryPrompt = new MockFormEntryPromptBuilder().withSelectChoices(asList(new SelectChoice("AAA", "AAA"), new SelectChoice("BBB", "BBB"))).withAppearance("quick no-buttons").build();
    SelectOneWidget widget = getWidget();
    populateRecyclerView(widget);
    // Select AAA
    clickChoice(widget, 0);
    assertThat(widget.getAnswer().getDisplayText(), is("AAA"));
    verify(listener).advance();
}
Also used : SelectChoice(org.javarosa.core.model.SelectChoice) MockFormEntryPromptBuilder(org.odk.collect.android.support.MockFormEntryPromptBuilder) GeneralSelectOneWidgetTest(org.odk.collect.android.widgets.base.GeneralSelectOneWidgetTest) Test(org.junit.Test)

Example 9 with MockFormEntryPromptBuilder

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

the class ListMultiWidgetTest method whenSpacesInUnderlyingValuesExist_shouldAppropriateWarningBeDisplayed.

@Test
public void whenSpacesInUnderlyingValuesExist_shouldAppropriateWarningBeDisplayed() {
    formEntryPrompt = new MockFormEntryPromptBuilder().withSelectChoices(asList(new SelectChoice("a", "a a"), new SelectChoice("a", "b b"))).build();
    TextView warningTv = getWidget().findViewById(R.id.warning_text);
    assertThat(warningTv.getVisibility(), is(View.VISIBLE));
    assertThat(warningTv.getText(), is("Warning: underlying values a a, b b have spaces"));
}
Also used : SelectChoice(org.javarosa.core.model.SelectChoice) TextView(android.widget.TextView) MockFormEntryPromptBuilder(org.odk.collect.android.support.MockFormEntryPromptBuilder) Test(org.junit.Test) GeneralSelectMultiWidgetTest(org.odk.collect.android.widgets.base.GeneralSelectMultiWidgetTest)

Example 10 with MockFormEntryPromptBuilder

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

the class SelectMultiImageMapWidgetTest method whenSpacesInUnderlyingValuesExist_shouldAppropriateWarningBeDisplayed.

@Test
public void whenSpacesInUnderlyingValuesExist_shouldAppropriateWarningBeDisplayed() {
    formEntryPrompt = new MockFormEntryPromptBuilder().withSelectChoices(asList(new SelectChoice("a", "a a"), new SelectChoice("a", "b b"))).withImageURI("jr://images/body.svg").build();
    TextView warningTv = getWidget().findViewById(R.id.warning_text);
    assertThat(warningTv.getVisibility(), is(View.VISIBLE));
    assertThat(warningTv.getText(), is("Warning: underlying values a a, b b have spaces"));
}
Also used : SelectChoice(org.javarosa.core.model.SelectChoice) TextView(android.widget.TextView) MockFormEntryPromptBuilder(org.odk.collect.android.support.MockFormEntryPromptBuilder) 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