blob: fcfb16eb4c60956f6aa6ea0b50d3754f3b31e59d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
package de.test.antennapod.util;
import junit.framework.*;
import de.danoeh.antennapod.core.util.*;
/**
* Tests for {@link RewindAfterPauseUtils}.
*/
public class RewindAfterPauseUtilTest extends TestCase {
public void testCalculatePositionWithRewindNoRewind() {
final int ORIGINAL_POSITION = 10000;
long lastPlayed = System.currentTimeMillis();
int position = RewindAfterPauseUtils.calculatePositionWithRewind(ORIGINAL_POSITION, lastPlayed);
assertEquals(ORIGINAL_POSITION, position);
}
public void testCalculatePositionWithRewindSmallRewind() {
final int ORIGINAL_POSITION = 10000;
long lastPlayed = System.currentTimeMillis() - RewindAfterPauseUtils.ELAPSED_TIME_FOR_SHORT_REWIND - 1000;
int position = RewindAfterPauseUtils.calculatePositionWithRewind(ORIGINAL_POSITION, lastPlayed);
assertEquals(ORIGINAL_POSITION - RewindAfterPauseUtils.SHORT_REWIND, position);
}
public void testCalculatePositionWithRewindMediumRewind() {
final int ORIGINAL_POSITION = 10000;
long lastPlayed = System.currentTimeMillis() - RewindAfterPauseUtils.ELAPSED_TIME_FOR_MEDIUM_REWIND - 1000;
int position = RewindAfterPauseUtils.calculatePositionWithRewind(ORIGINAL_POSITION, lastPlayed);
assertEquals(ORIGINAL_POSITION - RewindAfterPauseUtils.MEDIUM_REWIND, position);
}
public void testCalculatePositionWithRewindLongRewind() {
final int ORIGINAL_POSITION = 30000;
long lastPlayed = System.currentTimeMillis() - RewindAfterPauseUtils.ELAPSED_TIME_FOR_LONG_REWIND - 1000;
int position = RewindAfterPauseUtils.calculatePositionWithRewind(ORIGINAL_POSITION, lastPlayed);
assertEquals(ORIGINAL_POSITION - RewindAfterPauseUtils.LONG_REWIND, position);
}
public void testCalculatePositionWithRewindNegativeNumber() {
final int ORIGINAL_POSITION = 100;
long lastPlayed = System.currentTimeMillis() - RewindAfterPauseUtils.ELAPSED_TIME_FOR_LONG_REWIND - 1000;
int position = RewindAfterPauseUtils.calculatePositionWithRewind(ORIGINAL_POSITION, lastPlayed);
assertEquals(0, position);
}
}
|