Search in sources :

Example 16 with VideoModel

use of org.edx.mobile.model.VideoModel 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 17 with VideoModel

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

Example 18 with VideoModel

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

Aggregations

VideoModel (org.edx.mobile.model.VideoModel)18 DownloadEntry (org.edx.mobile.model.db.DownloadEntry)10 Test (org.junit.Test)9 List (java.util.List)5 Cursor (android.database.Cursor)2 NativeDownloadModel (org.edx.mobile.model.download.NativeDownloadModel)2 IDatabase (org.edx.mobile.module.db.IDatabase)2 ContentValues (android.content.ContentValues)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1 AnalyticsRegistry (org.edx.mobile.module.analytics.AnalyticsRegistry)1 DataCallback (org.edx.mobile.module.db.DataCallback)1 DownloadEntryAdapter (org.edx.mobile.view.adapters.DownloadEntryAdapter)1