ExoPlayerTestRunner.Builder


public final class ExoPlayerTestRunner.Builder


Builder to set-up an ExoPlayerTestRunner. Default fake implementations will be used for unset test properties.

Summary

Public constructors

Builder(Context context)

Public methods

ExoPlayerTestRunner

Builds an ExoPlayerTestRunner using the provided values or their defaults.

ExoPlayerTestRunner.Builder
@CanIgnoreReturnValue
initialSeek(int mediaItemIndex, long positionMs)

Seeks before setting the media sources and preparing the player.

ExoPlayerTestRunner.Builder

Sets an ActionSchedule to be run by the test runner.

ExoPlayerTestRunner.Builder

Sets an AnalyticsListener to be registered.

ExoPlayerTestRunner.Builder
ExoPlayerTestRunner.Builder
ExoPlayerTestRunner.Builder
@CanIgnoreReturnValue
setExpectedPlayerEndedCount(int expectedPlayerEndedCount)

Sets the number of times the test runner is expected to reach the STATE_ENDED or STATE_IDLE.

ExoPlayerTestRunner.Builder
ExoPlayerTestRunner.Builder

Sets a manifest to be used by a FakeMediaSource in the test runner.

ExoPlayerTestRunner.Builder
@CanIgnoreReturnValue
setMediaSources(MediaSource[] mediaSources)

Sets the MediaSources to be used by the test runner.

ExoPlayerTestRunner.Builder
@CanIgnoreReturnValue
setPauseAtEndOfMediaItems(boolean pauseAtEndOfMediaItems)

Sets whether to enable pausing at the end of media items.

ExoPlayerTestRunner.Builder

Sets an Player.Listener to be registered to listen to player events.

ExoPlayerTestRunner.Builder
@CanIgnoreReturnValue
setRenderers(Renderer[] renderers)
ExoPlayerTestRunner.Builder
ExoPlayerTestRunner.Builder
@CanIgnoreReturnValue
setSupportedFormats(Format[] supportedFormats)

Sets a list of Formats to be used by a FakeMediaSource to create media periods.

ExoPlayerTestRunner.Builder

Sets a Timeline to be used by a FakeMediaSource in the test runner.

ExoPlayerTestRunner.Builder
ExoPlayerTestRunner.Builder
@CanIgnoreReturnValue
setUseLazyPreparation(boolean useLazyPreparation)
ExoPlayerTestRunner.Builder

Sets the video Surface.

ExoPlayerTestRunner.Builder

Skips calling setMediaSources before preparing.

Public constructors

Builder

public Builder(Context context)

Public methods

build

public ExoPlayerTestRunner build()

Builds an ExoPlayerTestRunner using the provided values or their defaults.

initialSeek

@CanIgnoreReturnValue
public ExoPlayerTestRunner.Builder initialSeek(int mediaItemIndex, long positionMs)

Seeks before setting the media sources and preparing the player.

Parameters
int mediaItemIndex

The media item index to seek to.

long positionMs

The position in milliseconds to seek to.

Returns
ExoPlayerTestRunner.Builder

This builder.

setActionSchedule

@CanIgnoreReturnValue
public ExoPlayerTestRunner.Builder setActionSchedule(ActionSchedule actionSchedule)

Sets an ActionSchedule to be run by the test runner. The first action will be executed immediately before prepare.

Parameters
ActionSchedule actionSchedule

An ActionSchedule to be used by the test runner.

Returns
ExoPlayerTestRunner.Builder

This builder.

setAnalyticsListener

@CanIgnoreReturnValue
public ExoPlayerTestRunner.Builder setAnalyticsListener(AnalyticsListener analyticsListener)

Sets an AnalyticsListener to be registered.

Parameters
AnalyticsListener analyticsListener

An AnalyticsListener to be registered.

Returns
ExoPlayerTestRunner.Builder

This builder.

setBandwidthMeter

@CanIgnoreReturnValue
public ExoPlayerTestRunner.Builder setBandwidthMeter(BandwidthMeter bandwidthMeter)
Returns
ExoPlayerTestRunner.Builder

This builder.

setClock

@CanIgnoreReturnValue
public ExoPlayerTestRunner.Builder setClock(Clock clock)
Returns
ExoPlayerTestRunner.Builder

This builder.

See also
setClock

setExpectedPlayerEndedCount

@CanIgnoreReturnValue
public ExoPlayerTestRunner.Builder setExpectedPlayerEndedCount(int expectedPlayerEndedCount)

Sets the number of times the test runner is expected to reach the STATE_ENDED or STATE_IDLE. The default is 1. This affects how long blockUntilEnded waits.

Parameters
int expectedPlayerEndedCount

The number of times the player is expected to reach the ended or idle state.

Returns
ExoPlayerTestRunner.Builder

This builder.

setLoadControl

@CanIgnoreReturnValue
public ExoPlayerTestRunner.Builder setLoadControl(LoadControl loadControl)
Returns
ExoPlayerTestRunner.Builder

This builder.

See also
setLoadControl

setManifest

@CanIgnoreReturnValue
public ExoPlayerTestRunner.Builder setManifest(Object manifest)

Sets a manifest to be used by a FakeMediaSource in the test runner. The default value is null. Setting the manifest is not allowed after a call to setMediaSources or skipSettingMediaSources.

Parameters
Object manifest

A manifest to be used by a FakeMediaSource in the test runner.

Returns
ExoPlayerTestRunner.Builder

This builder.

setMediaSources

@CanIgnoreReturnValue
public ExoPlayerTestRunner.Builder setMediaSources(MediaSource[] mediaSources)

Sets the MediaSources to be used by the test runner. The default value is a with the timeline and manifest provided by setTimeline and setManifest. Setting media sources is not allowed after calls to skipSettingMediaSources, setTimeline and/or setManifest.

Parameters
MediaSource[] mediaSources

The MediaSources to be used by the test runner.

Returns
ExoPlayerTestRunner.Builder

This builder.

setPauseAtEndOfMediaItems

@CanIgnoreReturnValue
public ExoPlayerTestRunner.Builder setPauseAtEndOfMediaItems(boolean pauseAtEndOfMediaItems)

Sets whether to enable pausing at the end of media items.

Parameters
boolean pauseAtEndOfMediaItems

Whether to pause at the end of media items.

Returns
ExoPlayerTestRunner.Builder

This builder.

setPlayerListener

@CanIgnoreReturnValue
public ExoPlayerTestRunner.Builder setPlayerListener(Player.Listener playerListener)

Sets an Player.Listener to be registered to listen to player events.

Parameters
Player.Listener playerListener

A Player.Listener to be registered by the test runner to listen to player events.

Returns
ExoPlayerTestRunner.Builder

This builder.

setRenderers

@CanIgnoreReturnValue
public ExoPlayerTestRunner.Builder setRenderers(Renderer[] renderers)
Returns
ExoPlayerTestRunner.Builder

This builder.

See also
setRenderers

setRenderersFactory

@CanIgnoreReturnValue
public ExoPlayerTestRunner.Builder setRenderersFactory(RenderersFactory renderersFactory)
Returns
ExoPlayerTestRunner.Builder

This builder.

setSupportedFormats

@CanIgnoreReturnValue
public ExoPlayerTestRunner.Builder setSupportedFormats(Format[] supportedFormats)

Sets a list of Formats to be used by a FakeMediaSource to create media periods. The default value is a single VIDEO_FORMAT. Note that this parameter doesn't have any influence if a media source with setMediaSources is set.

Parameters
Format[] supportedFormats

A list of supported Formats.

Returns
ExoPlayerTestRunner.Builder

This builder.

setTimeline

@CanIgnoreReturnValue
public ExoPlayerTestRunner.Builder setTimeline(Timeline timeline)

Sets a Timeline to be used by a FakeMediaSource in the test runner. The default value is a seekable, non-dynamic FakeTimeline with a duration of DEFAULT_WINDOW_DURATION_US. Setting the timeline is not allowed after a call to setMediaSources or skipSettingMediaSources.

Parameters
Timeline timeline

A Timeline to be used by a FakeMediaSource in the test runner.

Returns
ExoPlayerTestRunner.Builder

This builder.

setUseLazyPreparation

@CanIgnoreReturnValue
public ExoPlayerTestRunner.Builder setUseLazyPreparation(boolean useLazyPreparation)
Returns
ExoPlayerTestRunner.Builder

This builder.

setVideoSurface

@CanIgnoreReturnValue
public ExoPlayerTestRunner.Builder setVideoSurface(Surface surface)

Sets the video Surface. The default value is null.

Parameters
Surface surface

The Surface to be used by the player.

Returns
ExoPlayerTestRunner.Builder

This builder.

skipSettingMediaSources

@CanIgnoreReturnValue
public ExoPlayerTestRunner.Builder skipSettingMediaSources()

Skips calling setMediaSources before preparing. Calling this method is not allowed after calls to setMediaSources, setTimeline and/or setManifest.

Returns
ExoPlayerTestRunner.Builder

This builder.