remove soundcloud and make first search test work
This commit is contained in:
@@ -6,7 +6,6 @@ import java.util.HashSet;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.schabi.newpipe.extractor.NewPipe.getServiceByUrl;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
||||
|
||||
public class NewPipeTest {
|
||||
@@ -28,17 +27,11 @@ public class NewPipeTest {
|
||||
@Test
|
||||
public void getServiceWithId() throws Exception {
|
||||
assertEquals(NewPipe.getService(YouTube.getServiceId()), YouTube);
|
||||
assertEquals(NewPipe.getService(SoundCloud.getServiceId()), SoundCloud);
|
||||
|
||||
assertNotEquals(NewPipe.getService(SoundCloud.getServiceId()), YouTube);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getServiceWithName() throws Exception {
|
||||
assertEquals(NewPipe.getService(YouTube.getServiceInfo().getName()), YouTube);
|
||||
assertEquals(NewPipe.getService(SoundCloud.getServiceInfo().getName()), SoundCloud);
|
||||
|
||||
assertNotEquals(NewPipe.getService(YouTube.getServiceInfo().getName()), SoundCloud);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -46,27 +39,17 @@ public class NewPipeTest {
|
||||
assertEquals(getServiceByUrl("https://www.youtube.com/watch?v=_r6CgaFNAGg"), YouTube);
|
||||
assertEquals(getServiceByUrl("https://www.youtube.com/channel/UCi2bIyFtz-JdI-ou8kaqsqg"), YouTube);
|
||||
assertEquals(getServiceByUrl("https://www.youtube.com/playlist?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH"), YouTube);
|
||||
assertEquals(getServiceByUrl("https://soundcloud.com/shupemoosic/pegboard-nerds-try-this"), SoundCloud);
|
||||
assertEquals(getServiceByUrl("https://soundcloud.com/deluxe314/sets/pegboard-nerds"), SoundCloud);
|
||||
assertEquals(getServiceByUrl("https://soundcloud.com/pegboardnerds"), SoundCloud);
|
||||
|
||||
assertNotEquals(getServiceByUrl("https://soundcloud.com/pegboardnerds"), YouTube);
|
||||
assertNotEquals(getServiceByUrl("https://www.youtube.com/playlist?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH"), SoundCloud);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getIdWithServiceName() throws Exception {
|
||||
assertEquals(NewPipe.getIdOfService(YouTube.getServiceInfo().getName()), YouTube.getServiceId());
|
||||
assertEquals(NewPipe.getIdOfService(SoundCloud.getServiceInfo().getName()), SoundCloud.getServiceId());
|
||||
|
||||
assertNotEquals(NewPipe.getIdOfService(SoundCloud.getServiceInfo().getName()), YouTube.getServiceId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getServiceNameWithId() throws Exception {
|
||||
assertEquals(NewPipe.getNameOfService(YouTube.getServiceId()), YouTube.getServiceInfo().getName());
|
||||
assertEquals(NewPipe.getNameOfService(SoundCloud.getServiceId()), SoundCloud.getServiceInfo().getName());
|
||||
|
||||
assertNotEquals(NewPipe.getNameOfService(YouTube.getServiceId()), SoundCloud.getServiceInfo().getName());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
package org.schabi.newpipe.extractor.services.soundcloud;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.extractor.InfoItem;
|
||||
import org.schabi.newpipe.extractor.channel.ChannelInfoItem;
|
||||
import org.schabi.newpipe.extractor.playlist.PlaylistInfoItem;
|
||||
import org.schabi.newpipe.extractor.search.SearchResult;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
||||
import org.schabi.newpipe.extractor.stream.StreamType;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl;
|
||||
|
||||
public abstract class BaseSoundcloudSearchTest {
|
||||
|
||||
protected static SearchResult result;
|
||||
|
||||
@Test
|
||||
public void testResultList() {
|
||||
assertFalse("Got empty result list", result.resultList.isEmpty());
|
||||
for(InfoItem infoItem: result.resultList) {
|
||||
assertIsSecureUrl(infoItem.getUrl());
|
||||
assertIsSecureUrl(infoItem.getThumbnailUrl());
|
||||
assertFalse(infoItem.getName().isEmpty());
|
||||
assertFalse("Name is probably a URI: " + infoItem.getName(),
|
||||
infoItem.getName().contains("://"));
|
||||
if(infoItem instanceof StreamInfoItem) {
|
||||
// test stream item
|
||||
StreamInfoItem streamInfoItem = (StreamInfoItem) infoItem;
|
||||
assertIsSecureUrl(streamInfoItem.getUploaderUrl());
|
||||
assertFalse(streamInfoItem.getUploadDate().isEmpty());
|
||||
assertFalse(streamInfoItem.getUploaderName().isEmpty());
|
||||
assertEquals(StreamType.AUDIO_STREAM, streamInfoItem.getStreamType());
|
||||
} else if(infoItem instanceof ChannelInfoItem) {
|
||||
// Nothing special to check?
|
||||
} else if(infoItem instanceof PlaylistInfoItem) {
|
||||
// test playlist item
|
||||
assertTrue(infoItem.getUrl().contains("/sets/"));
|
||||
long streamCount = ((PlaylistInfoItem) infoItem).getStreamCount();
|
||||
assertTrue(streamCount > 0);
|
||||
} else {
|
||||
fail("Unknown infoItem type: " + infoItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testResultErrors() {
|
||||
assertNotNull(result.errors);
|
||||
if (!result.errors.isEmpty()) {
|
||||
for (Throwable error : result.errors) {
|
||||
error.printStackTrace();
|
||||
}
|
||||
}
|
||||
assertTrue(result.errors.isEmpty());
|
||||
}
|
||||
}
|
||||
@@ -1,198 +0,0 @@
|
||||
package org.schabi.newpipe.extractor.services.soundcloud;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.services.BaseChannelExtractorTest;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertEmpty;
|
||||
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
|
||||
import static org.schabi.newpipe.extractor.services.DefaultTests.*;
|
||||
|
||||
/**
|
||||
* Test for {@link SoundcloudChannelExtractor}
|
||||
*/
|
||||
public class SoundcloudChannelExtractorTest {
|
||||
public static class LilUzi implements BaseChannelExtractorTest {
|
||||
private static SoundcloudChannelExtractor extractor;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
extractor = (SoundcloudChannelExtractor) SoundCloud
|
||||
.getChannelExtractor("http://soundcloud.com/liluzivert/sets");
|
||||
extractor.fetchPage();
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
// Extractor
|
||||
//////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
@Test
|
||||
public void testServiceId() {
|
||||
assertEquals(SoundCloud.getServiceId(), extractor.getServiceId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testName() {
|
||||
assertEquals("LIL UZI VERT", extractor.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testId() {
|
||||
assertEquals("10494998", extractor.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUrl() throws ParsingException {
|
||||
assertEquals("https://soundcloud.com/liluzivert", extractor.getUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOriginalUrl() throws ParsingException {
|
||||
assertEquals("http://soundcloud.com/liluzivert/sets", extractor.getOriginalUrl());
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
// ListExtractor
|
||||
//////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
@Test
|
||||
public void testRelatedItems() throws Exception {
|
||||
defaultTestRelatedItems(extractor, SoundCloud.getServiceId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMoreRelatedItems() throws Exception {
|
||||
defaultTestMoreItems(extractor, SoundCloud.getServiceId());
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
// ChannelExtractor
|
||||
//////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
@Test
|
||||
public void testDescription() {
|
||||
assertNotNull(extractor.getDescription());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAvatarUrl() {
|
||||
assertIsSecureUrl(extractor.getAvatarUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBannerUrl() {
|
||||
assertIsSecureUrl(extractor.getBannerUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFeedUrl() {
|
||||
assertEmpty(extractor.getFeedUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSubscriberCount() {
|
||||
assertTrue("Wrong subscriber count", extractor.getSubscriberCount() >= 1e6);
|
||||
}
|
||||
}
|
||||
|
||||
public static class DubMatix implements BaseChannelExtractorTest {
|
||||
private static SoundcloudChannelExtractor extractor;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
extractor = (SoundcloudChannelExtractor) SoundCloud
|
||||
.getChannelExtractor("https://soundcloud.com/dubmatix");
|
||||
extractor.fetchPage();
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
// Additional Testing
|
||||
//////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
@Test
|
||||
public void testGetPageInNewExtractor() throws Exception {
|
||||
final ChannelExtractor newExtractor = SoundCloud.getChannelExtractor(extractor.getUrl());
|
||||
defaultTestGetPageInNewExtractor(extractor, newExtractor, SoundCloud.getServiceId());
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
// Extractor
|
||||
//////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
@Test
|
||||
public void testServiceId() {
|
||||
assertEquals(SoundCloud.getServiceId(), extractor.getServiceId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testName() {
|
||||
assertEquals("dubmatix", extractor.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testId() {
|
||||
assertEquals("542134", extractor.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUrl() throws ParsingException {
|
||||
assertEquals("https://soundcloud.com/dubmatix", extractor.getUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOriginalUrl() throws ParsingException {
|
||||
assertEquals("https://soundcloud.com/dubmatix", extractor.getOriginalUrl());
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
// ListExtractor
|
||||
//////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
@Test
|
||||
public void testRelatedItems() throws Exception {
|
||||
defaultTestRelatedItems(extractor, SoundCloud.getServiceId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMoreRelatedItems() throws Exception {
|
||||
defaultTestMoreItems(extractor, SoundCloud.getServiceId());
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
// ChannelExtractor
|
||||
//////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
@Test
|
||||
public void testDescription() {
|
||||
assertNotNull(extractor.getDescription());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAvatarUrl() {
|
||||
assertIsSecureUrl(extractor.getAvatarUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBannerUrl() {
|
||||
assertIsSecureUrl(extractor.getBannerUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFeedUrl() {
|
||||
assertEmpty(extractor.getFeedUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSubscriberCount() {
|
||||
assertTrue("Wrong subscriber count", extractor.getSubscriberCount() >= 2e6);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
package org.schabi.newpipe.extractor.services.soundcloud;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.extractor.ListExtractor;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.kiosk.KioskExtractor;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
|
||||
|
||||
/**
|
||||
* Test for {@link SoundcloudChartsUrlIdHandler}
|
||||
*/
|
||||
public class SoundcloudChartsExtractorTest {
|
||||
|
||||
static KioskExtractor extractor;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
extractor = SoundCloud
|
||||
.getKioskList()
|
||||
.getExtractorById("Top 50", null);
|
||||
extractor.fetchPage();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetDownloader() throws Exception {
|
||||
assertNotNull(NewPipe.getDownloader());
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void testGetName() throws Exception {
|
||||
assertEquals(extractor.getName(), "Top 50");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testId() {
|
||||
assertEquals(extractor.getId(), "Top 50");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetStreams() throws Exception {
|
||||
ListExtractor.InfoItemsPage<StreamInfoItem> page = extractor.getInitialPage();
|
||||
if(!page.getErrors().isEmpty()) {
|
||||
System.err.println("----------");
|
||||
List<Throwable> errors = page.getErrors();
|
||||
for(Throwable e: errors) {
|
||||
e.printStackTrace();
|
||||
System.err.println("----------");
|
||||
}
|
||||
}
|
||||
assertTrue("no streams are received",
|
||||
!page.getItems().isEmpty()
|
||||
&& page.getErrors().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetStreamsErrors() throws Exception {
|
||||
assertTrue("errors during stream list extraction", extractor.getInitialPage().getErrors().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHasMoreStreams() throws Exception {
|
||||
// Setup the streams
|
||||
extractor.getInitialPage();
|
||||
assertTrue("has more streams", extractor.hasNextPage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetNextPageUrl() throws Exception {
|
||||
assertTrue(extractor.hasNextPage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetNextPage() throws Exception {
|
||||
extractor.getInitialPage().getItems();
|
||||
assertFalse("extractor has next streams", extractor.getPage(extractor.getNextPageUrl()) == null
|
||||
|| extractor.getPage(extractor.getNextPageUrl()).getItems().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetCleanUrl() throws Exception {
|
||||
assertEquals(extractor.getUrl(), "https://soundcloud.com/charts/top");
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
package org.schabi.newpipe.extractor.services.soundcloud;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
|
||||
import static junit.framework.TestCase.assertFalse;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* Test for {@link SoundcloudChartsUrlIdHandler}
|
||||
*/
|
||||
public class SoundcloudChartsUrlIdHandlerTest {
|
||||
private static SoundcloudChartsUrlIdHandler urlIdHandler;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
urlIdHandler = new SoundcloudChartsUrlIdHandler();
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getUrl() throws Exception {
|
||||
assertEquals(urlIdHandler.setId("Top 50").getUrl(), "https://soundcloud.com/charts/top");
|
||||
assertEquals(urlIdHandler.setId("New & hot").getUrl(), "https://soundcloud.com/charts/new");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getId() throws ParsingException {
|
||||
assertEquals(urlIdHandler.setUrl("http://soundcloud.com/charts/top?genre=all-music").getId(), "Top 50");
|
||||
assertEquals(urlIdHandler.setUrl("HTTP://www.soundcloud.com/charts/new/?genre=all-music&country=all-countries").getId(), "New & hot");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void acceptUrl() throws ParsingException {
|
||||
assertTrue(urlIdHandler.acceptUrl("https://soundcloud.com/charts"));
|
||||
assertTrue(urlIdHandler.acceptUrl("https://soundcloud.com/charts/"));
|
||||
assertTrue(urlIdHandler.acceptUrl("https://www.soundcloud.com/charts/new"));
|
||||
assertTrue(urlIdHandler.acceptUrl("http://soundcloud.com/charts/top?genre=all-music"));
|
||||
assertTrue(urlIdHandler.acceptUrl("HTTP://www.soundcloud.com/charts/new/?genre=all-music&country=all-countries"));
|
||||
|
||||
assertFalse(urlIdHandler.acceptUrl("kdskjfiiejfia"));
|
||||
assertFalse(urlIdHandler.acceptUrl("soundcloud.com/charts askjkf"));
|
||||
assertFalse(urlIdHandler.acceptUrl(" soundcloud.com/charts"));
|
||||
assertFalse(urlIdHandler.acceptUrl(""));
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
package org.schabi.newpipe.extractor.services.soundcloud;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
|
||||
public class SoundcloudParsingHelperTest {
|
||||
@BeforeClass
|
||||
public static void setUp() {
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resolveUrlWithEmbedPlayerTest() throws Exception {
|
||||
Assert.assertEquals("https://soundcloud.com/trapcity", SoundcloudParsingHelper.resolveUrlWithEmbedPlayer("https://api.soundcloud.com/users/26057743"));
|
||||
Assert.assertEquals("https://soundcloud.com/nocopyrightsounds", SoundcloudParsingHelper.resolveUrlWithEmbedPlayer("https://api.soundcloud.com/users/16069159"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resolveIdWithEmbedPlayerTest() throws Exception {
|
||||
Assert.assertEquals("26057743", SoundcloudParsingHelper.resolveIdWithEmbedPlayer("https://soundcloud.com/trapcity"));
|
||||
Assert.assertEquals("16069159", SoundcloudParsingHelper.resolveIdWithEmbedPlayer("https://soundcloud.com/nocopyrightsounds"));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,319 +0,0 @@
|
||||
package org.schabi.newpipe.extractor.services.soundcloud;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.extractor.ListExtractor;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.ServiceList;
|
||||
import org.schabi.newpipe.extractor.playlist.PlaylistExtractor;
|
||||
import org.schabi.newpipe.extractor.services.BasePlaylistExtractorTest;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
|
||||
import static org.schabi.newpipe.extractor.services.DefaultTests.*;
|
||||
|
||||
/**
|
||||
* Test for {@link PlaylistExtractor}
|
||||
*/
|
||||
public class SoundcloudPlaylistExtractorTest {
|
||||
public static class LuvTape implements BasePlaylistExtractorTest {
|
||||
private static SoundcloudPlaylistExtractor extractor;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
extractor = (SoundcloudPlaylistExtractor) SoundCloud
|
||||
.getPlaylistExtractor("https://soundcloud.com/liluzivert/sets/the-perfect-luv-tape-r?test=123");
|
||||
extractor.fetchPage();
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
// Extractor
|
||||
//////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
@Test
|
||||
public void testServiceId() {
|
||||
assertEquals(SoundCloud.getServiceId(), extractor.getServiceId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testName() {
|
||||
assertEquals("THE PERFECT LUV TAPE®️", extractor.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testId() {
|
||||
assertEquals("246349810", extractor.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUrl() throws Exception {
|
||||
assertEquals("https://soundcloud.com/liluzivert/sets/the-perfect-luv-tape-r", extractor.getUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOriginalUrl() throws Exception {
|
||||
assertEquals("https://soundcloud.com/liluzivert/sets/the-perfect-luv-tape-r?test=123", extractor.getOriginalUrl());
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
// ListExtractor
|
||||
//////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
@Test
|
||||
public void testRelatedItems() throws Exception {
|
||||
defaultTestRelatedItems(extractor, SoundCloud.getServiceId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMoreRelatedItems() {
|
||||
try {
|
||||
defaultTestMoreItems(extractor, SoundCloud.getServiceId());
|
||||
} catch (Throwable ignored) {
|
||||
return;
|
||||
}
|
||||
|
||||
fail("This playlist doesn't have more items, it should throw an error");
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
// PlaylistExtractor
|
||||
//////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
@Test
|
||||
public void testThumbnailUrl() {
|
||||
assertIsSecureUrl(extractor.getThumbnailUrl());
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void testBannerUrl() {
|
||||
assertIsSecureUrl(extractor.getBannerUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUploaderUrl() {
|
||||
final String uploaderUrl = extractor.getUploaderUrl();
|
||||
assertIsSecureUrl(uploaderUrl);
|
||||
assertTrue(uploaderUrl, uploaderUrl.contains("liluzivert"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUploaderName() {
|
||||
assertTrue(extractor.getUploaderName().contains("LIL UZI VERT"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUploaderAvatarUrl() {
|
||||
assertIsSecureUrl(extractor.getUploaderAvatarUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStreamCount() {
|
||||
assertTrue("Error in the streams count", extractor.getStreamCount() >= 10);
|
||||
}
|
||||
}
|
||||
|
||||
public static class RandomHouseDanceMusic implements BasePlaylistExtractorTest {
|
||||
private static SoundcloudPlaylistExtractor extractor;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
extractor = (SoundcloudPlaylistExtractor) SoundCloud
|
||||
.getPlaylistExtractor("https://soundcloud.com/hunter-leader/sets/house-electro-dance-music-2");
|
||||
extractor.fetchPage();
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
// Extractor
|
||||
//////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
@Test
|
||||
public void testServiceId() {
|
||||
assertEquals(SoundCloud.getServiceId(), extractor.getServiceId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testName() {
|
||||
assertEquals("House, Electro , Dance Music 2", extractor.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testId() {
|
||||
assertEquals("310980722", extractor.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUrl() throws Exception {
|
||||
assertEquals("https://soundcloud.com/hunter-leader/sets/house-electro-dance-music-2", extractor.getUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOriginalUrl() throws Exception {
|
||||
assertEquals("https://soundcloud.com/hunter-leader/sets/house-electro-dance-music-2", extractor.getOriginalUrl());
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
// ListExtractor
|
||||
//////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
@Test
|
||||
public void testRelatedItems() throws Exception {
|
||||
defaultTestRelatedItems(extractor, SoundCloud.getServiceId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMoreRelatedItems() throws Exception {
|
||||
defaultTestMoreItems(extractor, SoundCloud.getServiceId());
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
// PlaylistExtractor
|
||||
//////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
@Test
|
||||
public void testThumbnailUrl() {
|
||||
assertIsSecureUrl(extractor.getThumbnailUrl());
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void testBannerUrl() {
|
||||
assertIsSecureUrl(extractor.getBannerUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUploaderUrl() {
|
||||
final String uploaderUrl = extractor.getUploaderUrl();
|
||||
assertIsSecureUrl(uploaderUrl);
|
||||
assertTrue(uploaderUrl, uploaderUrl.contains("hunter-leader"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUploaderName() {
|
||||
assertEquals("Gosu", extractor.getUploaderName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUploaderAvatarUrl() {
|
||||
assertIsSecureUrl(extractor.getUploaderAvatarUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStreamCount() {
|
||||
assertTrue("Error in the streams count", extractor.getStreamCount() >= 10);
|
||||
}
|
||||
}
|
||||
|
||||
public static class EDMxxx implements BasePlaylistExtractorTest {
|
||||
private static SoundcloudPlaylistExtractor extractor;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
extractor = (SoundcloudPlaylistExtractor) SoundCloud
|
||||
.getPlaylistExtractor("https://soundcloud.com/user350509423/sets/edm-xxx");
|
||||
extractor.fetchPage();
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
// Additional Testing
|
||||
//////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
@Test
|
||||
public void testGetPageInNewExtractor() throws Exception {
|
||||
final PlaylistExtractor newExtractor = SoundCloud.getPlaylistExtractor(extractor.getUrl());
|
||||
defaultTestGetPageInNewExtractor(extractor, newExtractor, SoundCloud.getServiceId());
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
// Extractor
|
||||
//////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
@Test
|
||||
public void testServiceId() {
|
||||
assertEquals(SoundCloud.getServiceId(), extractor.getServiceId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testName() {
|
||||
assertEquals("EDM xXx", extractor.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testId() {
|
||||
assertEquals("136000376", extractor.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUrl() throws Exception {
|
||||
assertEquals("https://soundcloud.com/user350509423/sets/edm-xxx", extractor.getUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOriginalUrl() throws Exception {
|
||||
assertEquals("https://soundcloud.com/user350509423/sets/edm-xxx", extractor.getOriginalUrl());
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
// ListExtractor
|
||||
//////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
@Test
|
||||
public void testRelatedItems() throws Exception {
|
||||
defaultTestRelatedItems(extractor, SoundCloud.getServiceId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMoreRelatedItems() throws Exception {
|
||||
ListExtractor.InfoItemsPage<StreamInfoItem> currentPage = defaultTestMoreItems(extractor, ServiceList.SoundCloud.getServiceId());
|
||||
// Test for 2 more levels
|
||||
for (int i = 0; i < 2; i++) {
|
||||
currentPage = extractor.getPage(currentPage.getNextPageUrl());
|
||||
defaultTestListOfItems(SoundCloud.getServiceId(), currentPage.getItems(), currentPage.getErrors());
|
||||
}
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
// PlaylistExtractor
|
||||
//////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
@Test
|
||||
public void testThumbnailUrl() {
|
||||
assertIsSecureUrl(extractor.getThumbnailUrl());
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void testBannerUrl() {
|
||||
assertIsSecureUrl(extractor.getBannerUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUploaderUrl() {
|
||||
final String uploaderUrl = extractor.getUploaderUrl();
|
||||
assertIsSecureUrl(uploaderUrl);
|
||||
assertTrue(uploaderUrl, uploaderUrl.contains("user350509423"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUploaderName() {
|
||||
assertEquals("user350509423", extractor.getUploaderName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUploaderAvatarUrl() {
|
||||
assertIsSecureUrl(extractor.getUploaderAvatarUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStreamCount() {
|
||||
assertTrue("Error in the streams count", extractor.getStreamCount() >= 3900);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package org.schabi.newpipe.extractor.services.soundcloud;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.search.SearchEngine;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
|
||||
|
||||
/**
|
||||
* Test for {@link SearchEngine}
|
||||
*/
|
||||
public class SoundcloudSearchEngineAllTest extends BaseSoundcloudSearchTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
SearchEngine engine = SoundCloud.getSearchEngine();
|
||||
|
||||
// SoundCloud will suggest "lil uzi vert" instead of "lill uzi vert"
|
||||
// keep in mind that the suggestions can NOT change by country (the parameter "de")
|
||||
result = engine.search("lill uzi vert", 0, "de", SearchEngine.Filter.ANY)
|
||||
.getSearchResult();
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void testSuggestion() {
|
||||
//todo write a real test
|
||||
assertTrue(result.suggestion != null);
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
package org.schabi.newpipe.extractor.services.soundcloud;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.extractor.InfoItem;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.search.SearchEngine;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
|
||||
|
||||
/**
|
||||
* Test for {@link SearchEngine}
|
||||
*/
|
||||
public class SoundcloudSearchEngineChannelTest extends BaseSoundcloudSearchTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
SearchEngine engine = SoundCloud.getSearchEngine();
|
||||
|
||||
// SoundCloud will suggest "lil uzi vert" instead of "lill uzi vert"
|
||||
// keep in mind that the suggestions can NOT change by country (the parameter "de")
|
||||
result = engine.search("lill uzi vert", 0, "de", SearchEngine.Filter.CHANNEL)
|
||||
.getSearchResult();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testResultsItemType() {
|
||||
for (InfoItem infoItem : result.resultList) {
|
||||
assertEquals(InfoItem.InfoType.CHANNEL, infoItem.getInfoType());
|
||||
}
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void testSuggestion() {
|
||||
//todo write a real test
|
||||
assertTrue(result.suggestion != null);
|
||||
}
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
package org.schabi.newpipe.extractor.services.soundcloud;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.extractor.InfoItem;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.search.SearchEngine;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
|
||||
|
||||
|
||||
/*
|
||||
* Created by Christian Schabesberger on 29.12.15.
|
||||
*
|
||||
* Copyright (C) Christian Schabesberger 2015 <chris.schabesberger@mailbox.org>
|
||||
* YoutubeSearchEngineStreamTest.java is part of NewPipe.
|
||||
*
|
||||
* NewPipe is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* NewPipe is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Test for {@link SearchEngine}
|
||||
*/
|
||||
public class SoundcloudSearchEnginePlaylistTest extends BaseSoundcloudSearchTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
SearchEngine engine = SoundCloud.getSearchEngine();
|
||||
|
||||
// Search by country not yet implemented
|
||||
result = engine.search("parkmemme", 0, "", SearchEngine.Filter.PLAYLIST)
|
||||
.getSearchResult();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUserItemType() {
|
||||
for (InfoItem infoItem : result.resultList) {
|
||||
assertEquals(InfoItem.InfoType.PLAYLIST, infoItem.getInfoType());
|
||||
}
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void testSuggestion() {
|
||||
//todo write a real test
|
||||
assertTrue(result.suggestion != null);
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
package org.schabi.newpipe.extractor.services.soundcloud;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.extractor.InfoItem;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.search.SearchEngine;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
|
||||
|
||||
/**
|
||||
* Test for {@link SearchEngine}
|
||||
*/
|
||||
public class SoundcloudSearchEngineStreamTest extends BaseSoundcloudSearchTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
SearchEngine engine = SoundCloud.getSearchEngine();
|
||||
|
||||
// SoundCloud will suggest "lil uzi vert" instead of "lill uzi vert",
|
||||
// keep in mind that the suggestions can NOT change by country (the parameter "de")
|
||||
result = engine.search("lill uzi vert", 0, "de", SearchEngine.Filter.STREAM)
|
||||
.getSearchResult();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testResultsItemType() {
|
||||
for (InfoItem infoItem : result.resultList) {
|
||||
assertEquals(InfoItem.InfoType.STREAM, infoItem.getInfoType());
|
||||
}
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void testSuggestion() {
|
||||
//todo write a real test
|
||||
assertTrue(result.suggestion != null);
|
||||
}
|
||||
}
|
||||
@@ -1,119 +0,0 @@
|
||||
package org.schabi.newpipe.extractor.services.soundcloud;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
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;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector;
|
||||
import org.schabi.newpipe.extractor.stream.StreamType;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
|
||||
|
||||
/**
|
||||
* Test for {@link StreamExtractor}
|
||||
*/
|
||||
public class SoundcloudStreamExtractorDefaultTest {
|
||||
private static SoundcloudStreamExtractor extractor;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
extractor = (SoundcloudStreamExtractor) SoundCloud.getStreamExtractor("https://soundcloud.com/liluzivert/do-what-i-want-produced-by-maaly-raw-don-cannon");
|
||||
extractor.fetchPage();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetInvalidTimeStamp() throws ParsingException {
|
||||
assertTrue(extractor.getTimeStamp() + "",
|
||||
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(extractor.getTimeStamp() + "", "69");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetTitle() throws ParsingException {
|
||||
assertEquals(extractor.getName(), "Do What I Want [Produced By Maaly Raw + Don Cannon]");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetDescription() throws ParsingException {
|
||||
assertEquals(extractor.getDescription(), "The Perfect LUV Tape®️");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetUploaderName() throws ParsingException {
|
||||
assertEquals(extractor.getUploaderName(), "LIL UZI VERT");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetLength() throws ParsingException {
|
||||
assertEquals(extractor.getLength(), 175);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetViewCount() throws ParsingException {
|
||||
assertTrue(Long.toString(extractor.getViewCount()),
|
||||
extractor.getViewCount() > 44227978);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetUploadDate() throws ParsingException {
|
||||
assertEquals("2016-07-31", extractor.getUploadDate());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetUploaderUrl() throws ParsingException {
|
||||
assertIsSecureUrl(extractor.getUploaderUrl());
|
||||
assertEquals("https://soundcloud.com/liluzivert", extractor.getUploaderUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetThumbnailUrl() throws ParsingException {
|
||||
assertIsSecureUrl(extractor.getThumbnailUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetUploaderAvatarUrl() throws ParsingException {
|
||||
assertIsSecureUrl(extractor.getUploaderAvatarUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetAudioStreams() throws IOException, ExtractionException {
|
||||
assertFalse(extractor.getAudioStreams().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStreamType() throws ParsingException {
|
||||
assertTrue(extractor.getStreamType() == StreamType.AUDIO_STREAM);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetRelatedVideos() throws ExtractionException, IOException {
|
||||
StreamInfoItemsCollector relatedVideos = extractor.getRelatedVideos();
|
||||
assertFalse(relatedVideos.getItems().isEmpty());
|
||||
assertTrue(relatedVideos.getErrors().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetSubtitlesListDefault() throws IOException, ExtractionException {
|
||||
// Video (/view?v=YQHsXMglC9A) set in the setUp() method has no captions => null
|
||||
assertTrue(extractor.getSubtitlesDefault().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetSubtitlesList() throws IOException, ExtractionException {
|
||||
// Video (/view?v=YQHsXMglC9A) set in the setUp() method has no captions => null
|
||||
assertTrue(extractor.getSubtitlesDefault().isEmpty());
|
||||
}
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
package org.schabi.newpipe.extractor.services.soundcloud;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Test for {@link SoundcloudStreamUrlIdHandler}
|
||||
*/
|
||||
public class SoundcloudStreamUrlIdHandlerTest {
|
||||
private static SoundcloudStreamUrlIdHandler urlIdHandler;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
urlIdHandler = SoundcloudStreamUrlIdHandler.getInstance();
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void getIdWithNullAsUrl() throws ParsingException {
|
||||
urlIdHandler.setUrl(null).getId();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getIdForInvalidUrls() {
|
||||
List<String> invalidUrls = new ArrayList<>(50);
|
||||
invalidUrls.add("https://soundcloud.com/liluzivert/t.e.s.t");
|
||||
invalidUrls.add("https://soundcloud.com/liluzivert/tracks");
|
||||
invalidUrls.add("https://soundcloud.com/");
|
||||
for (String invalidUrl : invalidUrls) {
|
||||
Throwable exception = null;
|
||||
try {
|
||||
urlIdHandler.setUrl(invalidUrl).getId();
|
||||
} catch (ParsingException e) {
|
||||
exception = e;
|
||||
}
|
||||
if (exception == null) {
|
||||
fail("Expected ParsingException for url: " + invalidUrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getId() throws Exception {
|
||||
assertEquals("309689103", urlIdHandler.setUrl("https://soundcloud.com/liluzivert/15-ysl").getId());
|
||||
assertEquals("309689082", urlIdHandler.setUrl("https://www.soundcloud.com/liluzivert/15-luv-scars-ko").getId());
|
||||
assertEquals("309689035", urlIdHandler.setUrl("http://soundcloud.com/liluzivert/15-boring-shit").getId());
|
||||
assertEquals("294488599", urlIdHandler.setUrl("http://www.soundcloud.com/liluzivert/secure-the-bag-produced-by-glohan-beats").getId());
|
||||
assertEquals("294488438", urlIdHandler.setUrl("HtTpS://sOuNdClOuD.cOm/LiLuZiVeRt/In-O4-pRoDuCeD-bY-dP-bEaTz").getId());
|
||||
assertEquals("294488147", urlIdHandler.setUrl("https://soundcloud.com/liluzivert/fresh-produced-by-zaytoven#t=69").getId());
|
||||
assertEquals("294487876", urlIdHandler.setUrl("https://soundcloud.com/liluzivert/threesome-produced-by-zaytoven#t=1:09").getId());
|
||||
assertEquals("294487684", urlIdHandler.setUrl("https://soundcloud.com/liluzivert/blonde-brigitte-produced-manny-fresh#t=1:9").getId());
|
||||
assertEquals("294487428", urlIdHandler.setUrl("https://soundcloud.com/liluzivert/today-produced-by-c-note#t=1m9s").getId());
|
||||
assertEquals("294487157", urlIdHandler.setUrl("https://soundcloud.com/liluzivert/changed-my-phone-produced-by-c-note#t=1m09s").getId());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testAcceptUrl() throws ParsingException {
|
||||
assertTrue(urlIdHandler.acceptUrl("https://soundcloud.com/liluzivert/15-ysl"));
|
||||
assertTrue(urlIdHandler.acceptUrl("https://www.soundcloud.com/liluzivert/15-luv-scars-ko"));
|
||||
assertTrue(urlIdHandler.acceptUrl("http://soundcloud.com/liluzivert/15-boring-shit"));
|
||||
assertTrue(urlIdHandler.acceptUrl("http://www.soundcloud.com/liluzivert/secure-the-bag-produced-by-glohan-beats"));
|
||||
assertTrue(urlIdHandler.acceptUrl("HtTpS://sOuNdClOuD.cOm/LiLuZiVeRt/In-O4-pRoDuCeD-bY-dP-bEaTz"));
|
||||
assertTrue(urlIdHandler.acceptUrl("https://soundcloud.com/liluzivert/fresh-produced-by-zaytoven#t=69"));
|
||||
assertTrue(urlIdHandler.acceptUrl("https://soundcloud.com/liluzivert/threesome-produced-by-zaytoven#t=1:09"));
|
||||
assertTrue(urlIdHandler.acceptUrl("https://soundcloud.com/liluzivert/blonde-brigitte-produced-manny-fresh#t=1:9"));
|
||||
assertTrue(urlIdHandler.acceptUrl("https://soundcloud.com/liluzivert/today-produced-by-c-note#t=1m9s"));
|
||||
assertTrue(urlIdHandler.acceptUrl("https://soundcloud.com/liluzivert/changed-my-phone-produced-by-c-note#t=1m09s"));
|
||||
}
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
package org.schabi.newpipe.extractor.services.soundcloud;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.ServiceList;
|
||||
import org.schabi.newpipe.extractor.UrlIdHandler;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.subscription.SubscriptionExtractor;
|
||||
import org.schabi.newpipe.extractor.subscription.SubscriptionItem;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Test for {@link SoundcloudSubscriptionExtractor}
|
||||
*/
|
||||
public class SoundcloudSubscriptionExtractorTest {
|
||||
private static SoundcloudSubscriptionExtractor subscriptionExtractor;
|
||||
private static UrlIdHandler urlHandler;
|
||||
|
||||
@BeforeClass
|
||||
public static void setupClass() {
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
subscriptionExtractor = new SoundcloudSubscriptionExtractor(ServiceList.SoundCloud);
|
||||
urlHandler = ServiceList.SoundCloud.getChannelUrlIdHandler();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFromChannelUrl() throws Exception {
|
||||
testList(subscriptionExtractor.fromChannelUrl("https://soundcloud.com/monstercat"));
|
||||
testList(subscriptionExtractor.fromChannelUrl("http://soundcloud.com/monstercat"));
|
||||
testList(subscriptionExtractor.fromChannelUrl("soundcloud.com/monstercat"));
|
||||
testList(subscriptionExtractor.fromChannelUrl("monstercat"));
|
||||
|
||||
//Empty followings user
|
||||
testList(subscriptionExtractor.fromChannelUrl("some-random-user-184047028"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInvalidSourceException() {
|
||||
List<String> invalidList = Arrays.asList(
|
||||
"httttps://invalid.com/user",
|
||||
".com/monstercat",
|
||||
"ithinkthatthisuserdontexist",
|
||||
"",
|
||||
null
|
||||
);
|
||||
|
||||
for (String invalidUser : invalidList) {
|
||||
try {
|
||||
subscriptionExtractor.fromChannelUrl(invalidUser);
|
||||
|
||||
fail("didn't throw exception");
|
||||
} catch (IOException e) {
|
||||
// Ignore it, could be an unstable network on the CI server
|
||||
} catch (Exception e) {
|
||||
boolean isExpectedException = e instanceof SubscriptionExtractor.InvalidSourceException;
|
||||
assertTrue(e.getClass().getSimpleName() + " is not the expected exception", isExpectedException);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void testList(List<SubscriptionItem> subscriptionItems) throws ParsingException {
|
||||
for (SubscriptionItem item : subscriptionItems) {
|
||||
assertNotNull(item.getName());
|
||||
assertNotNull(item.getUrl());
|
||||
assertTrue(urlHandler.acceptUrl(item.getUrl()));
|
||||
assertFalse(item.getServiceId() == -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
package org.schabi.newpipe.extractor.services.soundcloud;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.SuggestionExtractor;
|
||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
|
||||
|
||||
/**
|
||||
* Test for {@link SuggestionExtractor}
|
||||
*/
|
||||
public class SoundcloudSuggestionExtractorTest {
|
||||
private static SuggestionExtractor suggestionExtractor;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
suggestionExtractor = SoundCloud.getSuggestionExtractor();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIfSuggestions() throws IOException, ExtractionException {
|
||||
assertFalse(suggestionExtractor.suggestionList("lil uzi vert", "de").isEmpty());
|
||||
}
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
package org.schabi.newpipe.extractor.services.youtube;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.extractor.InfoItem;
|
||||
import org.schabi.newpipe.extractor.channel.ChannelInfoItem;
|
||||
import org.schabi.newpipe.extractor.playlist.PlaylistInfoItem;
|
||||
import org.schabi.newpipe.extractor.search.SearchResult;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl;
|
||||
|
||||
public abstract class BaseYoutubeSearchTest {
|
||||
|
||||
protected static SearchResult result;
|
||||
|
||||
@Test
|
||||
public void testResultList() {
|
||||
assertFalse("Got empty result list", result.resultList.isEmpty());
|
||||
for(InfoItem infoItem: result.resultList) {
|
||||
assertIsSecureUrl(infoItem.getUrl());
|
||||
assertIsSecureUrl(infoItem.getThumbnailUrl());
|
||||
assertFalse(infoItem.getName().isEmpty());
|
||||
assertFalse("Name is probably a URI: " + infoItem.getName(),
|
||||
infoItem.getName().contains("://"));
|
||||
if(infoItem instanceof StreamInfoItem) {
|
||||
// test stream item
|
||||
StreamInfoItem streamInfoItem = (StreamInfoItem) infoItem;
|
||||
assertIsSecureUrl(streamInfoItem.getUploaderUrl());
|
||||
assertFalse(streamInfoItem.getUploadDate().isEmpty());
|
||||
assertFalse(streamInfoItem.getUploaderName().isEmpty());
|
||||
} else if(infoItem instanceof ChannelInfoItem) {
|
||||
// Nothing special to check?
|
||||
} else if(infoItem instanceof PlaylistInfoItem) {
|
||||
// test playlist item
|
||||
long streamCount = ((PlaylistInfoItem) infoItem).getStreamCount();
|
||||
assertTrue(streamCount > 0);
|
||||
} else {
|
||||
fail("Unknown infoItem type: " + infoItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testResultErrors() {
|
||||
assertNotNull(result.errors);
|
||||
if (!result.errors.isEmpty()) {
|
||||
for (Throwable error : result.errors) {
|
||||
error.printStackTrace();
|
||||
}
|
||||
}
|
||||
assertTrue(result.errors.isEmpty());
|
||||
}
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
package org.schabi.newpipe.extractor.services.youtube;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.extractor.InfoItem;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.search.SearchEngine;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
||||
|
||||
|
||||
/*
|
||||
* Created by Christian Schabesberger on 29.12.15.
|
||||
*
|
||||
* Copyright (C) Christian Schabesberger 2015 <chris.schabesberger@mailbox.org>
|
||||
* YoutubeSearchEngineStreamTest.java is part of NewPipe.
|
||||
*
|
||||
* NewPipe is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* NewPipe is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Test for {@link SearchEngine}
|
||||
*/
|
||||
public class YoutubeSearchEngineChannelTest extends BaseYoutubeSearchTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
SearchEngine engine = YouTube.getSearchEngine();
|
||||
|
||||
// Youtube will suggest "gronkh" instead of "grrunkh"
|
||||
// keep in mind that the suggestions can change by country (the parameter "de")
|
||||
result = engine.search("grrunkh", 0, "de", SearchEngine.Filter.CHANNEL)
|
||||
.getSearchResult();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testResultsItemType() {
|
||||
for (InfoItem infoItem : result.resultList) {
|
||||
assertEquals(InfoItem.InfoType.CHANNEL, infoItem.getInfoType());
|
||||
}
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void testSuggestion() {
|
||||
//todo write a real test
|
||||
assertTrue(result.suggestion != null);
|
||||
}
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
package org.schabi.newpipe.extractor.services.youtube;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.extractor.InfoItem;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.playlist.PlaylistInfoItem;
|
||||
import org.schabi.newpipe.extractor.search.SearchEngine;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
||||
|
||||
|
||||
/*
|
||||
* Created by Christian Schabesberger on 29.12.15.
|
||||
*
|
||||
* Copyright (C) Christian Schabesberger 2015 <chris.schabesberger@mailbox.org>
|
||||
* YoutubeSearchEngineStreamTest.java is part of NewPipe.
|
||||
*
|
||||
* NewPipe is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* NewPipe is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Test for {@link SearchEngine}
|
||||
*/
|
||||
public class YoutubeSearchEnginePlaylistTest extends BaseYoutubeSearchTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
SearchEngine engine = YouTube.getSearchEngine();
|
||||
|
||||
// Youtube will suggest "gronkh" instead of "grrunkh"
|
||||
// keep in mind that the suggestions can change by country (the parameter "de")
|
||||
result = engine.search("grrunkh", 0, "de", SearchEngine.Filter.PLAYLIST)
|
||||
.getSearchResult();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInfoItemType() {
|
||||
for (InfoItem infoItem : result.resultList) {
|
||||
assertTrue(infoItem instanceof PlaylistInfoItem);
|
||||
assertEquals(InfoItem.InfoType.PLAYLIST, infoItem.getInfoType());
|
||||
}
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void testSuggestion() {
|
||||
//todo write a real test
|
||||
assertTrue(result.suggestion != null);
|
||||
}
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
package org.schabi.newpipe.extractor.services.youtube;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.extractor.InfoItem;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.search.SearchEngine;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
||||
|
||||
|
||||
/*
|
||||
* Created by Christian Schabesberger on 29.12.15.
|
||||
*
|
||||
* Copyright (C) Christian Schabesberger 2015 <chris.schabesberger@mailbox.org>
|
||||
* YoutubeSearchEngineStreamTest.java is part of NewPipe.
|
||||
*
|
||||
* NewPipe is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* NewPipe is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Test for {@link SearchEngine}
|
||||
*/
|
||||
public class YoutubeSearchEngineStreamTest extends BaseYoutubeSearchTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
SearchEngine engine = YouTube.getSearchEngine();
|
||||
|
||||
// Youtube will suggest "results" instead of "rsults",
|
||||
// keep in mind that the suggestions can change by country (the parameter "de")
|
||||
result = engine.search("abc", 0, "de", SearchEngine.Filter.STREAM)
|
||||
.getSearchResult();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testResultsItemType() {
|
||||
for (InfoItem infoItem : result.resultList) {
|
||||
assertEquals(InfoItem.InfoType.STREAM, infoItem.getInfoType());
|
||||
}
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void testSuggestion() {
|
||||
//todo write a real test
|
||||
assertTrue(result.suggestion != null);
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ package org.schabi.newpipe.extractor.services.youtube;
|
||||
* Created by Christian Schabesberger on 29.12.15.
|
||||
*
|
||||
* Copyright (C) Christian Schabesberger 2015 <chris.schabesberger@mailbox.org>
|
||||
* YoutubeSearchEngineStreamTest.java is part of NewPipe.
|
||||
* YoutubeSearchExtractorStreamTest.java is part of NewPipe.
|
||||
*
|
||||
* NewPipe is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,23 +1,25 @@
|
||||
package org.schabi.newpipe.extractor.services.youtube;
|
||||
package org.schabi.newpipe.extractor.services.youtube.search;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.extractor.InfoItem;
|
||||
import org.schabi.newpipe.extractor.ListExtractor;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.channel.ChannelInfoItem;
|
||||
import org.schabi.newpipe.extractor.search.SearchEngine;
|
||||
import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeSearchEngine;
|
||||
import org.schabi.newpipe.extractor.search.SearchExtractor;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
||||
|
||||
/*
|
||||
* Created by Christian Schabesberger on 29.12.15.
|
||||
*
|
||||
* Copyright (C) Christian Schabesberger 2015 <chris.schabesberger@mailbox.org>
|
||||
* YoutubeSearchEngineStreamTest.java is part of NewPipe.
|
||||
* YoutubeSearchExtractorStreamTest.java is part of NewPipe.
|
||||
*
|
||||
* NewPipe is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -36,20 +38,22 @@ import static org.junit.Assert.assertTrue;
|
||||
/**
|
||||
* Test for {@link SearchEngine}
|
||||
*/
|
||||
public class YoutubeSearchEngineAllTest extends BaseYoutubeSearchTest {
|
||||
public class YoutubeSearchExtractorAllTest {
|
||||
|
||||
private static SearchExtractor extractor;
|
||||
private static ListExtractor.InfoItemsPage<InfoItem> itemsPage;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUpClass() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
YoutubeSearchEngine engine = new YoutubeSearchEngine(1);
|
||||
|
||||
result = engine.search("pewdiepie", 0, "de", SearchEngine.Filter.ANY)
|
||||
.getSearchResult();
|
||||
extractor = YouTube.getSearchExtractor("pewdiepie", "de");
|
||||
extractor.fetchPage();
|
||||
itemsPage = extractor.getInitialPage();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testResultList_FirstElement() {
|
||||
InfoItem firstInfoItem = result.getResults().get(0);
|
||||
InfoItem firstInfoItem = itemsPage.getItems().get(0);
|
||||
|
||||
// THe channel should be the first item
|
||||
assertTrue(firstInfoItem instanceof ChannelInfoItem);
|
||||
@@ -59,8 +63,8 @@ public class YoutubeSearchEngineAllTest extends BaseYoutubeSearchTest {
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void testSuggestion() {
|
||||
public void testSuggestion() throws Exception {
|
||||
//todo write a real test
|
||||
assertTrue(result.getSuggestion() != null);
|
||||
assertTrue(extractor.getSearchSuggestion() != null);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user