diff options
Diffstat (limited to 'app/src/androidTest/java/de/test/antennapod/service')
4 files changed, 32 insertions, 32 deletions
diff --git a/app/src/androidTest/java/de/test/antennapod/service/download/DownloadServiceTest.java b/app/src/androidTest/java/de/test/antennapod/service/download/DownloadServiceTest.java index b75044d73..fd395f7c1 100644 --- a/app/src/androidTest/java/de/test/antennapod/service/download/DownloadServiceTest.java +++ b/app/src/androidTest/java/de/test/antennapod/service/download/DownloadServiceTest.java @@ -5,8 +5,8 @@ import android.content.Intent; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.core.util.Consumer; -import androidx.test.InstrumentationRegistry; -import androidx.test.runner.AndroidJUnit4; +import androidx.test.platform.app.InstrumentationRegistry; +import androidx.test.ext.junit.runners.AndroidJUnit4; import de.test.antennapod.EspressoTestUtils; import org.awaitility.Awaitility; @@ -81,7 +81,7 @@ public class DownloadServiceTest { @After public void tearDown() throws Exception { DownloadService.setDownloaderFactory(origFactory); - Context context = InstrumentationRegistry.getTargetContext(); + Context context = InstrumentationRegistry.getInstrumentation().getTargetContext(); DownloadRequester.getInstance().cancelAllDownloads(context); context.stopService(new Intent(context, DownloadService.class)); EspressoTestUtils.tryKillDownloadService(); @@ -106,9 +106,7 @@ public class DownloadServiceTest { // OPEN: Ideally, I'd like the download time long enough so that multiple in-progress DownloadEvents // are generated (to simulate typical download), but it'll make download time quite long (1-2 seconds) // to do so - DownloadService.setDownloaderFactory(new StubDownloaderFactory(50, downloadStatus -> { - downloadStatus.setSuccessful(); - })); + DownloadService.setDownloaderFactory(new StubDownloaderFactory(50, DownloadStatus::setSuccessful)); UserPreferences.setEnqueueDownloadedEpisodes(enqueueDownloaded); withFeedItemEventListener(feedItemEventListener -> { @@ -117,7 +115,8 @@ public class DownloadServiceTest { assertFalse("The media in test should not yet been downloaded", DBReader.getFeedMedia(testMedia11.getId()).isDownloaded()); - DownloadRequester.getInstance().downloadMedia(false, InstrumentationRegistry.getTargetContext(), true, testMedia11.getItem()); + DownloadRequester.getInstance().downloadMedia(false, InstrumentationRegistry + .getInstrumentation().getTargetContext(), true, testMedia11.getItem()); Awaitility.await() .atMost(5000, TimeUnit.MILLISECONDS) .until(() -> feedItemEventListener.getEvents().size() >= numEventsExpected); @@ -144,11 +143,10 @@ public class DownloadServiceTest { } private void doTestCancelDownload_UndoEnqueue(boolean itemAlreadyInQueue) throws Exception { - Context context = InstrumentationRegistry.getTargetContext(); + Context context = InstrumentationRegistry.getInstrumentation().getTargetContext(); // let download take longer to ensure the test can cancel the download in time - DownloadService.setDownloaderFactory(new StubDownloaderFactory(30000, downloadStatus -> { - downloadStatus.setSuccessful(); - })); + DownloadService.setDownloaderFactory( + new StubDownloaderFactory(30000, DownloadStatus::setSuccessful)); UserPreferences.setEnqueueDownloadedEpisodes(true); UserPreferences.setEnableAutodownload(false); diff --git a/app/src/androidTest/java/de/test/antennapod/service/download/HttpDownloaderTest.java b/app/src/androidTest/java/de/test/antennapod/service/download/HttpDownloaderTest.java index 301ceea6c..4ef6594e3 100644 --- a/app/src/androidTest/java/de/test/antennapod/service/download/HttpDownloaderTest.java +++ b/app/src/androidTest/java/de/test/antennapod/service/download/HttpDownloaderTest.java @@ -1,6 +1,6 @@ package de.test.antennapod.service.download; -import androidx.test.InstrumentationRegistry; +import androidx.test.platform.app.InstrumentationRegistry; import androidx.test.filters.LargeTest; import android.util.Log; @@ -51,7 +51,7 @@ public class HttpDownloaderTest { @Before public void setUp() throws Exception { UserPreferences.init(InstrumentationRegistry.getInstrumentation().getTargetContext()); - destDir = InstrumentationRegistry.getTargetContext().getExternalFilesDir(DOWNLOAD_DIR); + destDir = InstrumentationRegistry.getInstrumentation().getTargetContext().getExternalFilesDir(DOWNLOAD_DIR); assertNotNull(destDir); assertTrue(destDir.exists()); httpServer = new HTTPBin(); @@ -82,7 +82,7 @@ public class HttpDownloaderTest { downloader.call(); DownloadStatus status = downloader.getResult(); assertNotNull(status); - assertTrue(status.isSuccessful() == expectedResult); + assertEquals(expectedResult, status.isSuccessful()); assertTrue(status.isDone()); // the file should not exist if the download has failed and deleteExisting was true assertTrue(!deleteExisting || new File(feedFile.getFile_url()).exists() == expectedResult); 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 cfce069ec..c9cbf1bb2 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 @@ -38,6 +38,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -173,7 +174,7 @@ public class PlaybackServiceMediaPlayerTest { throw assertionError; assertTrue(res); - assertTrue(psmp.getPSMPInfo().playerStatus == PlayerStatus.INITIALIZED); + assertSame(PlayerStatus.INITIALIZED, psmp.getPSMPInfo().playerStatus); assertFalse(psmp.isStartWhenPrepared()); callback.cancel(); psmp.shutdown(); @@ -214,7 +215,7 @@ public class PlaybackServiceMediaPlayerTest { throw assertionError; assertTrue(res); - assertTrue(psmp.getPSMPInfo().playerStatus == PlayerStatus.INITIALIZED); + assertSame(PlayerStatus.INITIALIZED, psmp.getPSMPInfo().playerStatus); assertTrue(psmp.isStartWhenPrepared()); callback.cancel(); psmp.shutdown(); @@ -256,7 +257,7 @@ public class PlaybackServiceMediaPlayerTest { if (assertionError != null) throw assertionError; assertTrue(res); - assertTrue(psmp.getPSMPInfo().playerStatus == PlayerStatus.PREPARED); + assertSame(PlayerStatus.PREPARED, psmp.getPSMPInfo().playerStatus); callback.cancel(); psmp.shutdown(); @@ -301,7 +302,7 @@ public class PlaybackServiceMediaPlayerTest { if (assertionError != null) throw assertionError; assertTrue(res); - assertTrue(psmp.getPSMPInfo().playerStatus == PlayerStatus.PLAYING); + assertSame(PlayerStatus.PLAYING, psmp.getPSMPInfo().playerStatus); callback.cancel(); psmp.shutdown(); } @@ -339,7 +340,7 @@ public class PlaybackServiceMediaPlayerTest { if (assertionError != null) throw assertionError; assertTrue(res); - assertTrue(psmp.getPSMPInfo().playerStatus == PlayerStatus.INITIALIZED); + assertSame(PlayerStatus.INITIALIZED, psmp.getPSMPInfo().playerStatus); assertFalse(psmp.isStartWhenPrepared()); callback.cancel(); psmp.shutdown(); @@ -378,7 +379,7 @@ public class PlaybackServiceMediaPlayerTest { if (assertionError != null) throw assertionError; assertTrue(res); - assertTrue(psmp.getPSMPInfo().playerStatus == PlayerStatus.INITIALIZED); + assertSame(PlayerStatus.INITIALIZED, psmp.getPSMPInfo().playerStatus); assertTrue(psmp.isStartWhenPrepared()); callback.cancel(); psmp.shutdown(); @@ -420,7 +421,7 @@ public class PlaybackServiceMediaPlayerTest { if (assertionError != null) throw assertionError; assertTrue(res); - assertTrue(psmp.getPSMPInfo().playerStatus == PlayerStatus.PREPARED); + assertSame(PlayerStatus.PREPARED, psmp.getPSMPInfo().playerStatus); callback.cancel(); psmp.shutdown(); } @@ -465,7 +466,7 @@ public class PlaybackServiceMediaPlayerTest { if (assertionError != null) throw assertionError; assertTrue(res); - assertTrue(psmp.getPSMPInfo().playerStatus == PlayerStatus.PLAYING); + assertSame(PlayerStatus.PLAYING, psmp.getPSMPInfo().playerStatus); callback.cancel(); psmp.shutdown(); } diff --git a/app/src/androidTest/java/de/test/antennapod/service/playback/PlaybackServiceTaskManagerTest.java b/app/src/androidTest/java/de/test/antennapod/service/playback/PlaybackServiceTaskManagerTest.java index fce78ea4f..f039c8bdf 100644 --- a/app/src/androidTest/java/de/test/antennapod/service/playback/PlaybackServiceTaskManagerTest.java +++ b/app/src/androidTest/java/de/test/antennapod/service/playback/PlaybackServiceTaskManagerTest.java @@ -1,7 +1,7 @@ package de.test.antennapod.service.playback; import android.content.Context; -import androidx.test.InstrumentationRegistry; +import androidx.test.platform.app.InstrumentationRegistry; import androidx.test.annotation.UiThreadTest; import androidx.test.filters.LargeTest; @@ -29,6 +29,7 @@ import de.danoeh.antennapod.core.storage.PodDBAdapter; import de.danoeh.antennapod.core.util.playback.Playable; import static de.test.antennapod.util.event.FeedItemEventListener.withFeedItemEventListener; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; @@ -92,9 +93,9 @@ public class PlaybackServiceTaskManagerTest { PlaybackServiceTaskManager pstm = new PlaybackServiceTaskManager(c, defaultPSTM); List<FeedItem> testQueue = pstm.getQueue(); assertNotNull(testQueue); - assertTrue(queue.size() == testQueue.size()); + assertEquals(testQueue.size(), queue.size()); for (int i = 0; i < queue.size(); i++) { - assertTrue(queue.get(i).getId() == testQueue.get(i).getId()); + assertEquals(testQueue.get(i).getId(), queue.get(i).getId()); } pstm.shutdown(); } @@ -114,9 +115,9 @@ public class PlaybackServiceTaskManagerTest { assertNotNull(queue); testQueue = pstm.getQueue(); assertNotNull(testQueue); - assertTrue(queue.size() == testQueue.size()); + assertEquals(testQueue.size(), queue.size()); for (int i = 0; i < queue.size(); i++) { - assertTrue(queue.get(i).getId() == testQueue.get(i).getId()); + assertEquals(testQueue.get(i).getId(), queue.get(i).getId()); } pstm.shutdown(); } @@ -171,7 +172,7 @@ public class PlaybackServiceTaskManagerTest { } @Override - public void onSleepTimerAlmostExpired() { + public void onSleepTimerAlmostExpired(long timeLeft) { } @@ -232,7 +233,7 @@ public class PlaybackServiceTaskManagerTest { } @Override - public void onSleepTimerAlmostExpired() { + public void onSleepTimerAlmostExpired(long timeLeft) { } @@ -329,7 +330,7 @@ public class PlaybackServiceTaskManagerTest { } @Override - public void onSleepTimerAlmostExpired() { + public void onSleepTimerAlmostExpired(long timeLeft) { } @@ -375,7 +376,7 @@ public class PlaybackServiceTaskManagerTest { } @Override - public void onSleepTimerAlmostExpired() { + public void onSleepTimerAlmostExpired(long timeLeft) { } @@ -433,7 +434,7 @@ public class PlaybackServiceTaskManagerTest { } @Override - public void onSleepTimerAlmostExpired() { + public void onSleepTimerAlmostExpired(long timeLeft) { } |