TestHostNavigator

class TestHostNavigator(var startRoot: NavRoot = DummyRoot) : HostNavigator

Constructors

Link copied to clipboard
constructor(startRoot: NavRoot = DummyRoot)

Properties

Link copied to clipboard
open override val snapshot: State<StackSnapshot>
Link copied to clipboard
open override var startRoot: NavRoot

Functions

Link copied to clipboard
open override fun destinationNavigator(entry: StackEntry<*>): DestinationNavigator2

Since this navigator does not have a back stack, the returned DestinationNavigator2 always treats its destination as the current one. Use destinationNavigator to get one that behaves differently.

fun destinationNavigator(isCurrentDestination: Boolean = true): DestinationNavigator2

Returns a DestinationNavigator2 that forwards all navigation events to this navigator, so that they can be asserted on with test and testIn.

Link copied to clipboard
open override fun getEntryFor(id: StackEntry.Id): StackEntry<*>
Link copied to clipboard
open override fun getTopEntryFor(destinationId: DestinationId<*>): StackEntry<*>
Link copied to clipboard
open override fun navigate(block: Navigator.() -> Unit)
Link copied to clipboard
open override fun navigateBack()
Link copied to clipboard
open override fun <T : BaseRoute> navigateBackTo(popUpTo: KClass<T>, inclusive: Boolean)
Link copied to clipboard
open override fun navigateTo(route: NavRoute)
Link copied to clipboard
open override fun navigateUp()
Link copied to clipboard
fun platformNavigator(): PlatformNavigator

Returns a PlatformNavigator for injection into a screen's activity or permission navigator. Create one instance per navigator under test and inject that same instance wherever needed.

Link copied to clipboard
open override fun replaceAllBackStacks(root: NavRoot)
Link copied to clipboard
open override fun showRoot(root: NavRoot)
Link copied to clipboard
open override fun switchBackStack(root: NavRoot)
Link copied to clipboard
suspend fun TestHostNavigator.test(timeout: Duration? = null, name: String? = null, validate: suspend NavigatorTurbine.() -> Unit)

Collects events from TestHostNavigator and allows the validate lambda to consume and assert properties on them in order. If any exception occurs during validation the exception is rethrown from this method.

Link copied to clipboard
fun TestHostNavigator.testIn(scope: CoroutineScope, timeout: Duration? = null, name: String? = null): NavigatorTurbine

Collects events from TestHostNavigator and returns a NavigatorTurbine for consuming and asserting properties on them in order. If any exception occurs during validation the exception is rethrown from this method.