use of de.danoeh.antennapod.model.feed.FeedItem in project AntennaPod by AntennaPod.
the class DbCleanupTests method testPerformAutoCleanupHandleUnplayed.
@Test
public void testPerformAutoCleanupHandleUnplayed() throws IOException {
final int numItems = EPISODE_CACHE_SIZE * 2;
Feed feed = new Feed("url", null, "title");
List<FeedItem> items = new ArrayList<>();
feed.setItems(items);
List<File> files = new ArrayList<>();
populateItems(numItems, feed, items, files, FeedItem.UNPLAYED, false, false);
DBTasks.performAutoCleanup(context);
for (File file : files) {
assertTrue(file.exists());
}
}
use of de.danoeh.antennapod.model.feed.FeedItem in project AntennaPod by AntennaPod.
the class DbCleanupTests method testPerformAutoCleanupShouldDelete.
@Test
public void testPerformAutoCleanupShouldDelete() throws IOException {
final int numItems = EPISODE_CACHE_SIZE * 2;
Feed feed = new Feed("url", null, "title");
List<FeedItem> items = new ArrayList<>();
feed.setItems(items);
List<File> files = new ArrayList<>();
populateItems(numItems, feed, items, files, FeedItem.PLAYED, false, false);
DBTasks.performAutoCleanup(context);
for (int i = 0; i < files.size(); i++) {
if (i < EPISODE_CACHE_SIZE) {
assertTrue(files.get(i).exists());
} else {
assertFalse(files.get(i).exists());
}
}
}
use of de.danoeh.antennapod.model.feed.FeedItem in project AntennaPod by AntennaPod.
the class DbCleanupTests method testPerformAutoCleanupShouldNotDeleteBecauseInQueue.
@Test
public void testPerformAutoCleanupShouldNotDeleteBecauseInQueue() throws IOException {
final int numItems = EPISODE_CACHE_SIZE * 2;
Feed feed = new Feed("url", null, "title");
List<FeedItem> items = new ArrayList<>();
feed.setItems(items);
List<File> files = new ArrayList<>();
populateItems(numItems, feed, items, files, FeedItem.PLAYED, true, false);
DBTasks.performAutoCleanup(context);
for (File file : files) {
assertTrue(file.exists());
}
}
use of de.danoeh.antennapod.model.feed.FeedItem in project AntennaPod by AntennaPod.
the class DbQueueCleanupAlgorithmTest method testPerformAutoCleanupHandleUnplayed.
/**
* For APQueueCleanupAlgorithm we expect even unplayed episodes to be deleted if needed
* if they aren't in the queue.
*/
@Test
public void testPerformAutoCleanupHandleUnplayed() throws IOException {
final int numItems = EPISODE_CACHE_SIZE * 2;
Feed feed = new Feed("url", null, "title");
List<FeedItem> items = new ArrayList<>();
feed.setItems(items);
List<File> files = new ArrayList<>();
populateItems(numItems, feed, items, files, FeedItem.UNPLAYED, false, false);
DBTasks.performAutoCleanup(context);
for (int i = 0; i < files.size(); i++) {
if (i < EPISODE_CACHE_SIZE) {
assertTrue(files.get(i).exists());
} else {
assertFalse(files.get(i).exists());
}
}
}
use of de.danoeh.antennapod.model.feed.FeedItem in project AntennaPod by AntennaPod.
the class DbTasksTest method testUpdateFeedMediaUrlResetState.
@Test
public void testUpdateFeedMediaUrlResetState() {
final Feed feed = new Feed("url", null, "title");
FeedItem item = new FeedItem(0, "item", "id", "link", new Date(), FeedItem.PLAYED, feed);
feed.setItems(singletonList(item));
PodDBAdapter adapter = PodDBAdapter.getInstance();
adapter.open();
adapter.setCompleteFeed(feed);
adapter.close();
// ensure that objects have been saved in db, then reset
assertTrue(feed.getId() != 0);
assertTrue(item.getId() != 0);
FeedMedia media = new FeedMedia(item, "url", 1024, "mime/type");
item.setMedia(media);
List<FeedItem> list = new ArrayList<>();
list.add(item);
feed.setItems(list);
final Feed newFeed = DBTasks.updateFeed(context, feed, false);
assertNotSame(newFeed, feed);
final Feed feedFromDB = DBReader.getFeed(newFeed.getId());
final FeedItem feedItemFromDB = feedFromDB.getItems().get(0);
assertTrue(feedItemFromDB.isNew());
}
Aggregations