Search in sources :

Example 16 with PlaybackServiceTaskManager

use of de.danoeh.antennapod.core.service.playback.PlaybackServiceTaskManager in project AntennaPod by AntennaPod.

the class PlaybackServiceTaskManagerTest method testStartWidgetUpdater.

@Test
public void testStartWidgetUpdater() throws InterruptedException {
    final Context c = InstrumentationRegistry.getInstrumentation().getTargetContext();
    final int NUM_COUNTDOWNS = 2;
    final int TIMEOUT = 3 * PlaybackServiceTaskManager.WIDGET_UPDATER_NOTIFICATION_INTERVAL;
    final CountDownLatch countDownLatch = new CountDownLatch(NUM_COUNTDOWNS);
    PlaybackServiceTaskManager pstm = new PlaybackServiceTaskManager(c, new PlaybackServiceTaskManager.PSTMCallback() {

        @Override
        public void positionSaverTick() {
        }

        @Override
        public WidgetUpdater.WidgetState requestWidgetState() {
            countDownLatch.countDown();
            return null;
        }

        @Override
        public void onChapterLoaded(Playable media) {
        }
    });
    pstm.startWidgetUpdater();
    countDownLatch.await(TIMEOUT, TimeUnit.MILLISECONDS);
    pstm.shutdown();
}
Also used : Context(android.content.Context) Playable(de.danoeh.antennapod.model.playback.Playable) PlaybackServiceTaskManager(de.danoeh.antennapod.core.service.playback.PlaybackServiceTaskManager) CountDownLatch(java.util.concurrent.CountDownLatch) LargeTest(androidx.test.filters.LargeTest) Test(org.junit.Test) UiThreadTest(androidx.test.annotation.UiThreadTest)

Aggregations

Context (android.content.Context)16 PlaybackServiceTaskManager (de.danoeh.antennapod.core.service.playback.PlaybackServiceTaskManager)16 UiThreadTest (androidx.test.annotation.UiThreadTest)14 LargeTest (androidx.test.filters.LargeTest)14 Test (org.junit.Test)14 CountDownLatch (java.util.concurrent.CountDownLatch)5 FeedItem (de.danoeh.antennapod.core.feed.FeedItem)2 SleepTimerUpdatedEvent (de.danoeh.antennapod.event.playback.SleepTimerUpdatedEvent)2 Playable (de.danoeh.antennapod.model.playback.Playable)2 EventDistributor (de.danoeh.antennapod.core.feed.EventDistributor)1