Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
d0e5709
Move geopoly UI code to Fragment
seadowg Dec 2, 2025
9fa9189
Remove unused title from geotrace view
seadowg Dec 2, 2025
9a0f518
Extract super class for widget answer dialogs
seadowg Dec 3, 2025
ac334ab
Move WidgetAnswerDialogFragment to its own file
seadowg Dec 3, 2025
724ebcd
Fix references in tests
seadowg Dec 3, 2025
bac1082
Convert intent to constructor params
seadowg Dec 4, 2025
c0f12a1
Add GeoPolyDialogFragment that handles read only and output mode
seadowg Dec 4, 2025
fffe330
Generalize test helper
seadowg Dec 5, 2025
c2c1dfb
Add allow-mock-accuracy support to GeoPolyDialogFragment
seadowg Dec 8, 2025
969e160
Add existing answer support to GeoPolyDialogFragment
seadowg Dec 8, 2025
1af0f0a
Fix OutputMode matching
seadowg Dec 8, 2025
eb56037
Add result handling to GeoPolyDialogFragment
seadowg Dec 8, 2025
10b47a4
Spike out using Fragment instead of Activity for geotrace
seadowg Dec 8, 2025
f55d1d9
Fix tests
seadowg Dec 9, 2025
a9a183b
Remove external Activity integration points for geotrace
seadowg Dec 9, 2025
1f1e00b
Rework requestGeoTrace to work for both geopoly types
seadowg Dec 9, 2025
96a9bcc
Use dialog for geoshape as well
seadowg Dec 9, 2025
dddfb56
Remove external Activity integration points for geoshape
seadowg Dec 9, 2025
9314603
Remove GeoPolyActivity
seadowg Dec 9, 2025
f240b47
Fix Fragment recreation bug
seadowg Dec 9, 2025
2a59105
Pull out MockFragmentFactory
seadowg Dec 9, 2025
88c3947
Add assertDisabled
seadowg Dec 11, 2025
e2ad4de
Make language for constants consistent
seadowg Dec 11, 2025
37f8a7a
Correct typo
seadowg Dec 11, 2025
ecfbed3
Move helper to test helpers
seadowg Dec 11, 2025
98cc919
Simplify inputPolygon
seadowg Dec 11, 2025
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
Prev Previous commit
Next Next commit
Generalize test helper
  • Loading branch information
seadowg committed Dec 9, 2025
commit fffe3303e35341ba0b24a31a56564710f1a7b369
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.odk.collect.android.widgets.utilities

import androidx.core.os.bundleOf
import androidx.fragment.app.Fragment
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.viewmodel.CreationExtras
Expand All @@ -22,6 +23,7 @@ import org.odk.collect.androidshared.ui.FragmentFactoryBuilder
import org.odk.collect.fragmentstest.FragmentScenarioLauncherRule
import org.odk.collect.geo.geopoly.GeoPolyFragment
import org.odk.collect.geo.geopoly.GeoPolyFragment.OutputMode
import kotlin.reflect.KClass

@RunWith(AndroidJUnit4::class)
class GeoPolyDialogFragmentTest {
Expand Down Expand Up @@ -54,12 +56,12 @@ class GeoPolyDialogFragmentTest {
@Test
fun `configures GeoPolyFragment with readOnly from prompt`() {
prompt = MockFormEntryPromptBuilder(prompt).withReadOnly(true).build()
launchAndAssertOnGeoPolyFragment {
launcherRule.launchAndAssertOnChild<GeoPolyFragment>(GeoPolyDialogFragment::class) {
assertThat(it.readOnly, equalTo(true))
}

prompt = MockFormEntryPromptBuilder(prompt).withReadOnly(false).build()
launchAndAssertOnGeoPolyFragment {
launcherRule.launchAndAssertOnChild<GeoPolyFragment>(GeoPolyDialogFragment::class) {
assertThat(it.readOnly, equalTo(false))
}
}
Expand All @@ -70,7 +72,7 @@ class GeoPolyDialogFragmentTest {
.withControlType(Constants.DATATYPE_GEOSHAPE)
.build()

launchAndAssertOnGeoPolyFragment {
launcherRule.launchAndAssertOnChild<GeoPolyFragment>(GeoPolyDialogFragment::class) {
assertThat(it.outputMode, equalTo(OutputMode.GEOSHAPE))
}
}
Expand All @@ -81,7 +83,7 @@ class GeoPolyDialogFragmentTest {
.withControlType(Constants.DATATYPE_GEOTRACE)
.build()

launchAndAssertOnGeoPolyFragment {
launcherRule.launchAndAssertOnChild<GeoPolyFragment>(GeoPolyDialogFragment::class) {
assertThat(it.outputMode, equalTo(OutputMode.GEOTRACE))
}
}
Expand All @@ -92,18 +94,20 @@ class GeoPolyDialogFragmentTest {
.withControlType(Constants.DATATYPE_DATE)
.build()

launchAndAssertOnGeoPolyFragment {
launcherRule.launchAndAssertOnChild<GeoPolyFragment>(GeoPolyDialogFragment::class) {
assertThat(it.outputMode, equalTo(null))
}
}

private fun launchAndAssertOnGeoPolyFragment(assertion: (GeoPolyFragment) -> Unit) {
launcherRule.launch(
GeoPolyDialogFragment::class.java,
@Suppress("UNCHECKED_CAST")
private fun <T : Fragment> FragmentScenarioLauncherRule.launchAndAssertOnChild(
fragment: KClass<out Fragment>, assertion: (T) -> Unit
) {
this.launch(
fragment.java,
bundleOf(ARG_FORM_INDEX to prompt.index)
).onFragment {
val geoPolyFragment = it.childFragmentManager.fragments[0] as GeoPolyFragment
assertion(geoPolyFragment)
assertion(it.childFragmentManager.fragments[0] as T)
}
}
}