use of org.odk.collect.android.javarosawrapper.FormController in project collect by opendatakit.
the class SelectOneWidget method clearFollowingItemsetWidgets.
/**
* If there are "fast external itemset" selects right after this select, assume that they are linked to the current question and clear them.
*/
private void clearFollowingItemsetWidgets() {
FormController formController = Collect.getInstance().getFormController();
if (formController == null) {
return;
}
if (formController.currentCaptionPromptIsQuestion()) {
try {
FormIndex startFormIndex = formController.getQuestionPrompt().getIndex();
formController.stepToNextScreenEvent();
while (formController.currentCaptionPromptIsQuestion() && formController.getQuestionPrompt().getFormElement().getAdditionalAttribute(null, "query") != null) {
formController.saveAnswer(formController.getQuestionPrompt().getIndex(), null);
formController.stepToNextScreenEvent();
}
formController.jumpToIndex(startFormIndex);
} catch (JavaRosaException e) {
Timber.d(e);
}
}
}
use of org.odk.collect.android.javarosawrapper.FormController in project collect by opendatakit.
the class FormSaveViewModelTest method setup.
@Before
public void setup() {
// Useful given some methods will execute AsyncTasks
Robolectric.getBackgroundThreadScheduler().pause();
formController = mock(FormController.class);
logger = mock(AuditEventLogger.class);
mediaUtils = mock(MediaUtils.class);
Analytics analytics = mock(Analytics.class);
when(formController.getAuditEventLogger()).thenReturn(logger);
when(logger.isChangeReasonRequired()).thenReturn(false);
audioRecorder = mock(AudioRecorder.class);
currentProjectProvider = mock(CurrentProjectProvider.class);
when(currentProjectProvider.getCurrentProject()).thenReturn(Project.Companion.getDEMO_PROJECT());
viewModel = new FormSaveViewModel(savedStateHandle, () -> CURRENT_TIME, formSaver, mediaUtils, analytics, scheduler, audioRecorder, currentProjectProvider);
viewModel.formLoaded(formController);
}
use of org.odk.collect.android.javarosawrapper.FormController in project collect by opendatakit.
the class BackgroundAudioViewModelTest method setBackgroundRecordingEnabled_whenTrue_logsEventToAuditLog.
@Test
public void setBackgroundRecordingEnabled_whenTrue_logsEventToAuditLog() {
FormController formController = mock(FormController.class);
AuditEventLogger auditEventLogger = mock(AuditEventLogger.class);
when(formController.getAuditEventLogger()).thenReturn(auditEventLogger);
viewModel.formLoaded(formController);
when(clock.get()).thenReturn(1234L);
viewModel.setBackgroundRecordingEnabled(true);
verify(auditEventLogger).logEvent(AuditEvent.AuditEventType.BACKGROUND_AUDIO_ENABLED, true, 1234L);
}
use of org.odk.collect.android.javarosawrapper.FormController in project collect by opendatakit.
the class FormEntryViewModelTest method setup.
@Before
public void setup() {
formController = mock(FormController.class);
startingIndex = new FormIndex(null, 0, 0, new TreeReference());
when(formController.getFormIndex()).thenReturn(startingIndex);
when(formController.getFormDef()).thenReturn(new FormDef());
AuditEventLogger auditEventLogger = mock(AuditEventLogger.class);
when(formController.getAuditEventLogger()).thenReturn(auditEventLogger);
viewModel = new FormEntryViewModel(mock(Supplier.class));
viewModel.formLoaded(formController);
}
use of org.odk.collect.android.javarosawrapper.FormController in project collect by opendatakit.
the class OSMWidgetTest method setUp.
@Before
public void setUp() {
widgetActivity = widgetTestActivity();
shadowActivity = shadowOf(widgetActivity);
intentLauncher = IntentLauncherImpl.INSTANCE;
formController = mock(FormController.class);
FormDef formDef = mock(FormDef.class);
questionDef = mock(QuestionDef.class);
when(formController.getInstanceFile()).thenReturn(instancePath);
when(formController.getMediaFolder()).thenReturn(mediaFolder);
when(formController.getSubmissionMetadata()).thenReturn(new FormController.InstanceMetadata("instanceId", "instanceTesTName", null));
when(formController.getFormDef()).thenReturn(formDef);
when(formDef.getID()).thenReturn(0);
}
Aggregations