Search in sources :

Example 6 with FormMapViewModel

use of org.odk.collect.android.activities.viewmodels.FormMapViewModel in project collect by opendatakit.

the class FormMapViewModelTest method instanceThatFailedToSend_thatCantBeEdited_returnsNotViewableStatus.

// E.g. encrypted forms
@Test
public void instanceThatFailedToSend_thatCantBeEdited_returnsNotViewableStatus() {
    FormMapViewModel viewModel = new FormMapViewModel(TEST_FORM_1, testInstancesRepository);
    List<FormMapViewModel.MappableFormInstance> instances = viewModel.getMappableFormInstances();
    assertThat(instances.get(5).getClickAction(), is(FormMapViewModel.ClickAction.NOT_VIEWABLE_TOAST));
}
Also used : FormMapViewModel(org.odk.collect.android.activities.viewmodels.FormMapViewModel) Test(org.junit.Test)

Example 7 with FormMapViewModel

use of org.odk.collect.android.activities.viewmodels.FormMapViewModel in project collect by opendatakit.

the class FormMapViewModelTest method finalizedInstance_thatCanBeEdited_hasEditableClickAction.

@Test
public void finalizedInstance_thatCanBeEdited_hasEditableClickAction() {
    FormMapViewModel viewModel = new FormMapViewModel(TEST_FORM_1, testInstancesRepository);
    List<FormMapViewModel.MappableFormInstance> instances = viewModel.getMappableFormInstances();
    assertThat(instances.get(1).getClickAction(), is(FormMapViewModel.ClickAction.OPEN_EDIT));
}
Also used : FormMapViewModel(org.odk.collect.android.activities.viewmodels.FormMapViewModel) Test(org.junit.Test)

Example 8 with FormMapViewModel

use of org.odk.collect.android.activities.viewmodels.FormMapViewModel in project collect by opendatakit.

the class FormMapViewModelTest method submittedInstance_thatCanBeEdited_returnsViewableStatus.

// Sent instances should never be editable.
@Test
public void submittedInstance_thatCanBeEdited_returnsViewableStatus() {
    FormMapViewModel viewModel = new FormMapViewModel(TEST_FORM_1, testInstancesRepository);
    List<FormMapViewModel.MappableFormInstance> instances = viewModel.getMappableFormInstances();
    assertThat(instances.get(4).getClickAction(), is(FormMapViewModel.ClickAction.OPEN_READ_ONLY));
}
Also used : FormMapViewModel(org.odk.collect.android.activities.viewmodels.FormMapViewModel) Test(org.junit.Test)

Example 9 with FormMapViewModel

use of org.odk.collect.android.activities.viewmodels.FormMapViewModel in project collect by opendatakit.

the class FormMapViewModelTest method getMappableInstances_excludesInstancesWithoutGeometry.

@Test
public void getMappableInstances_excludesInstancesWithoutGeometry() {
    FormMapViewModel viewModel = new FormMapViewModel(TEST_FORM_1, testInstancesRepository);
    List<FormMapViewModel.MappableFormInstance> mappableFormInstances = viewModel.getMappableFormInstances();
    assertThat(mappableFormInstances.size(), is(6));
    assertThat(mappableFormInstances, not(contains(hasProperty("databaseId"), is(3L))));
}
Also used : FormMapViewModel(org.odk.collect.android.activities.viewmodels.FormMapViewModel) Test(org.junit.Test)

Example 10 with FormMapViewModel

use of org.odk.collect.android.activities.viewmodels.FormMapViewModel in project collect by opendatakit.

the class FormMapViewModelTest method getMappableInstances_excludesInstancesWithCorruptGeometry.

@Test
public void getMappableInstances_excludesInstancesWithCorruptGeometry() {
    FormMapViewModel viewModel = new FormMapViewModel(TEST_FORM_2, testInstancesRepository);
    List<FormMapViewModel.MappableFormInstance> mappableFormInstances = viewModel.getMappableFormInstances();
    assertThat(mappableFormInstances.size(), is(0));
}
Also used : FormMapViewModel(org.odk.collect.android.activities.viewmodels.FormMapViewModel) Test(org.junit.Test)

Aggregations

FormMapViewModel (org.odk.collect.android.activities.viewmodels.FormMapViewModel)13 Test (org.junit.Test)12 Instance (org.odk.collect.forms.instances.Instance)2 InMemInstancesRepository (org.odk.collect.formstest.InMemInstancesRepository)2 Nullable (androidx.annotation.Nullable)1 ViewModelProvider (androidx.lifecycle.ViewModelProvider)1 Form (org.odk.collect.forms.Form)1