use of org.odk.collect.android.tasks.FormLoaderTask in project collect by opendatakit.
the class FormNavigationTestCase method testIndices.
private void testIndices(String formName, String[] expectedIndices) throws ExecutionException, InterruptedException {
try {
copyToSdCard(formName);
} catch (IOException e) {
Timber.i(e);
}
FormLoaderTask formLoaderTask = new FormLoaderTask(formPath(formName), null, null);
formLoaderTask.setFormLoaderListener(new FormLoaderListener() {
@Override
public void loadingComplete(FormLoaderTask task, FormDef fd) {
try {
// form and then swiping back once. Verify the expected indices before and after each swipe.
for (int i = 0; i < expectedIndices.length - 1; i++) {
FormController formController = task.getFormController();
// check the current index
assertEquals(expectedIndices[i], formController.getFormIndex().toString());
if (i < expectedIndices.length - 2) {
formController.stepToNextScreenEvent();
} else {
formController.stepToPreviousScreenEvent();
}
// check the index again after navigating
assertEquals(expectedIndices[i + 1], formController.getFormIndex().toString());
}
} catch (Exception e) {
Timber.i(e);
}
}
@Override
public void loadingError(String errorMsg) {
}
@Override
public void onProgressStep(String stepMessage) {
}
});
formLoaderTask.execute(formPath(formName)).get();
}
Aggregations