Skip to content

Commit 8ce711f

Browse files
committed
[Test] Add sub channel name, url and thumbnail tests
1 parent 6127826 commit 8ce711f

3 files changed

Lines changed: 39 additions & 0 deletions

File tree

extractor/src/test/java/org/schabi/newpipe/extractor/services/BaseStreamExtractorTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ public interface BaseStreamExtractorTest extends BaseExtractorTest {
55
void testUploaderName() throws Exception;
66
void testUploaderUrl() throws Exception;
77
void testUploaderAvatarUrl() throws Exception;
8+
void testSubChannelName() throws Exception;
9+
void testSubChannelUrl() throws Exception;
10+
void testSubChannelAvatarUrl() throws Exception;
811
void testThumbnailUrl() throws Exception;
912
void testDescription() throws Exception;
1013
void testLength() throws Exception;

extractor/src/test/java/org/schabi/newpipe/extractor/services/DefaultStreamExtractorTest.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ public abstract class DefaultStreamExtractorTest extends DefaultExtractorTest<St
4343
public abstract StreamType expectedStreamType();
4444
public abstract String expectedUploaderName();
4545
public abstract String expectedUploaderUrl();
46+
public String expectedSubChannelName() { return ""; } // default: there is no subchannel
47+
public String expectedSubChannelUrl() { return ""; } // default: there is no subchannel
4648
public abstract List<String> expectedDescriptionContains(); // e.g. for full links
4749
public abstract long expectedLength();
4850
public long expectedTimestamp() { return 0; } // default: there is no timestamp
@@ -92,6 +94,36 @@ public void testUploaderAvatarUrl() throws Exception {
9294
assertIsSecureUrl(extractor().getUploaderAvatarUrl());
9395
}
9496

97+
@Test
98+
@Override
99+
public void testSubChannelName() throws Exception {
100+
assertEquals(expectedSubChannelName(), extractor().getSubChannelName());
101+
}
102+
103+
@Test
104+
@Override
105+
public void testSubChannelUrl() throws Exception {
106+
final String subChannelUrl = extractor().getSubChannelUrl();
107+
assertEquals(expectedSubChannelUrl(), subChannelUrl);
108+
109+
if (!expectedSubChannelUrl().isEmpty()) {
110+
// this stream has a subchannel
111+
assertIsSecureUrl(subChannelUrl);
112+
}
113+
}
114+
115+
@Test
116+
@Override
117+
public void testSubChannelAvatarUrl() throws Exception {
118+
if (expectedSubChannelName().isEmpty() && expectedSubChannelUrl().isEmpty()) {
119+
// this stream has no subchannel
120+
assertEquals("", extractor().getSubChannelAvatarUrl());
121+
} else {
122+
// this stream has a subchannel
123+
assertIsSecureUrl(extractor().getSubChannelAvatarUrl());
124+
}
125+
}
126+
95127
@Test
96128
@Override
97129
public void testThumbnailUrl() throws Exception {

extractor/src/test/java/org/schabi/newpipe/extractor/services/peertube/PeertubeStreamExtractorTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ public void testGetLanguageInformation() throws ParsingException {
5656
@Override public StreamType expectedStreamType() { return StreamType.VIDEO_STREAM; }
5757
@Override public String expectedUploaderName() { return "Framasoft"; }
5858
@Override public String expectedUploaderUrl() { return "https://framatube.org/accounts/framasoft@framatube.org"; }
59+
@Override public String expectedSubChannelName() { return "Les vidéos de Framasoft"; }
60+
@Override public String expectedSubChannelUrl() { return "https://framatube.org/video-channels/bf54d359-cfad-4935-9d45-9d6be93f63e8"; }
5961
@Override public List<String> expectedDescriptionContains() { // CRLF line ending
6062
return Arrays.asList("**[Want to help to translate this video?](https://weblate.framasoft.org/projects/what-is-peertube-video/)**\r\n"
6163
+ "\r\n"
@@ -117,6 +119,8 @@ public static void setUp() throws Exception {
117119
@Override public StreamType expectedStreamType() { return StreamType.VIDEO_STREAM; }
118120
@Override public String expectedUploaderName() { return "Tomas Berezovskiy"; }
119121
@Override public String expectedUploaderUrl() { return "https://peertube.co.uk/accounts/tomas_berezovskiy@peertube.iriseden.eu"; }
122+
@Override public String expectedSubChannelName() { return "smm.expx3"; }
123+
@Override public String expectedSubChannelUrl() { return "https://peertube.iriseden.eu/video-channels/smm.expx3"; }
120124
@Override public List<String> expectedDescriptionContains() { // LF line ending
121125
return Arrays.asList("https://en.informnapalm.org/dpr-combatant-describes-orders-given-russian-officers/ "
122126
+ " The InformNapalm team received another video of a separatist prisoner of war telling about his "

0 commit comments

Comments
 (0)