@UnstableApi
class FakeDownloader : Downloader


A fake Downloader.

Summary

Public constructors

Creates a FakeDownloader.

Public functions

Unit

Asserts that download or remove has been canceled or not canceled.

Unit

Asserts that download has started.

Unit

Asserts that the FakeDownloader instance was created with the given id.

Unit

Asserts that remove has started or not started.

Unit

Asserts that the FakeDownloader instance was created with the given streamKeys.

Unit

Permanently cancels the downloading by this downloader.

Unit

Downloads the content.

Unit

Fails download or remove with an error.

Unit

Finishes the download or remove without an error.

Unit

Increments the number of bytes that the fake downloader has downloaded.

Unit

Removes the content.

Public constructors

FakeDownloader

FakeDownloader(request: DownloadRequest!)

Creates a FakeDownloader.

Parameters
request: DownloadRequest!

The download request.

Public functions

assertCanceled

fun assertCanceled(canceled: Boolean): Unit

Asserts that download or remove has been canceled or not canceled.

assertDownloadStarted

fun assertDownloadStarted(): Unit

Asserts that download has started.

assertId

fun assertId(id: String!): Unit

Asserts that the FakeDownloader instance was created with the given id.

assertRemoveStarted

fun assertRemoveStarted(started: Boolean): Unit

Asserts that remove has started or not started.

assertStreamKeys

fun assertStreamKeys(streamKeys: Array<StreamKey!>!): Unit

Asserts that the FakeDownloader instance was created with the given streamKeys.

cancel

fun cancel(): Unit

Permanently cancels the downloading by this downloader. The caller should also interrupt the downloading thread immediately after calling this method.

Once canceled, download cannot be called again.

download

fun download(progressListener: Downloader.ProgressListener?): Unit

Downloads the content.

If downloading fails, this method can be called again to resume the download. It cannot be called again after the download has been canceled.

If downloading is canceled whilst this method is executing, then it is expected that it will return reasonably quickly. However, there are no guarantees about how the method will return, meaning that it can return without throwing, or by throwing any of its documented exceptions. The caller must use its own knowledge about whether downloading has been canceled to determine whether this is why the method has returned, rather than relying on the method returning in a particular way.

Parameters
progressListener: Downloader.ProgressListener?

A listener to receive progress updates, or null.

Throws
java.io.IOException

If the download failed to complete successfully.

java.lang.InterruptedException

If the download was interrupted.

java.util.concurrent.CancellationException

If the download was canceled.

fail

fun fail(): Unit

Fails download or remove with an error.

finish

fun finish(): Unit

Finishes the download or remove without an error.

incrementBytesDownloaded

fun incrementBytesDownloaded(): Unit

Increments the number of bytes that the fake downloader has downloaded.

remove

fun remove(): Unit

Removes the content.