|
| 1 | +package org.schabi.newpipe.extractor.services.soundcloud; |
| 2 | + |
| 3 | +import org.junit.jupiter.api.BeforeAll; |
| 4 | +import org.junit.jupiter.api.Test; |
| 5 | +import org.schabi.newpipe.downloader.DownloaderTestImpl; |
| 6 | +import org.schabi.newpipe.extractor.NewPipe; |
| 7 | +import org.schabi.newpipe.extractor.channel.tabs.ChannelTabExtractor; |
| 8 | +import org.schabi.newpipe.extractor.channel.tabs.ChannelTabs; |
| 9 | +import org.schabi.newpipe.extractor.exceptions.ExtractionException; |
| 10 | +import org.schabi.newpipe.extractor.exceptions.ParsingException; |
| 11 | +import org.schabi.newpipe.extractor.services.BaseListExtractorTest; |
| 12 | +import org.schabi.newpipe.extractor.services.soundcloud.extractors.SoundcloudChannelTabExtractor; |
| 13 | + |
| 14 | +import java.io.IOException; |
| 15 | + |
| 16 | +import static org.junit.jupiter.api.Assertions.assertEquals; |
| 17 | +import static org.schabi.newpipe.extractor.ServiceList.SoundCloud; |
| 18 | +import static org.schabi.newpipe.extractor.services.DefaultTests.defaultTestGetPageInNewExtractor; |
| 19 | +import static org.schabi.newpipe.extractor.services.DefaultTests.defaultTestMoreItems; |
| 20 | +import static org.schabi.newpipe.extractor.services.DefaultTests.defaultTestRelatedItems; |
| 21 | + |
| 22 | +class SoundcloudChannelTabExtractorTest { |
| 23 | + |
| 24 | + static class Tracks implements BaseListExtractorTest { |
| 25 | + private static SoundcloudChannelTabExtractor extractor; |
| 26 | + |
| 27 | + @BeforeAll |
| 28 | + static void setUp() throws IOException, ExtractionException { |
| 29 | + NewPipe.init(DownloaderTestImpl.getInstance()); |
| 30 | + extractor = (SoundcloudChannelTabExtractor) SoundCloud |
| 31 | + .getChannelTabExtractorFromId("10494998", ChannelTabs.TRACKS); |
| 32 | + extractor.fetchPage(); |
| 33 | + } |
| 34 | + |
| 35 | + @Test |
| 36 | + @Override |
| 37 | + public void testServiceId() throws Exception { |
| 38 | + assertEquals(SoundCloud.getServiceId(), extractor.getServiceId()); |
| 39 | + } |
| 40 | + |
| 41 | + @Test |
| 42 | + @Override |
| 43 | + public void testName() throws Exception { |
| 44 | + assertEquals(ChannelTabs.TRACKS, extractor.getName()); |
| 45 | + } |
| 46 | + |
| 47 | + @Test |
| 48 | + @Override |
| 49 | + public void testId() throws Exception { |
| 50 | + assertEquals("10494998", extractor.getId()); |
| 51 | + } |
| 52 | + |
| 53 | + @Test |
| 54 | + @Override |
| 55 | + public void testUrl() throws Exception { |
| 56 | + assertEquals("https://soundcloud.com/liluzivert/tracks", extractor.getUrl()); |
| 57 | + } |
| 58 | + |
| 59 | + @Test |
| 60 | + @Override |
| 61 | + public void testOriginalUrl() throws Exception { |
| 62 | + assertEquals("https://soundcloud.com/liluzivert/tracks", extractor.getOriginalUrl()); |
| 63 | + } |
| 64 | + |
| 65 | + @Test |
| 66 | + @Override |
| 67 | + public void testRelatedItems() throws Exception { |
| 68 | + defaultTestRelatedItems(extractor); |
| 69 | + } |
| 70 | + |
| 71 | + @Test |
| 72 | + @Override |
| 73 | + public void testMoreRelatedItems() throws Exception { |
| 74 | + defaultTestMoreItems(extractor); |
| 75 | + } |
| 76 | + |
| 77 | + /*////////////////////////////////////////////////////////////////////////// |
| 78 | + // Additional Testing |
| 79 | + //////////////////////////////////////////////////////////////////////////*/ |
| 80 | + |
| 81 | + @Test |
| 82 | + void testGetPageInNewExtractor() throws Exception { |
| 83 | + final ChannelTabExtractor newTabExtractor = |
| 84 | + SoundCloud.getChannelTabExtractorFromId("10494998", ChannelTabs.TRACKS); |
| 85 | + defaultTestGetPageInNewExtractor(extractor, newTabExtractor); |
| 86 | + } |
| 87 | + } |
| 88 | + |
| 89 | + static class Playlists implements BaseListExtractorTest { |
| 90 | + private static SoundcloudChannelTabExtractor extractor; |
| 91 | + |
| 92 | + @BeforeAll |
| 93 | + static void setUp() throws IOException, ExtractionException { |
| 94 | + NewPipe.init(DownloaderTestImpl.getInstance()); |
| 95 | + extractor = (SoundcloudChannelTabExtractor) SoundCloud |
| 96 | + .getChannelTabExtractorFromId("323371733", ChannelTabs.PLAYLISTS); |
| 97 | + extractor.fetchPage(); |
| 98 | + } |
| 99 | + |
| 100 | + @Test |
| 101 | + @Override |
| 102 | + public void testServiceId() { |
| 103 | + assertEquals(SoundCloud.getServiceId(), extractor.getServiceId()); |
| 104 | + } |
| 105 | + |
| 106 | + @Test |
| 107 | + @Override |
| 108 | + public void testName() throws Exception { |
| 109 | + assertEquals(ChannelTabs.PLAYLISTS, extractor.getName()); |
| 110 | + } |
| 111 | + |
| 112 | + @Test |
| 113 | + @Override |
| 114 | + public void testId() throws ParsingException { |
| 115 | + assertEquals("323371733", extractor.getId()); |
| 116 | + } |
| 117 | + |
| 118 | + @Test |
| 119 | + @Override |
| 120 | + public void testUrl() throws ParsingException { |
| 121 | + assertEquals("https://soundcloud.com/trackaholic/sets", extractor.getUrl()); |
| 122 | + } |
| 123 | + |
| 124 | + @Test |
| 125 | + @Override |
| 126 | + public void testOriginalUrl() throws Exception { |
| 127 | + assertEquals("https://soundcloud.com/trackaholic/sets", extractor.getOriginalUrl()); |
| 128 | + } |
| 129 | + |
| 130 | + @Test |
| 131 | + @Override |
| 132 | + public void testRelatedItems() throws Exception { |
| 133 | + defaultTestRelatedItems(extractor); |
| 134 | + } |
| 135 | + |
| 136 | + @Test |
| 137 | + @Override |
| 138 | + public void testMoreRelatedItems() throws Exception { |
| 139 | + defaultTestMoreItems(extractor); |
| 140 | + } |
| 141 | + } |
| 142 | + |
| 143 | + static class Albums implements BaseListExtractorTest { |
| 144 | + private static SoundcloudChannelTabExtractor extractor; |
| 145 | + |
| 146 | + @BeforeAll |
| 147 | + static void setUp() throws IOException, ExtractionException { |
| 148 | + NewPipe.init(DownloaderTestImpl.getInstance()); |
| 149 | + extractor = (SoundcloudChannelTabExtractor) SoundCloud |
| 150 | + .getChannelTabExtractorFromId("4803918", ChannelTabs.ALBUMS); |
| 151 | + extractor.fetchPage(); |
| 152 | + } |
| 153 | + |
| 154 | + @Test |
| 155 | + @Override |
| 156 | + public void testServiceId() { |
| 157 | + assertEquals(SoundCloud.getServiceId(), extractor.getServiceId()); |
| 158 | + } |
| 159 | + |
| 160 | + @Test |
| 161 | + @Override |
| 162 | + public void testName() throws Exception { |
| 163 | + assertEquals(ChannelTabs.ALBUMS, extractor.getName()); |
| 164 | + } |
| 165 | + |
| 166 | + @Test |
| 167 | + @Override |
| 168 | + public void testId() throws ParsingException { |
| 169 | + assertEquals("4803918", extractor.getId()); |
| 170 | + } |
| 171 | + |
| 172 | + @Test |
| 173 | + @Override |
| 174 | + public void testUrl() throws ParsingException { |
| 175 | + assertEquals("https://soundcloud.com/bigsean-1/albums", extractor.getUrl()); |
| 176 | + } |
| 177 | + |
| 178 | + @Test |
| 179 | + @Override |
| 180 | + public void testOriginalUrl() throws Exception { |
| 181 | + assertEquals("https://soundcloud.com/bigsean-1/albums", extractor.getOriginalUrl()); |
| 182 | + } |
| 183 | + |
| 184 | + @Test |
| 185 | + @Override |
| 186 | + public void testRelatedItems() throws Exception { |
| 187 | + defaultTestRelatedItems(extractor); |
| 188 | + } |
| 189 | + |
| 190 | + @Test |
| 191 | + @Override |
| 192 | + public void testMoreRelatedItems() throws Exception { |
| 193 | + defaultTestMoreItems(extractor); |
| 194 | + } |
| 195 | + } |
| 196 | +} |
0 commit comments