diff options
author | Max Bechtold <max.bechtold@andrena.de> | 2019-12-21 11:12:39 +0100 |
---|---|---|
committer | Max Bechtold <max.bechtold@andrena.de> | 2019-12-21 11:52:01 +0100 |
commit | 9ca5cab24678873881709c5c554c1ce54c5db220 (patch) | |
tree | f97dd7474a03a5ad6155aa95400b9e152f6d9d09 /app/src/androidTest/java/de/test/antennapod/service/playback/PlaybackServiceMediaPlayerTest.java | |
parent | 87cca61dcd8337facf695f03f1330c55bfa85168 (diff) | |
parent | 46731178b4f0590edf7bcb14e5dcec02f2e98f57 (diff) | |
download | AntennaPod-9ca5cab24678873881709c5c554c1ce54c5db220.zip |
Merge remote-tracking branch 'upstream/develop' into feat/simple-adjust-volume-per-feed
Diffstat (limited to 'app/src/androidTest/java/de/test/antennapod/service/playback/PlaybackServiceMediaPlayerTest.java')
-rw-r--r-- | app/src/androidTest/java/de/test/antennapod/service/playback/PlaybackServiceMediaPlayerTest.java | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/app/src/androidTest/java/de/test/antennapod/service/playback/PlaybackServiceMediaPlayerTest.java b/app/src/androidTest/java/de/test/antennapod/service/playback/PlaybackServiceMediaPlayerTest.java index e4081a55a..f7f3c1aa7 100644 --- a/app/src/androidTest/java/de/test/antennapod/service/playback/PlaybackServiceMediaPlayerTest.java +++ b/app/src/androidTest/java/de/test/antennapod/service/playback/PlaybackServiceMediaPlayerTest.java @@ -2,8 +2,8 @@ package de.test.antennapod.service.playback; import android.content.Context; -import androidx.test.InstrumentationRegistry; import androidx.test.filters.MediumTest; +import androidx.test.platform.app.InstrumentationRegistry; import de.danoeh.antennapod.core.feed.VolumeReductionSetting; import de.test.antennapod.EspressoTestUtils; import junit.framework.AssertionFailedError; @@ -33,7 +33,7 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; -import static androidx.test.InstrumentationRegistry.getInstrumentation; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; @@ -46,13 +46,12 @@ import static org.junit.Assert.fail; */ @MediumTest public class PlaybackServiceMediaPlayerTest { - private static final String PLAYABLE_FILE_URL = "http://127.0.0.1:" + HTTPBin.PORT + "/files/0"; private static final String PLAYABLE_DEST_URL = "psmptestfile.mp3"; private String PLAYABLE_LOCAL_URL = null; private static final int LATCH_TIMEOUT_SECONDS = 3; private HTTPBin httpServer; - + private String playableFileUrl; private volatile AssertionFailedError assertionError; @After @@ -68,10 +67,11 @@ public class PlaybackServiceMediaPlayerTest { EspressoTestUtils.makeNotFirstRun(); EspressoTestUtils.clearDatabase(); - final Context context = InstrumentationRegistry.getTargetContext(); + final Context context = getInstrumentation().getTargetContext(); httpServer = new HTTPBin(); httpServer.start(); + playableFileUrl = httpServer.getBaseUrl() + "/files/0"; File cacheDir = context.getExternalFilesDir("testFiles"); if (cacheDir == null) @@ -82,7 +82,7 @@ public class PlaybackServiceMediaPlayerTest { assertTrue(cacheDir.canWrite()); assertTrue(cacheDir.canRead()); if (!dest.exists()) { - InputStream i = InstrumentationRegistry.getContext().getAssets().open("testfile.mp3"); + InputStream i = getInstrumentation().getTargetContext().getAssets().open("3sec.mp3"); OutputStream o = new FileOutputStream(new File(cacheDir, PLAYABLE_DEST_URL)); IOUtils.copy(i, o); o.flush(); @@ -168,7 +168,7 @@ public class PlaybackServiceMediaPlayerTest { } }); PlaybackServiceMediaPlayer psmp = new LocalPSMP(c, callback); - Playable p = writeTestPlayable(PLAYABLE_FILE_URL, null); + Playable p = writeTestPlayable(playableFileUrl, null); psmp.playMediaObject(p, true, false, false); boolean res = countDownLatch.await(LATCH_TIMEOUT_SECONDS, TimeUnit.SECONDS); if (assertionError != null) @@ -208,7 +208,7 @@ public class PlaybackServiceMediaPlayerTest { } }); PlaybackServiceMediaPlayer psmp = new LocalPSMP(c, callback); - Playable p = writeTestPlayable(PLAYABLE_FILE_URL, null); + Playable p = writeTestPlayable(playableFileUrl, null); psmp.playMediaObject(p, true, true, false); boolean res = countDownLatch.await(LATCH_TIMEOUT_SECONDS, TimeUnit.SECONDS); @@ -252,7 +252,7 @@ public class PlaybackServiceMediaPlayerTest { } }); PlaybackServiceMediaPlayer psmp = new LocalPSMP(c, callback); - Playable p = writeTestPlayable(PLAYABLE_FILE_URL, null); + Playable p = writeTestPlayable(playableFileUrl, null); psmp.playMediaObject(p, true, false, true); boolean res = countDownLatch.await(LATCH_TIMEOUT_SECONDS, TimeUnit.SECONDS); if (assertionError != null) @@ -297,7 +297,7 @@ public class PlaybackServiceMediaPlayerTest { } }); PlaybackServiceMediaPlayer psmp = new LocalPSMP(c, callback); - Playable p = writeTestPlayable(PLAYABLE_FILE_URL, null); + Playable p = writeTestPlayable(playableFileUrl, null); psmp.playMediaObject(p, true, true, true); boolean res = countDownLatch.await(LATCH_TIMEOUT_SECONDS, TimeUnit.SECONDS); if (assertionError != null) @@ -335,7 +335,7 @@ public class PlaybackServiceMediaPlayerTest { } }); PlaybackServiceMediaPlayer psmp = new LocalPSMP(c, callback); - Playable p = writeTestPlayable(PLAYABLE_FILE_URL, PLAYABLE_LOCAL_URL); + Playable p = writeTestPlayable(playableFileUrl, PLAYABLE_LOCAL_URL); psmp.playMediaObject(p, false, false, false); boolean res = countDownLatch.await(LATCH_TIMEOUT_SECONDS, TimeUnit.SECONDS); if (assertionError != null) @@ -374,7 +374,7 @@ public class PlaybackServiceMediaPlayerTest { } }); PlaybackServiceMediaPlayer psmp = new LocalPSMP(c, callback); - Playable p = writeTestPlayable(PLAYABLE_FILE_URL, PLAYABLE_LOCAL_URL); + Playable p = writeTestPlayable(playableFileUrl, PLAYABLE_LOCAL_URL); psmp.playMediaObject(p, false, true, false); boolean res = countDownLatch.await(LATCH_TIMEOUT_SECONDS, TimeUnit.SECONDS); if (assertionError != null) @@ -416,7 +416,7 @@ public class PlaybackServiceMediaPlayerTest { } }); PlaybackServiceMediaPlayer psmp = new LocalPSMP(c, callback); - Playable p = writeTestPlayable(PLAYABLE_FILE_URL, PLAYABLE_LOCAL_URL); + Playable p = writeTestPlayable(playableFileUrl, PLAYABLE_LOCAL_URL); psmp.playMediaObject(p, false, false, true); boolean res = countDownLatch.await(LATCH_TIMEOUT_SECONDS, TimeUnit.SECONDS); if (assertionError != null) @@ -461,7 +461,7 @@ public class PlaybackServiceMediaPlayerTest { } }); PlaybackServiceMediaPlayer psmp = new LocalPSMP(c, callback); - Playable p = writeTestPlayable(PLAYABLE_FILE_URL, PLAYABLE_LOCAL_URL); + Playable p = writeTestPlayable(playableFileUrl, PLAYABLE_LOCAL_URL); psmp.playMediaObject(p, false, true, true); boolean res = countDownLatch.await(LATCH_TIMEOUT_SECONDS, TimeUnit.SECONDS); if (assertionError != null) @@ -524,7 +524,7 @@ public class PlaybackServiceMediaPlayerTest { } }); PlaybackServiceMediaPlayer psmp = new LocalPSMP(c, callback); - Playable p = writeTestPlayable(PLAYABLE_FILE_URL, PLAYABLE_LOCAL_URL); + Playable p = writeTestPlayable(playableFileUrl, PLAYABLE_LOCAL_URL); if (initialState == PlayerStatus.PLAYING) { psmp.playMediaObject(p, stream, true, true); } @@ -617,7 +617,7 @@ public class PlaybackServiceMediaPlayerTest { PlaybackServiceMediaPlayer psmp = new LocalPSMP(c, callback); if (initialState == PlayerStatus.PREPARED || initialState == PlayerStatus.PLAYING || initialState == PlayerStatus.PAUSED) { boolean startWhenPrepared = (initialState != PlayerStatus.PREPARED); - psmp.playMediaObject(writeTestPlayable(PLAYABLE_FILE_URL, PLAYABLE_LOCAL_URL), false, startWhenPrepared, true); + psmp.playMediaObject(writeTestPlayable(playableFileUrl, PLAYABLE_LOCAL_URL), false, startWhenPrepared, true); } if (initialState == PlayerStatus.PAUSED) { psmp.pause(false, false); @@ -674,7 +674,7 @@ public class PlaybackServiceMediaPlayerTest { } }); PlaybackServiceMediaPlayer psmp = new LocalPSMP(c, callback); - Playable p = writeTestPlayable(PLAYABLE_FILE_URL, PLAYABLE_LOCAL_URL); + Playable p = writeTestPlayable(playableFileUrl, PLAYABLE_LOCAL_URL); if (initialState == PlayerStatus.INITIALIZED || initialState == PlayerStatus.PLAYING || initialState == PlayerStatus.PREPARED @@ -748,7 +748,7 @@ public class PlaybackServiceMediaPlayerTest { } }); PlaybackServiceMediaPlayer psmp = new LocalPSMP(c, callback); - Playable p = writeTestPlayable(PLAYABLE_FILE_URL, PLAYABLE_LOCAL_URL); + Playable p = writeTestPlayable(playableFileUrl, PLAYABLE_LOCAL_URL); boolean prepareImmediately = initialState != PlayerStatus.INITIALIZED; boolean startImmediately = initialState != PlayerStatus.PREPARED; psmp.playMediaObject(p, false, startImmediately, prepareImmediately); |