Search in sources :

Example 11 with DownloadBuilder

use of com.google.android.exoplayer2.testutil.DownloadBuilder in project ExoPlayer by google.

the class DefaultDownloadIndexTest method releaseAndRecreateDownloadIndex_returnsTheSameDownload.

@Test
public void releaseAndRecreateDownloadIndex_returnsTheSameDownload() throws DatabaseIOException {
    String id = "id";
    Download download = new DownloadBuilder(id).build();
    downloadIndex.putDownload(download);
    downloadIndex = new DefaultDownloadIndex(databaseProvider);
    Download readDownload = downloadIndex.getDownload(id);
    assertThat(readDownload).isNotNull();
    assertEqual(readDownload, download);
}
Also used : DownloadBuilder(com.google.android.exoplayer2.testutil.DownloadBuilder) Test(org.junit.Test)

Example 12 with DownloadBuilder

use of com.google.android.exoplayer2.testutil.DownloadBuilder in project ExoPlayer by google.

the class DefaultDownloadIndexTest method setStopReason_notTerminalState_doesNotSetStopReason.

@Test
public void setStopReason_notTerminalState_doesNotSetStopReason() throws Exception {
    String id = "id";
    DownloadBuilder downloadBuilder = new DownloadBuilder(id).setState(STATE_DOWNLOADING);
    Download download = downloadBuilder.build();
    downloadIndex.putDownload(download);
    int notMetRequirements = 0x12345678;
    downloadIndex.setStopReason(notMetRequirements);
    Download readDownload = downloadIndex.getDownload(id);
    assertEqual(readDownload, download);
}
Also used : DownloadBuilder(com.google.android.exoplayer2.testutil.DownloadBuilder) Test(org.junit.Test)

Example 13 with DownloadBuilder

use of com.google.android.exoplayer2.testutil.DownloadBuilder in project ExoPlayer by google.

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);
}
Also used : DownloadBuilder(com.google.android.exoplayer2.testutil.DownloadBuilder) Test(org.junit.Test)

Example 14 with DownloadBuilder

use of com.google.android.exoplayer2.testutil.DownloadBuilder in project ExoPlayer by google.

the class DownloadManagerTest method mergeRequest_stopped_staysStopped.

@Test
public void mergeRequest_stopped_staysStopped() {
    DownloadRequest downloadRequest = createDownloadRequest(ID1);
    DownloadBuilder downloadBuilder = new DownloadBuilder(downloadRequest).setState(Download.STATE_STOPPED).setStopReason(/* stopReason= */
    1);
    Download download = downloadBuilder.build();
    Download mergedDownload = DownloadManager.mergeRequest(download, downloadRequest, download.stopReason, NOW_MS);
    assertEqualIgnoringUpdateTime(mergedDownload, download);
}
Also used : DownloadBuilder(com.google.android.exoplayer2.testutil.DownloadBuilder) Test(org.junit.Test)

Example 15 with DownloadBuilder

use of com.google.android.exoplayer2.testutil.DownloadBuilder in project ExoPlayer by google.

the class DownloadManagerTest method mergeRequest_removing_becomesRestarting.

@Test
public void mergeRequest_removing_becomesRestarting() {
    DownloadRequest downloadRequest = createDownloadRequest(ID1);
    DownloadBuilder downloadBuilder = new DownloadBuilder(downloadRequest).setState(Download.STATE_REMOVING);
    Download download = downloadBuilder.build();
    Download mergedDownload = DownloadManager.mergeRequest(download, downloadRequest, download.stopReason, NOW_MS);
    Download expectedDownload = downloadBuilder.setStartTimeMs(NOW_MS).setState(Download.STATE_RESTARTING).build();
    assertEqualIgnoringUpdateTime(mergedDownload, expectedDownload);
}
Also used : DownloadBuilder(com.google.android.exoplayer2.testutil.DownloadBuilder) Test(org.junit.Test)

Aggregations

DownloadBuilder (com.google.android.exoplayer2.testutil.DownloadBuilder)18 Test (org.junit.Test)18 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)2