use of org.odk.collect.android.support.MockFormEntryPromptBuilder in project collect by opendatakit.
the class AuditEventLoggerTest method setup.
@Before
public void setup() {
FormEntryPrompt prompt = new MockFormEntryPromptBuilder().withAnswerDisplayText("The answer").build();
when(formController.getQuestionPrompt(any())).thenReturn(prompt);
}
use of org.odk.collect.android.support.MockFormEntryPromptBuilder in project collect by opendatakit.
the class FormSaveViewModelTest method whenFormSaverFinishes_saved_andFormIsCurrentlyOnRepeat_logsSaveAndQuestionAuditEventsAfterFlush.
@Test
public void whenFormSaverFinishes_saved_andFormIsCurrentlyOnRepeat_logsSaveAndQuestionAuditEventsAfterFlush() throws RepeatsInFieldListException {
when(formController.getEvent()).thenReturn(EVENT_REPEAT);
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);
}
use of org.odk.collect.android.support.MockFormEntryPromptBuilder in project collect by opendatakit.
the class FormSaveViewModelTest method whenFormSaverFinishes_saved_andFormIsCurrentlyOnGroup_logsSaveAndQuestionAuditEventsAfterFlush.
@Test
public void whenFormSaverFinishes_saved_andFormIsCurrentlyOnGroup_logsSaveAndQuestionAuditEventsAfterFlush() throws RepeatsInFieldListException {
when(formController.getEvent()).thenReturn(EVENT_GROUP);
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);
}
use of org.odk.collect.android.support.MockFormEntryPromptBuilder in project collect by opendatakit.
the class PromptAutoplayerTest method whenPromptHasAutoplayAudio_andIsSelectOne_withNoButtonsAppearance_playsPromptAudio.
@Test
public void whenPromptHasAutoplayAudio_andIsSelectOne_withNoButtonsAppearance_playsPromptAudio() throws Exception {
FormEntryPrompt prompt = new MockFormEntryPromptBuilder().withControlType(Constants.CONTROL_SELECT_ONE).withAppearance("whatever " + NO_BUTTONS).withAudioURI(REFERENCES.get(0).first).withAdditionalAttribute("autoplay", "audio").withSelectChoices(asList(new SelectChoice("1", "1"), new SelectChoice("2", "2"))).withSpecialFormSelectChoiceText(asList(new Pair<>(FormEntryCaption.TEXT_FORM_AUDIO, REFERENCES.get(1).first), new Pair<>(FormEntryCaption.TEXT_FORM_AUDIO, REFERENCES.get(2).first))).build();
assertThat(autoplayer.autoplayIfNeeded(prompt), equalTo(true));
verify(audioHelper).playInOrder(asList(new Clip(prompt.getIndex().toString(), REFERENCES.get(0).second)));
}
use of org.odk.collect.android.support.MockFormEntryPromptBuilder in project collect by opendatakit.
the class PromptAutoplayerTest method whenPromptHasAutoplayAudio_andIsSelectOne_withDeprecatedCompactAppearance_playsPromptAudio.
@Test
public void whenPromptHasAutoplayAudio_andIsSelectOne_withDeprecatedCompactAppearance_playsPromptAudio() throws Exception {
FormEntryPrompt prompt = new MockFormEntryPromptBuilder().withControlType(Constants.CONTROL_SELECT_ONE).withAppearance(COMPACT).withAudioURI(REFERENCES.get(0).first).withAdditionalAttribute("autoplay", "audio").withSelectChoices(asList(new SelectChoice("1", "1"), new SelectChoice("2", "2"))).withSpecialFormSelectChoiceText(asList(new Pair<>(FormEntryCaption.TEXT_FORM_AUDIO, REFERENCES.get(1).first), new Pair<>(FormEntryCaption.TEXT_FORM_AUDIO, REFERENCES.get(2).first))).build();
assertThat(autoplayer.autoplayIfNeeded(prompt), equalTo(true));
verify(audioHelper).playInOrder(asList(new Clip(prompt.getIndex().toString(), REFERENCES.get(0).second)));
}
Aggregations