TestDownloadManagerListener


@UnstableApi
class TestDownloadManagerListener : DownloadManager.Listener


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

Summary

Public constructors

Public functions

Unit

Asserts that the specified download is removed.

Unit

Asserts that the specified download transitions to the specified state.

Unit

Blocks until the manager is idle.

Unit

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

Unit

Blocks until the manager is initialized.

Unit
onDownloadChanged(
    downloadManager: DownloadManager!,
    download: Download!,
    finalException: Exception?
)

Called when the state of a download changes.

Unit
onDownloadRemoved(downloadManager: DownloadManager!, download: Download!)

Called when a download is removed.

Unit
onIdle(downloadManager: DownloadManager!)

Called when there is no active download left.

Unit
onInitialized(downloadManager: DownloadManager!)

Called when all downloads have been restored.

Inherited functions

From androidx.media3.exoplayer.offline.DownloadManager.Listener
Unit
onDownloadsPausedChanged(
    downloadManager: DownloadManager!,
    downloadsPaused: Boolean
)

Called when downloads are (paused or resumed.

Unit
onRequirementsStateChanged(
    downloadManager: DownloadManager!,
    requirements: Requirements!,
    @Requirements.RequirementFlags notMetRequirements: Int
)

Called when the download requirements state changed.

Unit
onWaitingForRequirementsChanged(
    downloadManager: DownloadManager!,
    waitingForRequirements: Boolean
)

Called when there is a change in whether this manager has one or more downloads that are not progressing for the sole reason that the Requirements are not met.

Public constructors

TestDownloadManagerListener

TestDownloadManagerListener(downloadManager: DownloadManager!)

Public functions

assertRemoved

fun assertRemoved(id: String!): Unit

Asserts that the specified download is removed.

assertState

fun assertState(id: String!, @Download.State state: Int): Unit

Asserts that the specified download transitions to the specified state.

blockUntilIdle

fun blockUntilIdle(): Unit

Blocks until the manager is idle.

blockUntilIdleAndThrowAnyFailure

fun blockUntilIdleAndThrowAnyFailure(): Unit

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

blockUntilInitialized

fun blockUntilInitialized(): Unit

Blocks until the manager is initialized.

onDownloadChanged

fun onDownloadChanged(
    downloadManager: DownloadManager!,
    download: Download!,
    finalException: Exception?
): Unit

Called when the state of a download changes.

Parameters
downloadManager: DownloadManager!

The reporting instance.

download: Download!

The state of the download.

finalException: Exception?

If the download is transitioning to STATE_FAILED, this is the final exception that resulted in the failure.

onDownloadRemoved

fun onDownloadRemoved(downloadManager: DownloadManager!, download: Download!): Unit

Called when a download is removed.

Parameters
downloadManager: DownloadManager!

The reporting instance.

download: Download!

The last state of the download before it was removed.

onIdle

fun onIdle(downloadManager: DownloadManager!): Unit

Called when there is no active download left.

Parameters
downloadManager: DownloadManager!

The reporting instance.

onInitialized

fun onInitialized(downloadManager: DownloadManager!): Unit

Called when all downloads have been restored.

Parameters
downloadManager: DownloadManager!

The reporting instance.