@UnstableApi
abstract class ExoHostedTest : HostActivity.HostedTest


A HostedTest for ExoPlayer playback tests.

Summary

Public constructors

ExoHostedTest(tag: @Size(max = 23) String!, fullPlaybackNoSeeking: Boolean)
ExoHostedTest(
    tag: @Size(max = 23) String!,
    expectedPlayingTimeMs: Long,
    failOnPlayerError: Boolean
)

Public functions

Boolean
blockUntilStopped(timeoutMs: Long)

Called on the main thread to block until the test has stopped or forceStop is called.

Boolean

Called on the main thread to force stop the test (if it is not stopped already).

Unit

Called on the test thread after the test has finished and been stopped.

Unit
onStart(
    host: HostActivity!,
    surface: Surface!,
    overlayFrameLayout: FrameLayout!
)

Called on the main thread when the test is started.

Unit

Sets a schedule to be applied during the test.

Protected functions

Unit
assertPassed(
    audioCounters: DecoderCounters!,
    videoCounters: DecoderCounters!
)
DrmSessionManager!
ExoPlayer!
buildExoPlayer(
    host: HostActivity!,
    surface: Surface!,
    trackSelector: MappingTrackSelector!
)
abstract MediaSource!
buildSource(
    host: HostActivity!,
    drmSessionManager: DrmSessionManager!,
    overlayFrameLayout: FrameLayout!
)
DefaultTrackSelector!
Unit
logMetrics(
    audioCounters: DecoderCounters!,
    videoCounters: DecoderCounters!
)
Unit

Protected properties

String!

Constants

EXPECTED_PLAYING_TIME_MEDIA_DURATION_MS

const val EXPECTED_PLAYING_TIME_MEDIA_DURATION_MS = -2: Long

EXPECTED_PLAYING_TIME_UNSET

const val EXPECTED_PLAYING_TIME_UNSET = -1: Long

MAX_PLAYING_TIME_DISCREPANCY_MS

const val MAX_PLAYING_TIME_DISCREPANCY_MS = 5000: Long

Public constructors

ExoHostedTest

ExoHostedTest(tag: @Size(max = 23) String!, fullPlaybackNoSeeking: Boolean)
Parameters
tag: @Size(max = 23) String!

A tag to use for logging.

fullPlaybackNoSeeking: Boolean

Whether the test will play the target media in full without seeking. If set to true, the test will assert that the total time spent playing the media was within MAX_PLAYING_TIME_DISCREPANCY_MS of the media duration. If set to false, the test will not assert an expected playing time.

ExoHostedTest

ExoHostedTest(
    tag: @Size(max = 23) String!,
    expectedPlayingTimeMs: Long,
    failOnPlayerError: Boolean
)
Parameters
tag: @Size(max = 23) String!

A tag to use for logging.

expectedPlayingTimeMs: Long

The expected playing time. If set to a non-negative value, the test will assert that the total time spent playing the media was within MAX_PLAYING_TIME_DISCREPANCY_MS of the specified value. EXPECTED_PLAYING_TIME_MEDIA_DURATION_MS should be passed to assert that the expected playing time equals the duration of the media being played. Else EXPECTED_PLAYING_TIME_UNSET should be passed to indicate that the test should not assert an expected playing time.

failOnPlayerError: Boolean

Whether a player error should be considered a test failure.

Public functions

blockUntilStopped

fun blockUntilStopped(timeoutMs: Long): Boolean

Called on the main thread to block until the test has stopped or forceStop is called.

Parameters
timeoutMs: Long

The maximum time to block in milliseconds.

Returns
Boolean

Whether the test has stopped successful.

forceStop

fun forceStop(): Boolean

Called on the main thread to force stop the test (if it is not stopped already).

Returns
Boolean

Whether the test was forced stopped.

onFinished

fun onFinished(): Unit

Called on the test thread after the test has finished and been stopped.

Implementations may use this method to assert that test criteria were met.

onStart

fun onStart(
    host: HostActivity!,
    surface: Surface!,
    overlayFrameLayout: FrameLayout!
): Unit

Called on the main thread when the test is started.

The test will not be started until the HostActivity has been resumed and its Surface has been created.

Parameters
host: HostActivity!

The HostActivity in which the test is being run.

surface: Surface!

The Surface.

overlayFrameLayout: FrameLayout!

A FrameLayout that is on top of the surface.

setSchedule

fun setSchedule(schedule: ActionSchedule!): Unit

Sets a schedule to be applied during the test.

Parameters
schedule: ActionSchedule!

The schedule.

Protected functions

assertPassed

protected fun assertPassed(
    audioCounters: DecoderCounters!,
    videoCounters: DecoderCounters!
): Unit

buildDrmSessionManager

protected fun buildDrmSessionManager(): DrmSessionManager!

buildExoPlayer

protected fun buildExoPlayer(
    host: HostActivity!,
    surface: Surface!,
    trackSelector: MappingTrackSelector!
): ExoPlayer!

buildSource

protected abstract fun buildSource(
    host: HostActivity!,
    drmSessionManager: DrmSessionManager!,
    overlayFrameLayout: FrameLayout!
): MediaSource!

buildTrackSelector

protected fun buildTrackSelector(host: HostActivity!): DefaultTrackSelector!

logMetrics

protected fun logMetrics(
    audioCounters: DecoderCounters!,
    videoCounters: DecoderCounters!
): Unit

onPlayerErrorInternal

protected fun onPlayerErrorInternal(error: ExoPlaybackException!): Unit

Protected properties

tag

protected val tagString!