Search in sources :

Example 6 with DownloadBuilder

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

the class DefaultDownloadIndexTest method getDownloads_withStates_returnsAllDownloadStatusWithTheSameStates.

@Test
public void getDownloads_withStates_returnsAllDownloadStatusWithTheSameStates() throws DatabaseIOException {
    Download download1 = new DownloadBuilder("id1").setStartTimeMs(0).setState(Download.STATE_REMOVING).build();
    downloadIndex.putDownload(download1);
    Download download2 = new DownloadBuilder("id2").setStartTimeMs(1).setState(STATE_STOPPED).build();
    downloadIndex.putDownload(download2);
    Download download3 = new DownloadBuilder("id3").setStartTimeMs(2).setState(Download.STATE_COMPLETED).build();
    downloadIndex.putDownload(download3);
    try (DownloadCursor cursor = downloadIndex.getDownloads(Download.STATE_REMOVING, Download.STATE_COMPLETED)) {
        assertThat(cursor.getCount()).isEqualTo(2);
        cursor.moveToNext();
        assertEqual(cursor.getDownload(), download1);
        cursor.moveToNext();
        assertEqual(cursor.getDownload(), download3);
    }
}
Also used : DownloadBuilder(com.google.android.exoplayer2.testutil.DownloadBuilder) Test(org.junit.Test)

Example 7 with DownloadBuilder

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

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

Example 8 with DownloadBuilder

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

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

Example 9 with DownloadBuilder

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

the class DefaultDownloadIndexTest method addAndGetDownload_nonExistingId_returnsTheSameDownload.

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

Example 10 with DownloadBuilder

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

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();
}
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