ScreenController

class ScreenController


ScreenController provides API that allows testing of a Screen.

This controller will allows:

Summary

Public constructors

Creates a ScreenController to control a Screen for testing.

Public functions

Screen

Returns the Screen being controlled.

Any?

Returns the result that was set via setResult, or null if one was not set.

(Mutable)List<Template!>

Returns all the Templates returned from onGetTemplate for the being controlled.

ScreenController

Moves the Screen being controlled to the input state.

Unit

Resets values tracked by this ScreenController.

Public constructors

ScreenController

Added in 1.1.0
ScreenController(screen: Screen)

Creates a ScreenController to control a Screen for testing.

Throws
java.lang.NullPointerException

if screen is null

java.lang.IllegalArgumentException

if screen was not created with a TestCarContext

Public functions

getScreen

Added in 1.1.0
fun getScreen(): Screen

Returns the Screen being controlled.

getScreenResult

Added in 1.1.0
fun getScreenResult(): Any?

Returns the result that was set via setResult, or null if one was not set.

getTemplatesReturned

Added in 1.1.0
fun getTemplatesReturned(): (Mutable)List<Template!>

Returns all the Templates returned from onGetTemplate for the being controlled.

The templates are stored in the order in which they were returned from onGetTemplate, where the first template in the list, is the first template returned.

The templates will be stored until reset is called.

moveToState

Added in 1.1.0
fun moveToState(state: Lifecycle.State): ScreenController

Moves the Screen being controlled to the input state.

Note that moving the Screen up a state will also push the Screen onto the androidx.car.app.ScreenManager's screen stack if it isn't the current top.

DESTROYED is a terminal state, and you cannot move to any other state after the Screen reaches that state.

See also
getLifecycle

reset

Added in 1.1.0
fun reset(): Unit

Resets values tracked by this ScreenController.