Search in sources :

Example 11 with DownloadEntry

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

the class DbTests method testgetVideosCountBySection.

@Test
public void testgetVideosCountBySection() throws Exception {
    db.clearDataByUser(username);
    String enrollmentId = "enrollmentId";
    String chapter = "chapter";
    String section = "section";
    db.getVideosCountBySection(enrollmentId, chapter, section, new DataCallback<Integer>() {

        @Override
        public void onResult(Integer result) {
            assertTrue(result == 0);
            print("get the VideosCountBySection is: " + result);
            unlock();
        }

        @Override
        public void onFail(Exception ex) {
            fail(ex.getMessage());
        }
    });
    lock();
    DownloadEntry de = getDummyVideoModel();
    de.chapter = "fake_chapter";
    de.section = "fake_section";
    de.eid = "fake_eid";
    db.addVideoData(de, null);
    String enrollmentid = "fake_eid";
    String Chapter = "fake_chapter";
    String Section = "fake_section";
    db.getVideosCountBySection(enrollmentid, Chapter, Section, new DataCallback<Integer>() {

        @Override
        public void onResult(Integer result) {
            assertNotNull(result);
            assertTrue(result == 1);
            print("get the VideosCountBySection is: " + 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 12 with DownloadEntry

use of org.edx.mobile.model.db.DownloadEntry 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)

Example 13 with DownloadEntry

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

the class DbTests method testisVideoDownloadedInChapter.

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

        @Override
        public void onResult(Boolean result) {
            assertNotNull(result);
            // assertTrue(result);
            assertFalse("Video should not be downloaded in chapter " + chapter, result);
            print("Result for VideoDownloaded In Chapter is:" + result.toString());
            unlock();
        }

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

        @Override
        public void onResult(Boolean result) {
            assertNotNull(result);
            assertTrue(result);
            // assertFalse("Video should not be downloaded in chapter "+ chapter, result);
            print("Result for VideoDownloaded In Chapter is:" + result.toString());
            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 14 with DownloadEntry

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

the class DbTests method testupdateVideoLastPlayedOffset.

@Test
public void testupdateVideoLastPlayedOffset() throws Exception {
    db.clearDataByUser(username);
    String videoId = "videoId";
    int offset = 1;
    db.updateVideoLastPlayedOffset(videoId, offset, new DataCallback<Integer>() {

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

        @Override
        public void onFail(Exception ex) {
            fail(ex.getMessage());
        }
    });
    lock();
    DownloadEntry de = getDummyVideoModel();
    de.id = 1;
    de.videoId = videoId;
    int Offset = 2;
    db.addVideoData(de, null);
    db.updateVideoLastPlayedOffset(videoId, Offset, new DataCallback<Integer>() {

        @Override
        public void onResult(Integer result) {
            assertNotNull(result);
            assertTrue(result == 1);
            print("Result for updated the VideoLastPlayedOffset " + result.toString());
            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 15 with DownloadEntry

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

the class DbTests method testupdateDownloadCompleteInfoByDmId.

@Test
public void testupdateDownloadCompleteInfoByDmId() throws Exception {
    db.clearDataByUser(username);
    long dmId = 1;
    DownloadEntry de = getDummyVideoModel();
    db.updateDownloadCompleteInfoByDmId(dmId, de, new DataCallback<Integer>() {

        @Override
        public void onResult(Integer result) {
            assertNotNull(result);
            assertTrue(result == 0);
            print("Result for update DownloadComplete InfoByDmId in assertfail:" + result.toString());
            unlock();
        }

        @Override
        public void onFail(Exception ex) {
            fail(ex.getMessage());
        }
    });
    lock();
    DownloadEntry de1 = getDummyVideoModel();
    de1.dmId = 1;
    db.addVideoData(de1, null);
    db.updateDownloadCompleteInfoByDmId(dmId, de1, new DataCallback<Integer>() {

        @Override
        public void onResult(Integer result) {
            assertNotNull(result);
            assertTrue(result == 1);
            print("Result for update DownloadComplete InfoByDmId is in AssertTrue:" + result.toString());
            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