Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ internal class SetupFragment : Fragment(R.layout.fragment_setup) {
// Overall setup result
observeOverallSetupResult()
// Start the setup process
viewModel.start()
if (savedInstanceState == null) {
viewModel.start()
}
}

private fun observeOverallSetupResult() = viewModel.overallSetupResult.observe(viewLifecycleOwner) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@ class SetupViewModelTest {
fun `should not request location permission if collectLocation is disabled`() = runTest {
// Given
coEvery { configManager.getProjectConfiguration().general.collectLocation } returns false
coEvery { configManager.getProjectConfiguration().synchronization.down.commCare } returns mockk()
coEvery {
configManager
.getProjectConfiguration()
.synchronization.down.commCare
} returns mockk()

// when
viewModel.start()
Expand All @@ -95,7 +99,11 @@ class SetupViewModelTest {
// Given
justRun { locationStore.collectLocationInBackground() }
coEvery { configManager.getProjectConfiguration() } returns mockk<ProjectConfiguration>()
coEvery { configManager.getProjectConfiguration().synchronization.down.commCare } returns mockk()
coEvery {
configManager
.getProjectConfiguration()
.synchronization.down.commCare
} returns mockk()

// when
viewModel.locationPermissionCheckDone(granted = true)
Expand All @@ -109,7 +117,11 @@ class SetupViewModelTest {
// Given
justRun { locationStore.collectLocationInBackground() }
coEvery { configManager.getProjectConfiguration() } returns mockk<ProjectConfiguration>()
coEvery { configManager.getProjectConfiguration().synchronization.down.commCare } returns mockk()
coEvery {
configManager
.getProjectConfiguration()
.synchronization.down.commCare
} returns mockk()

// when
viewModel.locationPermissionCheckDone(granted = false)
Expand All @@ -122,7 +134,11 @@ class SetupViewModelTest {
fun `should request CommCare permission if needed when location permission is granted`() = runTest {
// Given
justRun { locationStore.collectLocationInBackground() }
coEvery { configManager.getProjectConfiguration().synchronization.down.commCare } returns mockk()
coEvery {
configManager
.getProjectConfiguration()
.synchronization.down.commCare
} returns mockk()

// When
viewModel.locationPermissionCheckDone(true)
Expand All @@ -135,7 +151,11 @@ class SetupViewModelTest {
fun `should request CommCare permission if needed when location permission is not granted`() = runTest {
// Given
justRun { locationStore.collectLocationInBackground() }
coEvery { configManager.getProjectConfiguration().synchronization.down.commCare } returns mockk()
coEvery {
configManager
.getProjectConfiguration()
.synchronization.down.commCare
} returns mockk()

// When
viewModel.locationPermissionCheckDone(false)
Expand Down