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