Search in sources :

Example 1 with DownloadedState

use of org.edx.mobile.model.db.DownloadEntry.DownloadedState in project edx-app-android by edx.

the class DbTests method testgetDownloadedStateForVideoId.

@Test
public void testgetDownloadedStateForVideoId() throws Exception {
    db.clearDataByUser(username);
    String videoId = "videoId";
    db.getDownloadedStateForVideoId(videoId, new DataCallback<DownloadEntry.DownloadedState>() {

        @Override
        public void onResult(DownloadedState result) {
            assertTrue(result == DownloadedState.ONLINE);
            print("Result for getDownloadedStateForVideoId for not downloaded" + result);
            unlock();
        }

        @Override
        public void onFail(Exception ex) {
            fail(ex.getMessage());
        }
    });
    lock();
    DownloadEntry de = getDummyVideoModel();
    de.videoId = "videoId-" + System.currentTimeMillis();
    de.downloaded = DownloadedState.DOWNLOADED;
    db.addVideoData(de, null);
    db.getDownloadedStateForVideoId(de.videoId, new DataCallback<DownloadEntry.DownloadedState>() {

        @Override
        public void onResult(DownloadedState result) {
            assertNotNull(result);
            assertTrue(result == DownloadedState.DOWNLOADED);
            print("Result for getDownloadedStateForVideoId for downloaded is" + result);
            unlock();
        }

        @Override
        public void onFail(Exception ex) {
            fail(ex.getMessage());
        }
    });
    lock();
}
Also used : DownloadedState(org.edx.mobile.model.db.DownloadEntry.DownloadedState) DownloadEntry(org.edx.mobile.model.db.DownloadEntry) Test(org.junit.Test)

Aggregations

DownloadEntry (org.edx.mobile.model.db.DownloadEntry)1 DownloadedState (org.edx.mobile.model.db.DownloadEntry.DownloadedState)1 Test (org.junit.Test)1