From f575826394f986c9f2b80a5d09905d5595ae6255 Mon Sep 17 00:00:00 2001 From: Christian Schabesberger Date: Sun, 20 Nov 2016 19:01:06 +0100 Subject: [PATCH] fix unit tests --- .../extractor/youtube/YoutubeChannelExtractorTest.java | 5 +++++ .../newpipe/extractor/youtube/YoutubeSearchEngineTest.java | 2 ++ .../newpipe/extractor/youtube/YoutubeSearchResultTest.java | 4 ++++ .../extractor/youtube/YoutubeStreamExtractorDefaultTest.java | 5 ++++- .../extractor/youtube/YoutubeStreamExtractorGemaTest.java | 1 + .../youtube/YoutubeStreamExtractorLiveStreamTest.java | 2 ++ .../youtube/YoutubeStreamExtractorRestrictedTest.java | 5 ++++- 7 files changed, 22 insertions(+), 2 deletions(-) diff --git a/app/src/androidTest/java/org/schabi/newpipe/extractor/youtube/YoutubeChannelExtractorTest.java b/app/src/androidTest/java/org/schabi/newpipe/extractor/youtube/YoutubeChannelExtractorTest.java index 7ae8cafa1..b47677a16 100644 --- a/app/src/androidTest/java/org/schabi/newpipe/extractor/youtube/YoutubeChannelExtractorTest.java +++ b/app/src/androidTest/java/org/schabi/newpipe/extractor/youtube/YoutubeChannelExtractorTest.java @@ -32,10 +32,15 @@ public class YoutubeChannelExtractorTest extends AndroidTestCase { @Override public void setUp() throws Exception { super.setUp(); + NewPipe.init(new Downloader()); extractor = NewPipe.getService("Youtube") .getChannelExtractorInstance("https://www.youtube.com/channel/UCYJ61XIK64sp6ZFFS8sctxw", 0); } + public void testGetDownloader() throws Exception { + assertNotNull(NewPipe.getDownloader()); + } + public void testGetChannelName() throws Exception { assertEquals(extractor.getChannelName(), "Gronkh"); } diff --git a/app/src/androidTest/java/org/schabi/newpipe/extractor/youtube/YoutubeSearchEngineTest.java b/app/src/androidTest/java/org/schabi/newpipe/extractor/youtube/YoutubeSearchEngineTest.java index 93f1fe108..71e63b7f0 100644 --- a/app/src/androidTest/java/org/schabi/newpipe/extractor/youtube/YoutubeSearchEngineTest.java +++ b/app/src/androidTest/java/org/schabi/newpipe/extractor/youtube/YoutubeSearchEngineTest.java @@ -2,6 +2,7 @@ package org.schabi.newpipe.extractor.youtube; import android.test.AndroidTestCase; +import org.schabi.newpipe.Downloader; import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.search.SearchEngine; import org.schabi.newpipe.extractor.search.SearchResult; @@ -34,6 +35,7 @@ public class YoutubeSearchEngineTest extends AndroidTestCase { @Override public void setUp() throws Exception { super.setUp(); + NewPipe.init(new Downloader()); SearchEngine engine = NewPipe.getService("Youtube").getSearchEngineInstance(); result = engine.search("this is something boring", 0, "de").getSearchResult(); diff --git a/app/src/androidTest/java/org/schabi/newpipe/extractor/youtube/YoutubeSearchResultTest.java b/app/src/androidTest/java/org/schabi/newpipe/extractor/youtube/YoutubeSearchResultTest.java index ce0cd477a..5d68903cf 100644 --- a/app/src/androidTest/java/org/schabi/newpipe/extractor/youtube/YoutubeSearchResultTest.java +++ b/app/src/androidTest/java/org/schabi/newpipe/extractor/youtube/YoutubeSearchResultTest.java @@ -2,6 +2,8 @@ package org.schabi.newpipe.extractor.youtube; import android.test.AndroidTestCase; +import org.schabi.newpipe.Downloader; +import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.search.SuggestionExtractor; import org.schabi.newpipe.extractor.services.youtube.YoutubeSuggestionExtractor; @@ -35,6 +37,8 @@ public class YoutubeSearchResultTest extends AndroidTestCase { @Override public void setUp() throws Exception { + super.setUp(); + NewPipe.init(new Downloader()); SuggestionExtractor engine = new YoutubeSuggestionExtractor(0); suggestionReply = engine.suggestionList("hello", "de"); } diff --git a/app/src/androidTest/java/org/schabi/newpipe/extractor/youtube/YoutubeStreamExtractorDefaultTest.java b/app/src/androidTest/java/org/schabi/newpipe/extractor/youtube/YoutubeStreamExtractorDefaultTest.java index b118230ee..abde32ed7 100644 --- a/app/src/androidTest/java/org/schabi/newpipe/extractor/youtube/YoutubeStreamExtractorDefaultTest.java +++ b/app/src/androidTest/java/org/schabi/newpipe/extractor/youtube/YoutubeStreamExtractorDefaultTest.java @@ -2,6 +2,7 @@ package org.schabi.newpipe.extractor.youtube; import android.test.AndroidTestCase; +import org.schabi.newpipe.Downloader; import org.schabi.newpipe.extractor.AbstractStreamInfo; import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.exceptions.ExtractionException; @@ -35,7 +36,9 @@ public class YoutubeStreamExtractorDefaultTest extends AndroidTestCase { public static final String HTTPS = "https://"; private StreamExtractor extractor; - public void setUp() throws IOException, ExtractionException { + public void setUp() throws Exception { + super.setUp(); + NewPipe.init(new Downloader()); extractor = NewPipe.getService("Youtube") .getExtractorInstance("https://www.youtube.com/watch?v=YQHsXMglC9A"); } diff --git a/app/src/androidTest/java/org/schabi/newpipe/extractor/youtube/YoutubeStreamExtractorGemaTest.java b/app/src/androidTest/java/org/schabi/newpipe/extractor/youtube/YoutubeStreamExtractorGemaTest.java index 0d150cd22..3e6cf8d2c 100644 --- a/app/src/androidTest/java/org/schabi/newpipe/extractor/youtube/YoutubeStreamExtractorGemaTest.java +++ b/app/src/androidTest/java/org/schabi/newpipe/extractor/youtube/YoutubeStreamExtractorGemaTest.java @@ -39,6 +39,7 @@ public class YoutubeStreamExtractorGemaTest extends AndroidTestCase { public void testGemaError() throws IOException, ExtractionException { if(testActive) { try { + NewPipe.init(new Downloader()); NewPipe.getService("Youtube") .getExtractorInstance("https://www.youtube.com/watch?v=3O1_3zBUKM8"); } catch(YoutubeStreamExtractor.GemaException ge) { diff --git a/app/src/androidTest/java/org/schabi/newpipe/extractor/youtube/YoutubeStreamExtractorLiveStreamTest.java b/app/src/androidTest/java/org/schabi/newpipe/extractor/youtube/YoutubeStreamExtractorLiveStreamTest.java index dca969442..72fcfd45d 100644 --- a/app/src/androidTest/java/org/schabi/newpipe/extractor/youtube/YoutubeStreamExtractorLiveStreamTest.java +++ b/app/src/androidTest/java/org/schabi/newpipe/extractor/youtube/YoutubeStreamExtractorLiveStreamTest.java @@ -37,6 +37,8 @@ public class YoutubeStreamExtractorLiveStreamTest extends AndroidTestCase { public void setUp() throws IOException, ExtractionException { //todo: make the extractor not throw over a livestream /* + + NewPipe.init(new Downloader()); extractor = NewPipe.getService("Youtube") .getExtractorInstance("https://www.youtube.com/watch?v=J0s6NjqdjLE", new Downloader()); */ diff --git a/app/src/androidTest/java/org/schabi/newpipe/extractor/youtube/YoutubeStreamExtractorRestrictedTest.java b/app/src/androidTest/java/org/schabi/newpipe/extractor/youtube/YoutubeStreamExtractorRestrictedTest.java index ec2f6618e..092b082c7 100644 --- a/app/src/androidTest/java/org/schabi/newpipe/extractor/youtube/YoutubeStreamExtractorRestrictedTest.java +++ b/app/src/androidTest/java/org/schabi/newpipe/extractor/youtube/YoutubeStreamExtractorRestrictedTest.java @@ -2,6 +2,7 @@ package org.schabi.newpipe.extractor.youtube; import android.test.AndroidTestCase; +import org.schabi.newpipe.Downloader; import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.exceptions.ParsingException; @@ -14,7 +15,9 @@ public class YoutubeStreamExtractorRestrictedTest extends AndroidTestCase { public static final String HTTPS = "https://"; private StreamExtractor extractor; - public void setUp() throws IOException, ExtractionException { + public void setUp() throws Exception { + super.setUp(); + NewPipe.init(new Downloader()); extractor = NewPipe.getService("Youtube") .getExtractorInstance("https://www.youtube.com/watch?v=i6JTvzrpBy0"); }