2017-08-08 08:42:28 +02:00
|
|
|
package org.schabi.newpipe.extractor.services.soundcloud;
|
|
|
|
|
2017-12-07 02:09:46 +01:00
|
|
|
import org.junit.BeforeClass;
|
2017-08-08 08:42:28 +02:00
|
|
|
import org.junit.Test;
|
|
|
|
import org.schabi.newpipe.Downloader;
|
2017-08-12 22:19:56 +02:00
|
|
|
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
|
|
|
|
2017-08-08 17:01:50 +02:00
|
|
|
import static org.junit.Assert.*;
|
2018-01-04 17:21:03 +01:00
|
|
|
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl;
|
2017-08-08 17:01:50 +02:00
|
|
|
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
|
|
|
|
2017-12-07 02:09:46 +01:00
|
|
|
static ChannelExtractor extractor;
|
2017-08-08 08:42:28 +02:00
|
|
|
|
2017-12-07 02:09:46 +01:00
|
|
|
@BeforeClass
|
|
|
|
public static void setUp() throws Exception {
|
2017-08-08 08:42:28 +02:00
|
|
|
NewPipe.init(Downloader.getInstance());
|
2018-02-10 03:46:05 +01:00
|
|
|
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
|
2017-08-08 17:01:50 +02:00
|
|
|
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 {
|
2017-09-08 15:43:40 +02:00
|
|
|
assertEquals("LIL UZI VERT", extractor.getName());
|
2017-08-08 08:42:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testGetDescription() throws Exception {
|
2017-09-08 15:43:40 +02:00
|
|
|
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 {
|
2017-08-10 19:50:59 +02:00
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
}
|