Skip to content

Commit 88d2fff

Browse files
committed
add test for YoutubeTrendingExtractor
1 parent 8dabda2 commit 88d2fff

2 files changed

Lines changed: 84 additions & 1 deletion

File tree

src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeChannelExtractorTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,5 +102,4 @@ public void testGetNextStreams() throws Exception {
102102
assertTrue("extractor didn't have next streams", !extractor.getNextStreams().nextItemsList.isEmpty());
103103
assertTrue("extractor didn't have more streams after getNextStreams", extractor.hasMoreStreams());
104104
}
105-
106105
}
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,88 @@
11
package org.schabi.newpipe.extractor.services.youtube;
22

3+
/*
4+
* Created by Christian Schabesberger on 12.08.17.
5+
*
6+
* Copyright (C) Christian Schabesberger 2017 <chris.schabesberger@mailbox.org>
7+
* YoutubeTrendingExtractorTest.java is part of NewPipe.
8+
*
9+
* NewPipe is free software: you can redistribute it and/or modify
10+
* it under the terms of the GNU General Public License as published by
11+
* the Free Software Foundation, either version 3 of the License, or
12+
* (at your option) any later version.
13+
*
14+
* NewPipe is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
* GNU General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU General Public License
20+
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
21+
*/
22+
23+
import org.junit.Before;
24+
import org.junit.Test;
25+
import org.schabi.newpipe.Downloader;
26+
import org.schabi.newpipe.extractor.NewPipe;
27+
import org.schabi.newpipe.extractor.kiosk.KioskExtractor;
28+
29+
import static junit.framework.TestCase.assertFalse;
30+
import static org.junit.Assert.assertEquals;
31+
import static org.junit.Assert.assertNotNull;
32+
import static org.junit.Assert.assertTrue;
33+
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
34+
35+
36+
/**
37+
* Test for {@link YoutubeTrendingUrlIdHandler}
38+
*/
339
public class YoutubeTrendingExtractorTest {
40+
41+
KioskExtractor extractor;
42+
43+
@Before
44+
public void setUp() throws Exception {
45+
NewPipe.init(Downloader.getInstance());
46+
extractor = YouTube.getService()
47+
.getKioskList()
48+
.getExtractorByType("Trending");
49+
}
50+
51+
@Test
52+
public void testGetDownloader() throws Exception {
53+
assertNotNull(NewPipe.getDownloader());
54+
}
55+
56+
@Test
57+
public void testGetName() throws Exception {
58+
assertEquals(extractor.getName(), "Trending");
59+
}
60+
61+
@Test
62+
public void testId() throws Exception {
63+
assertEquals(extractor.getId(), "Trending");
64+
}
65+
66+
@Test
67+
public void testGetStreams() throws Exception {
68+
assertTrue("no streams are received", !extractor.getStreams().getItemList().isEmpty());
69+
}
70+
71+
@Test
72+
public void testGetStreamsErrors() throws Exception {
73+
assertTrue("errors during stream list extraction", extractor.getStreams().getErrors().isEmpty());
74+
}
75+
76+
@Test
77+
public void testHasMoreStreams() throws Exception {
78+
// Setup the streams
79+
extractor.getStreams();
80+
assertTrue("don't have more streams", extractor.hasMoreStreams());
81+
}
82+
83+
@Test
84+
public void testGetNextStreams() throws Exception {
85+
assertFalse("extractor has next streams", !extractor.getNextStreams().nextItemsList.isEmpty());
86+
assertFalse("extractor has more streams after getNextStreams", extractor.hasMoreStreams());
87+
}
488
}

0 commit comments

Comments
 (0)