use of de.danoeh.antennapod.core.feed.EventDistributor 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