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 aDownloadManager
to itsDownloadManager.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 downloadManager)
-
-
Method Detail
-
blockUntilInitialized
public void blockUntilInitialized() throws InterruptedException
Blocks until the manager is initialized.- Throws:
InterruptedException
-
blockUntilIdle
public void blockUntilIdle() throws InterruptedException
Blocks until the manager is idle.- Throws:
InterruptedException
-
blockUntilIdleAndThrowAnyFailure
public void blockUntilIdleAndThrowAnyFailure() throws Exception
Blocks 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.Listener
Called when all downloads have been restored.- Specified by:
onInitialized
in interfaceDownloadManager.Listener
- Parameters:
downloadManager
- The reporting instance.
-
onDownloadChanged
public void onDownloadChanged(DownloadManager downloadManager, Download download, @Nullable Exception finalException)
Description copied from interface:DownloadManager.Listener
Called when the state of a download changes.- Specified by:
onDownloadChanged
in 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.Listener
Called when a download is removed.- Specified by:
onDownloadRemoved
in 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.Listener
Called when there is no active download left.- Specified by:
onIdle
in interfaceDownloadManager.Listener
- Parameters:
downloadManager
- The reporting instance.
-
-