mirror of
https://github.com/AntennaPod/AntennaPod.git
synced 2024-12-28 01:32:15 +01:00
Moved some implementation tests to unit tests
This commit is contained in:
parent
1593a06077
commit
c50d37fa1b
@ -1,33 +1,37 @@
|
||||
package de.test.antennapod.util;
|
||||
package de.danoeh.antennapod.core.util;
|
||||
|
||||
import android.test.AndroidTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import de.danoeh.antennapod.core.util.Converter;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Test class for converter
|
||||
*/
|
||||
public class ConverterTest extends AndroidTestCase {
|
||||
public class ConverterTest {
|
||||
|
||||
public void testGetDurationStringLong() throws Exception {
|
||||
@Test
|
||||
public void testGetDurationStringLong() {
|
||||
String expected = "13:05:10";
|
||||
int input = 47110000;
|
||||
assertEquals(expected, Converter.getDurationStringLong(input));
|
||||
}
|
||||
|
||||
public void testGetDurationStringShort() throws Exception {
|
||||
@Test
|
||||
public void testGetDurationStringShort() {
|
||||
String expected = "13:05";
|
||||
assertEquals(expected, Converter.getDurationStringShort(47110000, true));
|
||||
assertEquals(expected, Converter.getDurationStringShort(785000, false));
|
||||
}
|
||||
|
||||
public void testDurationStringLongToMs() throws Exception {
|
||||
@Test
|
||||
public void testDurationStringLongToMs() {
|
||||
String input = "01:20:30";
|
||||
long expected = 4830000;
|
||||
assertEquals(expected, Converter.durationStringLongToMs(input));
|
||||
}
|
||||
|
||||
public void testDurationStringShortToMs() throws Exception {
|
||||
@Test
|
||||
public void testDurationStringShortToMs() {
|
||||
String input = "8:30";
|
||||
assertEquals(30600000, Converter.durationStringShortToMs(input, true));
|
||||
assertEquals(510000, Converter.durationStringShortToMs(input, false));
|
@ -1,14 +1,15 @@
|
||||
package de.test.antennapod.util;
|
||||
package de.danoeh.antennapod.core.util;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import de.danoeh.antennapod.core.util.RewindAfterPauseUtils;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Tests for {@link RewindAfterPauseUtils}.
|
||||
*/
|
||||
public class RewindAfterPauseUtilTest extends TestCase {
|
||||
public class RewindAfterPauseUtilTest {
|
||||
|
||||
@Test
|
||||
public void testCalculatePositionWithRewindNoRewind() {
|
||||
final int ORIGINAL_POSITION = 10000;
|
||||
long lastPlayed = System.currentTimeMillis();
|
||||
@ -17,6 +18,7 @@ public class RewindAfterPauseUtilTest extends TestCase {
|
||||
assertEquals(ORIGINAL_POSITION, position);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCalculatePositionWithRewindSmallRewind() {
|
||||
final int ORIGINAL_POSITION = 10000;
|
||||
long lastPlayed = System.currentTimeMillis() - RewindAfterPauseUtils.ELAPSED_TIME_FOR_SHORT_REWIND - 1000;
|
||||
@ -25,6 +27,7 @@ public class RewindAfterPauseUtilTest extends TestCase {
|
||||
assertEquals(ORIGINAL_POSITION - RewindAfterPauseUtils.SHORT_REWIND, position);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCalculatePositionWithRewindMediumRewind() {
|
||||
final int ORIGINAL_POSITION = 10000;
|
||||
long lastPlayed = System.currentTimeMillis() - RewindAfterPauseUtils.ELAPSED_TIME_FOR_MEDIUM_REWIND - 1000;
|
||||
@ -33,6 +36,7 @@ public class RewindAfterPauseUtilTest extends TestCase {
|
||||
assertEquals(ORIGINAL_POSITION - RewindAfterPauseUtils.MEDIUM_REWIND, position);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCalculatePositionWithRewindLongRewind() {
|
||||
final int ORIGINAL_POSITION = 30000;
|
||||
long lastPlayed = System.currentTimeMillis() - RewindAfterPauseUtils.ELAPSED_TIME_FOR_LONG_REWIND - 1000;
|
||||
@ -41,6 +45,7 @@ public class RewindAfterPauseUtilTest extends TestCase {
|
||||
assertEquals(ORIGINAL_POSITION - RewindAfterPauseUtils.LONG_REWIND, position);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCalculatePositionWithRewindNegativeNumber() {
|
||||
final int ORIGINAL_POSITION = 100;
|
||||
long lastPlayed = System.currentTimeMillis() - RewindAfterPauseUtils.ELAPSED_TIME_FOR_LONG_REWIND - 1000;
|
@ -1,19 +1,21 @@
|
||||
package de.test.antennapod.util;
|
||||
package de.danoeh.antennapod.core.util;
|
||||
|
||||
import android.test.AndroidTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import de.danoeh.antennapod.core.util.URIUtil;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Test class for URIUtil
|
||||
*/
|
||||
public class URIUtilTest extends AndroidTestCase {
|
||||
public class URIUtilTest {
|
||||
|
||||
@Test
|
||||
public void testGetURIFromRequestUrlShouldNotEncode() {
|
||||
final String testUrl = "http://example.com/this%20is%20encoded";
|
||||
assertEquals(testUrl, URIUtil.getURIFromRequestUrl(testUrl).toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetURIFromRequestUrlShouldEncode() {
|
||||
final String testUrl = "http://example.com/this is not encoded";
|
||||
final String expected = "http://example.com/this%20is%20not%20encoded";
|
Loading…
Reference in New Issue
Block a user