SessionController

public class SessionController
extends Object

java.lang.Object
   ↳ androidx.car.app.testing.SessionController


A controller 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 methods

SessionController create(Intent intent)

Creates the Session that is being controlled with the given intent.

SessionController destroy()

Destroys the Session that is being controlled.

Session get()

Returns the Session that is being controlled.

static SessionController of(Session session, TestCarContext context)

Creates a SessionController to control the provided Session.

SessionController pause()

Pauses the Session that is being controlled.

SessionController resume()

Resumes the Session that is being controlled.

SessionController start()

Starts the Session that is being controlled.

SessionController stop()

Stops the Session that is being controlled.

Inherited methods

Public methods

create

public SessionController create (Intent intent)

Creates the Session that is being controlled with the given intent.

If this is the first time this is called on the Session, this would trigger Session.onCreateScreen(Intent) and transition the lifecycle to the Lifecycle.State.CREATED state. Otherwise, this will trigger Session.onNewIntent(Intent).

Parameters
intent Intent

Returns
SessionController

destroy

public SessionController destroy ()

Destroys the Session that is being controlled.

Returns
SessionController

get

public Session get ()

Returns the Session that is being controlled.

Returns
Session

of

public static SessionController of (Session session, 
                TestCarContext context)

Creates a SessionController to control the provided Session.

Parameters
session Session: the Session to control

context TestCarContext: the TestCarContext that the session should use.

Returns
SessionController

Throws
NullPointerException if session or context is null

pause

public SessionController pause ()

Pauses the Session that is being controlled.

Returns
SessionController

resume

public SessionController resume ()

Resumes the Session that is being controlled.

Returns
SessionController

start

public SessionController start ()

Starts the Session that is being controlled.

Returns
SessionController

stop

public SessionController stop ()

Stops the Session that is being controlled.

Returns
SessionController