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();
}
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();
}
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();
}
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();
}
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();
}
Aggregations