androidx.navigation.testing


Classes

TestNavHostController

Subclass of NavHostController that offers additional APIs for testing Navigation.

TestNavigatorState

An implementation of NavigatorState that allows testing a androidx.navigation.Navigator in isolation (i.e., without requiring a androidx.navigation.NavController).

Extension functions summary

operator SavedStateHandle
SavedStateHandle.Companion.invoke(
    route: Any,
    typeMap: Map<KTypeNavType<*>>
)

SavedStateHandle constructor to create a SavedStateHandle with a serializable object.

Extension functions

operator fun SavedStateHandle.Companion.invoke(
    route: Any,
    typeMap: Map<KTypeNavType<*>> = emptyMap()
): SavedStateHandle

SavedStateHandle constructor to create a SavedStateHandle with a serializable object.

Returns a SavedStateHandle populated with arguments from route.

Note: To use this api in non-instrumented tests, run with robolectric. This is because android's Bundle is necessarily integrated into the parsing of route arguments.

Parameters
route: Any

The route to extract argument values from

typeMap: Map<KTypeNavType<*>> = emptyMap()

A mapping of KType to custom NavType<*> in the route. May be empty if route does not use custom NavTypes.