|
1 | 1 | package org.schabi.newpipe.extractor.services.soundcloud; |
2 | 2 |
|
| 3 | +import static org.junit.jupiter.api.Assertions.assertFalse; |
| 4 | +import static org.junit.jupiter.api.Assertions.assertTrue; |
| 5 | +import static org.schabi.newpipe.extractor.ExtractorAsserts.assertEmptyErrors; |
3 | 6 | import static org.schabi.newpipe.extractor.ServiceList.SoundCloud; |
4 | 7 | import static org.schabi.newpipe.extractor.services.DefaultTests.defaultTestGetPageInNewExtractor; |
5 | 8 |
|
6 | 9 | import org.junit.jupiter.api.Test; |
7 | 10 | import org.schabi.newpipe.extractor.InfoItem; |
| 11 | +import org.schabi.newpipe.extractor.ListExtractor; |
8 | 12 | import org.schabi.newpipe.extractor.StreamingService; |
9 | 13 | import org.schabi.newpipe.extractor.channel.tabs.ChannelTabExtractor; |
10 | 14 | import org.schabi.newpipe.extractor.channel.tabs.ChannelTabs; |
11 | 15 | import org.schabi.newpipe.extractor.services.DefaultListExtractorTest; |
12 | 16 |
|
| 17 | +import java.util.List; |
| 18 | + |
13 | 19 | class SoundcloudChannelTabExtractorTest { |
14 | 20 |
|
15 | 21 | static class Tracks extends DefaultListExtractorTest<ChannelTabExtractor> { |
@@ -88,4 +94,30 @@ protected ChannelTabExtractor createExtractor() throws Exception { |
88 | 94 | @Override public String expectedOriginalUrlContains() throws Exception { return "https://soundcloud.com/soreen-735855039/likes"; } |
89 | 95 | @Override public InfoItem.InfoType expectedInfoItemType() { return InfoItem.InfoType.PLAYLIST; } |
90 | 96 | } |
| 97 | + |
| 98 | + static class NoEmptyNextPages extends DefaultListExtractorTest<ChannelTabExtractor> { |
| 99 | + @Override |
| 100 | + protected ChannelTabExtractor createExtractor() throws Exception { |
| 101 | + return SoundCloud.getChannelTabExtractorFromId("73637815", ChannelTabs.TRACKS); |
| 102 | + } |
| 103 | + |
| 104 | + @Override public StreamingService expectedService() throws Exception { return SoundCloud; } |
| 105 | + @Override public String expectedName() throws Exception { return ChannelTabs.TRACKS; } |
| 106 | + @Override public String expectedId() throws Exception { return "73637815"; } |
| 107 | + @Override public String expectedUrlContains() throws Exception { return "https://soundcloud.com/hurtbox/tracks"; } |
| 108 | + @Override public String expectedOriginalUrlContains() throws Exception { return "https://soundcloud.com/hurtbox/tracks"; } |
| 109 | + @Override public InfoItem.InfoType expectedInfoItemType() { return InfoItem.InfoType.STREAM; } |
| 110 | + |
| 111 | + @Test |
| 112 | + public void testNextPages() throws Exception { |
| 113 | + ListExtractor.InfoItemsPage<InfoItem> page = extractor().getInitialPage(); |
| 114 | + for (int i = 1; i <= 5; i++) { |
| 115 | + assertEmptyErrors("Next page has errors", page.getErrors()); |
| 116 | + assertFalse(page.getItems().isEmpty(), "Next page is empty"); |
| 117 | + assertTrue(page.hasNextPage(), "Next page does not have more items"); |
| 118 | + page = extractor().getPage(page.getNextPage()); |
| 119 | + } |
| 120 | + } |
| 121 | + |
| 122 | + } |
91 | 123 | } |
0 commit comments