Skip to content

Commit

Permalink
Merge pull request #301 from gerin98/fix-navigation-traverser-indenta…
Browse files Browse the repository at this point in the history
…tion

Fix NavigationTraverser indentation
  • Loading branch information
Kritarie authored May 30, 2024
2 parents 0a879d7 + c70d09f commit 64caab3
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class NavigationTraverser(private val root: NavigableCompat) {
"$VERTICAL_LINE$INDENT_SPACE"
}
node.getNavigationSnapshotRecursive(
indent + childIndent,
childIndent,
index == children.lastIndex
)
}.forEach { stringBuilder.append(it) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,20 +84,34 @@ internal class NavigationTraverserTest {

@Test
fun globalBackStackWithSiblingJourney() {
traverser = NavigationTraverser(siblingRoot)

siblingRoot.transitionToState(Created(context))
val rootJourney =
DummyJourney(
DummyJourney(
DummyJourney(
DummyJourney(
siblingRoot
)
)
)
)
traverser = NavigationTraverser(rootJourney)

rootJourney.transitionToState(Created(context))
journey3.goToAnotherJourney()

assertThat(traverser.getGlobalBackstackDescription()).isEqualTo(
"""
SiblingJourney
├ DummyJourney3
| ├ DummyStep3
| └ DummyStep4
└ DummyJourney2
├ DummyStep1
└ DummyStep2
DummyJourney
└ DummyJourney
└ DummyJourney
└ DummyJourney
└ SiblingJourney
├ DummyJourney3
| ├ DummyStep3
| └ DummyStep4
└ DummyJourney2
├ DummyStep1
└ DummyStep2
""".trimIndent()
)
Expand Down Expand Up @@ -129,6 +143,16 @@ internal class NavigationTraverserTest {
}
}

private inner class DummyJourney(val otherJourney: Journey<*>) : Journey<MagellanDummyLayoutBinding>(
MagellanDummyLayoutBinding::inflate,
MagellanDummyLayoutBinding::container
) {

override fun onCreate(context: Context) {
navigator.goTo(otherJourney)
}
}

private inner class MultiStepJourney : Journey<MagellanDummyLayoutBinding>(
MagellanDummyLayoutBinding::inflate,
MagellanDummyLayoutBinding::container
Expand Down

0 comments on commit 64caab3

Please sign in to comment.