FakeDownloader
@UnstableApi
public class FakeDownloader implements Downloader
A fake Downloader.
Summary
Public constructors |
|---|
FakeDownloader(DownloadRequest request)Creates a |
Public methods |
|
|---|---|
void |
assertCanceled(boolean canceled)Asserts that |
void |
Asserts that |
void |
Asserts that the |
void |
assertRemoveStarted(boolean started)Asserts that |
void |
assertStreamKeys(StreamKey[] streamKeys)Asserts that the |
void |
cancel()Permanently cancels the downloading by this downloader. |
void |
download(@Nullable Downloader.ProgressListener progressListener)Downloads the content. |
void |
fail() |
void |
finish() |
void |
Increments the number of bytes that the fake downloader has downloaded. |
void |
remove()Removes the content. |
Public constructors
FakeDownloader
public FakeDownloader(DownloadRequest request)
Creates a FakeDownloader.
| Parameters | |
|---|---|
DownloadRequest request |
The |
Public methods
assertCanceled
public void assertCanceled(boolean canceled)
Asserts that download or remove has been canceled or not canceled.
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 |
| 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. |
incrementBytesDownloaded
public void incrementBytesDownloaded()
Increments the number of bytes that the fake downloader has downloaded.