use of androidx.media3.test.utils.DownloadBuilder in project media by androidx.
the class DownloadManagerTest method mergeRequest_completedWithStopReason_becomesStopped.
@Test
public void mergeRequest_completedWithStopReason_becomesStopped() {
DownloadRequest downloadRequest = createDownloadRequest(ID1);
DownloadBuilder downloadBuilder = new DownloadBuilder(downloadRequest).setState(Download.STATE_COMPLETED).setStopReason(/* stopReason= */
1);
Download download = downloadBuilder.build();
Download mergedDownload = DownloadManager.mergeRequest(download, downloadRequest, download.stopReason, NOW_MS);
Download expectedDownload = downloadBuilder.setStartTimeMs(NOW_MS).setState(Download.STATE_STOPPED).build();
assertEqualIgnoringUpdateTime(mergedDownload, expectedDownload);
}
use of androidx.media3.test.utils.DownloadBuilder in project media by androidx.
the class DownloadManagerTest method mergeRequest_failed_becomesQueued.
@Test
public void mergeRequest_failed_becomesQueued() {
DownloadRequest downloadRequest = createDownloadRequest(ID1);
DownloadBuilder downloadBuilder = new DownloadBuilder(downloadRequest).setState(Download.STATE_FAILED).setFailureReason(Download.FAILURE_REASON_UNKNOWN);
Download download = downloadBuilder.build();
Download mergedDownload = DownloadManager.mergeRequest(download, downloadRequest, download.stopReason, NOW_MS);
Download expectedDownload = downloadBuilder.setStartTimeMs(NOW_MS).setState(Download.STATE_QUEUED).setFailureReason(Download.FAILURE_REASON_NONE).build();
assertEqualIgnoringUpdateTime(mergedDownload, expectedDownload);
}
use of androidx.media3.test.utils.DownloadBuilder in project media by androidx.
the class DefaultDownloadIndexTest method setStatesToRemoving_setsStateAndClearsFailureReason.
@Test
public void setStatesToRemoving_setsStateAndClearsFailureReason() throws Exception {
String id = "id";
DownloadBuilder downloadBuilder = new DownloadBuilder(id).setState(Download.STATE_FAILED).setFailureReason(FAILURE_REASON_UNKNOWN);
Download download = downloadBuilder.build();
downloadIndex.putDownload(download);
downloadIndex.setStatesToRemoving();
download = downloadIndex.getDownload(id);
assertThat(download.state).isEqualTo(Download.STATE_REMOVING);
assertThat(download.failureReason).isEqualTo(FAILURE_REASON_NONE);
}
use of androidx.media3.test.utils.DownloadBuilder in project media by androidx.
the class DefaultDownloadIndexTest method removeDownload_existingId_getDownloadReturnsNull.
@Test
public void removeDownload_existingId_getDownloadReturnsNull() throws DatabaseIOException {
String id = "id";
Download download = new DownloadBuilder(id).build();
downloadIndex.putDownload(download);
downloadIndex.removeDownload(id);
Download readDownload = downloadIndex.getDownload(id);
assertThat(readDownload).isNull();
}
use of androidx.media3.test.utils.DownloadBuilder in project media by androidx.
the class DefaultDownloadIndexTest method addAndGetDownload_existingId_returnsUpdatedDownload.
@Test
public void addAndGetDownload_existingId_returnsUpdatedDownload() throws DatabaseIOException {
String id = "id";
DownloadBuilder downloadBuilder = new DownloadBuilder(id);
downloadIndex.putDownload(downloadBuilder.build());
Download download = downloadBuilder.setUri("different uri").setMimeType(MimeTypes.APPLICATION_MP4).setCacheKey("different cacheKey").setState(Download.STATE_FAILED).setPercentDownloaded(50).setBytesDownloaded(200).setContentLength(400).setFailureReason(FAILURE_REASON_UNKNOWN).setStopReason(0x12345678).setStartTimeMs(10).setUpdateTimeMs(20).setStreamKeys(new StreamKey(/* periodIndex= */
0, /* groupIndex= */
1, /* trackIndex= */
2), new StreamKey(/* periodIndex= */
3, /* groupIndex= */
4, /* trackIndex= */
5)).setCustomMetadata(new byte[] { 0, 1, 2, 3, 7, 8, 9, 10 }).setKeySetId(new byte[] { 0, 1, 2, 3 }).build();
downloadIndex.putDownload(download);
Download readDownload = downloadIndex.getDownload(id);
assertThat(readDownload).isNotNull();
assertEqual(readDownload, download);
}
Aggregations