Search in sources :

Example 11 with PlaybackServiceTaskManager

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

the class PlaybackServiceTaskManagerTest method testStartPositionSaver.

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

        @Override
        public void positionSaverTick() {
            countDownLatch.countDown();
        }

        @Override
        public void onSleepTimerAlmostExpired() {
        }

        @Override
        public void onSleepTimerExpired() {
        }

        @Override
        public void onSleepTimerReset() {
        }

        @Override
        public void onWidgetUpdaterTick() {
        }

        @Override
        public void onChapterLoaded(Playable media) {
        }
    });
    pstm.startPositionSaver();
    countDownLatch.await(TIMEOUT, TimeUnit.MILLISECONDS);
    pstm.shutdown();
}
Also used : Context(android.content.Context) Playable(de.danoeh.antennapod.core.util.playback.Playable) PlaybackServiceTaskManager(de.danoeh.antennapod.core.service.playback.PlaybackServiceTaskManager) CountDownLatch(java.util.concurrent.CountDownLatch)

Example 12 with PlaybackServiceTaskManager

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

the class PlaybackServiceTaskManagerTest method testIsSleepTimerActiveNegative.

public void testIsSleepTimerActiveNegative() {
    final Context c = getInstrumentation().getTargetContext();
    PlaybackServiceTaskManager pstm = new PlaybackServiceTaskManager(c, defaultPSTM);
    pstm.setSleepTimer(10000, false, false);
    pstm.disableSleepTimer();
    assertFalse(pstm.isSleepTimerActive());
    pstm.shutdown();
}
Also used : Context(android.content.Context) PlaybackServiceTaskManager(de.danoeh.antennapod.core.service.playback.PlaybackServiceTaskManager)

Example 13 with PlaybackServiceTaskManager

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

the class PlaybackServiceTaskManagerTest method testDisableSleepTimer.

public void testDisableSleepTimer() throws InterruptedException {
    final Context c = getInstrumentation().getTargetContext();
    final long TIME = 1000;
    final long TIMEOUT = 2 * TIME;
    final CountDownLatch countDownLatch = new CountDownLatch(1);
    PlaybackServiceTaskManager pstm = new PlaybackServiceTaskManager(c, new PlaybackServiceTaskManager.PSTMCallback() {

        @Override
        public void positionSaverTick() {
        }

        @Override
        public void onSleepTimerAlmostExpired() {
        }

        @Override
        public void onSleepTimerExpired() {
            fail("Sleeptimer expired");
        }

        @Override
        public void onSleepTimerReset() {
        }

        @Override
        public void onWidgetUpdaterTick() {
        }

        @Override
        public void onChapterLoaded(Playable media) {
        }
    });
    pstm.setSleepTimer(TIME, false, false);
    pstm.disableSleepTimer();
    assertFalse(countDownLatch.await(TIMEOUT, TimeUnit.MILLISECONDS));
    pstm.shutdown();
}
Also used : Context(android.content.Context) Playable(de.danoeh.antennapod.core.util.playback.Playable) PlaybackServiceTaskManager(de.danoeh.antennapod.core.service.playback.PlaybackServiceTaskManager) CountDownLatch(java.util.concurrent.CountDownLatch)

Example 14 with PlaybackServiceTaskManager

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

the class PlaybackServiceTaskManagerTest method testIsSleepTimerActivePositive.

public void testIsSleepTimerActivePositive() {
    final Context c = getInstrumentation().getTargetContext();
    PlaybackServiceTaskManager pstm = new PlaybackServiceTaskManager(c, defaultPSTM);
    pstm.setSleepTimer(10000, false, false);
    assertTrue(pstm.isSleepTimerActive());
    pstm.shutdown();
}
Also used : Context(android.content.Context) PlaybackServiceTaskManager(de.danoeh.antennapod.core.service.playback.PlaybackServiceTaskManager)

Example 15 with PlaybackServiceTaskManager

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

the class PlaybackServiceTaskManagerTest method testIsPositionSaverActive.

public void testIsPositionSaverActive() {
    final Context c = getInstrumentation().getTargetContext();
    PlaybackServiceTaskManager pstm = new PlaybackServiceTaskManager(c, defaultPSTM);
    pstm.startPositionSaver();
    assertTrue(pstm.isPositionSaverActive());
    pstm.shutdown();
}
Also used : Context(android.content.Context) PlaybackServiceTaskManager(de.danoeh.antennapod.core.service.playback.PlaybackServiceTaskManager)

Aggregations

PlaybackServiceTaskManager (de.danoeh.antennapod.core.service.playback.PlaybackServiceTaskManager)15 Context (android.content.Context)14 CountDownLatch (java.util.concurrent.CountDownLatch)5 Playable (de.danoeh.antennapod.core.util.playback.Playable)4 FeedItem (de.danoeh.antennapod.core.feed.FeedItem)2 EventDistributor (de.danoeh.antennapod.core.feed.EventDistributor)1