Package com.google.android.exoplayer2.testutil

## Class ExoPlayerTestRunner.Builder

- java.lang.Object
- - com.google.android.exoplayer2.testutil.ExoPlayerTestRunner.Builder

- Enclosing class:
    ExoPlayerTestRunner

      public static final class ExoPlayerTestRunner.Builder
      extends Object

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

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `Builder​(Context context)` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `ExoPlayerTestRunner` | `build()` | Builds an `ExoPlayerTestRunner` using the provided values or their defaults.
    `ExoPlayerTestRunner.Builder` | `initialSeek​(int mediaItemIndex, long positionMs)` | Seeks before setting the media sources and preparing the player.
    `ExoPlayerTestRunner.Builder` | `setActionSchedule​(ActionSchedule actionSchedule)` | Sets an `ActionSchedule` to be run by the test runner.
    `ExoPlayerTestRunner.Builder` | `setAnalyticsListener​(AnalyticsListener analyticsListener)` | Sets an `AnalyticsListener` to be registered.
    `ExoPlayerTestRunner.Builder` | `setBandwidthMeter​(BandwidthMeter bandwidthMeter)` |
    `ExoPlayerTestRunner.Builder` | `setClock​(Clock clock)` |
    `ExoPlayerTestRunner.Builder` | `setExpectedPlayerEndedCount​(int expectedPlayerEndedCount)` | Sets the number of times the test runner is expected to reach the `Player.STATE_ENDED` or `Player.STATE_IDLE`.
    `ExoPlayerTestRunner.Builder` | `setLoadControl​(LoadControl loadControl)` |
    `ExoPlayerTestRunner.Builder` | `setManifest​(Object manifest)` | Sets a manifest to be used by a `FakeMediaSource` in the test runner.
    `ExoPlayerTestRunner.Builder` | `setMediaSources​(MediaSource... mediaSources)` | Sets the `MediaSource`s to be used by the test runner.
    `ExoPlayerTestRunner.Builder` | `setPauseAtEndOfMediaItems​(boolean pauseAtEndOfMediaItems)` | Sets whether to enable pausing at the end of media items.
    `ExoPlayerTestRunner.Builder` | `setPlayerListener​(Player.Listener playerListener)` | Sets an `Player.Listener` to be registered to listen to player events.
    `ExoPlayerTestRunner.Builder` | `setRenderers​(Renderer... renderers)` |
    `ExoPlayerTestRunner.Builder` | `setRenderersFactory​(RenderersFactory renderersFactory)` |
    `ExoPlayerTestRunner.Builder` | `setSupportedFormats​(Format... supportedFormats)` | Sets a list of `Format`s to be used by a `FakeMediaSource` to create media periods.
    `ExoPlayerTestRunner.Builder` | `setTimeline​(Timeline timeline)` | Sets a `Timeline` to be used by a `FakeMediaSource` in the test runner.
    `ExoPlayerTestRunner.Builder` | `setTrackSelector​(DefaultTrackSelector trackSelector)` |
    `ExoPlayerTestRunner.Builder` | `setUseLazyPreparation​(boolean useLazyPreparation)` |
    `ExoPlayerTestRunner.Builder` | `setVideoSurface​(Surface surface)` | Sets the video `Surface`.
    `ExoPlayerTestRunner.Builder` | `skipSettingMediaSources()` | Skips calling `ExoPlayer.setMediaSources(List)` before preparing.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### Builder

          public Builder​(Context context)

  - ### Method Detail

    - #### 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 `FakeTimeline.TimelineWindowDefinition.DEFAULT_WINDOW_DURATION_US`. Setting the timeline is not allowed after a call to `setMediaSources(MediaSource...)` or `skipSettingMediaSources()`.
      Parameters:
        `timeline` - A `Timeline` to be used by a `FakeMediaSource` in the test runner.
      Returns:
        This builder.

    - #### 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(MediaSource...)` or `skipSettingMediaSources()`.
      Parameters:
        `manifest` - A manifest to be used by a `FakeMediaSource` in the test runner.
      Returns:
        This builder.

    - #### initialSeek

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

      Seeks before setting the media sources and preparing the player.
      Parameters:
        `mediaItemIndex` - The media item index to seek to.
        `positionMs` - The position in milliseconds to seek to.
      Returns:
        This builder.

    - #### setMediaSources

          @CanIgnoreReturnValue
          public ExoPlayerTestRunner.Builder setMediaSources​(MediaSource... mediaSources)

      Sets the `MediaSource`s to be used by the test runner. The default value is a `FakeMediaSource` with the timeline and manifest provided by `setTimeline(Timeline)` and `setManifest(Object)`. Setting media sources is not allowed after calls to `skipSettingMediaSources()`, `setTimeline(Timeline)` and/or `setManifest(Object)`.
      Parameters:
        `mediaSources` - The `MediaSource`s to be used by the test runner.
      Returns:
        This builder.

    - #### setSupportedFormats

          @CanIgnoreReturnValue
          public ExoPlayerTestRunner.Builder setSupportedFormats​(Format... supportedFormats)

      Sets a list of `Format`s to be used by a `FakeMediaSource` to create media periods. The default value is a single `ExoPlayerTestRunner.VIDEO_FORMAT`. Note that this parameter doesn't have any influence if a media source with `setMediaSources(MediaSource...)` is set.
      Parameters:
        `supportedFormats` - A list of supported `Format`s.
      Returns:
        This builder.

    - #### skipSettingMediaSources

          @CanIgnoreReturnValue
          public ExoPlayerTestRunner.Builder skipSettingMediaSources()

      Skips calling `ExoPlayer.setMediaSources(List)` before preparing. Calling this method is not allowed after calls to `setMediaSources(MediaSource...)`, `setTimeline(Timeline)` and/or `setManifest(Object)`.
      Returns:
        This builder.

    - #### setUseLazyPreparation

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

      Returns:
        This builder.
      See Also:
        `TestExoPlayerBuilder.setUseLazyPreparation(boolean)`

    - #### setPauseAtEndOfMediaItems

          @CanIgnoreReturnValue
          public ExoPlayerTestRunner.Builder setPauseAtEndOfMediaItems​(boolean pauseAtEndOfMediaItems)

      Sets whether to enable pausing at the end of media items.
      Parameters:
        `pauseAtEndOfMediaItems` - Whether to pause at the end of media items.
      Returns:
        This builder.

    - #### setTrackSelector

          @CanIgnoreReturnValue
          public ExoPlayerTestRunner.Builder setTrackSelector​(DefaultTrackSelector trackSelector)

      Returns:
        This builder.
      See Also:
        `TestExoPlayerBuilder.setTrackSelector(DefaultTrackSelector)`

    - #### setLoadControl

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

      Returns:
        This builder.
      See Also:
        `TestExoPlayerBuilder.setLoadControl(LoadControl)`

    - #### setBandwidthMeter

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

      Returns:
        This builder.
      See Also:
        `TestExoPlayerBuilder.setBandwidthMeter(BandwidthMeter)`

    - #### setRenderers

          @CanIgnoreReturnValue
          public ExoPlayerTestRunner.Builder setRenderers​(Renderer... renderers)

      Returns:
        This builder.
      See Also:
        `TestExoPlayerBuilder.setRenderers(Renderer...)`

    - #### setRenderersFactory

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

      Returns:
        This builder.
      See Also:
        `TestExoPlayerBuilder.setRenderersFactory(RenderersFactory)`

    - #### setClock

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

      Returns:
        This builder.
      See Also:
        `TestExoPlayerBuilder.setClock(Clock)`

    - #### 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 `Player.prepare()`.
      Parameters:
        `actionSchedule` - An `ActionSchedule` to be used by the test runner.
      Returns:
        This builder.

    - #### setVideoSurface

          @CanIgnoreReturnValue
          public ExoPlayerTestRunner.Builder setVideoSurface​(Surface surface)

      Sets the video `Surface`. The default value is `null`.
      Parameters:
        `surface` - The `Surface` to be used by the player.
      Returns:
        This builder.

    - #### setPlayerListener

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

      Sets an `Player.Listener` to be registered to listen to player events.
      Parameters:
        `playerListener` - A `Player.Listener` to be registered by the test runner to listen to player events.
      Returns:
        This builder.

    - #### setAnalyticsListener

          @CanIgnoreReturnValue
          public ExoPlayerTestRunner.Builder setAnalyticsListener​(AnalyticsListener analyticsListener)

      Sets an `AnalyticsListener` to be registered.
      Parameters:
        `analyticsListener` - An `AnalyticsListener` to be registered.
      Returns:
        This builder.

    - #### setExpectedPlayerEndedCount

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

      Sets the number of times the test runner is expected to reach the `Player.STATE_ENDED` or `Player.STATE_IDLE`. The default is 1. This affects how long `ExoPlayerTestRunner.blockUntilEnded(long)` waits.
      Parameters:
        `expectedPlayerEndedCount` - The number of times the player is expected to reach the ended or idle state.
      Returns:
        This builder.

    - #### build

          public ExoPlayerTestRunner build()

      Builds an `ExoPlayerTestRunner` using the provided values or their defaults.
      Returns:
        The built `ExoPlayerTestRunner`.