use of de.danoeh.antennapod.model.feed.FeedItem in project AntennaPod by AntennaPod.
the class PlaybackTest method testSmartMarkAsPlayed_Pause_WontAffectItem.
@Test
public void testSmartMarkAsPlayed_Pause_WontAffectItem() throws Exception {
setSmartMarkAsPlayedPreference(60);
uiTestUtils.addLocalFeedData(true);
activityTestRule.launchActivity(new Intent());
setupPlaybackController();
final int fiIdx = 0;
final FeedItem feedItem = DBReader.getQueue().get(fiIdx);
playFromQueue(fiIdx);
// let playback run a bit then pause
Awaitility.await().atMost(1000, MILLISECONDS).until(() -> PlayerStatus.PLAYING == controller.getStatus());
pauseEpisode();
Awaitility.await().atMost(1000, MILLISECONDS).until(() -> PlayerStatus.PAUSED == controller.getStatus());
assertThat("Ensure even with smart mark as play, after pause, the item remains in the queue.", DBReader.getQueue(), hasItems(feedItem));
assertThat("Ensure even with smart mark as play, after pause, the item played status remains false.", DBReader.getFeedItem(feedItem.getId()).isPlayed(), is(false));
}
use of de.danoeh.antennapod.model.feed.FeedItem in project AntennaPod by AntennaPod.
the class PlaybackTest method testContinuousPlaybackOnMultipleEpisodes.
@Test
public void testContinuousPlaybackOnMultipleEpisodes() throws Exception {
setContinuousPlaybackPreference(true);
uiTestUtils.addLocalFeedData(true);
activityTestRule.launchActivity(new Intent());
List<FeedItem> queue = DBReader.getQueue();
final FeedItem first = queue.get(0);
final FeedItem second = queue.get(1);
playFromQueue(0);
Awaitility.await().atMost(2, TimeUnit.SECONDS).until(() -> first.getMedia().getId() == PlaybackPreferences.getCurrentlyPlayingFeedMediaId());
Awaitility.await().atMost(6, TimeUnit.SECONDS).until(() -> second.getMedia().getId() == PlaybackPreferences.getCurrentlyPlayingFeedMediaId());
}
use of de.danoeh.antennapod.model.feed.FeedItem in project AntennaPod by AntennaPod.
the class PlaybackTest method replayEpisodeCheck.
/**
* Check if an episode can be played twice without problems.
*/
protected void replayEpisodeCheck(boolean followQueue) throws Exception {
setContinuousPlaybackPreference(followQueue);
uiTestUtils.addLocalFeedData(true);
DBWriter.clearQueue().get();
activityTestRule.launchActivity(new Intent());
final List<FeedItem> episodes = DBReader.getRecentlyPublishedEpisodes(0, 10, FeedItemFilter.unfiltered());
startLocalPlayback();
FeedMedia media = episodes.get(0).getMedia();
Awaitility.await().atMost(1, TimeUnit.SECONDS).until(() -> media.getId() == PlaybackPreferences.getCurrentlyPlayingFeedMediaId());
Awaitility.await().atMost(5, TimeUnit.SECONDS).until(() -> media.getId() != PlaybackPreferences.getCurrentlyPlayingFeedMediaId());
startLocalPlayback();
Awaitility.await().atMost(1, TimeUnit.SECONDS).until(() -> media.getId() == PlaybackPreferences.getCurrentlyPlayingFeedMediaId());
}
use of de.danoeh.antennapod.model.feed.FeedItem in project AntennaPod by AntennaPod.
the class DbNullCleanupAlgorithmTest method testPerformAutoCleanupShouldNotDelete.
/**
* A test with no items in the queue, but multiple items downloaded.
* The null algorithm should never delete any items, even if they're played and not in the queue.
*/
@Test
public void testPerformAutoCleanupShouldNotDelete() 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<>();
for (int i = 0; i < numItems; i++) {
FeedItem item = new FeedItem(0, "title", "id" + i, "link", new Date(), FeedItem.PLAYED, feed);
File f = new File(destFolder, "file " + i);
assertTrue(f.createNewFile());
files.add(f);
item.setMedia(new FeedMedia(0, item, 1, 0, 1L, "m", f.getAbsolutePath(), "url", true, new Date(numItems - i), 0, 0));
items.add(item);
}
PodDBAdapter adapter = PodDBAdapter.getInstance();
adapter.open();
adapter.setCompleteFeed(feed);
adapter.close();
assertTrue(feed.getId() != 0);
for (FeedItem item : items) {
assertTrue(item.getId() != 0);
// noinspection ConstantConditions
assertTrue(item.getMedia().getId() != 0);
}
DBTasks.performAutoCleanup(context);
for (int i = 0; i < files.size(); i++) {
assertTrue(files.get(i).exists());
}
}
use of de.danoeh.antennapod.model.feed.FeedItem in project AntennaPod by AntennaPod.
the class DbReaderTest method testGetNewItemIds.
@Test
public void testGetNewItemIds() {
final int numItems = 10;
List<FeedItem> newItems = saveNewItems(numItems);
long[] unreadIds = new long[newItems.size()];
for (int i = 0; i < newItems.size(); i++) {
unreadIds[i] = newItems.get(i).getId();
}
List<FeedItem> newItemsSaved = DBReader.getNewItemsList(0, Integer.MAX_VALUE);
assertNotNull(newItemsSaved);
assertEquals(newItemsSaved.size(), newItems.size());
for (FeedItem feedItem : newItemsSaved) {
long savedId = feedItem.getId();
boolean found = false;
for (long id : unreadIds) {
if (id == savedId) {
found = true;
break;
}
}
assertTrue(found);
}
}
Aggregations