2017-08-05 16:15:36 +02:00
package org.schabi.newpipe.extractor.services.youtube ;
2017-08-05 10:03:56 +02:00
2017-12-07 02:09:46 +01:00
import org.junit.BeforeClass ;
2017-08-05 10:03:56 +02:00
import org.junit.Test ;
import org.schabi.newpipe.Downloader ;
2017-08-12 22:19:56 +02:00
import org.schabi.newpipe.extractor.ListExtractor ;
2017-08-05 10:03:56 +02:00
import org.schabi.newpipe.extractor.NewPipe ;
2017-08-11 03:23:09 +02:00
import org.schabi.newpipe.extractor.channel.ChannelExtractor ;
2018-03-01 01:02:43 +01:00
import org.schabi.newpipe.extractor.stream.StreamInfoItem ;
2017-08-05 10:03:56 +02:00
2017-08-08 17:01:50 +02:00
import static org.junit.Assert.* ;
2017-11-25 03:13:26 +01:00
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertEmptyErrors ;
2017-08-07 18:12:51 +02:00
import static org.schabi.newpipe.extractor.ServiceList.YouTube ;
2017-08-06 22:20:15 +02:00
/ *
2017-08-05 10:03:56 +02:00
* Created by Christian Schabesberger on 12 . 09 . 16 .
*
* 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/>.
* /
/ * *
2017-08-11 03:23:09 +02:00
* Test for { @link ChannelExtractor }
2017-08-05 10:03:56 +02:00
* /
2017-08-11 03:23:09 +02:00
public class YoutubeChannelExtractorTest {
2017-08-05 10:03:56 +02:00
2017-12-07 02:09:46 +01:00
static YoutubeChannelExtractor extractor ;
2017-08-05 10:03:56 +02:00
2017-12-07 02:09:46 +01:00
@BeforeClass
public static void setUp ( ) throws Exception {
2017-08-05 10:03:56 +02:00
NewPipe . init ( Downloader . getInstance ( ) ) ;
2018-02-10 03:46:05 +01:00
extractor = ( YoutubeChannelExtractor ) YouTube
2017-08-16 04:56:10 +02:00
. getChannelExtractor ( " https://www.youtube.com/user/Gronkh " ) ;
2017-12-29 14:40:42 +01:00
extractor . fetchPage ( ) ;
2017-08-05 10:03:56 +02:00
}
@Test
2017-08-08 17:01:50 +02:00
public void testGetDownloader ( ) throws Exception {
2017-08-05 10:03:56 +02:00
assertNotNull ( NewPipe . getDownloader ( ) ) ;
}
@Test
2017-08-11 03:23:09 +02:00
public void testGetName ( ) throws Exception {
assertEquals ( extractor . getName ( ) , " Gronkh " ) ;
2017-08-05 10:03:56 +02:00
}
2017-08-16 04:56:10 +02:00
@Test
public void testGetId ( ) throws Exception {
assertEquals ( extractor . getId ( ) , " UCYJ61XIK64sp6ZFFS8sctxw " ) ;
}
@Test
public void testGetUrl ( ) throws Exception {
assertEquals ( extractor . getCleanUrl ( ) , " https://www.youtube.com/channel/UCYJ61XIK64sp6ZFFS8sctxw " ) ;
}
2017-08-07 19:00:36 +02:00
@Test
public void testGetDescription ( ) throws Exception {
assertEquals ( extractor . getDescription ( ) , " ★ ★ ★ KLICK MICH HART, DU SAU! :D ★ ★ ★ Zart im Schmelz und süffig im Abgang. Ungebremster Spieltrieb seit 1896. Tägliche Folgen nonstop seit dem 01.04.2010!... " ) ;
}
2017-08-05 10:03:56 +02:00
@Test
public void testGetAvatarUrl ( ) throws Exception {
assertTrue ( extractor . getAvatarUrl ( ) , extractor . getAvatarUrl ( ) . contains ( " yt3 " ) ) ;
}
@Test
2017-08-06 22:20:15 +02:00
public void testGetBannerUrl ( ) throws Exception {
2017-08-05 10:03:56 +02:00
assertTrue ( extractor . getBannerUrl ( ) , extractor . getBannerUrl ( ) . contains ( " yt3 " ) ) ;
}
@Test
public void testGetFeedUrl ( ) throws Exception {
2017-08-16 04:56:10 +02:00
assertEquals ( extractor . getFeedUrl ( ) , " https://www.youtube.com/feeds/videos.xml?channel_id=UCYJ61XIK64sp6ZFFS8sctxw " ) ;
2017-08-05 10:03:56 +02:00
}
@Test
public void testGetStreams ( ) throws Exception {
2018-03-01 01:02:43 +01:00
assertTrue ( " no streams are received " , ! extractor . getInfoItems ( ) . getItemList ( ) . isEmpty ( ) ) ;
2017-08-05 10:03:56 +02:00
}
@Test
public void testGetStreamsErrors ( ) throws Exception {
2018-03-01 01:02:43 +01:00
assertEmptyErrors ( " errors during stream list extraction " , extractor . getInfoItems ( ) . getErrors ( ) ) ;
2017-08-05 10:03:56 +02:00
}
@Test
2017-08-06 22:20:15 +02:00
public void testHasMoreStreams ( ) throws Exception {
// Setup the streams
2018-03-01 01:02:43 +01:00
extractor . getInfoItems ( ) ;
2018-02-24 22:20:50 +01:00
assertTrue ( " don't have more streams " , extractor . hasNextPage ( ) ) ;
2017-08-05 10:03:56 +02:00
}
@Test
public void testGetSubscriberCount ( ) throws Exception {
assertTrue ( " wrong subscriber count " , extractor . getSubscriberCount ( ) > = 0 ) ;
}
@Test
2018-02-26 16:49:15 +01:00
public void testGetNextPageUrl ( ) throws Exception {
assertTrue ( extractor . hasNextPage ( ) ) ;
}
@Test
public void testGetPage ( ) throws Exception {
2017-08-06 22:20:15 +02:00
// Setup the streams
2018-03-01 01:02:43 +01:00
extractor . getInfoItems ( ) ;
ListExtractor . InfoItemPage < StreamInfoItem > nextItemsResult = extractor . getPage ( extractor . getNextPageUrl ( ) ) ;
assertTrue ( " extractor didn't have next streams " , ! nextItemsResult . getItemsList ( ) . isEmpty ( ) ) ;
assertEmptyErrors ( " errors occurred during extraction of the next streams " , nextItemsResult . getErrors ( ) ) ;
2018-02-24 22:20:50 +01:00
assertTrue ( " extractor didn't have more streams after getInfoItemPage " , extractor . hasNextPage ( ) ) ;
2017-08-05 10:03:56 +02:00
}
}