From 622d9d87e4f1bb9afe06defc0ecc18c067408116 Mon Sep 17 00:00:00 2001 From: Ray Ryan Date: Fri, 26 Aug 2022 09:07:59 -0700 Subject: [PATCH] More realistic, failing `BackstackTransitionsTest` `BackstackTransitionsTest` now uses a map, to expose problems hidden when key and content are the same thing. As a result we crash when popping. Reproduces #63. --- .../compose/backstack/BackstackTransitionsTest.kt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/compose-backstack/src/androidTest/java/com/zachklipp/compose/backstack/BackstackTransitionsTest.kt b/compose-backstack/src/androidTest/java/com/zachklipp/compose/backstack/BackstackTransitionsTest.kt index ee44875..62a4964 100644 --- a/compose-backstack/src/androidTest/java/com/zachklipp/compose/backstack/BackstackTransitionsTest.kt +++ b/compose-backstack/src/androidTest/java/com/zachklipp/compose/backstack/BackstackTransitionsTest.kt @@ -83,19 +83,21 @@ class BackstackTransitionsTest { } private fun assertTransition(transition: BackstackTransition, forward: Boolean) { - val firstBackstack = listOf("one") - val secondBackstack = listOf("one", "two") + val firstBackstack = mapOf(1 to "one") + val secondBackstack = mapOf(1 to "one", 2 to "two") var backstack by mutableStateOf(if (forward) firstBackstack else secondBackstack) compose.mainClock.autoAdvance = false + compose.setContent { Backstack( - backstack, + backstack.keys.toList(), frameController = rememberTransitionController( animationSpec = animation, transition = transition ) - ) { BasicText(it) } + ) { BasicText(backstack.getValue(it)) } } + val initialText = if (forward) "one" else "two" val newText = if (forward) "two" else "one"