From eaf2600ce0aadbaca2763d127f422e215c6c8b3b Mon Sep 17 00:00:00 2001 From: AudricV <74829229+AudricV@users.noreply.github.com> Date: Sun, 16 Jul 2023 21:17:32 +0200 Subject: [PATCH] [SoundCloud] Implement link handlers and channels tabs and tags changes on tests Co-authored-by: ThetaDev --- .../SoundcloudChannelExtractorTest.java | 68 +++--- .../SoundcloudChannelTabExtractorTest.java | 196 ++++++++++++++++++ ...oundcloudChartsLinkHandlerFactoryTest.java | 2 +- 3 files changed, 225 insertions(+), 41 deletions(-) create mode 100644 extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChannelTabExtractorTest.java diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChannelExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChannelExtractorTest.java index 09974d482..26351fc0e 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChannelExtractorTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChannelExtractorTest.java @@ -4,7 +4,7 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.schabi.newpipe.downloader.DownloaderTestImpl; import org.schabi.newpipe.extractor.NewPipe; -import org.schabi.newpipe.extractor.channel.ChannelExtractor; +import org.schabi.newpipe.extractor.channel.tabs.ChannelTabs; import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.services.BaseChannelExtractorTest; import org.schabi.newpipe.extractor.services.soundcloud.extractors.SoundcloudChannelExtractor; @@ -12,8 +12,8 @@ import org.schabi.newpipe.extractor.services.soundcloud.extractors.SoundcloudCha import static org.junit.jupiter.api.Assertions.*; import static org.schabi.newpipe.extractor.ExtractorAsserts.assertEmpty; import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl; +import static org.schabi.newpipe.extractor.ExtractorAsserts.assertTabsContained; import static org.schabi.newpipe.extractor.ServiceList.SoundCloud; -import static org.schabi.newpipe.extractor.services.DefaultTests.*; /** * Test for {@link SoundcloudChannelExtractor} @@ -59,20 +59,6 @@ public class SoundcloudChannelExtractorTest { assertEquals("http://soundcloud.com/liluzivert/sets", extractor.getOriginalUrl()); } - /*////////////////////////////////////////////////////////////////////////// - // ListExtractor - //////////////////////////////////////////////////////////////////////////*/ - - @Test - public void testRelatedItems() throws Exception { - defaultTestRelatedItems(extractor); - } - - @Test - public void testMoreRelatedItems() throws Exception { - defaultTestMoreItems(extractor); - } - /*////////////////////////////////////////////////////////////////////////// // ChannelExtractor //////////////////////////////////////////////////////////////////////////*/ @@ -106,6 +92,19 @@ public class SoundcloudChannelExtractorTest { public void testVerified() throws Exception { assertTrue(extractor.isVerified()); } + + @Test + @Override + public void testTabs() throws Exception { + assertTabsContained(extractor.getTabs(), ChannelTabs.TRACKS, ChannelTabs.PLAYLISTS, + ChannelTabs.ALBUMS); + } + + @Test + @Override + public void testTags() throws Exception { + assertTrue(extractor.getTags().isEmpty()); + } } public static class DubMatix implements BaseChannelExtractorTest { @@ -119,16 +118,6 @@ public class SoundcloudChannelExtractorTest { extractor.fetchPage(); } - /*////////////////////////////////////////////////////////////////////////// - // Additional Testing - //////////////////////////////////////////////////////////////////////////*/ - - @Test - public void testGetPageInNewExtractor() throws Exception { - final ChannelExtractor newExtractor = SoundCloud.getChannelExtractor(extractor.getUrl()); - defaultTestGetPageInNewExtractor(extractor, newExtractor); - } - /*////////////////////////////////////////////////////////////////////////// // Extractor //////////////////////////////////////////////////////////////////////////*/ @@ -158,20 +147,6 @@ public class SoundcloudChannelExtractorTest { assertEquals("https://soundcloud.com/dubmatix", extractor.getOriginalUrl()); } - /*////////////////////////////////////////////////////////////////////////// - // ListExtractor - //////////////////////////////////////////////////////////////////////////*/ - - @Test - public void testRelatedItems() throws Exception { - defaultTestRelatedItems(extractor); - } - - @Test - public void testMoreRelatedItems() throws Exception { - defaultTestMoreItems(extractor); - } - /*////////////////////////////////////////////////////////////////////////// // ChannelExtractor //////////////////////////////////////////////////////////////////////////*/ @@ -205,5 +180,18 @@ public class SoundcloudChannelExtractorTest { public void testVerified() throws Exception { assertTrue(extractor.isVerified()); } + + @Test + @Override + public void testTabs() throws Exception { + assertTabsContained(extractor.getTabs(), ChannelTabs.TRACKS, ChannelTabs.PLAYLISTS, + ChannelTabs.ALBUMS); + } + + @Test + @Override + public void testTags() throws Exception { + assertTrue(extractor.getTags().isEmpty()); + } } } diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChannelTabExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChannelTabExtractorTest.java new file mode 100644 index 000000000..db213dd0c --- /dev/null +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChannelTabExtractorTest.java @@ -0,0 +1,196 @@ +package org.schabi.newpipe.extractor.services.soundcloud; + +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.schabi.newpipe.downloader.DownloaderTestImpl; +import org.schabi.newpipe.extractor.NewPipe; +import org.schabi.newpipe.extractor.channel.tabs.ChannelTabExtractor; +import org.schabi.newpipe.extractor.channel.tabs.ChannelTabs; +import org.schabi.newpipe.extractor.exceptions.ExtractionException; +import org.schabi.newpipe.extractor.exceptions.ParsingException; +import org.schabi.newpipe.extractor.services.BaseListExtractorTest; +import org.schabi.newpipe.extractor.services.soundcloud.extractors.SoundcloudChannelTabExtractor; + +import java.io.IOException; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.schabi.newpipe.extractor.ServiceList.SoundCloud; +import static org.schabi.newpipe.extractor.services.DefaultTests.defaultTestGetPageInNewExtractor; +import static org.schabi.newpipe.extractor.services.DefaultTests.defaultTestMoreItems; +import static org.schabi.newpipe.extractor.services.DefaultTests.defaultTestRelatedItems; + +class SoundcloudChannelTabExtractorTest { + + static class Tracks implements BaseListExtractorTest { + private static SoundcloudChannelTabExtractor extractor; + + @BeforeAll + static void setUp() throws IOException, ExtractionException { + NewPipe.init(DownloaderTestImpl.getInstance()); + extractor = (SoundcloudChannelTabExtractor) SoundCloud + .getChannelTabExtractorFromId("10494998", ChannelTabs.TRACKS); + extractor.fetchPage(); + } + + @Test + @Override + public void testServiceId() throws Exception { + assertEquals(SoundCloud.getServiceId(), extractor.getServiceId()); + } + + @Test + @Override + public void testName() throws Exception { + assertEquals(ChannelTabs.TRACKS, extractor.getName()); + } + + @Test + @Override + public void testId() throws Exception { + assertEquals("10494998", extractor.getId()); + } + + @Test + @Override + public void testUrl() throws Exception { + assertEquals("https://soundcloud.com/liluzivert/tracks", extractor.getUrl()); + } + + @Test + @Override + public void testOriginalUrl() throws Exception { + assertEquals("https://soundcloud.com/liluzivert/tracks", extractor.getOriginalUrl()); + } + + @Test + @Override + public void testRelatedItems() throws Exception { + defaultTestRelatedItems(extractor); + } + + @Test + @Override + public void testMoreRelatedItems() throws Exception { + defaultTestMoreItems(extractor); + } + + /*////////////////////////////////////////////////////////////////////////// + // Additional Testing + //////////////////////////////////////////////////////////////////////////*/ + + @Test + void testGetPageInNewExtractor() throws Exception { + final ChannelTabExtractor newTabExtractor = + SoundCloud.getChannelTabExtractorFromId("10494998", ChannelTabs.TRACKS); + defaultTestGetPageInNewExtractor(extractor, newTabExtractor); + } + } + + static class Playlists implements BaseListExtractorTest { + private static SoundcloudChannelTabExtractor extractor; + + @BeforeAll + static void setUp() throws IOException, ExtractionException { + NewPipe.init(DownloaderTestImpl.getInstance()); + extractor = (SoundcloudChannelTabExtractor) SoundCloud + .getChannelTabExtractorFromId("323371733", ChannelTabs.PLAYLISTS); + extractor.fetchPage(); + } + + @Test + @Override + public void testServiceId() { + assertEquals(SoundCloud.getServiceId(), extractor.getServiceId()); + } + + @Test + @Override + public void testName() throws Exception { + assertEquals(ChannelTabs.PLAYLISTS, extractor.getName()); + } + + @Test + @Override + public void testId() throws ParsingException { + assertEquals("323371733", extractor.getId()); + } + + @Test + @Override + public void testUrl() throws ParsingException { + assertEquals("https://soundcloud.com/trackaholic/sets", extractor.getUrl()); + } + + @Test + @Override + public void testOriginalUrl() throws Exception { + assertEquals("https://soundcloud.com/trackaholic/sets", extractor.getOriginalUrl()); + } + + @Test + @Override + public void testRelatedItems() throws Exception { + defaultTestRelatedItems(extractor); + } + + @Test + @Override + public void testMoreRelatedItems() throws Exception { + defaultTestMoreItems(extractor); + } + } + + static class Albums implements BaseListExtractorTest { + private static SoundcloudChannelTabExtractor extractor; + + @BeforeAll + static void setUp() throws IOException, ExtractionException { + NewPipe.init(DownloaderTestImpl.getInstance()); + extractor = (SoundcloudChannelTabExtractor) SoundCloud + .getChannelTabExtractorFromId("4803918", ChannelTabs.ALBUMS); + extractor.fetchPage(); + } + + @Test + @Override + public void testServiceId() { + assertEquals(SoundCloud.getServiceId(), extractor.getServiceId()); + } + + @Test + @Override + public void testName() throws Exception { + assertEquals(ChannelTabs.ALBUMS, extractor.getName()); + } + + @Test + @Override + public void testId() throws ParsingException { + assertEquals("4803918", extractor.getId()); + } + + @Test + @Override + public void testUrl() throws ParsingException { + assertEquals("https://soundcloud.com/bigsean-1/albums", extractor.getUrl()); + } + + @Test + @Override + public void testOriginalUrl() throws Exception { + assertEquals("https://soundcloud.com/bigsean-1/albums", extractor.getOriginalUrl()); + } + + @Test + @Override + public void testRelatedItems() throws Exception { + defaultTestRelatedItems(extractor); + } + + @Test + @Override + public void testMoreRelatedItems() throws Exception { + defaultTestMoreItems(extractor); + } + } +} diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChartsLinkHandlerFactoryTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChartsLinkHandlerFactoryTest.java index 6dcef794b..37227d7b9 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChartsLinkHandlerFactoryTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChartsLinkHandlerFactoryTest.java @@ -19,7 +19,7 @@ public class SoundcloudChartsLinkHandlerFactoryTest { @BeforeAll public static void setUp() { - linkHandler = new SoundcloudChartsLinkHandlerFactory(); + linkHandler = SoundcloudChartsLinkHandlerFactory.getInstance(); NewPipe.init(DownloaderTestImpl.getInstance()); }