use of de.danoeh.antennapod.model.feed.FeedMedia in project AntennaPod by AntennaPod.
the class DbCleanupTests method populateItems.
@SuppressWarnings("SameParameterValue")
void populateItems(final int numItems, Feed feed, List<FeedItem> items, List<File> files, int itemState, boolean addToQueue, boolean addToFavorites) throws IOException {
for (int i = 0; i < numItems; i++) {
Date itemDate = new Date(numItems - i);
Date playbackCompletionDate = null;
if (itemState == FeedItem.PLAYED) {
playbackCompletionDate = itemDate;
}
FeedItem item = new FeedItem(0, "title", "id" + i, "link", itemDate, itemState, 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, playbackCompletionDate, 0, 0));
items.add(item);
}
PodDBAdapter adapter = PodDBAdapter.getInstance();
adapter.open();
adapter.setCompleteFeed(feed);
if (addToQueue) {
adapter.setQueue(items);
}
if (addToFavorites) {
adapter.setFavorites(items);
}
adapter.close();
assertTrue(feed.getId() != 0);
for (FeedItem item : items) {
assertTrue(item.getId() != 0);
// noinspection ConstantConditions
assertTrue(item.getMedia().getId() != 0);
}
}
use of de.danoeh.antennapod.model.feed.FeedMedia in project AntennaPod by AntennaPod.
the class PlaybackVolumeUpdaterTest method updatesPreferencesForLoadedFeedMediaIfPlayerStatusIsSeeking.
@Test
public void updatesPreferencesForLoadedFeedMediaIfPlayerStatusIsSeeking() {
PlaybackVolumeUpdater playbackVolumeUpdater = new PlaybackVolumeUpdater();
when(mediaPlayer.getPlayerStatus()).thenReturn(PlayerStatus.SEEKING);
FeedMedia feedMedia = mockFeedMedia();
when(mediaPlayer.getPlayable()).thenReturn(feedMedia);
FeedPreferences feedPreferences = feedMedia.getItem().getFeed().getPreferences();
playbackVolumeUpdater.updateVolumeIfNecessary(mediaPlayer, FEED_ID, VolumeAdaptionSetting.LIGHT_REDUCTION);
verify(feedPreferences, times(1)).setVolumeAdaptionSetting(VolumeAdaptionSetting.LIGHT_REDUCTION);
verify(mediaPlayer, never()).pause(anyBoolean(), anyBoolean());
verify(mediaPlayer, never()).resume();
}
use of de.danoeh.antennapod.model.feed.FeedMedia in project AntennaPod by AntennaPod.
the class PlaybackVolumeUpdaterTest method noChangeIfPlayableIsNoItemOfAffectedFeed.
@Test
public void noChangeIfPlayableIsNoItemOfAffectedFeed() {
when(mediaPlayer.getPlayerStatus()).thenReturn(PlayerStatus.PLAYING);
FeedMedia feedMedia = mockFeedMedia();
when(mediaPlayer.getPlayable()).thenReturn(feedMedia);
when(feedMedia.getItem().getFeed().getId()).thenReturn(FEED_ID + 1);
PlaybackVolumeUpdater playbackVolumeUpdater = new PlaybackVolumeUpdater();
playbackVolumeUpdater.updateVolumeIfNecessary(mediaPlayer, FEED_ID, VolumeAdaptionSetting.OFF);
verify(mediaPlayer, never()).pause(anyBoolean(), anyBoolean());
verify(mediaPlayer, never()).resume();
}
use of de.danoeh.antennapod.model.feed.FeedMedia in project AntennaPod by AntennaPod.
the class PlaybackVolumeUpdaterTest method noChangeIfPlayerStatusIsError.
@Test
public void noChangeIfPlayerStatusIsError() {
PlaybackVolumeUpdater playbackVolumeUpdater = new PlaybackVolumeUpdater();
when(mediaPlayer.getPlayerStatus()).thenReturn(PlayerStatus.ERROR);
FeedMedia feedMedia = mockFeedMedia();
when(mediaPlayer.getPlayable()).thenReturn(feedMedia);
playbackVolumeUpdater.updateVolumeIfNecessary(mediaPlayer, FEED_ID, VolumeAdaptionSetting.OFF);
verify(mediaPlayer, never()).pause(anyBoolean(), anyBoolean());
verify(mediaPlayer, never()).resume();
}
use of de.danoeh.antennapod.model.feed.FeedMedia in project AntennaPod by AntennaPod.
the class PlaybackVolumeUpdaterTest method mockFeedMedia.
private FeedMedia mockFeedMedia() {
FeedMedia feedMedia = mock(FeedMedia.class);
FeedItem feedItem = mock(FeedItem.class);
Feed feed = mock(Feed.class);
FeedPreferences feedPreferences = mock(FeedPreferences.class);
when(feedMedia.getItem()).thenReturn(feedItem);
when(feedItem.getFeed()).thenReturn(feed);
when(feed.getId()).thenReturn(FEED_ID);
when(feed.getPreferences()).thenReturn(feedPreferences);
return feedMedia;
}
Aggregations