49 lines
1.7 KiB
Kotlin
49 lines
1.7 KiB
Kotlin
package de.fojadrachi.playtube
|
|
|
|
import org.junit.Assert.assertEquals
|
|
import org.junit.Assert.assertFalse
|
|
import org.junit.Assert.assertNull
|
|
import org.junit.Assert.assertTrue
|
|
import org.junit.Test
|
|
|
|
class PresencePlanTest {
|
|
private val now = 1_800_000_000_000L
|
|
private val playing = NowPlaying("Song", "Band", "https://i.ytimg.com/a.jpg", true, 30_000L, 200_000L)
|
|
|
|
@Test
|
|
fun `laufender Titel ergibt Details, Interpret, Cover und Zeitraum`() {
|
|
val plan = PresencePlan.from(playing, now)!!
|
|
assertEquals("Song", plan.details)
|
|
assertEquals("Band", plan.state)
|
|
assertEquals("https://i.ytimg.com/a.jpg", plan.artworkUrl)
|
|
assertEquals(now - 30_000L, plan.startMs)
|
|
assertEquals(now - 30_000L + 200_000L, plan.endMs)
|
|
}
|
|
|
|
@Test
|
|
fun `Pause und leerer Player zeigen nichts an`() {
|
|
assertNull(PresencePlan.from(playing.copy(playing = false), now))
|
|
assertNull(PresencePlan.from(NowPlaying.EMPTY, now))
|
|
}
|
|
|
|
@Test
|
|
fun `unbekannte Laenge ergibt kein Ende`() {
|
|
assertEquals(0L, PresencePlan.from(playing.copy(durationMs = 0L), now)!!.endMs)
|
|
}
|
|
|
|
@Test
|
|
fun `normales Weiterlaufen ist keine Aenderung`() {
|
|
val first = PresencePlan.from(playing, now)!!
|
|
val later = PresencePlan.from(playing.copy(positionMs = 31_800L), now + 1_500L)!!
|
|
assertTrue(later.sameAs(first))
|
|
}
|
|
|
|
@Test
|
|
fun `Spulen, neuer Titel und null sind Aenderungen`() {
|
|
val first = PresencePlan.from(playing, now)!!
|
|
assertFalse(PresencePlan.from(playing.copy(positionMs = 120_000L), now + 1_500L)!!.sameAs(first))
|
|
assertFalse(PresencePlan.from(playing.copy(title = "Anderer"), now)!!.sameAs(first))
|
|
assertFalse(first.sameAs(null))
|
|
}
|
|
}
|