Search in sources :

Example 1 with EventDistributor

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();
}
Also used : Context(android.content.Context) FeedItem(de.danoeh.antennapod.core.feed.FeedItem) EventDistributor(de.danoeh.antennapod.core.feed.EventDistributor) PlaybackServiceTaskManager(de.danoeh.antennapod.core.service.playback.PlaybackServiceTaskManager) CountDownLatch(java.util.concurrent.CountDownLatch)

Aggregations

Context (android.content.Context)1 EventDistributor (de.danoeh.antennapod.core.feed.EventDistributor)1 FeedItem (de.danoeh.antennapod.core.feed.FeedItem)1 PlaybackServiceTaskManager (de.danoeh.antennapod.core.service.playback.PlaybackServiceTaskManager)1 CountDownLatch (java.util.concurrent.CountDownLatch)1