use of org.edx.mobile.model.db.DownloadEntry in project edx-app-android by edx.
the class DbTests method testInsert.
@Test
public void testInsert() throws Exception {
DownloadEntry de = getDummyVideoModel();
de.isCourseActive = 1;
de.downloaded = DownloadedState.DOWNLOADING;
db.addVideoData(de, new DataCallback<Long>() {
@Override
public void onResult(Long result) {
print("inserted id: " + result);
assertNotNull(result);
assertTrue(result > 0);
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 testupdateVideoAsOnlineByVideoId.
@Test
public void testupdateVideoAsOnlineByVideoId() throws Exception {
db.clearDataByUser(username);
String videoId = "videoId";
// String videoId = "videoId-" + System.currentTimeMillis();
db.updateVideoAsOnlineByVideoId(videoId, new DataCallback<Integer>() {
@Override
public void onResult(Integer result) {
assertTrue(result == 0);
print("Result for updateVideoAsOnlineByVideoId for 0 is" + result.toString());
unlock();
}
@Override
public void onFail(Exception ex) {
fail(ex.getMessage());
}
});
lock();
DownloadEntry de1 = getDummyVideoModel();
de1.videoId = "videoId";
de1.downloaded = DownloadedState.ONLINE;
db.addVideoData(de1, null);
// String videoId1="" + System.currentTimeMillis();
db.updateVideoAsOnlineByVideoId(videoId, new DataCallback<Integer>() {
@Override
public void onResult(Integer result) {
assertNotNull(result);
assertTrue(result == 1);
print("Result for update Video As Online By VideoId " + result.intValue());
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 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();
}
use of org.edx.mobile.model.db.DownloadEntry in project edx-app-android by edx.
the class DbTests method testisAnyVideoDownloading.
@Test
public void testisAnyVideoDownloading() throws Exception {
db.clearDataByUser(username);
db.isAnyVideoDownloading(new DataCallback<Boolean>() {
@Override
public void onResult(Boolean result) {
assertNotNull(result);
assertFalse("something is downloading", result);
print("result for Video AnyVideoDownloading is:" + result);
unlock();
}
@Override
public void onFail(Exception ex) {
fail(ex.getMessage());
}
});
lock();
DownloadEntry de = getDummyVideoModel();
// avoid duplicate videoId
de.downloaded = DownloadedState.DOWNLOADING;
db.addVideoData(de, null);
db.isAnyVideoDownloading(new DataCallback<Boolean>() {
@Override
public void onResult(Boolean result) {
assertNotNull(result);
assertTrue("Result for Any Video Downloading is:" + result.toString(), 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 testgetWatchedStateForVideoId.
@Test
public void testgetWatchedStateForVideoId() throws Exception {
db.clearDataByUser(username);
String videoId = "videoId";
db.getWatchedStateForVideoId(videoId, new DataCallback<DownloadEntry.WatchedState>() {
@Override
public void onResult(WatchedState result) {
assertNotNull(result);
assertTrue(result == WatchedState.UNWATCHED);
print("result for getWatchedStateForVideoId :" + result.toString());
unlock();
}
@Override
public void onFail(Exception ex) {
fail(ex.getMessage());
}
});
lock();
DownloadEntry de = getDummyVideoModel();
de.watched = WatchedState.WATCHED;
de.videoId = "videoid";
db.addVideoData(de, null);
db.getWatchedStateForVideoId(de.videoId, new DataCallback<DownloadEntry.WatchedState>() {
@Override
public void onResult(WatchedState result) {
assertNotNull(result);
assertTrue(result == WatchedState.WATCHED);
print("Result for getWatchedStateForVideoId is in 1:" + result);
unlock();
}
@Override
public void onFail(Exception ex) {
fail(ex.getMessage());
}
});
lock();
}
Aggregations