summaryrefslogtreecommitdiff
path: root/ui/common
diff options
context:
space:
mode:
authorByteHamster <ByteHamster@users.noreply.github.com>2024-03-31 18:40:15 +0200
committerGitHub <noreply@github.com>2024-03-31 18:40:15 +0200
commitedb440a5a9a05e24c344a71b272b9238217e9c55 (patch)
tree13623ca7d0dac052ac35d693aac940d0727c87f9 /ui/common
parent4e47691e70e85736c7eeb30ce02c73176e565a86 (diff)
downloadAntennaPod-edb440a5a9a05e24c344a71b272b9238217e9c55.zip
Restructure related UI classes together (#7044)
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));
+ }
+}