Back to Exoplayer

TestDownloadManagerListener (ExoPlayer library)

docs/doc/reference/com/google/android/exoplayer2/robolectric/TestDownloadManagerListener.html

latest7.0 KB
Original Source

Package com.google.android.exoplayer2.robolectric

Class TestDownloadManagerListener

  • java.lang.Object

    • com.google.android.exoplayer2.robolectric.TestDownloadManagerListener
  • All Implemented Interfaces:DownloadManager.Listener


public final classTestDownloadManagerListenerextends[Object](https://developer.android.com/reference/java/lang/Object.html "class or interface in java.lang")implements[DownloadManager.Listener](../offline/DownloadManager.Listener.html "interface in com.google.android.exoplayer2.offline")

Allows tests to block for, and assert properties of, calls from a DownloadManager to its DownloadManager.Listener.

Constructor Summary

Constructors | Constructor | Description | | --- | --- | | TestDownloadManagerListener​(DownloadManager downloadManager) | |

Method Summary

All Methods Instance Methods Concrete Methods | Modifier and Type | Method | Description | | --- | --- | --- | | void | assertRemoved​(String id) | Asserts that the specified download is removed. | | void | assertState​(String id, @com.google.android.exoplayer2.offline.Download.State int state) | Asserts that the specified download transitions to the specified state. | | void | blockUntilIdle() | Blocks until the manager is idle. | | void | blockUntilIdleAndThrowAnyFailure() | Blocks until the manager is idle and throws if any of the downloads failed. | | void | blockUntilInitialized() | Blocks until the manager is initialized. | | void | onDownloadChanged​(DownloadManager downloadManager, Download download, Exception finalException) | Called when the state of a download changes. | | void | onDownloadRemoved​(DownloadManager downloadManager, Download download) | Called when a download is removed. | | void | onIdle​(DownloadManager downloadManager) | Called when there is no active download left. | | void | onInitialized​(DownloadManager downloadManager) | Called when all downloads have been restored. |

- 

Methods inherited from class java.lang.Object

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

- 

Methods inherited from interface com.google.android.exoplayer2.offline.DownloadManager.Listener

onDownloadsPausedChanged, onRequirementsStateChanged, onWaitingForRequirementsChanged

Constructor Detail

- 

TestDownloadManagerListener

public TestDownloadManagerListener​([DownloadManager](../offline/DownloadManager.html "class in com.google.android.exoplayer2.offline")downloadManager)

Method Detail

- 

blockUntilInitialized

public void blockUntilInitialized()
                           throws[InterruptedException](https://developer.android.com/reference/java/lang/InterruptedException.html "class or interface in java.lang")

Blocks until the manager is initialized. Throws:InterruptedException

- 

blockUntilIdle

public void blockUntilIdle()
                    throws[InterruptedException](https://developer.android.com/reference/java/lang/InterruptedException.html "class or interface in java.lang")

Blocks until the manager is idle. Throws:InterruptedException

- 

blockUntilIdleAndThrowAnyFailure

public void blockUntilIdleAndThrowAnyFailure()
                                      throws[Exception](https://developer.android.com/reference/java/lang/Exception.html "class or interface in java.lang")

Blocks until the manager is idle and throws if any of the downloads failed. Throws:Exception

- 

assertState

public void assertState​([String](https://developer.android.com/reference/java/lang/String.html "class or interface in java.lang")id,[@State](../offline/Download.State.html "annotation in com.google.android.exoplayer2.offline")@com.google.android.exoplayer2.offline.Download.State int state)

Asserts that the specified download transitions to the specified state.

- 

assertRemoved

public void assertRemoved​([String](https://developer.android.com/reference/java/lang/String.html "class or interface in java.lang")id)

Asserts that the specified download is removed.

- 

onInitialized

public void onInitialized​([DownloadManager](../offline/DownloadManager.html "class in com.google.android.exoplayer2.offline")downloadManager)

Description copied from interface: DownloadManager.Listener

Called when all downloads have been restored. Specified by:onInitialized in interface DownloadManager.ListenerParameters:downloadManager - The reporting instance.

- 

onDownloadChanged

public void onDownloadChanged​([DownloadManager](../offline/DownloadManager.html "class in com.google.android.exoplayer2.offline")downloadManager,[Download](../offline/Download.html "class in com.google.android.exoplayer2.offline")download,
                              @Nullable[Exception](https://developer.android.com/reference/java/lang/Exception.html "class or interface in java.lang")finalException)

Description copied from interface: DownloadManager.Listener

Called when the state of a download changes. Specified by:onDownloadChanged in interface DownloadManager.ListenerParameters:downloadManager - The reporting instance.download - The state of the download.finalException - If the download is transitioning to Download.STATE_FAILED, this is the final exception that resulted in the failure.

- 

onDownloadRemoved

public void onDownloadRemoved​([DownloadManager](../offline/DownloadManager.html "class in com.google.android.exoplayer2.offline")downloadManager,[Download](../offline/Download.html "class in com.google.android.exoplayer2.offline")download)

Description copied from interface: DownloadManager.Listener

Called when a download is removed. Specified by:onDownloadRemoved in interface DownloadManager.ListenerParameters:downloadManager - The reporting instance.download - The last state of the download before it was removed.

- 

onIdle

public void onIdle​([DownloadManager](../offline/DownloadManager.html "class in com.google.android.exoplayer2.offline")downloadManager)

Description copied from interface: DownloadManager.Listener

Called when there is no active download left. Specified by:onIdle in interface DownloadManager.ListenerParameters:downloadManager - The reporting instance.