Search in sources :

Example 91 with FeedMedia

use of de.danoeh.antennapod.model.feed.FeedMedia in project AntennaPod by AntennaPod.

the class RssParserTest method testRss2Basic.

@Test
public void testRss2Basic() throws Exception {
    File feedFile = FeedParserTestHelper.getFeedFile("feed-rss-testRss2Basic.xml");
    Feed feed = FeedParserTestHelper.runFeedParser(feedFile);
    assertEquals(Feed.TYPE_RSS2, feed.getType());
    assertEquals("title", feed.getTitle());
    assertEquals("en", feed.getLanguage());
    assertEquals("http://example.com", feed.getLink());
    assertEquals("This is the description", feed.getDescription());
    assertEquals("http://example.com/payment", feed.getPaymentLinks().get(0).url);
    assertEquals("http://example.com/picture", feed.getImageUrl());
    assertEquals(10, feed.getItems().size());
    for (int i = 0; i < feed.getItems().size(); i++) {
        FeedItem item = feed.getItems().get(i);
        assertEquals("http://example.com/item-" + i, item.getItemIdentifier());
        assertEquals("item-" + i, item.getTitle());
        assertNull(item.getDescription());
        assertEquals("http://example.com/items/" + i, item.getLink());
        assertEquals(new Date(i * 60000), item.getPubDate());
        assertNull(item.getPaymentLink());
        assertEquals("http://example.com/picture", item.getImageLocation());
        // media
        assertTrue(item.hasMedia());
        FeedMedia media = item.getMedia();
        // noinspection ConstantConditions
        assertEquals("http://example.com/media-" + i, media.getDownload_url());
        assertEquals(1024 * 1024, media.getSize());
        assertEquals("audio/mp3", media.getMime_type());
        // chapters
        assertNull(item.getChapters());
    }
}
Also used : FeedItem(de.danoeh.antennapod.model.feed.FeedItem) FeedMedia(de.danoeh.antennapod.model.feed.FeedMedia) File(java.io.File) Date(java.util.Date) Feed(de.danoeh.antennapod.model.feed.Feed) Test(org.junit.Test)

Aggregations

FeedMedia (de.danoeh.antennapod.model.feed.FeedMedia)91 FeedItem (de.danoeh.antennapod.model.feed.FeedItem)46 Test (org.junit.Test)28 Feed (de.danoeh.antennapod.model.feed.Feed)26 Date (java.util.Date)25 ArrayList (java.util.ArrayList)18 FeedPreferences (de.danoeh.antennapod.model.feed.FeedPreferences)15 File (java.io.File)15 Playable (de.danoeh.antennapod.model.playback.Playable)8 View (android.view.View)6 NonNull (androidx.annotation.NonNull)6 Context (android.content.Context)5 Log (android.util.Log)5 PlaybackServiceStarter (de.danoeh.antennapod.core.util.playback.PlaybackServiceStarter)5 Cursor (android.database.Cursor)4 Nullable (androidx.annotation.Nullable)4 R (de.danoeh.antennapod.R)4 DownloadRequest (de.danoeh.antennapod.core.service.download.DownloadRequest)4 DownloadService (de.danoeh.antennapod.core.service.download.DownloadService)4 Intent (android.content.Intent)3