SessionController


public class SessionController


SessionController provides API that allows testing of a Session.

This controller allows:

  • Injecting a TestCarContext into the Session instance, which provides access to the test managers and other testing functionalities.

Summary

Public constructors

SessionController(
    @NonNull Session session,
    @NonNull TestCarContext context,
    @NonNull Intent intent
)

Creates a SessionController to control the provided Session.

Public methods

@NonNull Session

Returns the Session that is being controlled.

@NonNull SessionController

Moves the Session being controlled to the input state.

Public constructors

SessionController

Added in 1.1.0
public SessionController(
    @NonNull Session session,
    @NonNull TestCarContext context,
    @NonNull Intent intent
)

Creates a SessionController to control the provided Session.

Parameters
@NonNull Session session

the Session to control

@NonNull TestCarContext context

the TestCarContext that the session should use.

@NonNull Intent intent

the Intent that the session should start with during the CREATED state.

Throws
java.lang.NullPointerException

if session or context is null

Public methods

getSession

Added in 1.1.0
public @NonNull Session getSession()

Returns the Session that is being controlled.

moveToState

Added in 1.1.0
public @NonNull SessionController moveToState(@NonNull Lifecycle.State state)

Moves the Session being controlled to the input state.

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

See also
getLifecycle