|
| 1 | +package org.schabi.newpipe.extractor.services.soundcloud; |
| 2 | + |
| 3 | +import org.junit.BeforeClass; |
| 4 | +import org.junit.Test; |
| 5 | +import org.schabi.newpipe.Downloader; |
| 6 | +import org.schabi.newpipe.extractor.NewPipe; |
| 7 | +import org.schabi.newpipe.extractor.channel.ChannelExtractor; |
| 8 | +import org.schabi.newpipe.extractor.exceptions.ParsingException; |
| 9 | +import org.schabi.newpipe.extractor.services.BaseChannelExtractorTest; |
| 10 | + |
| 11 | +import static org.junit.Assert.*; |
| 12 | +import static org.schabi.newpipe.extractor.ExtractorAsserts.assertEmpty; |
| 13 | +import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl; |
| 14 | +import static org.schabi.newpipe.extractor.ServiceList.SoundCloud; |
| 15 | +import static org.schabi.newpipe.extractor.services.DefaultTests.*; |
| 16 | + |
| 17 | +/** |
| 18 | + * Test for {@link SoundcloudChannelExtractor} |
| 19 | + */ |
| 20 | +public class SoundcloudChannelExtractorTest { |
| 21 | + public static class LilUzi implements BaseChannelExtractorTest { |
| 22 | + private static SoundcloudChannelExtractor extractor; |
| 23 | + |
| 24 | + @BeforeClass |
| 25 | + public static void setUp() throws Exception { |
| 26 | + NewPipe.init(Downloader.getInstance()); |
| 27 | + extractor = (SoundcloudChannelExtractor) SoundCloud |
| 28 | + .getChannelExtractor("http://soundcloud.com/liluzivert/sets"); |
| 29 | + extractor.fetchPage(); |
| 30 | + } |
| 31 | + |
| 32 | + /*////////////////////////////////////////////////////////////////////////// |
| 33 | + // Extractor |
| 34 | + //////////////////////////////////////////////////////////////////////////*/ |
| 35 | + |
| 36 | + @Test |
| 37 | + public void testServiceId() { |
| 38 | + assertEquals(SoundCloud.getServiceId(), extractor.getServiceId()); |
| 39 | + } |
| 40 | + |
| 41 | + @Test |
| 42 | + public void testName() { |
| 43 | + assertEquals("LIL UZI VERT", extractor.getName()); |
| 44 | + } |
| 45 | + |
| 46 | + @Test |
| 47 | + public void testId() { |
| 48 | + assertEquals("10494998", extractor.getId()); |
| 49 | + } |
| 50 | + |
| 51 | + @Test |
| 52 | + public void testUrl() throws ParsingException { |
| 53 | + assertEquals("https://soundcloud.com/liluzivert", extractor.getUrl()); |
| 54 | + } |
| 55 | + |
| 56 | + @Test |
| 57 | + public void testOriginalUrl() throws ParsingException { |
| 58 | + assertEquals("http://soundcloud.com/liluzivert/sets", extractor.getOriginalUrl()); |
| 59 | + } |
| 60 | + |
| 61 | + /*////////////////////////////////////////////////////////////////////////// |
| 62 | + // ListExtractor |
| 63 | + //////////////////////////////////////////////////////////////////////////*/ |
| 64 | + |
| 65 | + @Test |
| 66 | + public void testRelatedItems() throws Exception { |
| 67 | + defaultTestRelatedItems(extractor, SoundCloud.getServiceId()); |
| 68 | + } |
| 69 | + |
| 70 | + @Test |
| 71 | + public void testMoreRelatedItems() throws Exception { |
| 72 | + defaultTestMoreItems(extractor, SoundCloud.getServiceId()); |
| 73 | + } |
| 74 | + |
| 75 | + /*////////////////////////////////////////////////////////////////////////// |
| 76 | + // ChannelExtractor |
| 77 | + //////////////////////////////////////////////////////////////////////////*/ |
| 78 | + |
| 79 | + @Test |
| 80 | + public void testDescription() { |
| 81 | + assertNotNull(extractor.getDescription()); |
| 82 | + } |
| 83 | + |
| 84 | + @Test |
| 85 | + public void testAvatarUrl() { |
| 86 | + assertIsSecureUrl(extractor.getAvatarUrl()); |
| 87 | + } |
| 88 | + |
| 89 | + @Test |
| 90 | + public void testBannerUrl() { |
| 91 | + assertIsSecureUrl(extractor.getBannerUrl()); |
| 92 | + } |
| 93 | + |
| 94 | + @Test |
| 95 | + public void testFeedUrl() { |
| 96 | + assertEmpty(extractor.getFeedUrl()); |
| 97 | + } |
| 98 | + |
| 99 | + @Test |
| 100 | + public void testSubscriberCount() { |
| 101 | + assertTrue("Wrong subscriber count", extractor.getSubscriberCount() >= 1e6); |
| 102 | + } |
| 103 | + } |
| 104 | + |
| 105 | + public static class DubMatix implements BaseChannelExtractorTest { |
| 106 | + private static SoundcloudChannelExtractor extractor; |
| 107 | + |
| 108 | + @BeforeClass |
| 109 | + public static void setUp() throws Exception { |
| 110 | + NewPipe.init(Downloader.getInstance()); |
| 111 | + extractor = (SoundcloudChannelExtractor) SoundCloud |
| 112 | + .getChannelExtractor("https://soundcloud.com/dubmatix"); |
| 113 | + extractor.fetchPage(); |
| 114 | + } |
| 115 | + |
| 116 | + /*////////////////////////////////////////////////////////////////////////// |
| 117 | + // Additional Testing |
| 118 | + //////////////////////////////////////////////////////////////////////////*/ |
| 119 | + |
| 120 | + @Test |
| 121 | + public void testGetPageInNewExtractor() throws Exception { |
| 122 | + final ChannelExtractor newExtractor = SoundCloud.getChannelExtractor(extractor.getUrl()); |
| 123 | + defaultTestGetPageInNewExtractor(extractor, newExtractor, SoundCloud.getServiceId()); |
| 124 | + } |
| 125 | + |
| 126 | + /*////////////////////////////////////////////////////////////////////////// |
| 127 | + // Extractor |
| 128 | + //////////////////////////////////////////////////////////////////////////*/ |
| 129 | + |
| 130 | + @Test |
| 131 | + public void testServiceId() { |
| 132 | + assertEquals(SoundCloud.getServiceId(), extractor.getServiceId()); |
| 133 | + } |
| 134 | + |
| 135 | + @Test |
| 136 | + public void testName() { |
| 137 | + assertEquals("dubmatix", extractor.getName()); |
| 138 | + } |
| 139 | + |
| 140 | + @Test |
| 141 | + public void testId() { |
| 142 | + assertEquals("542134", extractor.getId()); |
| 143 | + } |
| 144 | + |
| 145 | + @Test |
| 146 | + public void testUrl() throws ParsingException { |
| 147 | + assertEquals("https://soundcloud.com/dubmatix", extractor.getUrl()); |
| 148 | + } |
| 149 | + |
| 150 | + @Test |
| 151 | + public void testOriginalUrl() throws ParsingException { |
| 152 | + assertEquals("https://soundcloud.com/dubmatix", extractor.getOriginalUrl()); |
| 153 | + } |
| 154 | + |
| 155 | + /*////////////////////////////////////////////////////////////////////////// |
| 156 | + // ListExtractor |
| 157 | + //////////////////////////////////////////////////////////////////////////*/ |
| 158 | + |
| 159 | + @Test |
| 160 | + public void testRelatedItems() throws Exception { |
| 161 | + defaultTestRelatedItems(extractor, SoundCloud.getServiceId()); |
| 162 | + } |
| 163 | + |
| 164 | + @Test |
| 165 | + public void testMoreRelatedItems() throws Exception { |
| 166 | + defaultTestMoreItems(extractor, SoundCloud.getServiceId()); |
| 167 | + } |
| 168 | + |
| 169 | + /*////////////////////////////////////////////////////////////////////////// |
| 170 | + // ChannelExtractor |
| 171 | + //////////////////////////////////////////////////////////////////////////*/ |
| 172 | + |
| 173 | + @Test |
| 174 | + public void testDescription() { |
| 175 | + assertNotNull(extractor.getDescription()); |
| 176 | + } |
| 177 | + |
| 178 | + @Test |
| 179 | + public void testAvatarUrl() { |
| 180 | + assertIsSecureUrl(extractor.getAvatarUrl()); |
| 181 | + } |
| 182 | + |
| 183 | + @Test |
| 184 | + public void testBannerUrl() { |
| 185 | + assertIsSecureUrl(extractor.getBannerUrl()); |
| 186 | + } |
| 187 | + |
| 188 | + @Test |
| 189 | + public void testFeedUrl() { |
| 190 | + assertEmpty(extractor.getFeedUrl()); |
| 191 | + } |
| 192 | + |
| 193 | + @Test |
| 194 | + public void testSubscriberCount() { |
| 195 | + assertTrue("Wrong subscriber count", extractor.getSubscriberCount() >= 2e6); |
| 196 | + } |
| 197 | + } |
| 198 | +} |
0 commit comments