Search in sources :

Example 6 with DefaultDownloadIndex

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

Example 7 with DefaultDownloadIndex

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();
}
Also used : Context(android.content.Context) DefaultDownloadIndex(com.google.android.exoplayer2.offline.DefaultDownloadIndex) SimpleCache(com.google.android.exoplayer2.upstream.cache.SimpleCache) DummyMainThread(com.google.android.exoplayer2.testutil.DummyMainThread) NoOpCacheEvictor(com.google.android.exoplayer2.upstream.cache.NoOpCacheEvictor) FakeDataSet(com.google.android.exoplayer2.testutil.FakeDataSet) File(java.io.File) StreamKey(com.google.android.exoplayer2.offline.StreamKey) Before(org.junit.Before)

Aggregations

Before (org.junit.Before)3 Test (org.junit.Test)3 Context (android.content.Context)2 StandaloneDatabaseProvider (com.google.android.exoplayer2.database.StandaloneDatabaseProvider)2 DefaultDownloadIndex (com.google.android.exoplayer2.offline.DefaultDownloadIndex)2 StreamKey (com.google.android.exoplayer2.offline.StreamKey)2 TestDownloadManagerListener (com.google.android.exoplayer2.robolectric.TestDownloadManagerListener)2 DownloadBuilder (com.google.android.exoplayer2.testutil.DownloadBuilder)2 DummyMainThread (com.google.android.exoplayer2.testutil.DummyMainThread)2 FakeDataSet (com.google.android.exoplayer2.testutil.FakeDataSet)2 NoOpCacheEvictor (com.google.android.exoplayer2.upstream.cache.NoOpCacheEvictor)2 SimpleCache (com.google.android.exoplayer2.upstream.cache.SimpleCache)2 File (java.io.File)2 Notification (android.app.Notification)1 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)1 Nullable (androidx.annotation.Nullable)1 DefaultDownloaderFactory (com.google.android.exoplayer2.offline.DefaultDownloaderFactory)1 Download (com.google.android.exoplayer2.offline.Download)1 DownloadManager (com.google.android.exoplayer2.offline.DownloadManager)1 DownloadService (com.google.android.exoplayer2.offline.DownloadService)1