use of de.danoeh.antennapod.core.service.playback.PlaybackServiceTaskManager in project AntennaPod by AntennaPod.
the class PlaybackServiceTaskManagerTest method testIsWidgetUpdaterActive.
public void testIsWidgetUpdaterActive() {
final Context c = getInstrumentation().getTargetContext();
PlaybackServiceTaskManager pstm = new PlaybackServiceTaskManager(c, defaultPSTM);
pstm.startWidgetUpdater();
assertTrue(pstm.isWidgetUpdaterActive());
pstm.shutdown();
}
use of de.danoeh.antennapod.core.service.playback.PlaybackServiceTaskManager in project AntennaPod by AntennaPod.
the class PlaybackServiceTaskManagerTest method testCancelAllTasksNoTasksStarted.
public void testCancelAllTasksNoTasksStarted() {
final Context c = getInstrumentation().getTargetContext();
PlaybackServiceTaskManager pstm = new PlaybackServiceTaskManager(c, defaultPSTM);
pstm.cancelAllTasks();
assertFalse(pstm.isPositionSaverActive());
assertFalse(pstm.isWidgetUpdaterActive());
assertFalse(pstm.isSleepTimerActive());
pstm.shutdown();
}
use of de.danoeh.antennapod.core.service.playback.PlaybackServiceTaskManager in project AntennaPod by AntennaPod.
the class PlaybackServiceTaskManagerTest method testStartWidgetUpdater.
public void testStartWidgetUpdater() throws InterruptedException {
final Context c = 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 void onSleepTimerAlmostExpired() {
}
@Override
public void onSleepTimerExpired() {
}
@Override
public void onSleepTimerReset() {
}
@Override
public void onWidgetUpdaterTick() {
countDownLatch.countDown();
}
@Override
public void onChapterLoaded(Playable media) {
}
});
pstm.startWidgetUpdater();
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 testCancelPositionSaver.
public void testCancelPositionSaver() {
final Context c = getInstrumentation().getTargetContext();
PlaybackServiceTaskManager pstm = new PlaybackServiceTaskManager(c, defaultPSTM);
pstm.startPositionSaver();
pstm.cancelPositionSaver();
assertFalse(pstm.isPositionSaverActive());
pstm.shutdown();
}
use of de.danoeh.antennapod.core.service.playback.PlaybackServiceTaskManager in project AntennaPod by AntennaPod.
the class PlaybackServiceTaskManagerTest method testGetQueueWriteAfterCreation.
public void testGetQueueWriteAfterCreation() throws InterruptedException {
final Context c = getInstrumentation().getTargetContext();
PlaybackServiceTaskManager pstm = new PlaybackServiceTaskManager(c, defaultPSTM);
List<FeedItem> testQueue = pstm.getQueue();
assertNotNull(testQueue);
assertTrue(testQueue.isEmpty());
final CountDownLatch countDownLatch = new CountDownLatch(1);
EventDistributor.EventListener queueListener = new EventDistributor.EventListener() {
@Override
public void update(EventDistributor eventDistributor, Integer arg) {
countDownLatch.countDown();
}
};
EventDistributor.getInstance().register(queueListener);
List<FeedItem> queue = writeTestQueue("a");
EventBus.getDefault().post(QueueEvent.setQueue(queue));
countDownLatch.await(5000, TimeUnit.MILLISECONDS);
assertNotNull(queue);
testQueue = pstm.getQueue();
assertNotNull(testQueue);
assertTrue(queue.size() == testQueue.size());
for (int i = 0; i < queue.size(); i++) {
assertTrue(queue.get(i).getId() == testQueue.get(i).getId());
}
pstm.shutdown();
}
Aggregations