Search in sources :

Example 46 with DownloadEntry

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

the class DbTests method testInsert.

@Test
public void testInsert() throws Exception {
    DownloadEntry de = getDummyVideoModel();
    de.isCourseActive = 1;
    de.downloaded = DownloadedState.DOWNLOADING;
    db.addVideoData(de, new DataCallback<Long>() {

        @Override
        public void onResult(Long result) {
            print("inserted id: " + result);
            assertNotNull(result);
            assertTrue(result > 0);
            unlock();
        }

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

Example 47 with DownloadEntry

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

the class DbTests method testupdateVideoAsOnlineByVideoId.

@Test
public void testupdateVideoAsOnlineByVideoId() throws Exception {
    db.clearDataByUser(username);
    String videoId = "videoId";
    // String videoId = "videoId-" + System.currentTimeMillis();
    db.updateVideoAsOnlineByVideoId(videoId, new DataCallback<Integer>() {

        @Override
        public void onResult(Integer result) {
            assertTrue(result == 0);
            print("Result for updateVideoAsOnlineByVideoId for 0 is" + result.toString());
            unlock();
        }

        @Override
        public void onFail(Exception ex) {
            fail(ex.getMessage());
        }
    });
    lock();
    DownloadEntry de1 = getDummyVideoModel();
    de1.videoId = "videoId";
    de1.downloaded = DownloadedState.ONLINE;
    db.addVideoData(de1, null);
    // String videoId1="" + System.currentTimeMillis();
    db.updateVideoAsOnlineByVideoId(videoId, new DataCallback<Integer>() {

        @Override
        public void onResult(Integer result) {
            assertNotNull(result);
            assertTrue(result == 1);
            print("Result for update Video As Online By VideoId " + result.intValue());
            unlock();
        }

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

Example 48 with DownloadEntry

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

the class DbTests method testgetVideoEntryByVideoId.

@Test
public void testgetVideoEntryByVideoId() throws Exception {
    db.clearDataByUser(username);
    String videoid = "videoid";
    db.getVideoEntryByVideoId(videoid, new DataCallback<VideoModel>() {

        @Override
        public void onResult(VideoModel result) {
            assertTrue(result == null);
            print("result for get VideoEntryByVideoId is:" + result);
            unlock();
        }

        @Override
        public void onFail(Exception ex) {
            fail(ex.getMessage());
        }
    });
    lock();
    DownloadEntry de = getDummyVideoModel();
    de.videoId = "videoid";
    db.addVideoData(de, null);
    db.getVideoEntryByVideoId(videoid, new DataCallback<VideoModel>() {

        @Override
        public void onResult(VideoModel result) {
            assertTrue(result != null);
            print("result for get VideoEntryByVideoId in AssertTrue:" + result);
            unlock();
        }

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

Example 49 with DownloadEntry

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

the class DbTests method testisAnyVideoDownloading.

@Test
public void testisAnyVideoDownloading() throws Exception {
    db.clearDataByUser(username);
    db.isAnyVideoDownloading(new DataCallback<Boolean>() {

        @Override
        public void onResult(Boolean result) {
            assertNotNull(result);
            assertFalse("something is downloading", result);
            print("result for Video AnyVideoDownloading is:" + result);
            unlock();
        }

        @Override
        public void onFail(Exception ex) {
            fail(ex.getMessage());
        }
    });
    lock();
    DownloadEntry de = getDummyVideoModel();
    // avoid duplicate videoId
    de.downloaded = DownloadedState.DOWNLOADING;
    db.addVideoData(de, null);
    db.isAnyVideoDownloading(new DataCallback<Boolean>() {

        @Override
        public void onResult(Boolean result) {
            assertNotNull(result);
            assertTrue("Result for Any Video Downloading  is:" + result.toString(), result);
            unlock();
        }

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

Example 50 with DownloadEntry

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

the class DbTests method testgetWatchedStateForVideoId.

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

        @Override
        public void onResult(WatchedState result) {
            assertNotNull(result);
            assertTrue(result == WatchedState.UNWATCHED);
            print("result for getWatchedStateForVideoId :" + result.toString());
            unlock();
        }

        @Override
        public void onFail(Exception ex) {
            fail(ex.getMessage());
        }
    });
    lock();
    DownloadEntry de = getDummyVideoModel();
    de.watched = WatchedState.WATCHED;
    de.videoId = "videoid";
    db.addVideoData(de, null);
    db.getWatchedStateForVideoId(de.videoId, new DataCallback<DownloadEntry.WatchedState>() {

        @Override
        public void onResult(WatchedState result) {
            assertNotNull(result);
            assertTrue(result == WatchedState.WATCHED);
            print("Result for getWatchedStateForVideoId is in 1:" + result);
            unlock();
        }

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

Aggregations

DownloadEntry (org.edx.mobile.model.db.DownloadEntry)50 Test (org.junit.Test)36 VideoModel (org.edx.mobile.model.VideoModel)10 List (java.util.List)6 HasDownloadEntry (org.edx.mobile.model.course.HasDownloadEntry)4 CourseComponent (org.edx.mobile.model.course.CourseComponent)2 DiscussionBlockModel (org.edx.mobile.model.course.DiscussionBlockModel)2 VideoBlockModel (org.edx.mobile.model.course.VideoBlockModel)2 WatchedState (org.edx.mobile.model.db.DownloadEntry.WatchedState)2 BulkVideosDownloadCancelledEvent (org.edx.mobile.module.storage.BulkVideosDownloadCancelledEvent)2 MenuItem (android.view.MenuItem)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 BaseFragmentActivity (org.edx.mobile.base.BaseFragmentActivity)1 BaseVideosDownloadStateActivity (org.edx.mobile.base.BaseVideosDownloadStateActivity)1 BlockPath (org.edx.mobile.model.course.BlockPath)1 IBlock (org.edx.mobile.model.course.IBlock)1 VideoInfo (org.edx.mobile.model.course.VideoInfo)1 DownloadedState (org.edx.mobile.model.db.DownloadEntry.DownloadedState)1