Class TestDownloadManagerListener
- java.lang.Object
-
- com.google.android.exoplayer2.robolectric.TestDownloadManagerListener
-
- All Implemented Interfaces:
DownloadManager.Listener
public final class TestDownloadManagerListener extends Object implements DownloadManager.Listener
Allows tests to block for, and assert properties of, calls from aDownloadManagerto itsDownloadManager.Listener.
-
-
Constructor Summary
Constructors Constructor Description TestDownloadManagerListener(DownloadManager downloadManager)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidassertRemoved(String id)Asserts that the specified download is removed.voidassertState(String id, @com.google.android.exoplayer2.offline.Download.State int state)Asserts that the specified download transitions to the specified state.voidblockUntilIdle()Blocks until the manager is idle.voidblockUntilIdleAndThrowAnyFailure()Blocks until the manager is idle and throws if any of the downloads failed.voidblockUntilInitialized()Blocks until the manager is initialized.voidonDownloadChanged(DownloadManager downloadManager, Download download, Exception finalException)Called when the state of a download changes.voidonDownloadRemoved(DownloadManager downloadManager, Download download)Called when a download is removed.voidonIdle(DownloadManager downloadManager)Called when there is no active download left.voidonInitialized(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 downloadManager)
-
-
Method Detail
-
blockUntilInitialized
public void blockUntilInitialized() throws InterruptedExceptionBlocks until the manager is initialized.- Throws:
InterruptedException
-
blockUntilIdle
public void blockUntilIdle() throws InterruptedExceptionBlocks until the manager is idle.- Throws:
InterruptedException
-
blockUntilIdleAndThrowAnyFailure
public void blockUntilIdleAndThrowAnyFailure() throws ExceptionBlocks until the manager is idle and throws if any of the downloads failed.- Throws:
Exception
-
assertState
public void assertState(String id, @State @com.google.android.exoplayer2.offline.Download.State int state)
Asserts that the specified download transitions to the specified state.
-
assertRemoved
public void assertRemoved(String id)
Asserts that the specified download is removed.
-
onInitialized
public void onInitialized(DownloadManager downloadManager)
Description copied from interface:DownloadManager.ListenerCalled when all downloads have been restored.- Specified by:
onInitializedin interfaceDownloadManager.Listener- Parameters:
downloadManager- The reporting instance.
-
onDownloadChanged
public void onDownloadChanged(DownloadManager downloadManager, Download download, @Nullable Exception finalException)
Description copied from interface:DownloadManager.ListenerCalled when the state of a download changes.- Specified by:
onDownloadChangedin interfaceDownloadManager.Listener- Parameters:
downloadManager- The reporting instance.download- The state of the download.finalException- If the download is transitioning toDownload.STATE_FAILED, this is the final exception that resulted in the failure.
-
onDownloadRemoved
public void onDownloadRemoved(DownloadManager downloadManager, Download download)
Description copied from interface:DownloadManager.ListenerCalled when a download is removed.- Specified by:
onDownloadRemovedin interfaceDownloadManager.Listener- Parameters:
downloadManager- The reporting instance.download- The last state of the download before it was removed.
-
onIdle
public void onIdle(DownloadManager downloadManager)
Description copied from interface:DownloadManager.ListenerCalled when there is no active download left.- Specified by:
onIdlein interfaceDownloadManager.Listener- Parameters:
downloadManager- The reporting instance.
-
-