Skip to content

Commit

Permalink
Fix testNavigateWithPopupToWithDuplicateScene.
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Sousa committed Oct 27, 2023
1 parent e4707d0 commit ccc9a67
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -581,9 +581,17 @@ class BackStackManagerTest {
lifecycleOwner = lifecycleOwner,
persistNavState = false,
)
manager.push("screen2")
manager.push("screen1", NavOptions(popUpTo = PopUpTo("screen1")))
manager.push("screen1")

fun navigate(path: String, navOptions: NavOptions) {
val previousEntry = manager.backStacks.value.lastOrNull()
manager.push(path, navOptions)
// Mark the previous entry as inactive to simulate the lifecycle change by the NavHost
previousEntry?.inActive()
}

navigate("screen2", NavOptions())
navigate("screen1", NavOptions(popUpTo = PopUpTo("screen1")))
navigate("screen1", NavOptions())

assertEquals(
listOf("screen1", "screen1", "screen1"),
Expand Down

0 comments on commit ccc9a67

Please sign in to comment.