|
5 | 5 | import org.schabi.newpipe.DownloaderTestImpl; |
6 | 6 | import org.schabi.newpipe.extractor.ListExtractor; |
7 | 7 | import org.schabi.newpipe.extractor.NewPipe; |
| 8 | +import org.schabi.newpipe.extractor.exceptions.ParsingException; |
8 | 9 | import org.schabi.newpipe.extractor.kiosk.KioskExtractor; |
| 10 | +import org.schabi.newpipe.extractor.services.BaseListExtractorTest; |
| 11 | +import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeTrendingExtractor; |
9 | 12 | import org.schabi.newpipe.extractor.stream.StreamInfoItem; |
10 | 13 |
|
11 | 14 | import java.util.List; |
12 | 15 |
|
13 | 16 | import static org.junit.Assert.*; |
14 | 17 | import static org.schabi.newpipe.extractor.ServiceList.SoundCloud; |
| 18 | +import static org.schabi.newpipe.extractor.ServiceList.YouTube; |
| 19 | +import static org.schabi.newpipe.extractor.services.DefaultTests.*; |
15 | 20 |
|
16 | | -/** |
17 | | - * Test for {@link SoundcloudChartsLinkHandlerFactory} |
18 | | - */ |
19 | 21 | public class SoundcloudChartsExtractorTest { |
| 22 | + public static class NewAndHot implements BaseListExtractorTest { |
| 23 | + private static SoundcloudChartsExtractor extractor; |
20 | 24 |
|
21 | | - static KioskExtractor extractor; |
| 25 | + @BeforeClass |
| 26 | + public static void setUp() throws Exception { |
| 27 | + NewPipe.init(DownloaderTestImpl.getInstance()); |
| 28 | + extractor = (SoundcloudChartsExtractor) SoundCloud.getKioskList() |
| 29 | + .getExtractorById("New & hot", null); |
| 30 | + extractor.fetchPage(); |
| 31 | + } |
22 | 32 |
|
23 | | - @BeforeClass |
24 | | - public static void setUp() throws Exception { |
25 | | - NewPipe.init(DownloaderTestImpl.getInstance()); |
26 | | - extractor = SoundCloud |
27 | | - .getKioskList() |
28 | | - .getExtractorById("Top 50", null); |
29 | | - extractor.fetchPage(); |
30 | | - } |
| 33 | + /*////////////////////////////////////////////////////////////////////////// |
| 34 | + // Extractor |
| 35 | + //////////////////////////////////////////////////////////////////////////*/ |
31 | 36 |
|
32 | | - @Test |
33 | | - public void testGetDownloader() throws Exception { |
34 | | - assertNotNull(NewPipe.getDownloader()); |
35 | | - } |
| 37 | + @Test |
| 38 | + public void testServiceId() { |
| 39 | + assertEquals(SoundCloud.getServiceId(), extractor.getServiceId()); |
| 40 | + } |
36 | 41 |
|
37 | | - @Test |
38 | | - public void testGetName() throws Exception { |
39 | | - assertEquals(extractor.getName(), "Top 50"); |
40 | | - } |
| 42 | + @Test |
| 43 | + public void testName() { |
| 44 | + assertEquals("New & hot", extractor.getName()); |
| 45 | + } |
41 | 46 |
|
42 | | - @Test |
43 | | - public void testId() { |
44 | | - assertEquals(extractor.getId(), "Top 50"); |
45 | | - } |
| 47 | + @Test |
| 48 | + public void testId() { |
| 49 | + assertEquals("New & hot", extractor.getId()); |
| 50 | + } |
46 | 51 |
|
47 | | - @Test |
48 | | - public void testGetStreams() throws Exception { |
49 | | - ListExtractor.InfoItemsPage<StreamInfoItem> page = extractor.getInitialPage(); |
50 | | - if (!page.getErrors().isEmpty()) { |
51 | | - System.err.println("----------"); |
52 | | - List<Throwable> errors = page.getErrors(); |
53 | | - for (Throwable e : errors) { |
54 | | - e.printStackTrace(); |
55 | | - System.err.println("----------"); |
56 | | - } |
57 | | - } |
58 | | - assertTrue("no streams are received", |
59 | | - !page.getItems().isEmpty() |
60 | | - && page.getErrors().isEmpty()); |
61 | | - } |
| 52 | + @Test |
| 53 | + public void testUrl() throws ParsingException { |
| 54 | + assertEquals("https://soundcloud.com/charts/new", extractor.getUrl()); |
| 55 | + } |
62 | 56 |
|
63 | | - @Test |
64 | | - public void testGetStreamsErrors() throws Exception { |
65 | | - assertTrue("errors during stream list extraction", extractor.getInitialPage().getErrors().isEmpty()); |
66 | | - } |
| 57 | + @Test |
| 58 | + public void testOriginalUrl() throws ParsingException { |
| 59 | + assertEquals("https://soundcloud.com/charts/new", extractor.getOriginalUrl()); |
| 60 | + } |
67 | 61 |
|
68 | | - @Test |
69 | | - public void testHasMoreStreams() throws Exception { |
70 | | - // Setup the streams |
71 | | - extractor.getInitialPage(); |
72 | | - assertTrue("has more streams", extractor.hasNextPage()); |
73 | | - } |
| 62 | + /*////////////////////////////////////////////////////////////////////////// |
| 63 | + // ListExtractor |
| 64 | + //////////////////////////////////////////////////////////////////////////*/ |
74 | 65 |
|
75 | | - @Test |
76 | | - public void testGetNextPageUrl() throws Exception { |
77 | | - assertTrue(extractor.hasNextPage()); |
78 | | - } |
| 66 | + @Test |
| 67 | + public void testRelatedItems() throws Exception { |
| 68 | + defaultTestRelatedItems(extractor); |
| 69 | + } |
79 | 70 |
|
80 | | - @Test |
81 | | - public void testGetNextPage() throws Exception { |
82 | | - extractor.getInitialPage().getItems(); |
83 | | - assertFalse("extractor has next streams", extractor.getPage(extractor.getNextPageUrl()) == null |
84 | | - || extractor.getPage(extractor.getNextPageUrl()).getItems().isEmpty()); |
| 71 | + @Test |
| 72 | + public void testMoreRelatedItems() throws Exception { |
| 73 | + defaultTestMoreItems(extractor); |
| 74 | + } |
85 | 75 | } |
86 | 76 |
|
87 | | - @Test |
88 | | - public void testGetCleanUrl() throws Exception { |
89 | | - assertEquals(extractor.getUrl(), "https://soundcloud.com/charts/top"); |
| 77 | + public static class Top50Charts implements BaseListExtractorTest { |
| 78 | + private static SoundcloudChartsExtractor extractor; |
| 79 | + |
| 80 | + @BeforeClass |
| 81 | + public static void setUp() throws Exception { |
| 82 | + NewPipe.init(DownloaderTestImpl.getInstance()); |
| 83 | + extractor = (SoundcloudChartsExtractor) SoundCloud.getKioskList() |
| 84 | + .getExtractorById("Top 50", null); |
| 85 | + extractor.fetchPage(); |
| 86 | + } |
| 87 | + |
| 88 | + /*////////////////////////////////////////////////////////////////////////// |
| 89 | + // Extractor |
| 90 | + //////////////////////////////////////////////////////////////////////////*/ |
| 91 | + |
| 92 | + @Test |
| 93 | + public void testServiceId() { |
| 94 | + assertEquals(SoundCloud.getServiceId(), extractor.getServiceId()); |
| 95 | + } |
| 96 | + |
| 97 | + @Test |
| 98 | + public void testName() { |
| 99 | + assertEquals("Top 50", extractor.getName()); |
| 100 | + } |
| 101 | + |
| 102 | + @Test |
| 103 | + public void testId() { |
| 104 | + assertEquals("Top 50", extractor.getId()); |
| 105 | + } |
| 106 | + |
| 107 | + @Test |
| 108 | + public void testUrl() throws ParsingException { |
| 109 | + assertEquals("https://soundcloud.com/charts/top", extractor.getUrl()); |
| 110 | + } |
| 111 | + |
| 112 | + @Test |
| 113 | + public void testOriginalUrl() throws ParsingException { |
| 114 | + assertEquals("https://soundcloud.com/charts/top", extractor.getOriginalUrl()); |
| 115 | + } |
| 116 | + |
| 117 | + /*////////////////////////////////////////////////////////////////////////// |
| 118 | + // ListExtractor |
| 119 | + //////////////////////////////////////////////////////////////////////////*/ |
| 120 | + |
| 121 | + @Test |
| 122 | + public void testRelatedItems() throws Exception { |
| 123 | + defaultTestRelatedItems(extractor); |
| 124 | + } |
| 125 | + |
| 126 | + @Test |
| 127 | + public void testMoreRelatedItems() throws Exception { |
| 128 | + defaultTestMoreItems(extractor); |
| 129 | + } |
90 | 130 | } |
91 | 131 | } |
0 commit comments