NewPipeExtractor/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamExtractorDe...

121 lines
4.2 KiB
Java
Raw Normal View History

2017-08-08 08:42:28 +02:00
package org.schabi.newpipe.extractor.services.soundcloud;
import org.junit.BeforeClass;
2017-08-08 08:42:28 +02:00
import org.junit.Test;
import org.schabi.newpipe.Downloader;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.stream.StreamExtractor;
2018-02-24 22:20:50 +01:00
import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector;
2017-08-08 08:42:28 +02:00
import org.schabi.newpipe.extractor.stream.StreamType;
2018-09-15 21:47:53 +02:00
import org.schabi.newpipe.extractor.utils.Localization;
2017-08-08 08:42:28 +02:00
import java.io.IOException;
import static org.junit.Assert.*;
2018-01-04 17:21:03 +01:00
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl;
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
2017-08-08 08:42:28 +02:00
/**
* Test for {@link StreamExtractor}
*/
public class SoundcloudStreamExtractorDefaultTest {
private static SoundcloudStreamExtractor extractor;
2017-08-08 08:42:28 +02:00
@BeforeClass
public static void setUp() throws Exception {
2018-09-15 21:47:53 +02:00
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
extractor = (SoundcloudStreamExtractor) SoundCloud.getStreamExtractor("https://soundcloud.com/liluzivert/do-what-i-want-produced-by-maaly-raw-don-cannon");
2017-11-28 13:37:01 +01:00
extractor.fetchPage();
2017-08-08 08:42:28 +02:00
}
@Test
public void testGetInvalidTimeStamp() throws ParsingException {
2017-08-11 03:23:09 +02:00
assertTrue(extractor.getTimeStamp() + "",
2017-08-08 08:42:28 +02:00
extractor.getTimeStamp() <= 0);
}
@Test
public void testGetValidTimeStamp() throws IOException, ExtractionException {
StreamExtractor extractor = SoundCloud.getStreamExtractor("https://soundcloud.com/liluzivert/do-what-i-want-produced-by-maaly-raw-don-cannon#t=69");
assertEquals("69", extractor.getTimeStamp() + "");
2017-08-08 08:42:28 +02:00
}
@Test
public void testGetTitle() throws ParsingException {
assertEquals("Do What I Want [Produced By Maaly Raw + Don Cannon]", extractor.getName());
2017-08-08 08:42:28 +02:00
}
@Test
public void testGetDescription() throws ParsingException {
assertEquals("The Perfect LUV Tape®", extractor.getDescription());
2017-08-08 08:42:28 +02:00
}
@Test
2017-08-08 23:36:11 +02:00
public void testGetUploaderName() throws ParsingException {
assertEquals("LIL UZI VERT", extractor.getUploaderName());
2017-08-08 08:42:28 +02:00
}
@Test
public void testGetLength() throws ParsingException {
assertEquals(175, extractor.getLength());
2017-08-08 08:42:28 +02:00
}
@Test
public void testGetViewCount() throws ParsingException {
assertTrue(Long.toString(extractor.getViewCount()),
extractor.getViewCount() > 44227978);
}
@Test
public void testGetUploadDate() throws ParsingException {
2018-01-04 17:21:03 +01:00
assertEquals("2016-07-31", extractor.getUploadDate());
2017-08-08 08:42:28 +02:00
}
@Test
2017-08-08 23:36:11 +02:00
public void testGetUploaderUrl() throws ParsingException {
2018-01-04 17:21:03 +01:00
assertIsSecureUrl(extractor.getUploaderUrl());
assertEquals("https://soundcloud.com/liluzivert", extractor.getUploaderUrl());
2017-08-08 08:42:28 +02:00
}
@Test
public void testGetThumbnailUrl() throws ParsingException {
2018-01-04 17:21:03 +01:00
assertIsSecureUrl(extractor.getThumbnailUrl());
2017-08-08 08:42:28 +02:00
}
@Test
2017-08-08 23:36:11 +02:00
public void testGetUploaderAvatarUrl() throws ParsingException {
2018-01-04 17:21:03 +01:00
assertIsSecureUrl(extractor.getUploaderAvatarUrl());
2017-08-08 08:42:28 +02:00
}
@Test
public void testGetAudioStreams() throws IOException, ExtractionException {
2017-11-25 02:07:12 +01:00
assertFalse(extractor.getAudioStreams().isEmpty());
2017-08-08 08:42:28 +02:00
}
@Test
public void testStreamType() throws ParsingException {
assertTrue(extractor.getStreamType() == StreamType.AUDIO_STREAM);
}
@Test
public void testGetRelatedVideos() throws ExtractionException, IOException {
StreamInfoItemsCollector relatedVideos = extractor.getRelatedStreams();
assertFalse(relatedVideos.getItems().isEmpty());
2017-08-08 08:42:28 +02:00
assertTrue(relatedVideos.getErrors().isEmpty());
}
@Test
2017-11-24 13:57:54 +01:00
public void testGetSubtitlesListDefault() throws IOException, ExtractionException {
// Video (/view?v=YQHsXMglC9A) set in the setUp() method has no captions => null
assertTrue(extractor.getSubtitlesDefault().isEmpty());
}
@Test
2017-11-24 13:57:54 +01:00
public void testGetSubtitlesList() throws IOException, ExtractionException {
// Video (/view?v=YQHsXMglC9A) set in the setUp() method has no captions => null
assertTrue(extractor.getSubtitlesDefault().isEmpty());
}
2017-08-08 08:42:28 +02:00
}