diff options
author | ByteHamster <ByteHamster@users.noreply.github.com> | 2021-02-22 17:26:28 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-22 17:26:28 +0100 |
commit | 69239e5e67095adbb43ef0e93aed865340a0886d (patch) | |
tree | e48c0fe173ee749ac0f200e64cb5a1c07e7c6a11 | |
parent | d6b6a0691d3194b5de3d9ef374a8927b475e9c63 (diff) | |
parent | 6add59819a34cb620651d8e660909db26242b69a (diff) | |
download | AntennaPod-69239e5e67095adbb43ef0e93aed865340a0886d.zip |
Merge pull request #4955 from ByteHamster/more-chapter-tests
Added auphonic files to chapter marks tests
-rw-r--r-- | core/src/test/java/de/danoeh/antennapod/core/util/id3reader/ChapterReaderTest.java | 31 | ||||
-rw-r--r-- | core/src/test/java/de/danoeh/antennapod/core/util/vorbiscommentreader/VorbisCommentChapterReaderTest.java | 44 | ||||
-rw-r--r-- | core/src/test/resources/media-parser/auphonic.m4a | bin | 0 -> 114657 bytes | |||
-rw-r--r-- | core/src/test/resources/media-parser/auphonic.mp3 | bin | 0 -> 143695 bytes | |||
-rw-r--r-- | core/src/test/resources/media-parser/auphonic.ogg | bin | 0 -> 6565 bytes | |||
-rw-r--r-- | core/src/test/resources/media-parser/auphonic.opus | bin | 0 -> 4189 bytes |
6 files changed, 75 insertions, 0 deletions
diff --git a/core/src/test/java/de/danoeh/antennapod/core/util/id3reader/ChapterReaderTest.java b/core/src/test/java/de/danoeh/antennapod/core/util/id3reader/ChapterReaderTest.java index 9f846c26d..ee4d43131 100644 --- a/core/src/test/java/de/danoeh/antennapod/core/util/id3reader/ChapterReaderTest.java +++ b/core/src/test/java/de/danoeh/antennapod/core/util/id3reader/ChapterReaderTest.java @@ -131,4 +131,35 @@ public class ChapterReaderTest { assertEquals(EmbeddedChapterImage.makeUrl(2766765, 15740), chapters.get(1).getImageUrl()); assertEquals(EmbeddedChapterImage.makeUrl(2782628, 2750569), chapters.get(2).getImageUrl()); } + + @Test + public void testRealFileAuphonic() throws IOException, ID3ReaderException { + CountingInputStream inputStream = new CountingInputStream(getClass().getClassLoader() + .getResource("media-parser/auphonic.mp3").openStream()); + ChapterReader reader = new ChapterReader(inputStream); + reader.readInputStream(); + List<Chapter> chapters = reader.getChapters(); + + assertEquals(4, chapters.size()); + + assertEquals(0, chapters.get(0).getStart()); + assertEquals(3000, chapters.get(1).getStart()); + assertEquals(6000, chapters.get(2).getStart()); + assertEquals(9000, chapters.get(3).getStart()); + + assertEquals("Chapter 1 - ❤️😊", chapters.get(0).getTitle()); + assertEquals("Chapter 2 - ßöÄ", chapters.get(1).getTitle()); + assertEquals("Chapter 3 - 爱", chapters.get(2).getTitle()); + assertEquals("Chapter 4", chapters.get(3).getTitle()); + + assertEquals("https://example.com", chapters.get(0).getLink()); + assertEquals("https://example.com", chapters.get(1).getLink()); + assertEquals("https://example.com", chapters.get(2).getLink()); + assertEquals("https://example.com", chapters.get(3).getLink()); + + assertEquals(EmbeddedChapterImage.makeUrl(765, 308), chapters.get(0).getImageUrl()); + assertEquals(EmbeddedChapterImage.makeUrl(1271, 308), chapters.get(1).getImageUrl()); + assertEquals(EmbeddedChapterImage.makeUrl(1771, 308), chapters.get(2).getImageUrl()); + assertEquals(EmbeddedChapterImage.makeUrl(2259, 308), chapters.get(3).getImageUrl()); + } } diff --git a/core/src/test/java/de/danoeh/antennapod/core/util/vorbiscommentreader/VorbisCommentChapterReaderTest.java b/core/src/test/java/de/danoeh/antennapod/core/util/vorbiscommentreader/VorbisCommentChapterReaderTest.java new file mode 100644 index 000000000..cf9228292 --- /dev/null +++ b/core/src/test/java/de/danoeh/antennapod/core/util/vorbiscommentreader/VorbisCommentChapterReaderTest.java @@ -0,0 +1,44 @@ +package de.danoeh.antennapod.core.util.vorbiscommentreader; + +import de.danoeh.antennapod.core.feed.Chapter; +import org.junit.Test; + +import java.io.IOException; +import java.io.InputStream; +import java.util.List; + +import static org.junit.Assert.assertEquals; + +public class VorbisCommentChapterReaderTest { + + @Test + public void testRealFilesAuphonic() throws IOException, VorbisCommentReaderException { + testRealFileAuphonic("media-parser/auphonic.ogg"); + testRealFileAuphonic("media-parser/auphonic.opus"); + } + + public void testRealFileAuphonic(String filename) throws IOException, VorbisCommentReaderException { + InputStream inputStream = getClass().getClassLoader() + .getResource(filename).openStream(); + VorbisCommentChapterReader reader = new VorbisCommentChapterReader(); + reader.readInputStream(inputStream); + List<Chapter> chapters = reader.getChapters(); + + assertEquals(4, chapters.size()); + + assertEquals(0, chapters.get(0).getStart()); + assertEquals(3000, chapters.get(1).getStart()); + assertEquals(6000, chapters.get(2).getStart()); + assertEquals(9000, chapters.get(3).getStart()); + + assertEquals("Chapter 1 - ❤️😊", chapters.get(0).getTitle()); + assertEquals("Chapter 2 - ßöÄ", chapters.get(1).getTitle()); + assertEquals("Chapter 3 - 爱", chapters.get(2).getTitle()); + assertEquals("Chapter 4", chapters.get(3).getTitle()); + + assertEquals("https://example.com", chapters.get(0).getLink()); + assertEquals("https://example.com", chapters.get(1).getLink()); + assertEquals("https://example.com", chapters.get(2).getLink()); + assertEquals("https://example.com", chapters.get(3).getLink()); + } +} diff --git a/core/src/test/resources/media-parser/auphonic.m4a b/core/src/test/resources/media-parser/auphonic.m4a Binary files differnew file mode 100644 index 000000000..ca59a80f6 --- /dev/null +++ b/core/src/test/resources/media-parser/auphonic.m4a diff --git a/core/src/test/resources/media-parser/auphonic.mp3 b/core/src/test/resources/media-parser/auphonic.mp3 Binary files differnew file mode 100644 index 000000000..ca2a7ed4f --- /dev/null +++ b/core/src/test/resources/media-parser/auphonic.mp3 diff --git a/core/src/test/resources/media-parser/auphonic.ogg b/core/src/test/resources/media-parser/auphonic.ogg Binary files differnew file mode 100644 index 000000000..de326517a --- /dev/null +++ b/core/src/test/resources/media-parser/auphonic.ogg diff --git a/core/src/test/resources/media-parser/auphonic.opus b/core/src/test/resources/media-parser/auphonic.opus Binary files differnew file mode 100644 index 000000000..08538ecb7 --- /dev/null +++ b/core/src/test/resources/media-parser/auphonic.opus |