use of com.google.android.exoplayer2.testutil.DownloadBuilder in project ExoPlayer by google.
the class DefaultDownloadIndexTest method setSingleDownloadStopReason_setReason.
@Test
public void setSingleDownloadStopReason_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(id, stopReason);
Download readDownload = downloadIndex.getDownload(id);
Download expectedDownload = downloadBuilder.setStopReason(stopReason).build();
assertEqual(readDownload, expectedDownload);
}
use of com.google.android.exoplayer2.testutil.DownloadBuilder in project ExoPlayer by google.
the class DefaultDownloadIndexTest method downloadIndex_versionDowngradeWipesData.
@Test
public void downloadIndex_versionDowngradeWipesData() throws DatabaseIOException {
Download download1 = new DownloadBuilder("id1").build();
downloadIndex.putDownload(download1);
DownloadCursor cursor = downloadIndex.getDownloads();
assertThat(cursor.getCount()).isEqualTo(1);
cursor.close();
SQLiteDatabase writableDatabase = databaseProvider.getWritableDatabase();
VersionTable.setVersion(writableDatabase, VersionTable.FEATURE_OFFLINE, EMPTY_NAME, Integer.MAX_VALUE);
downloadIndex = new DefaultDownloadIndex(databaseProvider);
cursor = downloadIndex.getDownloads();
assertThat(cursor.getCount()).isEqualTo(0);
cursor.close();
assertThat(VersionTable.getVersion(writableDatabase, VersionTable.FEATURE_OFFLINE, EMPTY_NAME)).isEqualTo(DefaultDownloadIndex.TABLE_VERSION);
}
use of com.google.android.exoplayer2.testutil.DownloadBuilder in project ExoPlayer by google.
the class DefaultDownloadIndexTest method setSingleDownloadStopReason_setReasonToNone.
@Test
public void setSingleDownloadStopReason_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(id, STOP_REASON_NONE);
Download readDownload = downloadIndex.getDownload(id);
Download expectedDownload = downloadBuilder.setStopReason(STOP_REASON_NONE).build();
assertEqual(readDownload, expectedDownload);
}
Aggregations