Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

Commit

Permalink
For #25980: Use new backQueue instead of removed backStack.
Browse files Browse the repository at this point in the history
  • Loading branch information
mcarare authored and mergify[bot] committed Oct 11, 2022
1 parent 55724de commit 8ed3bf7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -917,7 +917,7 @@ class SearchDialogFragment : AppCompatDialogFragment(), UserInteractionHandler {
internal fun getPreviousDestination(): NavBackStackEntry? {
// This duplicates the platform functionality for "previousBackStackEntry" but additionally skips this entry.

val descendingEntries = findNavController().backStack.descendingIterator()
val descendingEntries = findNavController().backQueue.reversed().iterator()
// Throw the topmost destination away.
if (descendingEntries.hasNext()) {
descendingEntries.next()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import org.junit.Assert.assertNull
import org.junit.Assert.assertSame
import org.junit.Before
import org.junit.Test
import java.util.ArrayDeque

internal class SearchDialogFragmentTest {
private val navController: NavController = mockk()
Expand All @@ -36,14 +35,14 @@ internal class SearchDialogFragmentTest {

@Test
fun `GIVEN this is the only visible fragment WHEN asking for the previous destination THEN return null`() {
every { navController.backStack } returns ArrayDeque(listOf(getDestination(fragmentName)))
every { navController.backQueue } returns ArrayDeque(listOf(getDestination(fragmentName)))

assertNull(fragment.getPreviousDestination())
}

@Test
fun `GIVEN this and FragmentB on top of this are visible WHEN asking for the previous destination THEN return null`() {
every { navController.backStack } returns ArrayDeque(
every { navController.backQueue } returns ArrayDeque(
listOf(
getDestination(fragmentName),
getDestination("FragmentB"),
Expand All @@ -56,7 +55,7 @@ internal class SearchDialogFragmentTest {
@Test
fun `GIVEN FragmentA, this and FragmentB are visible WHEN asking for the previous destination THEN return FragmentA`() {
val fragmentADestination = getDestination("FragmentA")
every { navController.backStack } returns ArrayDeque(
every { navController.backQueue } returns ArrayDeque(
listOf(
fragmentADestination,
getDestination(fragmentName),
Expand All @@ -70,7 +69,7 @@ internal class SearchDialogFragmentTest {
@Test
fun `GIVEN FragmentA and this on top of it are visible WHEN asking for the previous destination THEN return FragmentA`() {
val fragmentADestination = getDestination("FragmentA")
every { navController.backStack } returns ArrayDeque(
every { navController.backQueue } returns ArrayDeque(
listOf(
fragmentADestination,
getDestination(fragmentName),
Expand Down

0 comments on commit 8ed3bf7

Please sign in to comment.