Skip to content

Commit

Permalink
add testStateIdWithoutDestroy
Browse files Browse the repository at this point in the history
  • Loading branch information
Tlaster committed Mar 14, 2024
1 parent 313ce55 commit 4fb99c0
Showing 1 changed file with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -728,4 +728,33 @@ class BackStackManagerTest {
manager.push("screen3")
assertNotEquals(stateId, manager.backStacks.value.last().stateId)
}

@Test
fun testStateIdWithoutDestroy() {
val manager = BackStackManager()
val lifecycleOwner = TestLifecycleOwner()
val saveableStateHolder = TestSavedStateHolder()
manager.init(
stateHolder = StateHolder(),
savedStateHolder = saveableStateHolder,
lifecycleOwner = lifecycleOwner,
)
manager.setRouteGraph(
routeGraph = RouteGraph(
"screen1",
listOf(
TestRoute("screen1", "screen1"),
TestRoute("screen2", "screen2"),
TestRoute("screen3", "screen3"),
),
),
)
manager.push("screen2")
manager.push("screen3")
val lastEntry = manager.backStacks.value.last()
val stateId = lastEntry.stateId
manager.pop()
manager.push("screen3")
assertNotEquals(stateId, manager.backStacks.value.last().stateId)
}
}

0 comments on commit 4fb99c0

Please sign in to comment.