use of org.odk.collect.android.support.MockFormEntryPromptBuilder in project collect by opendatakit.
the class SignatureWidgetTest method whenPromptHasCurrentAnswer_showsInImageView.
@Test
public void whenPromptHasCurrentAnswer_showsInImageView() throws Exception {
CollectHelpers.overrideAppDependencyModule(new AppDependencyModule() {
@Override
public ImageLoader providesImageLoader() {
return new SynchronousImageLoader();
}
});
String imagePath = File.createTempFile("current", ".bmp").getAbsolutePath();
currentFile = new File(imagePath);
formEntryPrompt = new MockFormEntryPromptBuilder().withAnswerDisplayText(DrawWidgetTest.USER_SPECIFIED_IMAGE_ANSWER).build();
SignatureWidget widget = createWidget();
ImageView imageView = widget.getImageView();
assertThat(imageView, notNullValue());
Drawable drawable = imageView.getDrawable();
assertThat(drawable, notNullValue());
String loadedPath = shadowOf(((BitmapDrawable) drawable).getBitmap()).getCreatedFromPath();
assertThat(loadedPath, equalTo(imagePath));
}
use of org.odk.collect.android.support.MockFormEntryPromptBuilder in project collect by opendatakit.
the class SelectOneWidgetTest method whenQuickAppearanceIsNotUsed_shouldNotAdvanceToNextListenerBeCalledInButtonsMode.
@Test
public void whenQuickAppearanceIsNotUsed_shouldNotAdvanceToNextListenerBeCalledInButtonsMode() {
formEntryPrompt = new MockFormEntryPromptBuilder().withSelectChoices(asList(new SelectChoice("AAA", "AAA"), new SelectChoice("BBB", "BBB"))).build();
SelectOneWidget widget = getWidget();
populateRecyclerView(widget);
// Select AAA
clickChoice(widget, 0);
assertThat(widget.getAnswer().getDisplayText(), is("AAA"));
verify(listener, times(0)).advance();
}
use of org.odk.collect.android.support.MockFormEntryPromptBuilder in project collect by opendatakit.
the class SelectOneWidgetTest method usingReadOnlyOptionShouldMakeAllClickableElementsDisabled.
@Test
public void usingReadOnlyOptionShouldMakeAllClickableElementsDisabled() {
// No appearance
formEntryPrompt = new MockFormEntryPromptBuilder().withIndex("i am index").withSelectChoices(asList(new SelectChoice("1", "1"), new SelectChoice("2", "2"))).withReadOnly(true).build();
populateRecyclerView(getWidget());
AudioVideoImageTextLabel avitLabel = (AudioVideoImageTextLabel) getSpyWidget().binding.choicesRecyclerView.getLayoutManager().getChildAt(0);
assertThat(avitLabel.isEnabled(), is(Boolean.FALSE));
resetWidget();
// No-buttons appearance
formEntryPrompt = new MockFormEntryPromptBuilder(formEntryPrompt).withAppearance(Appearances.NO_BUTTONS).build();
populateRecyclerView(getWidget());
FrameLayout view = (FrameLayout) getSpyWidget().binding.choicesRecyclerView.getLayoutManager().getChildAt(0);
assertThat(view.isEnabled(), is(Boolean.FALSE));
}
use of org.odk.collect.android.support.MockFormEntryPromptBuilder in project collect by opendatakit.
the class SelectOneWidgetTest 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)));
}
use of org.odk.collect.android.support.MockFormEntryPromptBuilder in project collect by opendatakit.
the class SelectOneWidgetTest method whenAChoiceValueIsNull_selecting_doesNotSetAnswer.
@Test
public void whenAChoiceValueIsNull_selecting_doesNotSetAnswer() {
// The two arg constructor protects against null values
SelectChoice selectChoice = new SelectChoice();
selectChoice.setTextID("1");
formEntryPrompt = new MockFormEntryPromptBuilder().withSelectChoices(asList(selectChoice)).build();
SelectOneWidget widget = getWidget();
populateRecyclerView(widget);
clickChoice(widget, 0);
assertThat(widget.getAnswer(), nullValue());
}
Aggregations