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

89 lines
2.8 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.ListExtractor;
2017-08-08 08:42:28 +02:00
import org.schabi.newpipe.extractor.NewPipe;
2017-08-11 03:23:09 +02:00
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
2018-03-01 01:02:43 +01:00
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
2017-08-08 08:42:28 +02:00
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
/**
2017-08-11 03:23:09 +02:00
* Test for {@link ChannelExtractor}
2017-08-08 08:42:28 +02:00
*/
2017-08-11 03:23:09 +02:00
public class SoundcloudChannelExtractorTest {
2017-08-08 08:42:28 +02:00
static ChannelExtractor extractor;
2017-08-08 08:42:28 +02:00
@BeforeClass
public static void setUp() throws Exception {
2017-08-08 08:42:28 +02:00
NewPipe.init(Downloader.getInstance());
extractor = SoundCloud
2017-08-11 03:23:09 +02:00
.getChannelExtractor("https://soundcloud.com/liluzivert");
2017-12-29 14:40:42 +01:00
extractor.fetchPage();
2017-08-08 08:42:28 +02:00
}
@Test
public void testGetDownloader() throws Exception {
2017-08-08 08:42:28 +02:00
assertNotNull(NewPipe.getDownloader());
}
@Test
2017-08-11 03:23:09 +02:00
public void testGetName() throws Exception {
assertEquals("LIL UZI VERT", extractor.getName());
2017-08-08 08:42:28 +02:00
}
@Test
public void testGetDescription() throws Exception {
assertTrue(extractor.getDescription() != null);
2017-08-08 08:42:28 +02:00
}
@Test
public void testGetAvatarUrl() throws Exception {
2018-01-04 17:21:03 +01:00
assertIsSecureUrl(extractor.getAvatarUrl());
2017-08-08 08:42:28 +02:00
}
@Test
public void testGetStreams() throws Exception {
2018-03-01 01:02:43 +01:00
assertFalse("no streams are received", extractor.getInfoItems().getItemList().isEmpty());
2017-08-08 08:42:28 +02:00
}
@Test
public void testGetStreamsErrors() throws Exception {
2018-03-01 01:02:43 +01:00
assertTrue("errors during stream list extraction", extractor.getInfoItems().getErrors().isEmpty());
2017-08-08 08:42:28 +02:00
}
@Test
public void testHasMoreStreams() throws Exception {
// Setup the streams
2018-03-01 01:02:43 +01:00
extractor.getInfoItems();
2018-02-24 22:20:50 +01:00
assertTrue("don't have more streams", extractor.hasNextPage());
2017-08-08 08:42:28 +02:00
}
@Test
public void testGetSubscriberCount() throws Exception {
assertTrue("wrong subscriber count", extractor.getSubscriberCount() >= 1000000);
2017-08-08 08:42:28 +02:00
}
@Test
2018-02-26 16:49:15 +01:00
public void testGetNextPageUrl() throws Exception {
assertTrue(extractor.hasNextPage());
}
@Test
public void testGetPage() throws Exception {
2017-08-08 08:42:28 +02:00
// Setup the streams
2018-03-01 01:02:43 +01:00
extractor.getInfoItems();
ListExtractor.InfoItemPage<StreamInfoItem> nextItemsResult = extractor.getPage(extractor.getNextPageUrl());
assertTrue("extractor didn't have next streams", !nextItemsResult.getItemsList().isEmpty());
assertTrue("errors occurred during extraction of the next streams", nextItemsResult.getErrors().isEmpty());
2018-02-24 22:20:50 +01:00
assertTrue("extractor didn't have more streams after getInfoItemPage", extractor.hasNextPage());
2017-08-08 08:42:28 +02:00
}
}