Search in sources :

Example 31 with DownloadEntry

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

the class DbTests method testisVideoFilePresentByUrl.

@Test
public void testisVideoFilePresentByUrl() throws Exception {
    db.clearDataByUser(username);
    final String url = "fakeURL";
    db.isVideoFilePresentByUrl(url, new DataCallback<Boolean>() {

        @Override
        public void onResult(Boolean result) {
            assertNotNull(result);
            assertFalse("Video should not be present for " + url, result);
            unlock();
        }

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

        @Override
        public void onResult(Boolean result) {
            assertNotNull(result);
            assertTrue(result != null);
            // assertFalse("Video should not be present for " + url, result);
            print("Result for is VideoFilePresentByUrl in AssertTrue= " + 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 32 with DownloadEntry

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

the class DbTests method testgetDownloadingVideoDmIdsForChapter.

@Test
public void testgetDownloadingVideoDmIdsForChapter() throws Exception {
    db.clearDataByUser(username);
    String enrollmentId = "enrollmentId";
    String chapter = "chapter";
    db.getDownloadingVideoDmIdsForChapter(enrollmentId, chapter, new DataCallback<List<Long>>() {

        @Override
        public void onResult(List<Long> result) {
            assertNotNull(result);
            // assertTrue(result.length >= 0);
            assertTrue(result.size() == 0);
            // assertFalse("something is downloading", result);
            print("get All Downloading Videos DmidList :" + result.size());
            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.getDownloadingVideoDmIdsForChapter(enrollmentId, chapter, new DataCallback<List<Long>>() {

        @Override
        public void onResult(List<Long> result) {
            assertNotNull(result);
            assertTrue(result.size() == 1);
            // assertFalse("something is downloading", result);
            print("get All Downloading Videos DmidList :" + result.size());
            unlock();
        }

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

Example 33 with DownloadEntry

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

the class DbTests method testgetListOfOngoingDownloads.

@Test
public void testgetListOfOngoingDownloads() throws Exception {
    db.clearDataByUser(username);
    db.getListOfOngoingDownloads(new DataCallback<List<VideoModel>>() {

        @Override
        public void onResult(List<VideoModel> result) {
            assertNotNull(result);
            assertTrue(result.size() == 0);
            for (VideoModel model : result) {
                print(model.getChapterName());
                print("ID : " + model.getVideoId());
                print("result for get ListOfOngoingDownloads is:" + result.size());
            }
            unlock();
        }

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

        @Override
        public void onResult(List<VideoModel> result) {
            assertNotNull(result);
            assertTrue(result.size() == 1);
            for (VideoModel model : result) {
                print(model.getChapterName());
                print("ID : " + model.getVideoId());
                print("result for get ListOfOngoingDownloads is:" + result.size());
            }
            unlock();
        }

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

Example 34 with DownloadEntry

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

the class DbTests method testgetAllDownloadingVideosDmidList.

@Test
public void testgetAllDownloadingVideosDmidList() throws Exception {
    db.clearDataByUser(username);
    db.getAllDownloadingVideosDmidList(new DataCallback<List<Long>>() {

        @Override
        public void onResult(List<Long> result) {
            assertNotNull(result);
            assertTrue(result.size() == 0);
            unlock();
        }

        @Override
        public void onFail(Exception ex) {
            fail(ex.getMessage());
        }
    });
    lock();
    DownloadEntry de = getDummyVideoModel();
    de.downloaded = DownloadedState.DOWNLOADING;
    db.addVideoData(de, null);
    db.getAllDownloadingVideosDmidList(new DataCallback<List<Long>>() {

        @Override
        public void onResult(List<Long> result) {
            assertNotNull(result);
            assertTrue(result.size() == 1);
            unlock();
        }

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

Example 35 with DownloadEntry

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

the class DbTests method testgetDownloadingVideoDmIdsForSection.

@Test
public void testgetDownloadingVideoDmIdsForSection() throws Exception {
    db.clearDataByUser(username);
    String enrollmentId = "enrollmentId";
    String chapter = "chapter";
    String section = "section";
    db.getDownloadingVideoDmIdsForSection(enrollmentId, chapter, section, new DataCallback<List<Long>>() {

        @Override
        public void onResult(List<Long> result) {
            assertNotNull(result);
            // assertTrue(result.length >= 0);
            assertTrue(result.size() == 0);
            print("get DownloadingVideo DmIds For Section :" + result.size());
            unlock();
        }

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

        @Override
        public void onResult(List<Long> result) {
            assertNotNull(result);
            // assertTrue(result.length >= 0);
            assertTrue(result.size() == 1);
            // assertFalse("something is downloading", result);
            print("get DownloadingVideo DmIds For Section :" + result.size());
            unlock();
        }

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