Search in sources :

Example 61 with MockFormEntryPromptBuilder

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

the class SelectMultiWidgetTest 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) GeneralSelectMultiWidgetTest(org.odk.collect.android.widgets.base.GeneralSelectMultiWidgetTest) Test(org.junit.Test)

Example 62 with MockFormEntryPromptBuilder

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

the class SelectMultiWidgetTest method whenChoicesHaveAudio_audioButtonUsesIndexAsClipID.

@Test
public void whenChoicesHaveAudio_audioButtonUsesIndexAsClipID() throws Exception {
    formEntryPrompt = new MockFormEntryPromptBuilder().withIndex("i am index").withSelectChoices(asList(new SelectChoice("1", "1"), new SelectChoice("2", "2"))).withSpecialFormSelectChoiceText(asList(new Pair<>(FormEntryCaption.TEXT_FORM_AUDIO, REFERENCES.get(0).first), new Pair<>(FormEntryCaption.TEXT_FORM_AUDIO, REFERENCES.get(1).first))).build();
    populateRecyclerView(getWidget());
    verify(audioHelper).setAudio(any(AudioButton.class), eq(new Clip("i am index 0", REFERENCES.get(0).second)));
    verify(audioHelper).setAudio(any(AudioButton.class), eq(new Clip("i am index 1", REFERENCES.get(1).second)));
}
Also used : Clip(org.odk.collect.audioclips.Clip) SelectChoice(org.javarosa.core.model.SelectChoice) MockFormEntryPromptBuilder(org.odk.collect.android.support.MockFormEntryPromptBuilder) AudioButton(org.odk.collect.android.audio.AudioButton) Pair(androidx.core.util.Pair) GeneralSelectMultiWidgetTest(org.odk.collect.android.widgets.base.GeneralSelectMultiWidgetTest) Test(org.junit.Test)

Example 63 with MockFormEntryPromptBuilder

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

the class InternalRecordingRequesterTest method requestRecording_whenPromptQualityIsVoiceOnly_startsWithAMR.

@Test
public void requestRecording_whenPromptQualityIsVoiceOnly_startsWithAMR() {
    FormEntryPrompt prompt = new MockFormEntryPromptBuilder().withBindAttribute("odk", "quality", "voice-only").build();
    requester.requestRecording(prompt);
    verify(audioRecorder).start(prompt.getIndex(), Output.AMR);
}
Also used : FormEntryPrompt(org.javarosa.form.api.FormEntryPrompt) MockFormEntryPromptBuilder(org.odk.collect.android.support.MockFormEntryPromptBuilder) Test(org.junit.Test)

Example 64 with MockFormEntryPromptBuilder

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

the class InternalRecordingRequesterTest method requestRecording_whenPromptQualityIsLow_startsWithAACLow.

@Test
public void requestRecording_whenPromptQualityIsLow_startsWithAACLow() {
    FormEntryPrompt prompt = new MockFormEntryPromptBuilder().withBindAttribute("odk", "quality", "low").build();
    requester.requestRecording(prompt);
    verify(audioRecorder).start(prompt.getIndex(), Output.AAC_LOW);
}
Also used : FormEntryPrompt(org.javarosa.form.api.FormEntryPrompt) MockFormEntryPromptBuilder(org.odk.collect.android.support.MockFormEntryPromptBuilder) Test(org.junit.Test)

Example 65 with MockFormEntryPromptBuilder

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

the class RecordingRequesterProviderTest method whenNoQualitySpecified_andSettingExternalPreferred_createsExternalRecordingRequester.

@Test
public void whenNoQualitySpecified_andSettingExternalPreferred_createsExternalRecordingRequester() {
    FormEntryPrompt prompt = new MockFormEntryPromptBuilder().build();
    RecordingRequester recordingRequester = provider.create(prompt, true);
    assertThat(recordingRequester, instanceOf(ExternalAppRecordingRequester.class));
}
Also used : FormEntryPrompt(org.javarosa.form.api.FormEntryPrompt) 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