Search in sources :

Example 36 with DownloadEntry

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

the class DbTests method testupdateVideoWatchedState.

@Test
public void testupdateVideoWatchedState() throws Exception {
    db.clearDataByUser(username);
    String videoId = "videoId";
    WatchedState state = WatchedState.PARTIALLY_WATCHED;
    db.updateVideoWatchedState(videoId, state, new DataCallback<Integer>() {

        @Override
        public void onResult(Integer result) {
            assertNotNull(result);
            assertTrue(result == 0);
            print("updated VideoWatchedState for 0 is" + result);
            unlock();
        }

        @Override
        public void onFail(Exception ex) {
            fail(ex.getMessage());
        }
    });
    lock();
    DownloadEntry de = getDummyVideoModel();
    String videoid = de.videoId = "videoId-" + System.currentTimeMillis();
    WatchedState State = WatchedState.WATCHED;
    db.addVideoData(de, null);
    db.updateVideoWatchedState(videoid, State, new DataCallback<Integer>() {

        @Override
        public void onResult(Integer result) {
            assertNotNull(result);
            assertTrue(result == 1);
            print("updated VideoWatchedState for 1 is :" + result.toString());
            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)

Example 37 with DownloadEntry

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

the class DbTests method testgetIVideoModelByVideoUrl.

@Test
public void testgetIVideoModelByVideoUrl() throws Exception {
    db.clearDataByUser(username);
    final String videoUrl = "url";
    db.getIVideoModelByVideoUrl(videoUrl, new DataCallback<VideoModel>() {

        @Override
        public void onResult(VideoModel result) {
            assertNull("result should be null", result);
            unlock();
        }

        @Override
        public void onFail(Exception ex) {
            logger.error(ex);
            fail(ex.getMessage());
        }
    });
    lock();
    DownloadEntry de = getDummyVideoModel();
    de.url = "http://fake/url";
    db.addVideoData(de, null);
    db.getIVideoModelByVideoUrl(de.url, new DataCallback<VideoModel>() {

        @Override
        public void onResult(VideoModel result) {
            assertNotNull(result);
            print("VideoModel  present for url= " + result.getVideoUrl());
            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 38 with DownloadEntry

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

the class DbTests method getDummyVideoModel.

private DownloadEntry getDummyVideoModel() {
    DownloadEntry de = new DownloadEntry();
    de.username = username;
    de.title = "title";
    de.videoId = "videoId-" + System.currentTimeMillis();
    de.size = 1024;
    de.duration = 3600;
    de.filepath = "/fakepath";
    de.url = "http://fake/url";
    de.eid = "fake_eid";
    de.chapter = "fake_chapter";
    de.section = "fake_section";
    de.lastPlayedOffset = 0;
    de.lmsUrl = "http://fake/lms/url";
    de.isCourseActive = 1;
    de.downloaded = DownloadedState.DOWNLOADING;
    return de;
}
Also used : DownloadEntry(org.edx.mobile.model.db.DownloadEntry)

Example 39 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";
    // String videoId = "videoId-" + System.currentTimeMillis();
    db.getVideoEntryByVideoId(videoId, new DataCallback<VideoModel>() {

        @Override
        public void onResult(VideoModel result) {
            assertTrue(result == null);
            print("Result for Video Entry By VideoId= " + result);
            unlock();
        }

        @Override
        public void onFail(Exception ex) {
            fail(ex.getMessage());
        }
    });
    lock();
    DownloadEntry de = getDummyVideoModel();
    // de.videoId = "videoId-" + System.currentTimeMillis();
    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 Video Entry By VideoId in AssertTrue= " + result.getVideoId());
            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 40 with DownloadEntry

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

the class DbTests method testisVideoDownloadingInChapter.

@Test
public void testisVideoDownloadingInChapter() throws Exception {
    db.clearDataByUser(username);
    String enrollmentId = "enrollmentId";
    final String chapter = "chapter";
    db.isVideoDownloadingInChapter(enrollmentId, chapter, new DataCallback<Boolean>() {

        @Override
        public void onResult(Boolean result) {
            assertNotNull(result);
            // assertTrue(result);
            assertFalse("Video should not be present for chapter" + chapter, result);
            print("Boolean result for Video Downloading InChapter is:" + result.booleanValue());
            unlock();
        }

        @Override
        public void onFail(Exception ex) {
            fail(ex.getMessage());
        }
    });
    lock();
    DownloadEntry de = getDummyVideoModel();
    de.chapter = "chapter";
    de.eid = "enrollmentId";
    db.addVideoData(de, null);
    db.isVideoDownloadingInChapter(enrollmentId, chapter, new DataCallback<Boolean>() {

        @Override
        public void onResult(Boolean result) {
            assertNotNull(result);
            assertTrue(result);
            // assertFalse("Video should not be present for chapter"+ chapter, result);
            print("Boolean result for Video Downloading InChapter is:" + result.booleanValue());
            unlock();
        }

        @Override
        public void onFail(Exception ex) {
            fail(ex.getMessage());
        }
    });
    lock();
}
Also used : 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