# FakeDownloader

# FakeDownloader

Artifact:[androidx.media3:media3-test-utils-robolectric](https://developer.android.com/jetpack/androidx/releases/media3)  
[View Source](https://cs.android.com/search?q=file:androidx/media3/test/utils/robolectric/FakeDownloader.java+class:androidx.media3.test.utils.robolectric.FakeDownloader)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/media3/test/utils/robolectric/FakeDownloader "View this page in Java")

<br />

```
@UnstableApi
class FakeDownloader : Downloader
```

<br />

*** ** * ** ***

A fake[Downloader](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/Downloader).

## Summary

|                                                                                                                                                                                                                   ### Public constructors                                                                                                                                                                                                                    |
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [FakeDownloader](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/FakeDownloader#FakeDownloader(androidx.media3.exoplayer.offline.DownloadRequest))`(request: `[DownloadRequest](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest)`!)` Creates a[FakeDownloader](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/FakeDownloader). |

|                             ### Public functions                              |
|-------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [assertCanceled](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/FakeDownloader#assertCanceled(boolean))`(canceled: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)`)` Asserts that[download](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/FakeDownloader#download(androidx.media3.exoplayer.offline.Downloader.ProgressListener))or[remove](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/FakeDownloader#remove())has been canceled or not canceled. |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [assertDownloadStarted](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/FakeDownloader#assertDownloadStarted())`()` Asserts that[download](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/FakeDownloader#download(androidx.media3.exoplayer.offline.Downloader.ProgressListener))has started.                                                                                                                                                                                                                                        |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [assertId](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/FakeDownloader#assertId(java.lang.String))`(id: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`!)` Asserts that the[FakeDownloader](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/FakeDownloader)instance was created with the given`id`.                                                                                                                                                                                            |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [assertRemoveStarted](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/FakeDownloader#assertRemoveStarted(boolean))`(started: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)`)` Asserts that[remove](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/FakeDownloader#remove())has started or not started.                                                                                                                                                                                         |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [assertStreamKeys](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/FakeDownloader#assertStreamKeys(androidx.media3.common.StreamKey...))`(streamKeys: `[Array](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html)`<`[StreamKey](https://developer.android.com/reference/kotlin/androidx/media3/common/StreamKey)`!>!)` Asserts that the[FakeDownloader](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/FakeDownloader)instance was created with the given`streamKeys`.                                          |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [cancel](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/FakeDownloader#cancel())`()` Permanently cancels the downloading by this downloader.                                                                                                                                                                                                                                                                                                                                                                                                                               |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [download](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/FakeDownloader#download(androidx.media3.exoplayer.offline.Downloader.ProgressListener))`(progressListener: `[Downloader.ProgressListener](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/Downloader.ProgressListener)`?)` Downloads the content.                                                                                                                                                                                                                               |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [fail](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/FakeDownloader#fail())`()` Fails[download](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/FakeDownloader#download(androidx.media3.exoplayer.offline.Downloader.ProgressListener))or[remove](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/FakeDownloader#remove())with an error.                                                                                                                                                      |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [finish](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/FakeDownloader#finish())`()` Finishes the[download](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/FakeDownloader#download(androidx.media3.exoplayer.offline.Downloader.ProgressListener))or[remove](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/FakeDownloader#remove())without an error.                                                                                                                                        |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [incrementBytesDownloaded](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/FakeDownloader#incrementBytesDownloaded())`()` Increments the number of bytes that the fake downloader has downloaded.                                                                                                                                                                                                                                                                                                                                                                           |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [remove](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/FakeDownloader#remove())`()` Removes the content.                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |

## Public constructors

### FakeDownloader

```
FakeDownloader(request: DownloadRequest!)
```

Creates a[FakeDownloader](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/FakeDownloader).  

|                                                            Parameters                                                             |
|-----------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------|
| `request: `[DownloadRequest](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest)`!` | The[download request](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadRequest). |

## Public functions

### assertCanceled

```
fun assertCanceled(canceled: Boolean): Unit
```

Asserts that[download](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/FakeDownloader#download(androidx.media3.exoplayer.offline.Downloader.ProgressListener))or[remove](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/FakeDownloader#remove())has been canceled or not canceled.  

|                                                    Throws                                                     |
|---------------------------------------------------------------------------------------------------------------|---|
| [java.lang.InterruptedException](https://developer.android.com/reference/java/lang/InterruptedException.html) |   |

### assertDownloadStarted

```
fun assertDownloadStarted(): Unit
```

Asserts that[download](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/FakeDownloader#download(androidx.media3.exoplayer.offline.Downloader.ProgressListener))has started.  

|                                                    Throws                                                     |
|---------------------------------------------------------------------------------------------------------------|---|
| [java.lang.InterruptedException](https://developer.android.com/reference/java/lang/InterruptedException.html) |   |

### assertId

```
fun assertId(id: String!): Unit
```

Asserts that the[FakeDownloader](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/FakeDownloader)instance was created with the given`id`.  

### assertRemoveStarted

```
fun assertRemoveStarted(started: Boolean): Unit
```

Asserts that[remove](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/FakeDownloader#remove())has started or not started.  

|                                                    Throws                                                     |
|---------------------------------------------------------------------------------------------------------------|---|
| [java.lang.InterruptedException](https://developer.android.com/reference/java/lang/InterruptedException.html) |   |

### assertStreamKeys

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

Asserts that the[FakeDownloader](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/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](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/Downloader#download(androidx.media3.exoplayer.offline.Downloader.ProgressListener))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](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/Downloader#cancel()).

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](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/Downloader.ProgressListener)`?` | A listener to receive progress updates, or`null`. |

|                                                                Throws                                                                 |
|---------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------|
| [java.io.IOException](https://developer.android.com/reference/java/io/IOException.html)                                               | If the download failed to complete successfully. |
| [java.lang.InterruptedException](https://developer.android.com/reference/java/lang/InterruptedException.html)                         | If the download was interrupted.                 |
| [java.util.concurrent.CancellationException](https://developer.android.com/reference/java/util/concurrent/CancellationException.html) | If the download was canceled.                    |

### fail

```
fun fail(): Unit
```

Fails[download](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/FakeDownloader#download(androidx.media3.exoplayer.offline.Downloader.ProgressListener))or[remove](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/FakeDownloader#remove())with an error.  

|                                                    Throws                                                     |
|---------------------------------------------------------------------------------------------------------------|---|
| [java.lang.InterruptedException](https://developer.android.com/reference/java/lang/InterruptedException.html) |   |

### finish

```
fun finish(): Unit
```

Finishes the[download](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/FakeDownloader#download(androidx.media3.exoplayer.offline.Downloader.ProgressListener))or[remove](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/FakeDownloader#remove())without an error.  

|                                                    Throws                                                     |
|---------------------------------------------------------------------------------------------------------------|---|
| [java.lang.InterruptedException](https://developer.android.com/reference/java/lang/InterruptedException.html) |   |

### incrementBytesDownloaded

```
fun incrementBytesDownloaded(): Unit
```

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

### remove

```
fun remove(): Unit
```

Removes the content.