TestNavHostController


class TestNavHostController


Subclass of NavHostController that offers additional APIs for testing Navigation.

Summary

Public constructors

Public functions

Unit

Navigate directly to any destination on the current androidx.navigation.NavGraph via an explicit deep link.

Unit
setCurrentDestination(destRoute: String, args: Bundle)

Navigate directly to any destination on the current androidx.navigation.NavGraph via an explicit deep link.

Public properties

List<<Error class: unknown class>>

Gets an immutable copy of the NavBackStackEntry currently on the back stack.

Public constructors

TestNavHostController

Added in 2.3.0
TestNavHostController(context: Context)

Public functions

setCurrentDestination

Added in 2.3.0
fun setCurrentDestination(destId: @IdRes Int, args: Bundle = Bundle()): Unit

Navigate directly to any destination on the current androidx.navigation.NavGraph via an explicit deep link. If an implicit deep link exists for this destination use #navigate(Uri) instead.

Parameters
destId: @IdRes Int

The destination id to navigate to.

args: Bundle = Bundle()

The arguments to pass to the destination.

Throws
java.lang.IllegalArgumentException

If the destination does not exist on the NavGraph.

setCurrentDestination

Added in 2.4.0
fun setCurrentDestination(destRoute: String, args: Bundle = Bundle()): Unit

Navigate directly to any destination on the current androidx.navigation.NavGraph via an explicit deep link. If an implicit deep link exists for this destination use #navigate(Uri) instead.

Parameters
destRoute: String

The destination route to navigate to.

args: Bundle = Bundle()

The arguments to pass to the destination.

Throws
java.lang.IllegalArgumentException

If the destination does not exist on the NavGraph.

Public properties

backStack

Added in 2.3.0
val backStackList<<Error class: unknown class>>

Gets an immutable copy of the NavBackStackEntry currently on the back stack.