|
3 | 3 | import org.junit.BeforeClass; |
4 | 4 | import org.junit.Ignore; |
5 | 5 | import org.junit.Test; |
| 6 | +import org.junit.runner.RunWith; |
| 7 | +import org.junit.runners.Suite; |
| 8 | +import org.junit.runners.Suite.SuiteClasses; |
6 | 9 | import org.schabi.newpipe.DownloaderTestImpl; |
7 | 10 | import org.schabi.newpipe.extractor.ListExtractor; |
8 | 11 | import org.schabi.newpipe.extractor.NewPipe; |
|
11 | 14 | import org.schabi.newpipe.extractor.exceptions.ParsingException; |
12 | 15 | import org.schabi.newpipe.extractor.playlist.PlaylistExtractor; |
13 | 16 | import org.schabi.newpipe.extractor.services.BasePlaylistExtractorTest; |
| 17 | +import org.schabi.newpipe.extractor.services.youtube.YoutubePlaylistExtractorTest.ContinuationsTests; |
| 18 | +import org.schabi.newpipe.extractor.services.youtube.YoutubePlaylistExtractorTest.HugePlaylist; |
| 19 | +import org.schabi.newpipe.extractor.services.youtube.YoutubePlaylistExtractorTest.LearningPlaylist; |
| 20 | +import org.schabi.newpipe.extractor.services.youtube.YoutubePlaylistExtractorTest.NotAvailable; |
| 21 | +import org.schabi.newpipe.extractor.services.youtube.YoutubePlaylistExtractorTest.TimelessPopHits; |
14 | 22 | import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubePlaylistExtractor; |
15 | 23 | import org.schabi.newpipe.extractor.stream.StreamInfoItem; |
16 | 24 |
|
| 25 | +import static junit.framework.TestCase.assertFalse; |
17 | 26 | import static org.junit.Assert.assertEquals; |
| 27 | +import static org.junit.Assert.assertNull; |
18 | 28 | import static org.junit.Assert.assertTrue; |
19 | 29 | import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl; |
20 | 30 | import static org.schabi.newpipe.extractor.ServiceList.YouTube; |
|
23 | 33 | /** |
24 | 34 | * Test for {@link YoutubePlaylistExtractor} |
25 | 35 | */ |
| 36 | +@RunWith(Suite.class) |
| 37 | +@SuiteClasses({NotAvailable.class, TimelessPopHits.class, HugePlaylist.class, |
| 38 | + LearningPlaylist.class, ContinuationsTests.class}) |
26 | 39 | public class YoutubePlaylistExtractorTest { |
27 | 40 |
|
28 | 41 | public static class NotAvailable { |
@@ -114,7 +127,7 @@ public void testThumbnailUrl() throws Exception { |
114 | 127 |
|
115 | 128 | @Ignore |
116 | 129 | @Test |
117 | | - public void testBannerUrl() throws Exception { |
| 130 | + public void testBannerUrl() { |
118 | 131 | final String bannerUrl = extractor.getBannerUrl(); |
119 | 132 | assertIsSecureUrl(bannerUrl); |
120 | 133 | assertTrue(bannerUrl, bannerUrl.contains("yt")); |
@@ -227,7 +240,7 @@ public void testThumbnailUrl() throws Exception { |
227 | 240 |
|
228 | 241 | @Ignore |
229 | 242 | @Test |
230 | | - public void testBannerUrl() throws Exception { |
| 243 | + public void testBannerUrl() { |
231 | 244 | final String bannerUrl = extractor.getBannerUrl(); |
232 | 245 | assertIsSecureUrl(bannerUrl); |
233 | 246 | assertTrue(bannerUrl, bannerUrl.contains("yt")); |
@@ -324,7 +337,7 @@ public void testThumbnailUrl() throws Exception { |
324 | 337 |
|
325 | 338 | @Ignore |
326 | 339 | @Test |
327 | | - public void testBannerUrl() throws Exception { |
| 340 | + public void testBannerUrl() { |
328 | 341 | final String bannerUrl = extractor.getBannerUrl(); |
329 | 342 | assertIsSecureUrl(bannerUrl); |
330 | 343 | assertTrue(bannerUrl, bannerUrl.contains("yt")); |
@@ -352,4 +365,34 @@ public void testStreamCount() throws Exception { |
352 | 365 | assertTrue("Error in the streams count", extractor.getStreamCount() > 40); |
353 | 366 | } |
354 | 367 | } |
| 368 | + |
| 369 | + public static class ContinuationsTests { |
| 370 | + |
| 371 | + @BeforeClass |
| 372 | + public static void setUp() { |
| 373 | + NewPipe.init(DownloaderTestImpl.getInstance()); |
| 374 | + } |
| 375 | + |
| 376 | + @Test |
| 377 | + public void testNoContinuations() throws Exception { |
| 378 | + final YoutubePlaylistExtractor extractor = (YoutubePlaylistExtractor) YouTube |
| 379 | + .getPlaylistExtractor( |
| 380 | + "https://www.youtube.com/playlist?list=PLXJg25X-OulsVsnvZ7RVtSDW-id9_RzAO"); |
| 381 | + extractor.fetchPage(); |
| 382 | + |
| 383 | + assertNoMoreItems(extractor); |
| 384 | + } |
| 385 | + |
| 386 | + @Test |
| 387 | + public void testOnlySingleContinuation() throws Exception { |
| 388 | + final YoutubePlaylistExtractor extractor = (YoutubePlaylistExtractor) YouTube |
| 389 | + .getPlaylistExtractor( |
| 390 | + "https://www.youtube.com/playlist?list=PLjgwFL8urN2DFRuRkFTkmtHjyoNWHHdZX"); |
| 391 | + extractor.fetchPage(); |
| 392 | + |
| 393 | + final ListExtractor.InfoItemsPage<StreamInfoItem> page = defaultTestMoreItems( |
| 394 | + extractor); |
| 395 | + assertFalse("More items available when it shouldn't", page.hasNextPage()); |
| 396 | + } |
| 397 | + } |
355 | 398 | } |
0 commit comments