Search in sources :

Example 41 with DownloadEntry

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

the class DbTests method testaddVideoData.

@Test
public void testaddVideoData() throws Exception {
    db.clearDataByUser(username);
    DownloadEntry de1 = getDummyVideoModel();
    db.addVideoData(de1, new DataCallback<Long>() {

        @Override
        public void onResult(Long result) {
            // assertNotNull(result);
            // assertTrue(result >= 0);
            assertTrue(result > 0);
            print("addVideoData" + 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 42 with DownloadEntry

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

the class DbTests method testgetVideosDownloadedCount.

@Test
public void testgetVideosDownloadedCount() throws Exception {
    db.clearDataByUser(username);
    db.getVideosDownloadedCount(new DataCallback<Integer>() {

        @Override
        public void onResult(Integer result) {
            assertNotNull(result);
            // assertTrue(result >= 0);
            assertTrue(result == 0);
            print("Result for get Videos Downloaded Count is= " + result);
            unlock();
        }

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

        @Override
        public void onResult(Integer result) {
            assertNotNull(result);
            // assertTrue(result >= 0);
            assertTrue(result == 1);
            print("Result for get Videos Downloaded Count 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 43 with DownloadEntry

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

the class DbTests method testgetAllDeactivatedVideos.

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

        @Override
        public void onResult(List<VideoModel> result) {
            // assertNotNull(result);
            assertTrue(result.isEmpty());
            print("Result for getAllDeactivatedVideos for size 0 is" + result);
            unlock();
        }

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

        @Override
        public void onResult(List<VideoModel> result) {
            assertNotNull(result);
            assertTrue("result size = " + result.size(), result.size() == 1);
            print("Result for getAllDeactivatedVideos for size 1 is" + result.toString());
            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 44 with DownloadEntry

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

the class DbTests method testgetVideoByVideoUrl.

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

        @Override
        public void onResult(VideoModel result) {
            assertNull("result should be null", 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.getVideoByVideoUrl(de.url, new DataCallback<VideoModel>() {

        @Override
        public void onResult(VideoModel result) {
            assertNotNull(result);
            // assertTrue(result == 1);
            print("Result for getVideoByVideoUrl for not null:" + 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 45 with DownloadEntry

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

the class DbTests method testgetDownloadEntryByDmId.

@Test
public void testgetDownloadEntryByDmId() throws Exception {
    db.clearDataByUser(username);
    long dmId = 1;
    db.getDownloadEntryByDmId(dmId, new DataCallback<VideoModel>() {

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

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

        @Override
        public void onResult(VideoModel result) {
            assertTrue(result != null);
            print("result for getDownloadEntryByDmId for not null is:" + 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)

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