FakeNavigator

A fake Navigator that can be used in tests to record and assert navigation events.

This navigator acts as a real navigator for all intents and purposes, navigating either a given BackStack or using a simple real one under the hood if one isn't provided.

Example

val navigator = FakeNavigator(FavoritesScreen)
val presenter = FavoritesPresenter(navigator)

presenter.test {
val state = awaitItem()
state.eventSink(AddFavoriteClick)
assertThat(navigator.awaitNextScreen())
.isEqualTo(AddFavoriteScreen)
}

Constructors

Link copied to clipboard
constructor(backStack: BackStack<out BackStack.Record>)
constructor(root: Screen, vararg additionalScreens: Screen)

Types

Link copied to clipboard
data class GoToEvent(val screen: Screen, val success: Boolean)

Represents a recorded Navigator.goTo event.

Link copied to clipboard
data class PopEvent(val poppedScreen: Screen?, val result: PopResult? = null)

Represents a recorded Navigator.pop event.

Link copied to clipboard
data class ResetRootEvent(val newRoot: Screen, val oldScreens: ImmutableList<Screen>, val saveState: Boolean = false, val restoreState: Boolean = false)

Represents a recorded Navigator.resetRoot event.

Functions

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Awaits the next navigation goTo or throws if no goTo are performed.

Link copied to clipboard
suspend fun awaitNextScreen(): Screen

Awaits the next Screen that was navigated to or throws if no screens were navigated to.

Link copied to clipboard

Awaits the next navigation pop event or throws if no pops are performed.

Link copied to clipboard

Awaits the next navigation resetRoot or throws if no resets were performed.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override fun goTo(screen: Screen): Boolean
Link copied to clipboard
open override fun peek(): Screen?
Link copied to clipboard
open override fun peekBackStack(): ImmutableList<Screen>
Link copied to clipboard
open override fun pop(result: PopResult?): Screen?
Link copied to clipboard
open override fun resetRoot(newRoot: Screen, saveState: Boolean, restoreState: Boolean): ImmutableList<Screen>
Link copied to clipboard

Returns the next Screen that was navigated to or throws if no screens were navigated to.