rename UrlIdHandler to UIHFactory
This commit is contained in:
@@ -15,7 +15,7 @@ import static org.junit.Assert.*;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
|
||||
|
||||
/**
|
||||
* Test for {@link SoundcloudChartsUrlIdHandler}
|
||||
* Test for {@link SoundcloudChartsUIHFactory}
|
||||
*/
|
||||
public class SoundcloudChartsExtractorTest {
|
||||
|
||||
|
||||
@@ -11,14 +11,14 @@ import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* Test for {@link SoundcloudChartsUrlIdHandler}
|
||||
* Test for {@link SoundcloudChartsUIHFactory}
|
||||
*/
|
||||
public class SoundcloudChartsUrlIdHandlerTest {
|
||||
private static SoundcloudChartsUrlIdHandler urlIdHandler;
|
||||
public class SoundcloudChartsUIHFactoryTest {
|
||||
private static SoundcloudChartsUIHFactory urlIdHandler;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
urlIdHandler = new SoundcloudChartsUrlIdHandler();
|
||||
urlIdHandler = new SoundcloudChartsUIHFactory();
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
}
|
||||
|
||||
@@ -12,14 +12,14 @@ import java.util.List;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Test for {@link SoundcloudStreamUrlIdHandler}
|
||||
* Test for {@link SoundcloudStreamUIHFactory}
|
||||
*/
|
||||
public class SoundcloudStreamUrlIdHandlerTest {
|
||||
private static SoundcloudStreamUrlIdHandler urlIdHandler;
|
||||
public class SoundcloudStreamUIHFactoryTest {
|
||||
private static SoundcloudStreamUIHFactory urlIdHandler;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
urlIdHandler = SoundcloudStreamUrlIdHandler.getInstance();
|
||||
urlIdHandler = SoundcloudStreamUIHFactory.getInstance();
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ 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.UIHFactory;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.subscription.SubscriptionExtractor;
|
||||
import org.schabi.newpipe.extractor.subscription.SubscriptionItem;
|
||||
@@ -21,13 +21,13 @@ import static org.junit.Assert.*;
|
||||
*/
|
||||
public class SoundcloudSubscriptionExtractorTest {
|
||||
private static SoundcloudSubscriptionExtractor subscriptionExtractor;
|
||||
private static UrlIdHandler urlHandler;
|
||||
private static UIHFactory urlHandler;
|
||||
|
||||
@BeforeClass
|
||||
public static void setupClass() {
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
subscriptionExtractor = new SoundcloudSubscriptionExtractor(ServiceList.SoundCloud);
|
||||
urlHandler = ServiceList.SoundCloud.getChannelUrlIdHandler();
|
||||
urlHandler = ServiceList.SoundCloud.getChannelUIHFactory();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -4,7 +4,6 @@ import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.services.soundcloud.SoundcloudSearchExtractor;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
@@ -19,36 +18,36 @@ public class SoundcloudSearchQUHTest {
|
||||
|
||||
@Test
|
||||
public void testRegularValues() throws Exception {
|
||||
assertEquals("https://api-v2.soundcloud.com/search?q=asdf&client_id=rc0HfXXgVnLSGEuQMs1F8xxuAR2AL431&limit=10&offset=0", SoundCloud.getSearchQueryHandler().setQuery("asdf").getUrl());
|
||||
assertEquals("https://api-v2.soundcloud.com/search?q=hans&client_id=rc0HfXXgVnLSGEuQMs1F8xxuAR2AL431&limit=10&offset=0",SoundCloud.getSearchQueryHandler().setQuery("hans").getUrl());
|
||||
assertEquals("https://api-v2.soundcloud.com/search?q=Poifj%26jaijf&client_id=rc0HfXXgVnLSGEuQMs1F8xxuAR2AL431&limit=10&offset=0", SoundCloud.getSearchQueryHandler().setQuery("Poifj&jaijf").getUrl());
|
||||
assertEquals("https://api-v2.soundcloud.com/search?q=G%C3%BCl%C3%BCm&client_id=rc0HfXXgVnLSGEuQMs1F8xxuAR2AL431&limit=10&offset=0", SoundCloud.getSearchQueryHandler().setQuery("Gülüm").getUrl());
|
||||
assertEquals("https://api-v2.soundcloud.com/search?q=%3Fj%24%29H%C2%A7B&client_id=rc0HfXXgVnLSGEuQMs1F8xxuAR2AL431&limit=10&offset=0", SoundCloud.getSearchQueryHandler().setQuery("?j$)H§B").getUrl());
|
||||
assertEquals("https://api-v2.soundcloud.com/search?q=asdf&client_id=rc0HfXXgVnLSGEuQMs1F8xxuAR2AL431&limit=10&offset=0", SoundCloud.getSearchQIHFactory().setQuery("asdf").getUrl());
|
||||
assertEquals("https://api-v2.soundcloud.com/search?q=hans&client_id=rc0HfXXgVnLSGEuQMs1F8xxuAR2AL431&limit=10&offset=0",SoundCloud.getSearchQIHFactory().setQuery("hans").getUrl());
|
||||
assertEquals("https://api-v2.soundcloud.com/search?q=Poifj%26jaijf&client_id=rc0HfXXgVnLSGEuQMs1F8xxuAR2AL431&limit=10&offset=0", SoundCloud.getSearchQIHFactory().setQuery("Poifj&jaijf").getUrl());
|
||||
assertEquals("https://api-v2.soundcloud.com/search?q=G%C3%BCl%C3%BCm&client_id=rc0HfXXgVnLSGEuQMs1F8xxuAR2AL431&limit=10&offset=0", SoundCloud.getSearchQIHFactory().setQuery("Gülüm").getUrl());
|
||||
assertEquals("https://api-v2.soundcloud.com/search?q=%3Fj%24%29H%C2%A7B&client_id=rc0HfXXgVnLSGEuQMs1F8xxuAR2AL431&limit=10&offset=0", SoundCloud.getSearchQIHFactory().setQuery("?j$)H§B").getUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetContentFilter() throws Exception {
|
||||
assertEquals("tracks", SoundCloud.getSearchQueryHandler()
|
||||
assertEquals("tracks", SoundCloud.getSearchQIHFactory()
|
||||
.setQuery("", asList(new String[]{"tracks"}), "").getContentFilter().get(0));
|
||||
assertEquals("users", SoundCloud.getSearchQueryHandler()
|
||||
assertEquals("users", SoundCloud.getSearchQIHFactory()
|
||||
.setQuery("asdf", asList(new String[]{"users"}), "").getContentFilter().get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithContentfilter() throws Exception {
|
||||
assertEquals("https://api-v2.soundcloud.com/search/tracks?q=asdf&client_id=rc0HfXXgVnLSGEuQMs1F8xxuAR2AL431&limit=10&offset=0", SoundCloud.getSearchQueryHandler()
|
||||
assertEquals("https://api-v2.soundcloud.com/search/tracks?q=asdf&client_id=rc0HfXXgVnLSGEuQMs1F8xxuAR2AL431&limit=10&offset=0", SoundCloud.getSearchQIHFactory()
|
||||
.setQuery("asdf", asList(new String[]{"tracks"}), "").getUrl());
|
||||
assertEquals("https://api-v2.soundcloud.com/search/users?q=asdf&client_id=rc0HfXXgVnLSGEuQMs1F8xxuAR2AL431&limit=10&offset=0", SoundCloud.getSearchQueryHandler()
|
||||
assertEquals("https://api-v2.soundcloud.com/search/users?q=asdf&client_id=rc0HfXXgVnLSGEuQMs1F8xxuAR2AL431&limit=10&offset=0", SoundCloud.getSearchQIHFactory()
|
||||
.setQuery("asdf", asList(new String[]{"users"}), "").getUrl());
|
||||
assertEquals("https://api-v2.soundcloud.com/search/playlists?q=asdf&client_id=rc0HfXXgVnLSGEuQMs1F8xxuAR2AL431&limit=10&offset=0", SoundCloud.getSearchQueryHandler()
|
||||
assertEquals("https://api-v2.soundcloud.com/search/playlists?q=asdf&client_id=rc0HfXXgVnLSGEuQMs1F8xxuAR2AL431&limit=10&offset=0", SoundCloud.getSearchQIHFactory()
|
||||
.setQuery("asdf", asList(new String[]{"playlist"}), "").getUrl());
|
||||
assertEquals("https://api-v2.soundcloud.com/search?q=asdf&client_id=rc0HfXXgVnLSGEuQMs1F8xxuAR2AL431&limit=10&offset=0", SoundCloud.getSearchQueryHandler()
|
||||
assertEquals("https://api-v2.soundcloud.com/search?q=asdf&client_id=rc0HfXXgVnLSGEuQMs1F8xxuAR2AL431&limit=10&offset=0", SoundCloud.getSearchQIHFactory()
|
||||
.setQuery("asdf", asList(new String[]{"fjiijie"}), "").getUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetAvailableContentFilter() {
|
||||
final String[] contentFilter = SoundCloud.getSearchQueryHandler().getAvailableContentFilter();
|
||||
final String[] contentFilter = SoundCloud.getSearchQIHFactory().getAvailableContentFilter();
|
||||
assertEquals(4, contentFilter.length);
|
||||
assertEquals("tracks", contentFilter[0]);
|
||||
assertEquals("users", contentFilter[1]);
|
||||
@@ -58,7 +57,7 @@ public class SoundcloudSearchQUHTest {
|
||||
|
||||
@Test
|
||||
public void testGetAvailableSortFilter() {
|
||||
final String[] contentFilter = SoundCloud.getSearchQueryHandler().getAvailableSortFilter();
|
||||
final String[] contentFilter = SoundCloud.getSearchQIHFactory().getAvailableSortFilter();
|
||||
assertEquals(0, contentFilter.length);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,21 +5,21 @@ import org.junit.Test;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.services.youtube.urlIdHandlers.YoutubeChannelUrlIdHandler;
|
||||
import org.schabi.newpipe.extractor.services.youtube.urlIdHandlers.YoutubeChannelUIHFactory;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* Test for {@link YoutubeChannelUrlIdHandler}
|
||||
* Test for {@link YoutubeChannelUIHFactory}
|
||||
*/
|
||||
public class YoutubeChannelUrlIdHandlerTest {
|
||||
public class YoutubeChannelUIHFactoryTest {
|
||||
|
||||
private static YoutubeChannelUrlIdHandler urlIdHandler;
|
||||
private static YoutubeChannelUIHFactory urlIdHandler;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() {
|
||||
urlIdHandler = YoutubeChannelUrlIdHandler.getInstance();
|
||||
urlIdHandler = YoutubeChannelUIHFactory.getInstance();
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ 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.services.youtube.extractors.YoutubeStreamExtractor;
|
||||
import org.schabi.newpipe.extractor.services.youtube.urlIdHandlers.YoutubeStreamUrlIdHandler;
|
||||
import org.schabi.newpipe.extractor.services.youtube.urlIdHandlers.YoutubeStreamUIHFactory;
|
||||
import org.schabi.newpipe.extractor.stream.StreamExtractor;
|
||||
import org.schabi.newpipe.extractor.stream.SubtitlesFormat;
|
||||
import org.schabi.newpipe.extractor.stream.VideoStream;
|
||||
@@ -22,7 +22,7 @@ import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
||||
|
||||
/**
|
||||
* Test for {@link YoutubeStreamUrlIdHandler}
|
||||
* Test for {@link YoutubeStreamUIHFactory}
|
||||
*/
|
||||
public class YoutubeStreamExtractorControversialTest {
|
||||
private static YoutubeStreamExtractor extractor;
|
||||
|
||||
@@ -8,7 +8,7 @@ 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.services.youtube.extractors.YoutubeStreamExtractor;
|
||||
import org.schabi.newpipe.extractor.services.youtube.urlIdHandlers.YoutubeStreamUrlIdHandler;
|
||||
import org.schabi.newpipe.extractor.services.youtube.urlIdHandlers.YoutubeStreamUIHFactory;
|
||||
import org.schabi.newpipe.extractor.stream.StreamExtractor;
|
||||
import org.schabi.newpipe.extractor.stream.SubtitlesFormat;
|
||||
import org.schabi.newpipe.extractor.stream.VideoStream;
|
||||
@@ -22,7 +22,7 @@ import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
||||
|
||||
/**
|
||||
* Test for {@link YoutubeStreamUrlIdHandler}
|
||||
* Test for {@link YoutubeStreamUIHFactory}
|
||||
*/
|
||||
public class YoutubeStreamExtractorRestrictedTest {
|
||||
public static final String HTTPS = "https://";
|
||||
|
||||
@@ -6,7 +6,7 @@ import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.exceptions.FoundAdException;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.services.youtube.urlIdHandlers.YoutubeStreamUrlIdHandler;
|
||||
import org.schabi.newpipe.extractor.services.youtube.urlIdHandlers.YoutubeStreamUIHFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -14,15 +14,15 @@ import java.util.List;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Test for {@link YoutubeStreamUrlIdHandler}
|
||||
* Test for {@link YoutubeStreamUIHFactory}
|
||||
*/
|
||||
public class YoutubeStreamUrlIdHandlerTest {
|
||||
public class YoutubeStreamUIHFactoryTest {
|
||||
private static String AD_URL = "https://googleads.g.doubleclick.net/aclk?sa=l&ai=C-2IPgeVTWPf4GcOStgfOnIOADf78n61GvKmmobYDrgIQASDj-5MDKAJg9ZXOgeAEoAGgy_T-A8gBAakC2gkpmquIsT6oAwGqBJMBT9BgD5kVgbN0dX602bFFaDw9vsxq-We-S8VkrXVBi6W_e7brZ36GCz1WO3EPEeklYuJjXLUowwCOKsd-8xr1UlS_tusuFJv9iX35xoBHKTRvs8-0aDbfEIm6in37QDfFuZjqgEMB8-tg0Jn_Pf1RU5OzbuU40B4Gy25NUTnOxhDKthOhKBUSZEksCEerUV8GMu10iAXCxquwApIFBggDEAEYAaAGGsgGlIjthrUDgAfItIsBqAemvhvYBwHSCAUIgGEQAbgT6AE&num=1&sig=AOD64_1DybDd4qAm5O7o9UAbTNRdqXXHFQ&ctype=21&video_id=dMO_IXYPZew&client=ca-pub-6219811747049371&adurl=http://www.youtube.com/watch%3Fv%3DdMO_IXYPZew";
|
||||
private static YoutubeStreamUrlIdHandler urlIdHandler;
|
||||
private static YoutubeStreamUIHFactory urlIdHandler;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() {
|
||||
urlIdHandler = YoutubeStreamUrlIdHandler.getInstance();
|
||||
urlIdHandler = YoutubeStreamUIHFactory.getInstance();
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ 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.UIHFactory;
|
||||
import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeSubscriptionExtractor;
|
||||
import org.schabi.newpipe.extractor.subscription.SubscriptionExtractor;
|
||||
import org.schabi.newpipe.extractor.subscription.SubscriptionItem;
|
||||
@@ -23,13 +23,13 @@ import static org.junit.Assert.*;
|
||||
*/
|
||||
public class YoutubeSubscriptionExtractorTest {
|
||||
private static YoutubeSubscriptionExtractor subscriptionExtractor;
|
||||
private static UrlIdHandler urlHandler;
|
||||
private static UIHFactory urlHandler;
|
||||
|
||||
@BeforeClass
|
||||
public static void setupClass() {
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
subscriptionExtractor = new YoutubeSubscriptionExtractor(ServiceList.YouTube);
|
||||
urlHandler = ServiceList.YouTube.getChannelUrlIdHandler();
|
||||
urlHandler = ServiceList.YouTube.getChannelUIHFactory();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -26,7 +26,7 @@ import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.extractor.ListExtractor;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeTrendingExtractor;
|
||||
import org.schabi.newpipe.extractor.services.youtube.urlIdHandlers.YoutubeTrendingUrlIdHandler;
|
||||
import org.schabi.newpipe.extractor.services.youtube.urlIdHandlers.YoutubeTrendingUIHFactory;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
||||
import org.schabi.newpipe.extractor.utils.Utils;
|
||||
|
||||
@@ -37,7 +37,7 @@ import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
||||
|
||||
|
||||
/**
|
||||
* Test for {@link YoutubeTrendingUrlIdHandler}
|
||||
* Test for {@link YoutubeTrendingUIHFactory}
|
||||
*/
|
||||
public class YoutubeTrendingExtractorTest {
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.junit.Test;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.StreamingService;
|
||||
import org.schabi.newpipe.extractor.UrlIdHandler;
|
||||
import org.schabi.newpipe.extractor.UIHFactory;
|
||||
import org.schabi.newpipe.extractor.kiosk.KioskInfo;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
@@ -43,9 +43,9 @@ public class YoutubeTrendingKioskInfoTest {
|
||||
throws Exception {
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
StreamingService service = YouTube;
|
||||
UrlIdHandler urlIdHandler = service.getKioskList().getUrlIdHandlerByType("Trending");
|
||||
UIHFactory UIHFactory = service.getKioskList().getUrlIdHandlerByType("Trending");
|
||||
|
||||
kioskInfo = KioskInfo.getInfo(YouTube, urlIdHandler.setId("Trending").getUrl(), null);
|
||||
kioskInfo = KioskInfo.getInfo(YouTube, UIHFactory.setId("Trending").getUrl(), null);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
package org.schabi.newpipe.extractor.services.youtube;
|
||||
|
||||
/*
|
||||
* Created by Christian Schabesberger on 12.08.17.
|
||||
*
|
||||
* Copyright (C) Christian Schabesberger 2017 <chris.schabesberger@mailbox.org>
|
||||
* YoutubeTrendingUIHFactoryTest.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/>.
|
||||
*/
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.UIHFactory;
|
||||
import org.schabi.newpipe.extractor.services.youtube.urlIdHandlers.YoutubeTrendingUIHFactory;
|
||||
|
||||
import static junit.framework.TestCase.assertFalse;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
||||
|
||||
/**
|
||||
* Test for {@link YoutubeTrendingUIHFactory}
|
||||
*/
|
||||
public class YoutubeTrendingUIHFactoryTest {
|
||||
private static UIHFactory UIHFactory;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
UIHFactory = YouTube.getKioskList().getUrlIdHandlerByType("Trending");
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getUrl()
|
||||
throws Exception {
|
||||
assertEquals(UIHFactory.setId("").getUrl(), "https://www.youtube.com/feed/trending");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getId()
|
||||
throws Exception {
|
||||
assertEquals(UIHFactory.setUrl("").getId(), "Trending");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void acceptUrl() {
|
||||
assertTrue(UIHFactory.acceptUrl("https://www.youtube.com/feed/trending"));
|
||||
assertTrue(UIHFactory.acceptUrl("https://www.youtube.com/feed/trending?adsf=fjaj#fhe"));
|
||||
assertTrue(UIHFactory.acceptUrl("http://www.youtube.com/feed/trending"));
|
||||
assertTrue(UIHFactory.acceptUrl("www.youtube.com/feed/trending"));
|
||||
assertTrue(UIHFactory.acceptUrl("youtube.com/feed/trending"));
|
||||
assertTrue(UIHFactory.acceptUrl("youtube.com/feed/trending?akdsakjf=dfije&kfj=dkjak"));
|
||||
assertTrue(UIHFactory.acceptUrl("https://youtube.com/feed/trending"));
|
||||
assertTrue(UIHFactory.acceptUrl("m.youtube.com/feed/trending"));
|
||||
|
||||
assertFalse(UIHFactory.acceptUrl("https://youtu.be/feed/trending"));
|
||||
assertFalse(UIHFactory.acceptUrl("kdskjfiiejfia"));
|
||||
assertFalse(UIHFactory.acceptUrl("https://www.youtube.com/bullshit/feed/trending"));
|
||||
assertFalse(UIHFactory.acceptUrl("https://www.youtube.com/feed/trending/bullshit"));
|
||||
assertFalse(UIHFactory.acceptUrl("https://www.youtube.com/feed/bullshit/trending"));
|
||||
assertFalse(UIHFactory.acceptUrl("peter klaut aepferl youtube.com/feed/trending"));
|
||||
assertFalse(UIHFactory.acceptUrl("youtube.com/feed/trending askjkf"));
|
||||
assertFalse(UIHFactory.acceptUrl("askdjfi youtube.com/feed/trending askjkf"));
|
||||
assertFalse(UIHFactory.acceptUrl(" youtube.com/feed/trending"));
|
||||
assertFalse(UIHFactory.acceptUrl("https://www.youtube.com/feed/trending.html"));
|
||||
assertFalse(UIHFactory.acceptUrl(""));
|
||||
}
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
package org.schabi.newpipe.extractor.services.youtube;
|
||||
|
||||
/*
|
||||
* Created by Christian Schabesberger on 12.08.17.
|
||||
*
|
||||
* Copyright (C) Christian Schabesberger 2017 <chris.schabesberger@mailbox.org>
|
||||
* YoutubeTrendingUrlIdHandlerTest.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/>.
|
||||
*/
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.UrlIdHandler;
|
||||
import org.schabi.newpipe.extractor.services.youtube.urlIdHandlers.YoutubeTrendingUrlIdHandler;
|
||||
|
||||
import static junit.framework.TestCase.assertFalse;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
||||
|
||||
/**
|
||||
* Test for {@link YoutubeTrendingUrlIdHandler}
|
||||
*/
|
||||
public class YoutubeTrendingUrlIdHandlerTest {
|
||||
private static UrlIdHandler urlIdHandler;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
urlIdHandler = YouTube.getKioskList().getUrlIdHandlerByType("Trending");
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getUrl()
|
||||
throws Exception {
|
||||
assertEquals(urlIdHandler.setId("").getUrl(), "https://www.youtube.com/feed/trending");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getId()
|
||||
throws Exception {
|
||||
assertEquals(urlIdHandler.setUrl("").getId(), "Trending");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void acceptUrl() {
|
||||
assertTrue(urlIdHandler.acceptUrl("https://www.youtube.com/feed/trending"));
|
||||
assertTrue(urlIdHandler.acceptUrl("https://www.youtube.com/feed/trending?adsf=fjaj#fhe"));
|
||||
assertTrue(urlIdHandler.acceptUrl("http://www.youtube.com/feed/trending"));
|
||||
assertTrue(urlIdHandler.acceptUrl("www.youtube.com/feed/trending"));
|
||||
assertTrue(urlIdHandler.acceptUrl("youtube.com/feed/trending"));
|
||||
assertTrue(urlIdHandler.acceptUrl("youtube.com/feed/trending?akdsakjf=dfije&kfj=dkjak"));
|
||||
assertTrue(urlIdHandler.acceptUrl("https://youtube.com/feed/trending"));
|
||||
assertTrue(urlIdHandler.acceptUrl("m.youtube.com/feed/trending"));
|
||||
|
||||
assertFalse(urlIdHandler.acceptUrl("https://youtu.be/feed/trending"));
|
||||
assertFalse(urlIdHandler.acceptUrl("kdskjfiiejfia"));
|
||||
assertFalse(urlIdHandler.acceptUrl("https://www.youtube.com/bullshit/feed/trending"));
|
||||
assertFalse(urlIdHandler.acceptUrl("https://www.youtube.com/feed/trending/bullshit"));
|
||||
assertFalse(urlIdHandler.acceptUrl("https://www.youtube.com/feed/bullshit/trending"));
|
||||
assertFalse(urlIdHandler.acceptUrl("peter klaut aepferl youtube.com/feed/trending"));
|
||||
assertFalse(urlIdHandler.acceptUrl("youtube.com/feed/trending askjkf"));
|
||||
assertFalse(urlIdHandler.acceptUrl("askdjfi youtube.com/feed/trending askjkf"));
|
||||
assertFalse(urlIdHandler.acceptUrl(" youtube.com/feed/trending"));
|
||||
assertFalse(urlIdHandler.acceptUrl("https://www.youtube.com/feed/trending.html"));
|
||||
assertFalse(urlIdHandler.acceptUrl(""));
|
||||
}
|
||||
}
|
||||
@@ -2,8 +2,6 @@ package org.schabi.newpipe.extractor.services.youtube.search;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
||||
@@ -12,36 +10,36 @@ public class YoutubeSearchQUHTest {
|
||||
|
||||
@Test
|
||||
public void testRegularValues() throws Exception {
|
||||
assertEquals("https://www.youtube.com/results?q=asdf", YouTube.getSearchQueryHandler().setQuery("asdf").getUrl());
|
||||
assertEquals("https://www.youtube.com/results?q=hans",YouTube.getSearchQueryHandler().setQuery("hans").getUrl());
|
||||
assertEquals("https://www.youtube.com/results?q=Poifj%26jaijf", YouTube.getSearchQueryHandler().setQuery("Poifj&jaijf").getUrl());
|
||||
assertEquals("https://www.youtube.com/results?q=G%C3%BCl%C3%BCm", YouTube.getSearchQueryHandler().setQuery("Gülüm").getUrl());
|
||||
assertEquals("https://www.youtube.com/results?q=%3Fj%24%29H%C2%A7B", YouTube.getSearchQueryHandler().setQuery("?j$)H§B").getUrl());
|
||||
assertEquals("https://www.youtube.com/results?q=asdf", YouTube.getSearchQIHFactory().setQuery("asdf").getUrl());
|
||||
assertEquals("https://www.youtube.com/results?q=hans",YouTube.getSearchQIHFactory().setQuery("hans").getUrl());
|
||||
assertEquals("https://www.youtube.com/results?q=Poifj%26jaijf", YouTube.getSearchQIHFactory().setQuery("Poifj&jaijf").getUrl());
|
||||
assertEquals("https://www.youtube.com/results?q=G%C3%BCl%C3%BCm", YouTube.getSearchQIHFactory().setQuery("Gülüm").getUrl());
|
||||
assertEquals("https://www.youtube.com/results?q=%3Fj%24%29H%C2%A7B", YouTube.getSearchQIHFactory().setQuery("?j$)H§B").getUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetContentFilter() throws Exception {
|
||||
assertEquals("stream", YouTube.getSearchQueryHandler()
|
||||
assertEquals("stream", YouTube.getSearchQIHFactory()
|
||||
.setQuery("", asList(new String[]{"stream"}), "").getContentFilter().get(0));
|
||||
assertEquals("channel", YouTube.getSearchQueryHandler()
|
||||
assertEquals("channel", YouTube.getSearchQIHFactory()
|
||||
.setQuery("asdf", asList(new String[]{"channel"}), "").getContentFilter().get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithContentfilter() throws Exception {
|
||||
assertEquals("https://www.youtube.com/results?q=asdf&sp=EgIQAVAU", YouTube.getSearchQueryHandler()
|
||||
assertEquals("https://www.youtube.com/results?q=asdf&sp=EgIQAVAU", YouTube.getSearchQIHFactory()
|
||||
.setQuery("asdf", asList(new String[]{"stream"}), "").getUrl());
|
||||
assertEquals("https://www.youtube.com/results?q=asdf&sp=EgIQAlAU", YouTube.getSearchQueryHandler()
|
||||
assertEquals("https://www.youtube.com/results?q=asdf&sp=EgIQAlAU", YouTube.getSearchQIHFactory()
|
||||
.setQuery("asdf", asList(new String[]{"channel"}), "").getUrl());
|
||||
assertEquals("https://www.youtube.com/results?q=asdf&sp=EgIQA1AU", YouTube.getSearchQueryHandler()
|
||||
assertEquals("https://www.youtube.com/results?q=asdf&sp=EgIQA1AU", YouTube.getSearchQIHFactory()
|
||||
.setQuery("asdf", asList(new String[]{"playlist"}), "").getUrl());
|
||||
assertEquals("https://www.youtube.com/results?q=asdf", YouTube.getSearchQueryHandler()
|
||||
assertEquals("https://www.youtube.com/results?q=asdf", YouTube.getSearchQIHFactory()
|
||||
.setQuery("asdf", asList(new String[]{"fjiijie"}), "").getUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetAvailableContentFilter() {
|
||||
final String[] contentFilter = YouTube.getSearchQueryHandler().getAvailableContentFilter();
|
||||
final String[] contentFilter = YouTube.getSearchQIHFactory().getAvailableContentFilter();
|
||||
assertEquals(4, contentFilter.length);
|
||||
assertEquals("stream", contentFilter[0]);
|
||||
assertEquals("channel", contentFilter[1]);
|
||||
@@ -51,7 +49,7 @@ public class YoutubeSearchQUHTest {
|
||||
|
||||
@Test
|
||||
public void testGetAvailableSortFilter() {
|
||||
final String[] contentFilter = YouTube.getSearchQueryHandler().getAvailableSortFilter();
|
||||
final String[] contentFilter = YouTube.getSearchQIHFactory().getAvailableSortFilter();
|
||||
assertEquals(0, contentFilter.length);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user