ScreenController
public
class
ScreenController
extends Object
| java.lang.Object | |
| ↳ | androidx.car.app.testing.ScreenController |
A controller that allows testing of a Screen.
This controller will allows:
- Moving a
Screenthrough its differentLifecycle.States. - Retrieving all
Templates returned fromScreen.onGetTemplate(). The values can be reset withreset().
Summary
Public constructors | |
|---|---|
ScreenController(TestCarContext testCarContext, Screen screen)
Creates a ScreenController to control a |
|
Public methods | |
|---|---|
Screen
|
getScreen()
Returns the |
Object
|
getScreenResult()
Returns the result that was set via |
List<Template>
|
getTemplatesReturned()
Returns all the |
ScreenController
|
moveToState(Lifecycle.State state)
Moves the |
void
|
reset()
Resets values tracked by this |
Inherited methods | |
|---|---|
Public constructors
ScreenController
public ScreenController (TestCarContext testCarContext, Screen screen)
Creates a ScreenController to control a Screen for testing.
| Parameters | |
|---|---|
testCarContext |
TestCarContext |
screen |
Screen |
| Throws | |
|---|---|
NullPointerException |
if either testCarContext or screen are null
|
Public methods
getScreenResult
public Object getScreenResult ()
Returns the result that was set via Screen.setResult(Object), or null if
one was not set.
| Returns | |
|---|---|
Object |
|
getTemplatesReturned
public List<Template> getTemplatesReturned ()
Returns all the Templates returned from Screen.onGetTemplate() for the Screen being controlled.
The templates are stored in the order in which they were returned from
Screen.onGetTemplate(), where the first template in the list, is the first template
returned.
The templates will be stored until reset() is called.
| Returns | |
|---|---|
List<Template> |
|
moveToState
public ScreenController moveToState (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 ScreenManager's screen stack if it isn't the current top.
Lifecycle.State.DESTROYED is a terminal state, and you cannot move to any other
state after the Screen reaches that state.
| Parameters | |
|---|---|
state |
Lifecycle.State |
| Returns | |
|---|---|
ScreenController |
|
See also: