|
14 | 14 | import org.schabi.newpipe.extractor.exceptions.ParsingException; |
15 | 15 | import org.schabi.newpipe.extractor.playlist.PlaylistExtractor; |
16 | 16 | import org.schabi.newpipe.extractor.services.BasePlaylistExtractorTest; |
| 17 | +import org.schabi.newpipe.extractor.services.youtube.YoutubePlaylistExtractorTest.ContinuationsTests; |
17 | 18 | import org.schabi.newpipe.extractor.services.youtube.YoutubePlaylistExtractorTest.HugePlaylist; |
18 | 19 | import org.schabi.newpipe.extractor.services.youtube.YoutubePlaylistExtractorTest.LearningPlaylist; |
19 | 20 | import org.schabi.newpipe.extractor.services.youtube.YoutubePlaylistExtractorTest.NotAvailable; |
20 | 21 | import org.schabi.newpipe.extractor.services.youtube.YoutubePlaylistExtractorTest.TimelessPopHits; |
21 | 22 | import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubePlaylistExtractor; |
22 | 23 | import org.schabi.newpipe.extractor.stream.StreamInfoItem; |
23 | 24 |
|
| 25 | +import static junit.framework.TestCase.assertFalse; |
24 | 26 | import static org.junit.Assert.assertEquals; |
| 27 | +import static org.junit.Assert.assertNull; |
25 | 28 | import static org.junit.Assert.assertTrue; |
26 | 29 | import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl; |
27 | 30 | import static org.schabi.newpipe.extractor.ServiceList.YouTube; |
|
31 | 34 | * Test for {@link YoutubePlaylistExtractor} |
32 | 35 | */ |
33 | 36 | @RunWith(Suite.class) |
34 | | -@SuiteClasses({NotAvailable.class, TimelessPopHits.class, HugePlaylist.class, LearningPlaylist.class}) |
| 37 | +@SuiteClasses({NotAvailable.class, TimelessPopHits.class, HugePlaylist.class, |
| 38 | + LearningPlaylist.class, ContinuationsTests.class}) |
35 | 39 | public class YoutubePlaylistExtractorTest { |
36 | 40 |
|
37 | 41 | public static class NotAvailable { |
@@ -123,7 +127,7 @@ public void testThumbnailUrl() throws Exception { |
123 | 127 |
|
124 | 128 | @Ignore |
125 | 129 | @Test |
126 | | - public void testBannerUrl() throws Exception { |
| 130 | + public void testBannerUrl() { |
127 | 131 | final String bannerUrl = extractor.getBannerUrl(); |
128 | 132 | assertIsSecureUrl(bannerUrl); |
129 | 133 | assertTrue(bannerUrl, bannerUrl.contains("yt")); |
@@ -236,7 +240,7 @@ public void testThumbnailUrl() throws Exception { |
236 | 240 |
|
237 | 241 | @Ignore |
238 | 242 | @Test |
239 | | - public void testBannerUrl() throws Exception { |
| 243 | + public void testBannerUrl() { |
240 | 244 | final String bannerUrl = extractor.getBannerUrl(); |
241 | 245 | assertIsSecureUrl(bannerUrl); |
242 | 246 | assertTrue(bannerUrl, bannerUrl.contains("yt")); |
@@ -333,7 +337,7 @@ public void testThumbnailUrl() throws Exception { |
333 | 337 |
|
334 | 338 | @Ignore |
335 | 339 | @Test |
336 | | - public void testBannerUrl() throws Exception { |
| 340 | + public void testBannerUrl() { |
337 | 341 | final String bannerUrl = extractor.getBannerUrl(); |
338 | 342 | assertIsSecureUrl(bannerUrl); |
339 | 343 | assertTrue(bannerUrl, bannerUrl.contains("yt")); |
@@ -361,4 +365,34 @@ public void testStreamCount() throws Exception { |
361 | 365 | assertTrue("Error in the streams count", extractor.getStreamCount() > 40); |
362 | 366 | } |
363 | 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 | + } |
364 | 398 | } |
0 commit comments