use of com.google.android.exoplayer2.offline.DefaultDownloadIndex 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.offline.DefaultDownloadIndex in project ExoPlayer by google.
the class DownloadManagerDashTest method setUp.
@Before
public void setUp() throws Exception {
ShadowLog.stream = System.out;
testThread = new DummyMainThread();
Context context = ApplicationProvider.getApplicationContext();
tempFolder = Util.createTempDirectory(context, "ExoPlayerTest");
File cacheFolder = new File(tempFolder, "cache");
cacheFolder.mkdir();
cache = new SimpleCache(cacheFolder, new NoOpCacheEvictor(), TestUtil.getInMemoryDatabaseProvider());
MockitoAnnotations.initMocks(this);
fakeDataSet = new FakeDataSet().setData(TEST_MPD_URI, TEST_MPD).setRandomData("audio_init_data", 10).setRandomData("audio_segment_1", 4).setRandomData("audio_segment_2", 5).setRandomData("audio_segment_3", 6).setRandomData("text_segment_1", 1).setRandomData("text_segment_2", 2).setRandomData("text_segment_3", 3);
fakeStreamKey1 = new StreamKey(0, 0, 0);
fakeStreamKey2 = new StreamKey(0, 1, 0);
downloadIndex = new DefaultDownloadIndex(TestUtil.getInMemoryDatabaseProvider());
createDownloadManager();
}
Aggregations