forked from PaulWoitaschek/Voice
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split the matroska tests into multiple test classes for each class.
- Loading branch information
1 parent
0c76eab
commit fb4af87
Showing
6 changed files
with
111 additions
and
69 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
...st/java/de/ph1b/audiobook/features/chapterReader/matroska/MatroskaChapterFlattenerTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package de.ph1b.audiobook.features.chapterReader.matroska | ||
|
||
|
||
import de.ph1b.audiobook.misc.toMap | ||
import org.assertj.core.api.Assertions.assertThat | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import org.robolectric.RobolectricTestRunner | ||
|
||
|
||
@RunWith(RobolectricTestRunner::class) | ||
class MatroskaChapterFlattenerTest { | ||
|
||
@Test | ||
fun test() { | ||
val preferredLanguages = listOf("pol", "eng") | ||
val actual = MatroskaChapterFlattener.toSparseArray(MatroskaTestFileProvider.testFileMatroskaChapters, preferredLanguages) | ||
.toMap() | ||
assertThat(actual).isEqualTo(MatroskaTestFileProvider.testFileChapters) | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
.../test/java/de/ph1b/audiobook/features/chapterReader/matroska/MatroskaChapterReaderTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package de.ph1b.audiobook.features.chapterReader.matroska | ||
|
||
import de.ph1b.audiobook.misc.toMap | ||
import org.assertj.core.api.Assertions.assertThat | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import org.robolectric.RobolectricTestRunner | ||
import java.util.Locale | ||
|
||
@RunWith(RobolectricTestRunner::class) | ||
class MatroskaChapterReaderTest { | ||
|
||
@Test | ||
fun readChapters() { | ||
Locale.setDefault(Locale("pol", "PL", "Polish")) | ||
val actual = MatroskaChapterReader.read(MatroskaTestFileProvider.testFile).toMap() | ||
assertThat(actual).isEqualTo(MatroskaTestFileProvider.testFileChapters) | ||
} | ||
} |
69 changes: 0 additions & 69 deletions
69
...test/java/de/ph1b/audiobook/features/chapterReader/matroska/MatroskaChapterReadingTest.kt
This file was deleted.
Oops, something went wrong.
21 changes: 21 additions & 0 deletions
21
...ok/src/test/java/de/ph1b/audiobook/features/chapterReader/matroska/MatroskaChapterTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package de.ph1b.audiobook.features.chapterReader.matroska | ||
|
||
import org.assertj.core.api.Assertions.assertThat | ||
import org.junit.Test | ||
|
||
|
||
class MatroskaChapterTest { | ||
|
||
@Test | ||
fun testGetName() { | ||
assertThat(MatroskaChapter(0L, listOf(), listOf()).getName()).isNull() | ||
val chapter = MatroskaChapter(0L, listOf( | ||
MatroskaChapterName("Podczęść 1", setOf("pol")), | ||
MatroskaChapterName("Subpart 1", setOf("eng", "ger")), | ||
MatroskaChapterName("サブパート1", setOf("jpn")) | ||
), listOf()) | ||
assertThat(chapter.getName()).isEqualTo("Podczęść 1") | ||
assertThat(chapter.getName(listOf("ger", "jpn"))).isEqualTo("Subpart 1") | ||
assertThat(chapter.getName(listOf("ind", "kac", "jpn", "eng"))).isEqualTo("サブパート1") | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
...c/test/java/de/ph1b/audiobook/features/chapterReader/matroska/MatroskaTestFileProvider.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package de.ph1b.audiobook.features.chapterReader.matroska | ||
|
||
import java.io.File | ||
|
||
|
||
object MatroskaTestFileProvider { | ||
|
||
val testFile = File(javaClass.classLoader.getResource("matroskaChapterReader/simple.mka").path) | ||
val testFileMatroskaChapters = listOf( | ||
MatroskaChapter(0, listOf( | ||
MatroskaChapterName("Part 1", setOf("eng")) | ||
), listOf()), | ||
MatroskaChapter(2000000000L, listOf( | ||
MatroskaChapterName("Part 2", setOf("eng")) | ||
), listOf( | ||
MatroskaChapter(2000000000L, listOf( | ||
MatroskaChapterName("Podczęść 1", setOf("pol")), | ||
MatroskaChapterName("Subpart 1", setOf("eng", "ger")) | ||
), listOf()), | ||
MatroskaChapter(3000000000L, listOf( | ||
MatroskaChapterName("Subpart 2", setOf("eng")) | ||
), listOf()), | ||
MatroskaChapter(4000000000L, listOf(), listOf()) | ||
)) | ||
) | ||
val testFileChapters = mapOf( | ||
0 to "Part 1", | ||
2000 to "Part 2", | ||
2001 to "+ Podczęść 1", | ||
3000 to "+ Subpart 2", | ||
4000 to "+ Chapter 3" | ||
) | ||
} |
17 changes: 17 additions & 0 deletions
17
...test/java/de/ph1b/audiobook/features/chapterReader/matroska/ReadAsMatroskaChaptersTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package de.ph1b.audiobook.features.chapterReader.matroska | ||
|
||
import org.assertj.core.api.Assertions | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import org.robolectric.RobolectricTestRunner | ||
|
||
|
||
@RunWith(RobolectricTestRunner::class) | ||
class ReadAsMatroskaChaptersTest { | ||
|
||
@Test | ||
fun readMatroskaChaptersTest() { | ||
val chapters = ReadAsMatroskaChapters.read(MatroskaTestFileProvider.testFile) | ||
Assertions.assertThat(chapters).isEqualTo(MatroskaTestFileProvider.testFileMatroskaChapters) | ||
} | ||
} |