From f76cc4922e737930a3f6f7fe3d51e091aa3cb749 Mon Sep 17 00:00:00 2001 From: Coffeemakr Date: Thu, 7 Dec 2017 09:46:59 +0100 Subject: [PATCH] Fix channel info item collector --- .../channel/ChannelInfoItemCollector.java | 2 +- .../newpipe/extractor/ExtractorAsserts.java | 10 ++++++ .../youtube/YoutubeSearchEngineAllTest.java | 31 ++++++++++++++----- .../YoutubeSearchEngineChannelTest.java | 4 +++ .../YoutubeSearchEnginePlaylistTest.java | 4 +++ .../YoutubeSearchEngineStreamTest.java | 4 +++ 6 files changed, 47 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfoItemCollector.java b/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfoItemCollector.java index d588252f7..cf413879d 100644 --- a/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfoItemCollector.java +++ b/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfoItemCollector.java @@ -35,7 +35,7 @@ public class ChannelInfoItemCollector extends InfoItemCollector results = result.getResults(); + System.out.println("Results: " + results); + assertFalse("Results are empty: " + results, results.isEmpty()); + + InfoItem firstInfoItem = results.get(0); + + // THe channel should be the first item + assertTrue(firstInfoItem instanceof ChannelInfoItem); + assertEquals("name", "PewDiePie", firstInfoItem.name); + assertEquals("url","https://www.youtube.com/user/PewDiePie", firstInfoItem.url); + + for(InfoItem item: results) { + assertIsValidUrl(item.url); + } + } @Test diff --git a/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeSearchEngineChannelTest.java b/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeSearchEngineChannelTest.java index 48c476263..321bbed7e 100644 --- a/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeSearchEngineChannelTest.java +++ b/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeSearchEngineChannelTest.java @@ -10,6 +10,7 @@ import org.schabi.newpipe.extractor.search.SearchEngine; import org.schabi.newpipe.extractor.search.SearchResult; import static org.junit.Assert.*; +import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsValidUrl; import static org.schabi.newpipe.extractor.ServiceList.YouTube; @@ -53,6 +54,9 @@ public class YoutubeSearchEngineChannelTest { @Test public void testResultList() { assertFalse(result.resultList.isEmpty()); + for(InfoItem item: result.getResults()) { + assertIsValidUrl(item.url); + } } @Test diff --git a/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeSearchEnginePlaylistTest.java b/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeSearchEnginePlaylistTest.java index bc9096146..39d30d67b 100644 --- a/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeSearchEnginePlaylistTest.java +++ b/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeSearchEnginePlaylistTest.java @@ -10,6 +10,7 @@ import org.schabi.newpipe.extractor.search.SearchEngine; import org.schabi.newpipe.extractor.search.SearchResult; import static org.junit.Assert.*; +import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsValidUrl; import static org.schabi.newpipe.extractor.ServiceList.YouTube; @@ -53,6 +54,9 @@ public class YoutubeSearchEnginePlaylistTest { @Test public void testResultList() { assertFalse(result.resultList.isEmpty()); + for(InfoItem item: result.getResults()) { + assertIsValidUrl(item.url); + } } @Test diff --git a/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeSearchEngineStreamTest.java b/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeSearchEngineStreamTest.java index c0a8de516..261bbc529 100644 --- a/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeSearchEngineStreamTest.java +++ b/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeSearchEngineStreamTest.java @@ -10,6 +10,7 @@ import org.schabi.newpipe.extractor.search.SearchEngine; import org.schabi.newpipe.extractor.search.SearchResult; import static org.junit.Assert.*; +import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsValidUrl; import static org.schabi.newpipe.extractor.ServiceList.YouTube; @@ -53,6 +54,9 @@ public class YoutubeSearchEngineStreamTest { @Test public void testResultList() { assertFalse(result.resultList.isEmpty()); + for(InfoItem item: result.getResults()) { + assertIsValidUrl(item.url); + } } @Test