use of com.google.android.exoplayer2.offline.Download 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);
}
use of com.google.android.exoplayer2.offline.Download 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();
}
use of com.google.android.exoplayer2.offline.Download in project ExoPlayer by google.
the class DefaultDownloadIndexTest method downloadIndex_upgradesFromVersion2.
@Test
public void downloadIndex_upgradesFromVersion2() throws IOException {
Context context = ApplicationProvider.getApplicationContext();
File databaseFile = context.getDatabasePath(StandaloneDatabaseProvider.DATABASE_NAME);
try (FileOutputStream output = new FileOutputStream(databaseFile)) {
output.write(TestUtil.getByteArray(context, "media/offline/exoplayer_internal_v2.db"));
}
Download dashDownload = createDownload(/* uri= */
"http://www.test.com/manifest.mpd", /* mimeType= */
MimeTypes.APPLICATION_MPD, ImmutableList.of(), /* customCacheKey= */
null);
Download hlsDownload = createDownload(/* uri= */
"http://www.test.com/manifest.m3u8", /* mimeType= */
MimeTypes.APPLICATION_M3U8, ImmutableList.of(), /* customCacheKey= */
null);
Download ssDownload = createDownload(/* uri= */
"http://www.test.com/video.ism/manifest", /* mimeType= */
MimeTypes.APPLICATION_SS, Arrays.asList(new StreamKey(0, 0), new StreamKey(1, 1)), /* customCacheKey= */
null);
Download progressiveDownload = createDownload(/* uri= */
"http://www.test.com/video.mp4", /* mimeType= */
MimeTypes.VIDEO_UNKNOWN, ImmutableList.of(), /* customCacheKey= */
"customCacheKey");
databaseProvider = new StandaloneDatabaseProvider(context);
downloadIndex = new DefaultDownloadIndex(databaseProvider);
assertEqual(downloadIndex.getDownload("http://www.test.com/manifest.mpd"), dashDownload);
assertEqual(downloadIndex.getDownload("http://www.test.com/manifest.m3u8"), hlsDownload);
assertEqual(downloadIndex.getDownload("http://www.test.com/video.ism/manifest"), ssDownload);
assertEqual(downloadIndex.getDownload("http://www.test.com/video.mp4"), progressiveDownload);
}
use of com.google.android.exoplayer2.offline.Download 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);
}
use of com.google.android.exoplayer2.offline.Download 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);
}
Aggregations