use of de.danoeh.antennapod.core.util.playback.Playable in project AntennaPod by AntennaPod.
the class PlaybackServiceMediaPlayerTest method testPlayMediaObjectLocalNoStartNoPrepare.
public void testPlayMediaObjectLocalNoStartNoPrepare() throws InterruptedException {
final Context c = getInstrumentation().getTargetContext();
final CountDownLatch countDownLatch = new CountDownLatch(2);
PlaybackServiceMediaPlayer.PSMPCallback callback = new DefaultPSMPCallback() {
@Override
public void statusChanged(LocalPSMP.PSMPInfo newInfo) {
try {
checkPSMPInfo(newInfo);
if (newInfo.playerStatus == PlayerStatus.ERROR)
throw new IllegalStateException("MediaPlayer error");
if (countDownLatch.getCount() == 0) {
fail();
} else if (countDownLatch.getCount() == 2) {
assertEquals(PlayerStatus.INITIALIZING, newInfo.playerStatus);
countDownLatch.countDown();
} else {
assertEquals(PlayerStatus.INITIALIZED, newInfo.playerStatus);
countDownLatch.countDown();
}
} catch (AssertionFailedError e) {
if (assertionError == null)
assertionError = e;
}
}
};
PlaybackServiceMediaPlayer psmp = new LocalPSMP(c, callback);
Playable p = writeTestPlayable(PLAYABLE_FILE_URL, PLAYABLE_LOCAL_URL);
psmp.playMediaObject(p, false, false, false);
boolean res = countDownLatch.await(LATCH_TIMEOUT_SECONDS, TimeUnit.SECONDS);
if (assertionError != null)
throw assertionError;
assertTrue(res);
assertTrue(psmp.getPSMPInfo().playerStatus == PlayerStatus.INITIALIZED);
assertFalse(psmp.isStartWhenPrepared());
psmp.shutdown();
}
use of de.danoeh.antennapod.core.util.playback.Playable 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.util.playback.Playable 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.util.playback.Playable 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.util.playback.Playable in project AntennaPod by AntennaPod.
the class TimelineTest method testProcessShownotesAddTimecodeHHMMSSNoChapters.
public void testProcessShownotesAddTimecodeHHMMSSNoChapters() throws Exception {
final String timeStr = "10:11:12";
final long time = 3600 * 1000 * 10 + 60 * 1000 * 11 + 12 * 1000;
Playable p = newTestPlayable(null, "<p> Some test text with a timecode " + timeStr + " here.</p>");
Timeline t = new Timeline(context, p);
String res = t.processShownotes(true);
checkLinkCorrect(res, new long[] { time }, new String[] { timeStr });
}
Aggregations