docs/doc/reference/com/google/android/exoplayer2/testutil/MediaSourceTestRunner.html
Package com.google.android.exoplayer2.testutil
public classMediaSourceTestRunnerextends[Object](https://developer.android.com/reference/java/lang/Object.html "class or interface in java.lang")
A runner for MediaSource tests.
Fields | Modifier and Type | Field | Description |
| --- | --- | --- |
| static int | TIMEOUT_MS | |
Constructors | Constructor | Description |
| --- | --- |
| MediaSourceTestRunner(MediaSource mediaSource, Allocator allocator) | |
All Methods Instance Methods Concrete Methods | Modifier and Type | Method | Description |
| --- | --- | --- |
| void | assertCompletedManifestLoads(Integer... windowIndices) |
Asserts that the media source reported completed loads via MediaSourceEventListener.onLoadCompleted(int, MediaPeriodId, LoadEventInfo, MediaLoadData) for each specified window index and a null period id.
|
| void | assertCompletedMediaPeriodLoads(MediaSource.MediaPeriodId... mediaPeriodIds) |
Asserts that the media source reported completed loads via MediaSourceEventListener.onLoadCompleted(int, MediaPeriodId, LoadEventInfo, MediaLoadData) for each specified media period id, and asserts that the associated window index matches the one in the last known timeline returned from prepareSource(), assertTimelineChange() or assertTimelineChangeBlocking().
|
| void | assertNoTimelineChange() |
Asserts that the source has not notified its listener of a timeline change since the last call to assertTimelineChangeBlocking() or assertTimelineChange() (or since the runner was created if neither method has been called).
|
| void | assertPrepareAndReleaseAllPeriods() |
Creates and releases all periods (including ad periods) defined in the last timeline to be returned from prepareSource(), assertTimelineChange() or assertTimelineChangeBlocking().
|
| Timeline | assertTimelineChange() |
Asserts that the source has notified its listener of a single timeline change.
|
| Timeline | assertTimelineChangeBlocking() |
Asserts that the source notifies its listener of a single timeline change.
|
| MediaPeriod | createPeriod(MediaSource.MediaPeriodId periodId) |
Calls MediaSource.createPeriod(MediaSource.MediaPeriodId, Allocator, long) with a zero start position on the playback thread, asserting that a non-null MediaPeriod is returned.
|
| MediaPeriod | createPeriod(MediaSource.MediaPeriodId periodId, long startPositionUs) |
Calls MediaSource.createPeriod(MediaSource.MediaPeriodId, Allocator, long) on the playback thread, asserting that a non-null MediaPeriod is returned.
|
| CountDownLatch | preparePeriod(MediaPeriod mediaPeriod, long positionUs) |
Calls MediaPeriod.prepare(MediaPeriod.Callback, long) on the playback thread and blocks until the method has been called.
|
| Timeline | prepareSource() |
Prepares the source on the playback thread, asserting that it provides an initial timeline.
|
| void | release() |
Releases the runner.
|
| void | releasePeriod(MediaPeriod mediaPeriod) |
Calls MediaSource.releasePeriod(MediaPeriod) on the playback thread.
|
| void | releaseSource() |
Calls MediaSource.releaseSource(MediaSourceCaller) on the playback thread.
|
| void | runOnPlaybackThread(Runnable runnable) |
Runs the provided Runnable on the playback thread, blocking until execution completes.
|
-
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
public static final int TIMEOUT_MS
See Also:Constant Field Values
-
public MediaSourceTestRunner([MediaSource](../source/MediaSource.html "interface in com.google.android.exoplayer2.source")mediaSource,[Allocator](../upstream/Allocator.html "interface in com.google.android.exoplayer2.upstream")allocator)
Parameters:mediaSource - The source under test.allocator - The allocator to use during the test run.
-
public void runOnPlaybackThread([Runnable](https://developer.android.com/reference/java/lang/Runnable.html "class or interface in java.lang")runnable)
Runs the provided Runnable on the playback thread, blocking until execution completes.
Parameters:runnable - The Runnable to run.
-
public[Timeline](../Timeline.html "class in com.google.android.exoplayer2")prepareSource()
throws[IOException](https://developer.android.com/reference/java/io/IOException.html "class or interface in java.io")
Prepares the source on the playback thread, asserting that it provides an initial timeline.
Returns:The initial Timeline.Throws:IOException
-
public[MediaPeriod](../source/MediaPeriod.html "interface in com.google.android.exoplayer2.source")createPeriod([MediaSource.MediaPeriodId](../source/MediaSource.MediaPeriodId.html "class in com.google.android.exoplayer2.source")periodId)
Calls MediaSource.createPeriod(MediaSource.MediaPeriodId, Allocator, long) with a zero start position on the playback thread, asserting that a non-null MediaPeriod is returned.
Parameters:periodId - The id of the period to create.Returns:The created MediaPeriod.
-
public[MediaPeriod](../source/MediaPeriod.html "interface in com.google.android.exoplayer2.source")createPeriod([MediaSource.MediaPeriodId](../source/MediaSource.MediaPeriodId.html "class in com.google.android.exoplayer2.source")periodId,
long startPositionUs)
Calls MediaSource.createPeriod(MediaSource.MediaPeriodId, Allocator, long) on the playback thread, asserting that a non-null MediaPeriod is returned.
Parameters:periodId - The id of the period to create.startPositionUs - The expected start position, in microseconds.Returns:The created MediaPeriod.
-
public[CountDownLatch](https://developer.android.com/reference/java/util/concurrent/CountDownLatch.html "class or interface in java.util.concurrent")preparePeriod([MediaPeriod](../source/MediaPeriod.html "interface in com.google.android.exoplayer2.source")mediaPeriod,
long positionUs)
Calls MediaPeriod.prepare(MediaPeriod.Callback, long) on the playback thread and blocks until the method has been called.
Parameters:mediaPeriod - The MediaPeriod to prepare.positionUs - The position at which to prepare.Returns:A CountDownLatch that will be counted down when preparation completes.
-
public void releasePeriod([MediaPeriod](../source/MediaPeriod.html "interface in com.google.android.exoplayer2.source")mediaPeriod)
Calls MediaSource.releasePeriod(MediaPeriod) on the playback thread.
Parameters:mediaPeriod - The MediaPeriod to release.
-
public void releaseSource()
Calls MediaSource.releaseSource(MediaSourceCaller) on the playback thread.
-
public void assertNoTimelineChange()
Asserts that the source has not notified its listener of a timeline change since the last call to assertTimelineChangeBlocking() or assertTimelineChange() (or since the runner was created if neither method has been called).
-
public[Timeline](../Timeline.html "class in com.google.android.exoplayer2")assertTimelineChange()
Asserts that the source has notified its listener of a single timeline change.
Returns:The new Timeline.
-
public[Timeline](../Timeline.html "class in com.google.android.exoplayer2")assertTimelineChangeBlocking()
Asserts that the source notifies its listener of a single timeline change. If the source has not yet notified its listener, it has up to the timeout passed to the constructor to do so.
Returns:The new Timeline.
-
public void assertPrepareAndReleaseAllPeriods()
throws[InterruptedException](https://developer.android.com/reference/java/lang/InterruptedException.html "class or interface in java.lang")
Creates and releases all periods (including ad periods) defined in the last timeline to be returned from prepareSource(), assertTimelineChange() or assertTimelineChangeBlocking(). The MediaPeriodId.windowSequenceNumber is set to the index of the window.
Throws:InterruptedException
-
public void assertCompletedManifestLoads([Integer](https://developer.android.com/reference/java/lang/Integer.html "class or interface in java.lang")... windowIndices)
Asserts that the media source reported completed loads via MediaSourceEventListener.onLoadCompleted(int, MediaPeriodId, LoadEventInfo, MediaLoadData) for each specified window index and a null period id. Also asserts that no other loads with media period id null are reported.
-
public void assertCompletedMediaPeriodLoads([MediaSource.MediaPeriodId](../source/MediaSource.MediaPeriodId.html "class in com.google.android.exoplayer2.source")... mediaPeriodIds)
Asserts that the media source reported completed loads via MediaSourceEventListener.onLoadCompleted(int, MediaPeriodId, LoadEventInfo, MediaLoadData) for each specified media period id, and asserts that the associated window index matches the one in the last known timeline returned from prepareSource(), assertTimelineChange() or assertTimelineChangeBlocking().
-
public void release()
Releases the runner. Should be called when the runner is no longer required.