@UnstableApi
public class FakeDownloader implements Downloader


A fake Downloader.

Summary

Public constructors

Creates a FakeDownloader.

Public methods

void
assertCanceled(boolean canceled)

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

void

Asserts that download has started.

void

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

void
assertRemoveStarted(boolean started)

Asserts that remove has started or not started.

void
assertStreamKeys(StreamKey[] streamKeys)

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

void

Permanently cancels the downloading by this downloader.

void

Downloads the content.

void

Fails download or remove with an error.

void

Finishes the download or remove without an error.

void

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

void

Removes the content.

Public constructors

FakeDownloader

public FakeDownloader(DownloadRequest request)

Creates a FakeDownloader.

Parameters
DownloadRequest request

The download request.

Public methods

assertCanceled

public void assertCanceled(boolean canceled)

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

assertDownloadStarted

public void assertDownloadStarted()

Asserts that download has started.

assertId

public void assertId(String id)

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

assertRemoveStarted

public void assertRemoveStarted(boolean started)

Asserts that remove has started or not started.

assertStreamKeys

public void assertStreamKeys(StreamKey[] streamKeys)

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

cancel

public void cancel()

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

public void download(@Nullable Downloader.ProgressListener progressListener)

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
@Nullable Downloader.ProgressListener 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

public void fail()

Fails download or remove with an error.

finish

public void finish()

Finishes the download or remove without an error.

incrementBytesDownloaded

public void incrementBytesDownloaded()

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

remove

public void remove()

Removes the content.