Skip to content

Commit a09eedf

Browse files
committed
Fixed most tests
1 parent dfce024 commit a09eedf

14 files changed

+130
-147
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package org.schabi.newpipe.extractor.services;
22

33
public interface BaseStreamExtractorTest extends BaseExtractorTest {
4-
void testStreamType() throws Exception;
54
void testUploaderName() throws Exception;
65
void testUploaderUrl() throws Exception;
76
void testUploaderAvatarUrl() throws Exception;

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import org.schabi.newpipe.extractor.stream.Frameset;
2222
import org.schabi.newpipe.extractor.stream.Privacy;
2323
import org.schabi.newpipe.extractor.stream.StreamExtractor;
24-
import org.schabi.newpipe.extractor.stream.StreamType;
2524
import org.schabi.newpipe.extractor.streamdata.delivery.DASHManifestDeliveryData;
2625
import org.schabi.newpipe.extractor.streamdata.delivery.DeliveryData;
2726
import org.schabi.newpipe.extractor.streamdata.delivery.UrlBasedDeliveryData;
@@ -194,12 +193,13 @@ public void testViewCount() throws Exception {
194193
public void testUploadDate() throws Exception {
195194
final DateWrapper dateWrapper = extractor().getUploadDate();
196195

197-
if (expectedUploadDate() == null) {
196+
final String expectedUploadDate = expectedUploadDate();
197+
if (expectedUploadDate == null) {
198198
assertNull(dateWrapper);
199199
} else {
200200
assertNotNull(dateWrapper);
201201

202-
final LocalDateTime expectedDateTime = LocalDateTime.parse(expectedUploadDate(),
202+
final LocalDateTime expectedDateTime = LocalDateTime.parse(expectedUploadDate,
203203
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS"));
204204
final LocalDateTime actualDateTime = dateWrapper.offsetDateTime().toLocalDateTime();
205205

extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampStreamExtractorTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampExtractorHelper;
1414
import org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampStreamExtractor;
1515
import org.schabi.newpipe.extractor.stream.StreamExtractor;
16-
import org.schabi.newpipe.extractor.stream.StreamType;
1716

1817
import java.io.IOException;
1918
import java.util.Collections;

extractor/src/test/java/org/schabi/newpipe/extractor/services/media_ccc/MediaCCCOggTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
import org.schabi.newpipe.downloader.DownloaderTestImpl;
66
import org.schabi.newpipe.extractor.NewPipe;
77
import org.schabi.newpipe.extractor.services.media_ccc.extractors.MediaCCCStreamExtractor;
8-
import org.schabi.newpipe.extractor.stream.AudioStream;
98
import org.schabi.newpipe.extractor.stream.StreamExtractor;
9+
import org.schabi.newpipe.extractor.streamdata.stream.AudioStream;
1010

1111
import static org.junit.jupiter.api.Assertions.assertEquals;
1212
import static org.schabi.newpipe.extractor.ServiceList.MediaCCC;
@@ -34,7 +34,7 @@ public void getAudioStreamsCount() throws Exception {
3434
@Test
3535
public void getAudioStreamsContainOgg() throws Exception {
3636
for (AudioStream stream : extractor.getAudioStreams()) {
37-
assertEquals("OGG", stream.getFormat().toString());
37+
assertEquals("ogg", stream.mediaFormat().name());
3838
}
3939
}
4040
}

extractor/src/test/java/org/schabi/newpipe/extractor/services/media_ccc/MediaCCCStreamExtractorTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import org.schabi.newpipe.extractor.services.DefaultStreamExtractorTest;
99
import org.schabi.newpipe.extractor.services.media_ccc.extractors.MediaCCCStreamExtractor;
1010
import org.schabi.newpipe.extractor.stream.StreamExtractor;
11-
import org.schabi.newpipe.extractor.stream.StreamType;
1211

1312
import javax.annotation.Nullable;
1413

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import org.schabi.newpipe.extractor.exceptions.ParsingException;
1111
import org.schabi.newpipe.extractor.services.DefaultStreamExtractorTest;
1212
import org.schabi.newpipe.extractor.stream.StreamExtractor;
13-
import org.schabi.newpipe.extractor.stream.StreamType;
1413

1514
import java.io.IOException;
1615
import java.util.Arrays;

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

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
package org.schabi.newpipe.extractor.services.soundcloud;
22

3+
import static org.junit.jupiter.api.Assertions.assertEquals;
4+
import static org.junit.jupiter.api.Assertions.assertTrue;
5+
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
6+
37
import org.junit.jupiter.api.BeforeAll;
48
import org.junit.jupiter.api.Disabled;
59
import org.junit.jupiter.api.Test;
610
import org.schabi.newpipe.downloader.DownloaderTestImpl;
711
import org.schabi.newpipe.extractor.ExtractorAsserts;
8-
import org.schabi.newpipe.extractor.MediaFormat;
912
import org.schabi.newpipe.extractor.NewPipe;
1013
import org.schabi.newpipe.extractor.StreamingService;
1114
import org.schabi.newpipe.extractor.exceptions.GeographicRestrictionException;
1215
import org.schabi.newpipe.extractor.exceptions.SoundCloudGoPlusContentException;
1316
import org.schabi.newpipe.extractor.services.DefaultStreamExtractorTest;
14-
import org.schabi.newpipe.extractor.stream.AudioStream;
15-
import org.schabi.newpipe.extractor.stream.DeliveryMethod;
1617
import org.schabi.newpipe.extractor.stream.StreamExtractor;
17-
import org.schabi.newpipe.extractor.stream.StreamType;
18+
import org.schabi.newpipe.extractor.streamdata.delivery.ProgressiveHTTPDeliveryData;
19+
import org.schabi.newpipe.extractor.streamdata.format.registry.AudioFormatRegistry;
20+
import org.schabi.newpipe.extractor.streamdata.stream.AudioStream;
1821

1922
import java.util.Arrays;
2023
import java.util.Collections;
2124
import java.util.List;
2225

2326
import javax.annotation.Nullable;
2427

25-
import static org.junit.jupiter.api.Assertions.*;
26-
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
27-
2828
public class SoundcloudStreamExtractorTest {
2929
private static final String SOUNDCLOUD = "https://soundcloud.com/";
3030

@@ -186,29 +186,33 @@ public static void setUp() throws Exception {
186186
@Test
187187
public void testAudioStreams() throws Exception {
188188
super.testAudioStreams();
189+
189190
final List<AudioStream> audioStreams = extractor.getAudioStreams();
190191
assertEquals(2, audioStreams.size());
191-
audioStreams.forEach(audioStream -> {
192-
final DeliveryMethod deliveryMethod = audioStream.getDeliveryMethod();
193-
final String mediaUrl = audioStream.getContent();
194-
if (audioStream.getFormat() == MediaFormat.OPUS) {
192+
193+
for (final AudioStream audioStream : audioStreams) {
194+
assertTrue(audioStream.deliveryData() instanceof ProgressiveHTTPDeliveryData,
195+
"Wrong delivery method for mediaFormat=" + audioStream.mediaFormat()
196+
+ " , avgBR=" + audioStream.averageBitrate()
197+
+ " , deliverDataType=" + audioStream.deliveryData().getClass()
198+
);
199+
200+
final ProgressiveHTTPDeliveryData deliveryData =
201+
(ProgressiveHTTPDeliveryData) audioStream.deliveryData();
202+
203+
final String mediaUrl = deliveryData.url();
204+
if (audioStream.mediaFormat() == AudioFormatRegistry.OPUS) {
195205
// Assert that it's an OPUS 64 kbps media URL with a single range which comes
196206
// from an HLS SoundCloud CDN
197207
ExtractorAsserts.assertContains("-hls-opus-media.sndcdn.com", mediaUrl);
198208
ExtractorAsserts.assertContains(".64.opus", mediaUrl);
199-
assertSame(DeliveryMethod.HLS, deliveryMethod,
200-
"Wrong delivery method for stream " + audioStream.getId() + ": "
201-
+ deliveryMethod);
202-
} else if (audioStream.getFormat() == MediaFormat.MP3) {
209+
} else if (audioStream.mediaFormat() == AudioFormatRegistry.MP3) {
203210
// Assert that it's a MP3 128 kbps media URL which comes from a progressive
204211
// SoundCloud CDN
205212
ExtractorAsserts.assertContains("-media.sndcdn.com/bKOA7Pwbut93.128.mp3",
206213
mediaUrl);
207-
assertSame(DeliveryMethod.PROGRESSIVE_HTTP, deliveryMethod,
208-
"Wrong delivery method for stream " + audioStream.getId() + ": "
209-
+ deliveryMethod);
210214
}
211-
});
215+
}
212216
}
213217
}
214218
}

0 commit comments

Comments
 (0)