2017-09-23 17:14:21 +02:00
|
|
|
package org.schabi.newpipe.extractor.services.youtube;
|
|
|
|
|
2020-02-08 23:58:46 +01:00
|
|
|
/*
|
|
|
|
* Created by Christian Schabesberger on 12.08.17.
|
|
|
|
*
|
|
|
|
* Copyright (C) Christian Schabesberger 2017 <chris.schabesberger@mailbox.org>
|
|
|
|
* YoutubeTrendingKioskInfoTest.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-09-23 17:14:21 +02:00
|
|
|
|
2021-12-27 21:08:08 +01:00
|
|
|
import org.junit.jupiter.api.BeforeAll;
|
|
|
|
import org.junit.jupiter.api.Test;
|
2021-01-17 18:55:37 +01:00
|
|
|
import org.schabi.newpipe.downloader.DownloaderFactory;
|
2017-09-23 17:14:21 +02:00
|
|
|
import org.schabi.newpipe.extractor.NewPipe;
|
|
|
|
import org.schabi.newpipe.extractor.StreamingService;
|
|
|
|
import org.schabi.newpipe.extractor.kiosk.KioskInfo;
|
2019-04-28 22:03:16 +02:00
|
|
|
import org.schabi.newpipe.extractor.linkhandler.LinkHandlerFactory;
|
2017-09-23 17:14:21 +02:00
|
|
|
|
2021-04-09 11:58:05 +02:00
|
|
|
import java.util.Random;
|
|
|
|
|
2021-12-27 21:08:08 +01:00
|
|
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
|
|
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
2017-09-23 17:14:21 +02:00
|
|
|
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test for {@link KioskInfo}
|
|
|
|
*/
|
2018-02-10 03:46:05 +01:00
|
|
|
public class YoutubeTrendingKioskInfoTest {
|
2021-01-17 18:55:37 +01:00
|
|
|
|
|
|
|
private static final String RESOURCE_PATH = DownloaderFactory.RESOURCE_PATH + "kiosk";
|
|
|
|
|
2017-12-07 02:09:46 +01:00
|
|
|
static KioskInfo kioskInfo;
|
2017-09-23 17:14:21 +02:00
|
|
|
|
2021-12-27 21:08:08 +01:00
|
|
|
@BeforeAll
|
2017-12-07 02:09:46 +01:00
|
|
|
public static void setUp()
|
2017-09-23 17:14:21 +02:00
|
|
|
throws Exception {
|
2021-01-17 18:55:37 +01:00
|
|
|
YoutubeParsingHelper.resetClientVersionAndKey();
|
2021-04-09 11:58:05 +02:00
|
|
|
YoutubeParsingHelper.setNumberGenerator(new Random(1));
|
2021-01-17 18:55:37 +01:00
|
|
|
NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH));
|
|
|
|
LinkHandlerFactory LinkHandlerFactory = ((StreamingService) YouTube).getKioskList().getListLinkHandlerFactoryByType("Trending");
|
2017-09-23 17:14:21 +02:00
|
|
|
|
2018-10-05 16:01:10 +02:00
|
|
|
kioskInfo = KioskInfo.getInfo(YouTube, LinkHandlerFactory.fromId("Trending").getUrl());
|
2017-09-23 17:14:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void getStreams() {
|
2018-03-11 21:50:40 +01:00
|
|
|
assertFalse(kioskInfo.getRelatedItems().isEmpty());
|
2017-09-23 17:14:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
2017-09-25 12:43:40 +02:00
|
|
|
public void getId() {
|
2017-11-30 16:33:57 +01:00
|
|
|
assertTrue(kioskInfo.getId().equals("Trending")
|
|
|
|
|| kioskInfo.getId().equals("Trends"));
|
2017-09-25 12:43:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void getName() {
|
2017-11-11 12:17:14 +01:00
|
|
|
assertFalse(kioskInfo.getName().isEmpty());
|
2017-09-23 17:14:21 +02:00
|
|
|
}
|
|
|
|
}
|