ScreenController
public class ScreenController
ScreenController provides API that allows testing of a Screen.
This controller will allows:
- Moving a
Screenthrough its differentStates. - Retrieving all
Templates returned fromonGetTemplate. The values can be reset withreset.
Summary
Public constructors |
|---|
ScreenController(@NonNull Screen screen)Creates a ScreenController to control a |
Public methods |
|
|---|---|
@NonNull Screen |
Returns the |
@Nullable Object |
Returns the result that was set via |
@NonNull List<Template> |
Returns all the |
@NonNull ScreenController |
moveToState(@NonNull Lifecycle.State state)Moves the |
void |
reset()Resets values tracked by this |
Public constructors
ScreenController
public ScreenController(@NonNull Screen screen)
Creates a ScreenController to control a Screen for testing.
| Throws | |
|---|---|
java.lang.NullPointerException |
if |
java.lang.IllegalArgumentException |
if |
Public methods
getScreenResult
public @Nullable Object getScreenResult()
Returns the result that was set via setResult, or null if one was not set.
getTemplatesReturned
public @NonNull List<Template> getTemplatesReturned()
Returns all the Templates returned from onGetTemplate for the Screen 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
public @NonNull ScreenController moveToState(@NonNull Lifecycle.State state)
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 |