diff options
Diffstat (limited to 'core/src')
4 files changed, 120 insertions, 0 deletions
diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml index dd6053b5d..374cd7360 100644 --- a/core/src/main/res/values/strings.xml +++ b/core/src/main/res/values/strings.xml @@ -331,6 +331,7 @@ <string name="automation">Automation</string> <string name="download_pref_details">Details</string> <string name="import_export_pref">Import/Export</string> + <string name="import_export_search_keywords">backup, restore</string> <string name="appearance">Appearance</string> <string name="external_elements">External elements</string> <string name="interruptions">Interruptions</string> diff --git a/core/src/test/java/de/danoeh/antennapod/core/util/ConverterTest.java b/core/src/test/java/de/danoeh/antennapod/core/util/ConverterTest.java new file mode 100644 index 000000000..54e5462d0 --- /dev/null +++ b/core/src/test/java/de/danoeh/antennapod/core/util/ConverterTest.java @@ -0,0 +1,39 @@ +package de.danoeh.antennapod.core.util; + +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +/** + * Test class for converter + */ +public class ConverterTest { + + @Test + public void testGetDurationStringLong() { + String expected = "13:05:10"; + int input = 47110000; + assertEquals(expected, Converter.getDurationStringLong(input)); + } + + @Test + public void testGetDurationStringShort() { + String expected = "13:05"; + assertEquals(expected, Converter.getDurationStringShort(47110000, true)); + assertEquals(expected, Converter.getDurationStringShort(785000, false)); + } + + @Test + public void testDurationStringLongToMs() { + String input = "01:20:30"; + long expected = 4830000; + assertEquals(expected, Converter.durationStringLongToMs(input)); + } + + @Test + public void testDurationStringShortToMs() { + String input = "8:30"; + assertEquals(30600000, Converter.durationStringShortToMs(input, true)); + assertEquals(510000, Converter.durationStringShortToMs(input, false)); + } +} diff --git a/core/src/test/java/de/danoeh/antennapod/core/util/RewindAfterPauseUtilTest.java b/core/src/test/java/de/danoeh/antennapod/core/util/RewindAfterPauseUtilTest.java new file mode 100644 index 000000000..dc64f6ae0 --- /dev/null +++ b/core/src/test/java/de/danoeh/antennapod/core/util/RewindAfterPauseUtilTest.java @@ -0,0 +1,56 @@ +package de.danoeh.antennapod.core.util; + +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +/** + * Tests for {@link RewindAfterPauseUtils}. + */ +public class RewindAfterPauseUtilTest { + + @Test + public void testCalculatePositionWithRewindNoRewind() { + final int ORIGINAL_POSITION = 10000; + long lastPlayed = System.currentTimeMillis(); + int position = RewindAfterPauseUtils.calculatePositionWithRewind(ORIGINAL_POSITION, lastPlayed); + + assertEquals(ORIGINAL_POSITION, position); + } + + @Test + 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); + } + + @Test + 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); + } + + @Test + 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); + } + + @Test + 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); + } +} diff --git a/core/src/test/java/de/danoeh/antennapod/core/util/URIUtilTest.java b/core/src/test/java/de/danoeh/antennapod/core/util/URIUtilTest.java new file mode 100644 index 000000000..3feb4d376 --- /dev/null +++ b/core/src/test/java/de/danoeh/antennapod/core/util/URIUtilTest.java @@ -0,0 +1,24 @@ +package de.danoeh.antennapod.core.util; + +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +/** + * Test class for URIUtil + */ +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"; + assertEquals(expected, URIUtil.getURIFromRequestUrl(testUrl).toString()); + } +} |