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();
}
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();
}
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;
}
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();
}
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();
}
Aggregations