From 6efed5007dbcda045fad08ca7eb4fe75f65a442d Mon Sep 17 00:00:00 2001 From: mcarare Date: Mon, 10 Oct 2022 11:47:21 +0300 Subject: [PATCH] [fenix] For https://github.com/mozilla-mobile/fenix/issues/25980: Use new backQueue instead of removed backStack. --- .../org/mozilla/fenix/search/SearchDialogFragment.kt | 2 +- .../org/mozilla/fenix/search/SearchDialogFragmentTest.kt | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/org/mozilla/fenix/search/SearchDialogFragment.kt b/app/src/main/java/org/mozilla/fenix/search/SearchDialogFragment.kt index 6b74da3d17..e6068897ab 100644 --- a/app/src/main/java/org/mozilla/fenix/search/SearchDialogFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/search/SearchDialogFragment.kt @@ -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() diff --git a/app/src/test/java/org/mozilla/fenix/search/SearchDialogFragmentTest.kt b/app/src/test/java/org/mozilla/fenix/search/SearchDialogFragmentTest.kt index 0c32f0117e..da26a21028 100644 --- a/app/src/test/java/org/mozilla/fenix/search/SearchDialogFragmentTest.kt +++ b/app/src/test/java/org/mozilla/fenix/search/SearchDialogFragmentTest.kt @@ -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() @@ -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"), @@ -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), @@ -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),