use of de.danoeh.antennapod.model.feed.FeedItem in project AntennaPod by AntennaPod.
the class DbReaderTest method testGetNavDrawerDataQueueNotEmptyWithUnreadItems.
@Test
public void testGetNavDrawerDataQueueNotEmptyWithUnreadItems() {
final int numFeeds = 10;
final int numItems = 10;
final int numQueue = 1;
final int numNew = 2;
List<Feed> feeds = DbTestUtils.saveFeedlist(numFeeds, numItems, true);
PodDBAdapter adapter = PodDBAdapter.getInstance();
adapter.open();
for (int i = 0; i < numNew; i++) {
FeedItem item = feeds.get(0).getItems().get(i);
item.setNew();
adapter.setSingleFeedItem(item);
}
List<FeedItem> queue = new ArrayList<>();
for (int i = 0; i < numQueue; i++) {
FeedItem item = feeds.get(1).getItems().get(i);
queue.add(item);
}
adapter.setQueue(queue);
adapter.close();
NavDrawerData navDrawerData = DBReader.getNavDrawerData();
assertEquals(numFeeds, navDrawerData.items.size());
assertEquals(numNew, navDrawerData.numNewItems);
assertEquals(numQueue, navDrawerData.queueSize);
}
use of de.danoeh.antennapod.model.feed.FeedItem in project AntennaPod by AntennaPod.
the class DbReaderTest method testGetPlaybackHistory.
@Test
public void testGetPlaybackHistory() {
final int numItems = (DBReader.PLAYBACK_HISTORY_SIZE + 1) * 2;
final int playedItems = DBReader.PLAYBACK_HISTORY_SIZE + 1;
final int numReturnedItems = Math.min(playedItems, DBReader.PLAYBACK_HISTORY_SIZE);
final int numFeeds = 1;
Feed feed = DbTestUtils.saveFeedlist(numFeeds, numItems, true).get(0);
long[] ids = new long[playedItems];
PodDBAdapter adapter = PodDBAdapter.getInstance();
adapter.open();
for (int i = 0; i < playedItems; i++) {
FeedMedia m = feed.getItems().get(i).getMedia();
m.setPlaybackCompletionDate(new Date(i + 1));
adapter.setFeedMediaPlaybackCompletionDate(m);
ids[ids.length - 1 - i] = m.getItem().getId();
}
adapter.close();
List<FeedItem> saved = DBReader.getPlaybackHistory();
assertNotNull(saved);
assertEquals("Wrong size: ", numReturnedItems, saved.size());
for (int i = 0; i < numReturnedItems; i++) {
FeedItem item = saved.get(i);
assertNotNull(item.getMedia().getPlaybackCompletionDate());
assertEquals("Wrong sort order: ", item.getId(), ids[i]);
}
}
use of de.danoeh.antennapod.model.feed.FeedItem in project AntennaPod by AntennaPod.
the class DbReaderTest method testGetDownloadedItems.
@Test
public void testGetDownloadedItems() {
final int numItems = 10;
List<FeedItem> downloaded = saveDownloadedItems(numItems);
List<FeedItem> downloadedSaved = DBReader.getDownloadedItems();
assertNotNull(downloadedSaved);
assertEquals(downloaded.size(), downloadedSaved.size());
for (FeedItem item : downloadedSaved) {
assertNotNull(item.getMedia());
assertTrue(item.getMedia().isDownloaded());
assertNotNull(item.getMedia().getDownload_url());
}
}
use of de.danoeh.antennapod.model.feed.FeedItem in project AntennaPod by AntennaPod.
the class DbReaderTest method saveNewItems.
@SuppressWarnings("SameParameterValue")
private List<FeedItem> saveNewItems(int numItems) {
List<Feed> feeds = saveFeedlist(numItems, numItems, true);
List<FeedItem> items = new ArrayList<>();
for (Feed f : feeds) {
items.addAll(f.getItems());
}
List<FeedItem> newItems = new ArrayList<>();
Random random = new Random();
while (newItems.size() < numItems) {
int i = random.nextInt(numItems);
if (!newItems.contains(items.get(i))) {
FeedItem item = items.get(i);
item.setNew();
newItems.add(item);
}
}
PodDBAdapter adapter = PodDBAdapter.getInstance();
adapter.open();
adapter.storeFeedItemlist(newItems);
adapter.close();
return newItems;
}
use of de.danoeh.antennapod.model.feed.FeedItem in project AntennaPod by AntennaPod.
the class DbReaderTest method testLoadChaptersOfFeedItemWithChapters.
@Test
public void testLoadChaptersOfFeedItemWithChapters() {
final int numChapters = 3;
DbTestUtils.saveFeedlist(1, 3, false, false, 0);
List<Feed> feeds = saveFeedlist(1, 3, false, true, numChapters);
for (Feed feed : feeds) {
for (FeedItem item : feed.getItems()) {
assertTrue(item.hasChapters());
item.setChapters(DBReader.loadChaptersOfFeedItem(item));
assertTrue(item.hasChapters());
assertNotNull(item.getChapters());
assertEquals(numChapters, item.getChapters().size());
}
}
}
Aggregations