Search in sources :

Example 1 with DownloadBuilder

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

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

Example 2 with DownloadBuilder

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

the class DefaultDownloadIndexTest method setStopReason_setReasonToNone.

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

Example 3 with DownloadBuilder

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

the class DefaultDownloadIndexTest method setSingleDownloadStopReason_notTerminalState_doesNotSetStopReason.

@Test
public void setSingleDownloadStopReason_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(id, notMetRequirements);
    Download readDownload = downloadIndex.getDownload(id);
    assertEqual(readDownload, download);
}
Also used : DownloadBuilder(com.google.android.exoplayer2.testutil.DownloadBuilder) Test(org.junit.Test)

Example 4 with DownloadBuilder

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

the class DefaultDownloadIndexTest method setStopReason_setReason.

@Test
public void setStopReason_setReason() 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);
    int stopReason = 0x12345678;
    downloadIndex.setStopReason(stopReason);
    Download readDownload = downloadIndex.getDownload(id);
    Download expectedDownload = downloadBuilder.setStopReason(stopReason).build();
    assertEqual(readDownload, expectedDownload);
}
Also used : DownloadBuilder(com.google.android.exoplayer2.testutil.DownloadBuilder) Test(org.junit.Test)

Example 5 with DownloadBuilder

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

the class DefaultDownloadIndexTest method putDownload_setsVersion.

@Test
public void putDownload_setsVersion() throws DatabaseIOException {
    SQLiteDatabase readableDatabase = databaseProvider.getReadableDatabase();
    assertThat(VersionTable.getVersion(readableDatabase, VersionTable.FEATURE_OFFLINE, EMPTY_NAME)).isEqualTo(VersionTable.VERSION_UNSET);
    downloadIndex.putDownload(new DownloadBuilder("id1").build());
    assertThat(VersionTable.getVersion(readableDatabase, VersionTable.FEATURE_OFFLINE, EMPTY_NAME)).isEqualTo(DefaultDownloadIndex.TABLE_VERSION);
}
Also used : DownloadBuilder(com.google.android.exoplayer2.testutil.DownloadBuilder) SQLiteDatabase(android.database.sqlite.SQLiteDatabase) Test(org.junit.Test)

Aggregations

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