Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add test for discard after recreation
  • Loading branch information
seadowg committed Dec 18, 2025
commit 09d3f0ccbfb692f3ead7d2baee3bb771f5606ddd
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,45 @@ class GeoPolyFragmentTest {
)
}

@Test
fun whenPolygonHasBeenModified_recreating_andPressingBack_andClickingDiscard_setsOriginalAsResult() {
val onBackPressedDispatcher = OnBackPressedDispatcher()
val scenario = fragmentLauncherRule.launchInContainer(
GeoPolyFragment::class.java,
factory = FragmentFactoryBuilder()
.forClass(GeoPolyFragment::class) {
GeoPolyFragment(
{ onBackPressedDispatcher },
inputPolygon = listOf(MapPoint(0.0, 0.0), MapPoint(1.0, 1.0))
)
}
.build()
)

mapFragment.ready()

val resultListener = FragmentResultRecorder()
scenario.setFragmentResultListener(GeoPolyFragment.REQUEST_GEOPOLY, resultListener)

startInput()
mapFragment.click(MapPoint(2.0, 2.0))
resultListener.clear()

scenario.recreate()
scenario.setFragmentResultListener(GeoPolyFragment.REQUEST_GEOPOLY, resultListener)
mapFragment.ready()

onBackPressedDispatcher.onBackPressed()
Interactions.clickOn(withText(string.discard), root = isDialog())

val result = resultListener.lastResult
assertThat(result!!.first, equalTo(GeoPolyFragment.REQUEST_GEOPOLY))
assertThat(
result.second.getString(GeoPolyFragment.RESULT_GEOPOLY),
equalTo("0.0 0.0 0.0 0.0;1.0 1.0 0.0 0.0")
)
}

@Test
fun startingInput_usingAutomaticMode_usesRetainMockAccuracyTrueToStartLocationTracker() {
fragmentLauncherRule.launchInContainer(
Expand Down