Skip to content

Commit eaf2600

Browse files
AudricVTheta-Dev
authored andcommitted
[SoundCloud] Implement link handlers and channels tabs and tags changes on tests
Co-authored-by: ThetaDev <t.testboy@gmail.com>
1 parent 0ee2072 commit eaf2600

3 files changed

Lines changed: 225 additions & 41 deletions

File tree

extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChannelExtractorTest.java

Lines changed: 28 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
import org.junit.jupiter.api.Test;
55
import org.schabi.newpipe.downloader.DownloaderTestImpl;
66
import org.schabi.newpipe.extractor.NewPipe;
7-
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
7+
import org.schabi.newpipe.extractor.channel.tabs.ChannelTabs;
88
import org.schabi.newpipe.extractor.exceptions.ParsingException;
99
import org.schabi.newpipe.extractor.services.BaseChannelExtractorTest;
1010
import org.schabi.newpipe.extractor.services.soundcloud.extractors.SoundcloudChannelExtractor;
1111

1212
import static org.junit.jupiter.api.Assertions.*;
1313
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertEmpty;
1414
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl;
15+
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertTabsContained;
1516
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
16-
import static org.schabi.newpipe.extractor.services.DefaultTests.*;
1717

1818
/**
1919
* Test for {@link SoundcloudChannelExtractor}
@@ -59,20 +59,6 @@ public void testOriginalUrl() throws ParsingException {
5959
assertEquals("http://soundcloud.com/liluzivert/sets", extractor.getOriginalUrl());
6060
}
6161

62-
/*//////////////////////////////////////////////////////////////////////////
63-
// ListExtractor
64-
//////////////////////////////////////////////////////////////////////////*/
65-
66-
@Test
67-
public void testRelatedItems() throws Exception {
68-
defaultTestRelatedItems(extractor);
69-
}
70-
71-
@Test
72-
public void testMoreRelatedItems() throws Exception {
73-
defaultTestMoreItems(extractor);
74-
}
75-
7662
/*//////////////////////////////////////////////////////////////////////////
7763
// ChannelExtractor
7864
//////////////////////////////////////////////////////////////////////////*/
@@ -106,6 +92,19 @@ public void testSubscriberCount() {
10692
public void testVerified() throws Exception {
10793
assertTrue(extractor.isVerified());
10894
}
95+
96+
@Test
97+
@Override
98+
public void testTabs() throws Exception {
99+
assertTabsContained(extractor.getTabs(), ChannelTabs.TRACKS, ChannelTabs.PLAYLISTS,
100+
ChannelTabs.ALBUMS);
101+
}
102+
103+
@Test
104+
@Override
105+
public void testTags() throws Exception {
106+
assertTrue(extractor.getTags().isEmpty());
107+
}
109108
}
110109

111110
public static class DubMatix implements BaseChannelExtractorTest {
@@ -119,16 +118,6 @@ public static void setUp() throws Exception {
119118
extractor.fetchPage();
120119
}
121120

122-
/*//////////////////////////////////////////////////////////////////////////
123-
// Additional Testing
124-
//////////////////////////////////////////////////////////////////////////*/
125-
126-
@Test
127-
public void testGetPageInNewExtractor() throws Exception {
128-
final ChannelExtractor newExtractor = SoundCloud.getChannelExtractor(extractor.getUrl());
129-
defaultTestGetPageInNewExtractor(extractor, newExtractor);
130-
}
131-
132121
/*//////////////////////////////////////////////////////////////////////////
133122
// Extractor
134123
//////////////////////////////////////////////////////////////////////////*/
@@ -158,20 +147,6 @@ public void testOriginalUrl() throws ParsingException {
158147
assertEquals("https://soundcloud.com/dubmatix", extractor.getOriginalUrl());
159148
}
160149

161-
/*//////////////////////////////////////////////////////////////////////////
162-
// ListExtractor
163-
//////////////////////////////////////////////////////////////////////////*/
164-
165-
@Test
166-
public void testRelatedItems() throws Exception {
167-
defaultTestRelatedItems(extractor);
168-
}
169-
170-
@Test
171-
public void testMoreRelatedItems() throws Exception {
172-
defaultTestMoreItems(extractor);
173-
}
174-
175150
/*//////////////////////////////////////////////////////////////////////////
176151
// ChannelExtractor
177152
//////////////////////////////////////////////////////////////////////////*/
@@ -205,5 +180,18 @@ public void testSubscriberCount() {
205180
public void testVerified() throws Exception {
206181
assertTrue(extractor.isVerified());
207182
}
183+
184+
@Test
185+
@Override
186+
public void testTabs() throws Exception {
187+
assertTabsContained(extractor.getTabs(), ChannelTabs.TRACKS, ChannelTabs.PLAYLISTS,
188+
ChannelTabs.ALBUMS);
189+
}
190+
191+
@Test
192+
@Override
193+
public void testTags() throws Exception {
194+
assertTrue(extractor.getTags().isEmpty());
195+
}
208196
}
209197
}
Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
package org.schabi.newpipe.extractor.services.soundcloud;
2+
3+
import org.junit.jupiter.api.BeforeAll;
4+
import org.junit.jupiter.api.Test;
5+
import org.schabi.newpipe.downloader.DownloaderTestImpl;
6+
import org.schabi.newpipe.extractor.NewPipe;
7+
import org.schabi.newpipe.extractor.channel.tabs.ChannelTabExtractor;
8+
import org.schabi.newpipe.extractor.channel.tabs.ChannelTabs;
9+
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
10+
import org.schabi.newpipe.extractor.exceptions.ParsingException;
11+
import org.schabi.newpipe.extractor.services.BaseListExtractorTest;
12+
import org.schabi.newpipe.extractor.services.soundcloud.extractors.SoundcloudChannelTabExtractor;
13+
14+
import java.io.IOException;
15+
16+
import static org.junit.jupiter.api.Assertions.assertEquals;
17+
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
18+
import static org.schabi.newpipe.extractor.services.DefaultTests.defaultTestGetPageInNewExtractor;
19+
import static org.schabi.newpipe.extractor.services.DefaultTests.defaultTestMoreItems;
20+
import static org.schabi.newpipe.extractor.services.DefaultTests.defaultTestRelatedItems;
21+
22+
class SoundcloudChannelTabExtractorTest {
23+
24+
static class Tracks implements BaseListExtractorTest {
25+
private static SoundcloudChannelTabExtractor extractor;
26+
27+
@BeforeAll
28+
static void setUp() throws IOException, ExtractionException {
29+
NewPipe.init(DownloaderTestImpl.getInstance());
30+
extractor = (SoundcloudChannelTabExtractor) SoundCloud
31+
.getChannelTabExtractorFromId("10494998", ChannelTabs.TRACKS);
32+
extractor.fetchPage();
33+
}
34+
35+
@Test
36+
@Override
37+
public void testServiceId() throws Exception {
38+
assertEquals(SoundCloud.getServiceId(), extractor.getServiceId());
39+
}
40+
41+
@Test
42+
@Override
43+
public void testName() throws Exception {
44+
assertEquals(ChannelTabs.TRACKS, extractor.getName());
45+
}
46+
47+
@Test
48+
@Override
49+
public void testId() throws Exception {
50+
assertEquals("10494998", extractor.getId());
51+
}
52+
53+
@Test
54+
@Override
55+
public void testUrl() throws Exception {
56+
assertEquals("https://soundcloud.com/liluzivert/tracks", extractor.getUrl());
57+
}
58+
59+
@Test
60+
@Override
61+
public void testOriginalUrl() throws Exception {
62+
assertEquals("https://soundcloud.com/liluzivert/tracks", extractor.getOriginalUrl());
63+
}
64+
65+
@Test
66+
@Override
67+
public void testRelatedItems() throws Exception {
68+
defaultTestRelatedItems(extractor);
69+
}
70+
71+
@Test
72+
@Override
73+
public void testMoreRelatedItems() throws Exception {
74+
defaultTestMoreItems(extractor);
75+
}
76+
77+
/*//////////////////////////////////////////////////////////////////////////
78+
// Additional Testing
79+
//////////////////////////////////////////////////////////////////////////*/
80+
81+
@Test
82+
void testGetPageInNewExtractor() throws Exception {
83+
final ChannelTabExtractor newTabExtractor =
84+
SoundCloud.getChannelTabExtractorFromId("10494998", ChannelTabs.TRACKS);
85+
defaultTestGetPageInNewExtractor(extractor, newTabExtractor);
86+
}
87+
}
88+
89+
static class Playlists implements BaseListExtractorTest {
90+
private static SoundcloudChannelTabExtractor extractor;
91+
92+
@BeforeAll
93+
static void setUp() throws IOException, ExtractionException {
94+
NewPipe.init(DownloaderTestImpl.getInstance());
95+
extractor = (SoundcloudChannelTabExtractor) SoundCloud
96+
.getChannelTabExtractorFromId("323371733", ChannelTabs.PLAYLISTS);
97+
extractor.fetchPage();
98+
}
99+
100+
@Test
101+
@Override
102+
public void testServiceId() {
103+
assertEquals(SoundCloud.getServiceId(), extractor.getServiceId());
104+
}
105+
106+
@Test
107+
@Override
108+
public void testName() throws Exception {
109+
assertEquals(ChannelTabs.PLAYLISTS, extractor.getName());
110+
}
111+
112+
@Test
113+
@Override
114+
public void testId() throws ParsingException {
115+
assertEquals("323371733", extractor.getId());
116+
}
117+
118+
@Test
119+
@Override
120+
public void testUrl() throws ParsingException {
121+
assertEquals("https://soundcloud.com/trackaholic/sets", extractor.getUrl());
122+
}
123+
124+
@Test
125+
@Override
126+
public void testOriginalUrl() throws Exception {
127+
assertEquals("https://soundcloud.com/trackaholic/sets", extractor.getOriginalUrl());
128+
}
129+
130+
@Test
131+
@Override
132+
public void testRelatedItems() throws Exception {
133+
defaultTestRelatedItems(extractor);
134+
}
135+
136+
@Test
137+
@Override
138+
public void testMoreRelatedItems() throws Exception {
139+
defaultTestMoreItems(extractor);
140+
}
141+
}
142+
143+
static class Albums implements BaseListExtractorTest {
144+
private static SoundcloudChannelTabExtractor extractor;
145+
146+
@BeforeAll
147+
static void setUp() throws IOException, ExtractionException {
148+
NewPipe.init(DownloaderTestImpl.getInstance());
149+
extractor = (SoundcloudChannelTabExtractor) SoundCloud
150+
.getChannelTabExtractorFromId("4803918", ChannelTabs.ALBUMS);
151+
extractor.fetchPage();
152+
}
153+
154+
@Test
155+
@Override
156+
public void testServiceId() {
157+
assertEquals(SoundCloud.getServiceId(), extractor.getServiceId());
158+
}
159+
160+
@Test
161+
@Override
162+
public void testName() throws Exception {
163+
assertEquals(ChannelTabs.ALBUMS, extractor.getName());
164+
}
165+
166+
@Test
167+
@Override
168+
public void testId() throws ParsingException {
169+
assertEquals("4803918", extractor.getId());
170+
}
171+
172+
@Test
173+
@Override
174+
public void testUrl() throws ParsingException {
175+
assertEquals("https://soundcloud.com/bigsean-1/albums", extractor.getUrl());
176+
}
177+
178+
@Test
179+
@Override
180+
public void testOriginalUrl() throws Exception {
181+
assertEquals("https://soundcloud.com/bigsean-1/albums", extractor.getOriginalUrl());
182+
}
183+
184+
@Test
185+
@Override
186+
public void testRelatedItems() throws Exception {
187+
defaultTestRelatedItems(extractor);
188+
}
189+
190+
@Test
191+
@Override
192+
public void testMoreRelatedItems() throws Exception {
193+
defaultTestMoreItems(extractor);
194+
}
195+
}
196+
}

extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChartsLinkHandlerFactoryTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class SoundcloudChartsLinkHandlerFactoryTest {
1919

2020
@BeforeAll
2121
public static void setUp() {
22-
linkHandler = new SoundcloudChartsLinkHandlerFactory();
22+
linkHandler = SoundcloudChartsLinkHandlerFactory.getInstance();
2323
NewPipe.init(DownloaderTestImpl.getInstance());
2424
}
2525

0 commit comments

Comments
 (0)