diff options
author | ByteHamster <info@bytehamster.com> | 2022-01-06 12:36:06 +0100 |
---|---|---|
committer | ByteHamster <info@bytehamster.com> | 2022-01-06 12:36:11 +0100 |
commit | 485db9ebcd1a8799eed2036bf0d9c2ca210deecb (patch) | |
tree | 2088bc8e2c1730803a32bad80358b585bb992201 /app/src/androidTest/java | |
parent | 38c470eacec8f083e5d1ab440edbe4ea617d7486 (diff) | |
download | AntennaPod-485db9ebcd1a8799eed2036bf0d9c2ca210deecb.zip |
Remove queue loading logic from PlaybackServiceTaskManager
This just causes problems with keeping the preloaded list up-to-date.
We only call the method from background threads anyway.
Diffstat (limited to 'app/src/androidTest/java')
-rw-r--r-- | app/src/androidTest/java/de/test/antennapod/service/playback/PlaybackServiceTaskManagerTest.java | 82 |
1 files changed, 0 insertions, 82 deletions
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 013d4db50..17d3d2e17 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 @@ -8,7 +8,6 @@ import androidx.test.filters.LargeTest; import de.danoeh.antennapod.event.playback.SleepTimerUpdatedEvent; import de.danoeh.antennapod.core.preferences.SleepTimerPreferences; import de.danoeh.antennapod.core.widget.WidgetUpdater; -import org.awaitility.Awaitility; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; import org.junit.After; @@ -21,20 +20,13 @@ import java.util.List; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import de.danoeh.antennapod.event.QueueEvent; import de.danoeh.antennapod.model.feed.Feed; import de.danoeh.antennapod.model.feed.FeedItem; -import de.danoeh.antennapod.model.feed.FeedMedia; import de.danoeh.antennapod.core.service.playback.PlaybackServiceTaskManager; -import de.danoeh.antennapod.core.storage.DBReader; -import de.danoeh.antennapod.core.storage.DBWriter; import de.danoeh.antennapod.core.storage.PodDBAdapter; import de.danoeh.antennapod.model.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; import static org.junit.Assert.fail; @@ -89,80 +81,6 @@ public class PlaybackServiceTaskManagerTest { } @Test - public void testGetQueueWriteBeforeCreation() throws InterruptedException { - final Context c = InstrumentationRegistry.getInstrumentation().getTargetContext(); - List<FeedItem> queue = writeTestQueue("a"); - assertNotNull(queue); - PlaybackServiceTaskManager pstm = new PlaybackServiceTaskManager(c, defaultPSTM); - List<FeedItem> testQueue = pstm.getQueue(); - assertNotNull(testQueue); - assertEquals(testQueue.size(), queue.size()); - for (int i = 0; i < queue.size(); i++) { - assertEquals(testQueue.get(i).getId(), queue.get(i).getId()); - } - pstm.shutdown(); - } - - @Test - public void testGetQueueWriteAfterCreation() throws InterruptedException { - final Context c = InstrumentationRegistry.getInstrumentation().getTargetContext(); - - PlaybackServiceTaskManager pstm = new PlaybackServiceTaskManager(c, defaultPSTM); - List<FeedItem> testQueue = pstm.getQueue(); - assertNotNull(testQueue); - assertTrue(testQueue.isEmpty()); - - List<FeedItem> queue = writeTestQueue("a"); - EventBus.getDefault().post(QueueEvent.setQueue(queue)); - - assertNotNull(queue); - testQueue = pstm.getQueue(); - assertNotNull(testQueue); - assertEquals(testQueue.size(), queue.size()); - for (int i = 0; i < queue.size(); i++) { - assertEquals(testQueue.get(i).getId(), queue.get(i).getId()); - } - pstm.shutdown(); - } - - @Test - public void testQueueUpdatedUponDownloadComplete() throws Exception { - final Context c = InstrumentationRegistry.getInstrumentation().getTargetContext(); - { // Setup test data - List<FeedItem> queue = writeTestQueue("a"); - FeedItem item = DBReader.getFeedItem(queue.get(0).getId()); - FeedMedia media = new FeedMedia(item, "http://example.com/episode.mp3", 12345, "audio/mp3"); - item.setMedia(media); - DBWriter.setFeedMedia(media).get(); - DBWriter.setFeedItem(item).get(); - } - - PlaybackServiceTaskManager pstm = new PlaybackServiceTaskManager(c, defaultPSTM); - final FeedItem testItem = pstm.getQueue().get(0); - assertFalse("The item should not yet be downloaded", testItem.getMedia().isDownloaded()); - - withFeedItemEventListener( feedItemEventListener -> { - // simulate download complete (in DownloadService.MediaHandlerThread) - FeedItem item = DBReader.getFeedItem(testItem.getId()); - item.getMedia().setDownloaded(true); - item.getMedia().setFile_url("file://123"); - item.disableAutoDownload(); - DBWriter.setFeedMedia(item.getMedia()).get(); - DBWriter.setFeedItem(item).get(); - - Awaitility.await() - .atMost(1000, TimeUnit.MILLISECONDS) - .until(() -> feedItemEventListener.getEvents().size() > 0); - - final FeedItem itemUpdated = pstm.getQueue().get(0); - assertTrue("media.isDownloaded() should be true - The queue in PlaybackService should be updated after download is completed", - itemUpdated.getMedia().isDownloaded()); - }); - - pstm.shutdown(); - } - - @Test public void testStartPositionSaver() throws InterruptedException { final Context c = InstrumentationRegistry.getInstrumentation().getTargetContext(); final int NUM_COUNTDOWNS = 2; |