Skip to content

Commit

Permalink
Split the matroska tests into multiple test classes for each class.
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulWoitaschek committed Jul 19, 2017
1 parent 0c76eab commit fb4af87
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 69 deletions.
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)
}
}
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)
}
}

This file was deleted.

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")
}
}
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"
)
}
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)
}
}

0 comments on commit fb4af87

Please sign in to comment.