summaryrefslogtreecommitdiff
path: root/ui/common
diff options
context:
space:
mode:
Diffstat (limited to 'ui/common')
-rw-r--r--ui/common/build.gradle2
-rw-r--r--ui/common/src/test/java/de/danoeh/antennapod/ui/common/ConverterTest.java40
2 files changed, 42 insertions, 0 deletions
diff --git a/ui/common/build.gradle b/ui/common/build.gradle
index 26db9f9e4..1325761d3 100644
--- a/ui/common/build.gradle
+++ b/ui/common/build.gradle
@@ -16,4 +16,6 @@ dependencies {
implementation "androidx.viewpager2:viewpager2:$viewPager2Version"
implementation "com.google.android.material:material:$googleMaterialVersion"
implementation "androidx.core:core-splashscreen:1.0.0"
+
+ testImplementation "junit:junit:$junitVersion"
}
diff --git a/ui/common/src/test/java/de/danoeh/antennapod/ui/common/ConverterTest.java b/ui/common/src/test/java/de/danoeh/antennapod/ui/common/ConverterTest.java
new file mode 100644
index 000000000..516490ff3
--- /dev/null
+++ b/ui/common/src/test/java/de/danoeh/antennapod/ui/common/ConverterTest.java
@@ -0,0 +1,40 @@
+package de.danoeh.antennapod.ui.common;
+
+import de.danoeh.antennapod.ui.common.Converter;
+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));
+ }
+}