Show real programme artwork behind the channel logo (0.57.0)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
package tv.orbit.classic
|
||||
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.rules.TemporaryFolder
|
||||
import java.io.File
|
||||
|
||||
class ProgrammeArtworkTest {
|
||||
@get:Rule val folder = TemporaryFolder()
|
||||
private fun cache() = ArtworkCache(folder.newFolder())
|
||||
private val png = byteArrayOf(1, 2, 3)
|
||||
|
||||
@Test fun theShowsWideArtworkIsTriedFirst() {
|
||||
assertEquals(listOf("/Items/show/Images/Backdrop?maxWidth=1280&quality=80", "/Items/ep/Images/Backdrop?maxWidth=1280&quality=80", "/Items/ep/Images/Primary?maxWidth=1280&quality=80"), artworkPaths("ep", "show"))
|
||||
}
|
||||
|
||||
@Test fun aFilmOnlyAsksForItsOwnArtwork() {
|
||||
assertEquals(2, artworkPaths("film", "film").size)
|
||||
assertEquals(2, artworkPaths("film", null).size)
|
||||
}
|
||||
|
||||
@Test fun badIdsAreNeverRequested() {
|
||||
assertTrue(artworkPaths("../bad", "../worse").isEmpty())
|
||||
assertNull(loadArtwork(cache(), "../bad", null) { fail("should not fetch"); null })
|
||||
}
|
||||
|
||||
@Test fun itMovesOnWhenAPictureIsMissing() {
|
||||
val asked = mutableListOf<String>()
|
||||
val found = loadArtwork(cache(), "ep", "show") { path -> asked += path; if (path.contains("Primary")) png else null }
|
||||
assertArrayEquals(png, found)
|
||||
assertEquals(3, asked.size)
|
||||
}
|
||||
|
||||
@Test fun aFailureMeansNoPicture() {
|
||||
assertNull(loadArtwork(cache(), "ep", "show") { throw EmbyCheckException("no") })
|
||||
assertNull(loadArtwork(cache(), "ep", "show") { ByteArray(0) })
|
||||
}
|
||||
|
||||
@Test fun aShowsPictureIsOnlyFetchedOnce() {
|
||||
val cache = cache()
|
||||
var fetches = 0
|
||||
repeat(3) { i -> assertArrayEquals(png, loadArtwork(cache, "ep$i", "show") { fetches++; png }) }
|
||||
assertEquals(1, fetches)
|
||||
}
|
||||
|
||||
@Test fun theCacheStaysBounded() {
|
||||
val dir = folder.newFolder(); val cache = ArtworkCache(dir)
|
||||
repeat(160) { cache.put("k$it", png) }
|
||||
assertTrue(File(dir.path).listFiles()!!.size <= 150)
|
||||
}
|
||||
|
||||
@Test fun aPlannedChannelKnowsWhichShowIsOn() {
|
||||
val minute = 60_000L
|
||||
val media = { id: String -> ScheduledMedia(SampleItem(id, "Episode", 1, "", id, minute), "s-$id", minute) }
|
||||
val channel = ScheduledChannel(SampleChannel(listOf(media("x"), media("y")), "Paradox", 152), ChannelPlan(listOf(ScheduleEntry("show", EpisodeMark(1, 1), media("e"), 1_000_000L)), ScheduleCursor()))
|
||||
assertEquals("show", channel.seriesIdAt(1_000_000L))
|
||||
assertNull(channel.seriesIdAt(5L))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user