|
| 1 | +package org.schabi.newpipe.extractor.services.media_ccc; |
| 2 | + |
| 3 | +import org.junit.BeforeClass; |
| 4 | +import org.junit.Test; |
| 5 | +import org.schabi.newpipe.DownloaderTestImpl; |
| 6 | +import org.schabi.newpipe.extractor.NewPipe; |
| 7 | +import org.schabi.newpipe.extractor.kiosk.KioskExtractor; |
| 8 | +import org.schabi.newpipe.extractor.stream.StreamInfoItem; |
| 9 | + |
| 10 | +import java.time.OffsetDateTime; |
| 11 | +import java.util.List; |
| 12 | + |
| 13 | +import static org.junit.Assert.*; |
| 14 | +import static org.schabi.newpipe.extractor.ServiceList.MediaCCC; |
| 15 | +import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty; |
| 16 | + |
| 17 | +public class MediaCCCRecentListExtractorTest { |
| 18 | + private static KioskExtractor extractor; |
| 19 | + |
| 20 | + @BeforeClass |
| 21 | + public static void setUpClass() throws Exception { |
| 22 | + NewPipe.init(DownloaderTestImpl.getInstance()); |
| 23 | + extractor = MediaCCC.getKioskList().getExtractorById("recent", null); |
| 24 | + extractor.fetchPage(); |
| 25 | + } |
| 26 | + |
| 27 | + @Test |
| 28 | + public void testStreamList() throws Exception { |
| 29 | + final List<StreamInfoItem> items = extractor.getInitialPage().getItems(); |
| 30 | + assertEquals(100, items.size()); |
| 31 | + for (final StreamInfoItem item: items) { |
| 32 | + assertFalse(isNullOrEmpty(item.getName())); |
| 33 | + assertTrue(item.getDuration() > 0); |
| 34 | + assertTrue(isNullOrEmpty(item.getUploaderName())); // we do not get the uploader name |
| 35 | + assertTrue(item.getUploadDate().offsetDateTime().isBefore(OffsetDateTime.now())); |
| 36 | + assertTrue(item.getUploadDate().offsetDateTime().isAfter(OffsetDateTime.now().minusYears(1))); |
| 37 | + } |
| 38 | + } |
| 39 | + |
| 40 | + |
| 41 | +} |
0 commit comments