docs/doc/reference/com/google/android/exoplayer2/testutil/ExoHostedTest.html
Package com.google.android.exoplayer2.testutil
All Implemented Interfaces:AnalyticsListener, HostActivity.HostedTest
public abstract classExoHostedTestextends[Object](https://developer.android.com/reference/java/lang/Object.html "class or interface in java.lang")implements[AnalyticsListener](../analytics/AnalyticsListener.html "interface in com.google.android.exoplayer2.analytics"),[HostActivity.HostedTest](HostActivity.HostedTest.html "interface in com.google.android.exoplayer2.testutil")
A HostActivity.HostedTest for ExoPlayer playback tests.
-
AnalyticsListener.EventFlags, AnalyticsListener.Events, AnalyticsListener.EventTime
Fields | Modifier and Type | Field | Description |
| --- | --- | --- |
| static long | EXPECTED_PLAYING_TIME_MEDIA_DURATION_MS | |
| static long | EXPECTED_PLAYING_TIME_UNSET | |
| static long | MAX_PLAYING_TIME_DISCREPANCY_MS | |
| protected String | tag | |
-
EVENT_AUDIO_ATTRIBUTES_CHANGED, EVENT_AUDIO_CODEC_ERROR, EVENT_AUDIO_DECODER_INITIALIZED, EVENT_AUDIO_DECODER_RELEASED, EVENT_AUDIO_DISABLED, EVENT_AUDIO_ENABLED, EVENT_AUDIO_INPUT_FORMAT_CHANGED, EVENT_AUDIO_POSITION_ADVANCING, EVENT_AUDIO_SESSION_ID, EVENT_AUDIO_SINK_ERROR, EVENT_AUDIO_UNDERRUN, EVENT_AVAILABLE_COMMANDS_CHANGED, EVENT_BANDWIDTH_ESTIMATE, EVENT_CUES, EVENT_DEVICE_INFO_CHANGED, EVENT_DEVICE_VOLUME_CHANGED, EVENT_DOWNSTREAM_FORMAT_CHANGED, EVENT_DRM_KEYS_LOADED, EVENT_DRM_KEYS_REMOVED, EVENT_DRM_KEYS_RESTORED, EVENT_DRM_SESSION_ACQUIRED, EVENT_DRM_SESSION_MANAGER_ERROR, EVENT_DRM_SESSION_RELEASED, EVENT_DROPPED_VIDEO_FRAMES, EVENT_IS_LOADING_CHANGED, EVENT_IS_PLAYING_CHANGED, EVENT_LOAD_CANCELED, EVENT_LOAD_COMPLETED, EVENT_LOAD_ERROR, EVENT_LOAD_STARTED, EVENT_MAX_SEEK_TO_PREVIOUS_POSITION_CHANGED, EVENT_MEDIA_ITEM_TRANSITION, EVENT_MEDIA_METADATA_CHANGED, EVENT_METADATA, EVENT_PLAY_WHEN_READY_CHANGED, EVENT_PLAYBACK_PARAMETERS_CHANGED, EVENT_PLAYBACK_STATE_CHANGED, EVENT_PLAYBACK_SUPPRESSION_REASON_CHANGED, EVENT_PLAYER_ERROR, EVENT_PLAYER_RELEASED, EVENT_PLAYLIST_METADATA_CHANGED, EVENT_POSITION_DISCONTINUITY, EVENT_RENDERED_FIRST_FRAME, EVENT_REPEAT_MODE_CHANGED, EVENT_SEEK_BACK_INCREMENT_CHANGED, EVENT_SEEK_FORWARD_INCREMENT_CHANGED, EVENT_SHUFFLE_MODE_ENABLED_CHANGED, EVENT_SKIP_SILENCE_ENABLED_CHANGED, EVENT_SURFACE_SIZE_CHANGED, EVENT_TIMELINE_CHANGED, EVENT_TRACK_SELECTION_PARAMETERS_CHANGED, EVENT_TRACKS_CHANGED, EVENT_UPSTREAM_DISCARDED, EVENT_VIDEO_CODEC_ERROR, EVENT_VIDEO_DECODER_INITIALIZED, EVENT_VIDEO_DECODER_RELEASED, EVENT_VIDEO_DISABLED, EVENT_VIDEO_ENABLED, EVENT_VIDEO_FRAME_PROCESSING_OFFSET, EVENT_VIDEO_INPUT_FORMAT_CHANGED, EVENT_VIDEO_SIZE_CHANGED, EVENT_VOLUME_CHANGED
Constructors | Constructor | Description |
| --- | --- |
| ExoHostedTest(String tag, boolean fullPlaybackNoSeeking) | |
| ExoHostedTest(String tag, long expectedPlayingTimeMs, boolean failOnPlayerError) | |
All Methods Instance Methods Abstract Methods Concrete Methods | Modifier and Type | Method | Description |
| --- | --- | --- |
| protected void | assertPassed(DecoderCounters audioCounters, DecoderCounters videoCounters) | |
| boolean | blockUntilStopped(long timeoutMs) |
Called on the main thread to block until the test has stopped or HostActivity.HostedTest.forceStop() is called.
|
| protected DrmSessionManager | buildDrmSessionManager() | |
| protected ExoPlayer | buildExoPlayer(HostActivity host, Surface surface, MappingTrackSelector trackSelector) | |
| protected abstract MediaSource | buildSource(HostActivity host, DrmSessionManager drmSessionManager, FrameLayout overlayFrameLayout) | |
| protected DefaultTrackSelector | buildTrackSelector(HostActivity host) | |
| boolean | forceStop() |
Called on the main thread to force stop the test (if it is not stopped already).
|
| protected void | logMetrics(DecoderCounters audioCounters, DecoderCounters videoCounters) | |
| void | onAudioDisabled(AnalyticsListener.EventTime eventTime, DecoderCounters decoderCounters) |
Called when an audio renderer is disabled.
|
| void | onEvents(Player player, AnalyticsListener.Events events) |
Called after one or more events occurred.
|
| void | onFinished() |
Called on the test thread after the test has finished and been stopped.
|
| protected void | onPlayerErrorInternal(ExoPlaybackException error) | |
| void | onStart(HostActivity host, Surface surface, FrameLayout overlayFrameLayout) |
Called on the main thread when the test is started.
|
| void | onVideoDisabled(AnalyticsListener.EventTime eventTime, DecoderCounters decoderCounters) |
Called when a video renderer is disabled.
|
| void | setSchedule(ActionSchedule schedule) |
Sets a schedule to be applied during the test.
|
-
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
onAudioAttributesChanged, onAudioCodecError, onAudioDecoderInitialized, onAudioDecoderInitialized, onAudioDecoderReleased, onAudioEnabled, onAudioInputFormatChanged, onAudioInputFormatChanged, onAudioPositionAdvancing, onAudioSessionIdChanged, onAudioSinkError, onAudioUnderrun, onAvailableCommandsChanged, onBandwidthEstimate, onCues, onCues, onDeviceInfoChanged, onDeviceVolumeChanged, onDownstreamFormatChanged, onDrmKeysLoaded, onDrmKeysRemoved, onDrmKeysRestored, onDrmSessionAcquired, onDrmSessionAcquired, onDrmSessionManagerError, onDrmSessionReleased, onDroppedVideoFrames, onIsLoadingChanged, onIsPlayingChanged, onLoadCanceled, onLoadCompleted, onLoadError, onLoadingChanged, onLoadStarted, onMaxSeekToPreviousPositionChanged, onMediaItemTransition, onMediaMetadataChanged, onMetadata, onPlaybackParametersChanged, onPlaybackStateChanged, onPlaybackSuppressionReasonChanged, onPlayerError, onPlayerErrorChanged, onPlayerReleased, onPlayerStateChanged, onPlaylistMetadataChanged, onPlayWhenReadyChanged, onPositionDiscontinuity, onPositionDiscontinuity, onRenderedFirstFrame, onRepeatModeChanged, onSeekBackIncrementChanged, onSeekForwardIncrementChanged, onSeekStarted, onShuffleModeChanged, onSkipSilenceEnabledChanged, onSurfaceSizeChanged, onTimelineChanged, onTracksChanged, onTrackSelectionParametersChanged, onUpstreamDiscarded, onVideoCodecError, onVideoDecoderInitialized, onVideoDecoderInitialized, onVideoDecoderReleased, onVideoEnabled, onVideoFrameProcessingOffset, onVideoInputFormatChanged, onVideoInputFormatChanged, onVideoSizeChanged, onVideoSizeChanged, onVolumeChanged
-
public static final long MAX_PLAYING_TIME_DISCREPANCY_MS
See Also:Constant Field Values
-
public static final long EXPECTED_PLAYING_TIME_MEDIA_DURATION_MS
See Also:Constant Field Values
-
public static final long EXPECTED_PLAYING_TIME_UNSET
See Also:Constant Field Values
-
protected final[String](https://developer.android.com/reference/java/lang/String.html "class or interface in java.lang")tag
-
public ExoHostedTest(@Size(max=23L)[String](https://developer.android.com/reference/java/lang/String.html "class or interface in java.lang")tag,
boolean fullPlaybackNoSeeking)
Parameters:tag - A tag to use for logging.fullPlaybackNoSeeking - 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.
-
public ExoHostedTest(@Size(max=23L)[String](https://developer.android.com/reference/java/lang/String.html "class or interface in java.lang")tag,
long expectedPlayingTimeMs,
boolean failOnPlayerError)
Parameters:tag - A tag to use for logging.expectedPlayingTimeMs - 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 - Whether a player error should be considered a test failure.
-
public final void setSchedule([ActionSchedule](ActionSchedule.html "class in com.google.android.exoplayer2.testutil")schedule)
Sets a schedule to be applied during the test.
Parameters:schedule - The schedule.
-
public final void onStart([HostActivity](HostActivity.html "class in com.google.android.exoplayer2.testutil")host,[Surface](https://developer.android.com/reference/android/view/Surface.html "class or interface in android.view")surface,[FrameLayout](https://developer.android.com/reference/android/widget/FrameLayout.html "class or interface in android.widget")overlayFrameLayout)
Description copied from interface: HostActivity.HostedTest
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.
Specified by:onStart in interface HostActivity.HostedTestParameters:host - The HostActivity in which the test is being run.surface - The Surface.overlayFrameLayout - A FrameLayout that is on top of the surface.
-
public final boolean blockUntilStopped(long timeoutMs)
Description copied from interface: HostActivity.HostedTest
Called on the main thread to block until the test has stopped or HostActivity.HostedTest.forceStop() is called.
Specified by:blockUntilStopped in interface HostActivity.HostedTestParameters:timeoutMs - The maximum time to block in milliseconds.Returns:Whether the test has stopped successful.
-
public final boolean forceStop()
Description copied from interface: HostActivity.HostedTest
Called on the main thread to force stop the test (if it is not stopped already).
Specified by:forceStop in interface HostActivity.HostedTestReturns:Whether the test was forced stopped.
-
public final void onFinished()
Description copied from interface: HostActivity.HostedTest
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.
Specified by:onFinished in interface HostActivity.HostedTest
-
public void onEvents([Player](../Player.html "interface in com.google.android.exoplayer2")player,[AnalyticsListener.Events](../analytics/AnalyticsListener.Events.html "class in com.google.android.exoplayer2.analytics")events)
Description copied from interface: AnalyticsListener
Called after one or more events occurred.
State changes and events that happen within one Looper message queue iteration are reported together and only after all individual callbacks were triggered.
Listeners should prefer this method over individual callbacks in the following cases:
- They intend to trigger the same logic for multiple events (e.g. when updating a UI for both [`AnalyticsListener.onPlaybackStateChanged(EventTime, int)`](../analytics/AnalyticsListener.html#onPlaybackStateChanged(com.google.android.exoplayer2.analytics.AnalyticsListener.EventTime,@com.google.android.exoplayer2.Player.Stateint)) and [`AnalyticsListener.onPlayWhenReadyChanged(EventTime, boolean, int)`](../analytics/AnalyticsListener.html#onPlayWhenReadyChanged(com.google.android.exoplayer2.analytics.AnalyticsListener.EventTime,boolean,@com.google.android.exoplayer2.Player.PlayWhenReadyChangeReasonint))).
- They need access to the [`Player`](../Player.html "interface in com.google.android.exoplayer2") object to trigger further events (e.g. to call [`Player.seekTo(long)`](../Player.html#seekTo(long)) after a [`AnalyticsListener.onMediaItemTransition(EventTime, MediaItem, int)`](../analytics/AnalyticsListener.html#onMediaItemTransition(com.google.android.exoplayer2.analytics.AnalyticsListener.EventTime,com.google.android.exoplayer2.MediaItem,@com.google.android.exoplayer2.Player.MediaItemTransitionReasonint))).
- They intend to use multiple state values together or in combination with [`Player`](../Player.html "interface in com.google.android.exoplayer2") getter methods. For example using [`Player.getCurrentMediaItemIndex()`](../Player.html#getCurrentMediaItemIndex()) with the `timeline` provided in [`AnalyticsListener.onTimelineChanged(EventTime, int)`](../analytics/AnalyticsListener.html#onTimelineChanged(com.google.android.exoplayer2.analytics.AnalyticsListener.EventTime,@com.google.android.exoplayer2.Player.TimelineChangeReasonint)) is only safe from within this method.
- They are interested in events that logically happened together (e.g [`AnalyticsListener.onPlaybackStateChanged(EventTime, int)`](../analytics/AnalyticsListener.html#onPlaybackStateChanged(com.google.android.exoplayer2.analytics.AnalyticsListener.EventTime,@com.google.android.exoplayer2.Player.Stateint)) to [`Player.STATE_BUFFERING`](../Player.html#STATE_BUFFERING) because of [`AnalyticsListener.onMediaItemTransition(EventTime, MediaItem, int)`](../analytics/AnalyticsListener.html#onMediaItemTransition(com.google.android.exoplayer2.analytics.AnalyticsListener.EventTime,com.google.android.exoplayer2.MediaItem,@com.google.android.exoplayer2.Player.MediaItemTransitionReasonint))).
Specified by:onEvents in interface AnalyticsListenerParameters:player - The Player.events - The AnalyticsListener.Events that occurred in this iteration.
-
public void onAudioDisabled([AnalyticsListener.EventTime](../analytics/AnalyticsListener.EventTime.html "class in com.google.android.exoplayer2.analytics")eventTime,[DecoderCounters](../decoder/DecoderCounters.html "class in com.google.android.exoplayer2.decoder")decoderCounters)
Description copied from interface: AnalyticsListener
Called when an audio renderer is disabled.
Specified by:onAudioDisabled in interface AnalyticsListenerParameters:eventTime - The event time.decoderCounters - DecoderCounters that were updated by the renderer.
-
public void onVideoDisabled([AnalyticsListener.EventTime](../analytics/AnalyticsListener.EventTime.html "class in com.google.android.exoplayer2.analytics")eventTime,[DecoderCounters](../decoder/DecoderCounters.html "class in com.google.android.exoplayer2.decoder")decoderCounters)
Description copied from interface: AnalyticsListener
Called when a video renderer is disabled.
Specified by:onVideoDisabled in interface AnalyticsListenerParameters:eventTime - The event time.decoderCounters - DecoderCounters that were updated by the renderer.
-
protected[DrmSessionManager](../drm/DrmSessionManager.html "interface in com.google.android.exoplayer2.drm")buildDrmSessionManager()
-
protected[DefaultTrackSelector](../trackselection/DefaultTrackSelector.html "class in com.google.android.exoplayer2.trackselection")buildTrackSelector([HostActivity](HostActivity.html "class in com.google.android.exoplayer2.testutil")host)
-
protected[ExoPlayer](../ExoPlayer.html "interface in com.google.android.exoplayer2")buildExoPlayer([HostActivity](HostActivity.html "class in com.google.android.exoplayer2.testutil")host,[Surface](https://developer.android.com/reference/android/view/Surface.html "class or interface in android.view")surface,[MappingTrackSelector](../trackselection/MappingTrackSelector.html "class in com.google.android.exoplayer2.trackselection")trackSelector)
-
protected abstract[MediaSource](../source/MediaSource.html "interface in com.google.android.exoplayer2.source")buildSource([HostActivity](HostActivity.html "class in com.google.android.exoplayer2.testutil")host,[DrmSessionManager](../drm/DrmSessionManager.html "interface in com.google.android.exoplayer2.drm")drmSessionManager,[FrameLayout](https://developer.android.com/reference/android/widget/FrameLayout.html "class or interface in android.widget")overlayFrameLayout)
-
protected void onPlayerErrorInternal([ExoPlaybackException](../ExoPlaybackException.html "class in com.google.android.exoplayer2")error)
-
protected void logMetrics([DecoderCounters](../decoder/DecoderCounters.html "class in com.google.android.exoplayer2.decoder")audioCounters,[DecoderCounters](../decoder/DecoderCounters.html "class in com.google.android.exoplayer2.decoder")videoCounters)
-
protected void assertPassed([DecoderCounters](../decoder/DecoderCounters.html "class in com.google.android.exoplayer2.decoder")audioCounters,[DecoderCounters](../decoder/DecoderCounters.html "class in com.google.android.exoplayer2.decoder")videoCounters)