From 9180be85ba216e501b6ccfac9f9eba20d40d0021 Mon Sep 17 00:00:00 2001 From: Nathan Mascitelli Date: Sun, 10 Feb 2019 17:59:40 -0500 Subject: Update tests to handle minute timestamps The definition of 'short timestamp' now means minutes and seconds, while 'long timestamp' means hours, minutes, and seconds. The first part of a timestamp may have one or two digits. Tests updated for this new definition. --- .../de/test/antennapod/util/ConverterTest.java | 4 +-- .../antennapod/util/playback/TimelineTest.java | 30 ++++++++++++++++++---- 2 files changed, 27 insertions(+), 7 deletions(-) (limited to 'app/src/androidTest') diff --git a/app/src/androidTest/java/de/test/antennapod/util/ConverterTest.java b/app/src/androidTest/java/de/test/antennapod/util/ConverterTest.java index 47fca41ba..c7ed7d812 100644 --- a/app/src/androidTest/java/de/test/antennapod/util/ConverterTest.java +++ b/app/src/androidTest/java/de/test/antennapod/util/ConverterTest.java @@ -17,7 +17,7 @@ public class ConverterTest extends AndroidTestCase { public void testGetDurationStringShort() throws Exception { String expected = "13:05"; - int input = 47110000; + int input = 785000; assertEquals(expected, Converter.getDurationStringShort(input)); } @@ -29,7 +29,7 @@ public class ConverterTest extends AndroidTestCase { public void testDurationStringShortToMs() throws Exception { String input = "8:30"; - long expected = 30600000; + long expected = 510000; assertEquals(expected, Converter.durationStringShortToMs(input)); } } diff --git a/app/src/androidTest/java/de/test/antennapod/util/playback/TimelineTest.java b/app/src/androidTest/java/de/test/antennapod/util/playback/TimelineTest.java index 7e535e12c..40e6605d7 100644 --- a/app/src/androidTest/java/de/test/antennapod/util/playback/TimelineTest.java +++ b/app/src/androidTest/java/de/test/antennapod/util/playback/TimelineTest.java @@ -50,9 +50,29 @@ public class TimelineTest extends InstrumentationTestCase { checkLinkCorrect(res, new long[]{time}, new String[]{timeStr}); } - public void testProcessShownotesAddTimecodeHHMMNoChapters() throws Exception { + public void testProcessShownotesAddTimecodeHMMSSNoChapters() throws Exception { + final String timeStr = "2:11:12"; + final long time = 2 * 60 * 60 * 1000 + 11 * 60 * 1000 + 12 * 1000; + + Playable p = newTestPlayable(null, "

Some test text with a timecode " + timeStr + " here.

"); + Timeline t = new Timeline(context, p); + String res = t.processShownotes(true); + checkLinkCorrect(res, new long[]{time}, new String[]{timeStr}); + } + + public void testProcessShownotesAddTimecodeMSSNoChapters() throws Exception { + final String timeStr = "1:12"; + final long time = 60 * 1000 + 12 * 1000; + + Playable p = newTestPlayable(null, "

Some test text with a timecode " + timeStr + " here.

"); + Timeline t = new Timeline(context, p); + String res = t.processShownotes(true); + checkLinkCorrect(res, new long[]{time}, new String[]{timeStr}); + } + + public void testProcessShownotesAddTimecodeMMSSNoChapters() throws Exception { final String timeStr = "10:11"; - final long time = 3600 * 1000 * 10 + 60 * 1000 * 11; + final long time = 60 * 1000 * 10 + 1000 * 11; Playable p = newTestPlayable(null, "

Some test text with a timecode " + timeStr + " here.

"); Timeline t = new Timeline(context, p); @@ -61,7 +81,7 @@ public class TimelineTest extends InstrumentationTestCase { } public void testProcessShownotesAddTimecodeParentheses() throws Exception { - final String timeStr = "10:11"; + final String timeStr = "10:11:00"; final long time = 3600 * 1000 * 10 + 60 * 1000 * 11; Playable p = newTestPlayable(null, "

Some test text with a timecode (" + timeStr + ") here.

"); @@ -71,7 +91,7 @@ public class TimelineTest extends InstrumentationTestCase { } public void testProcessShownotesAddTimecodeBrackets() throws Exception { - final String timeStr = "10:11"; + final String timeStr = "10:11:00"; final long time = 3600 * 1000 * 10 + 60 * 1000 * 11; Playable p = newTestPlayable(null, "

Some test text with a timecode [" + timeStr + "] here.

"); @@ -81,7 +101,7 @@ public class TimelineTest extends InstrumentationTestCase { } public void testProcessShownotesAddTimecodeAngleBrackets() throws Exception { - final String timeStr = "10:11"; + final String timeStr = "10:11:00"; final long time = 3600 * 1000 * 10 + 60 * 1000 * 11; Playable p = newTestPlayable(null, "

Some test text with a timecode <" + timeStr + "> here.

"); -- cgit v1.2.3