Add the real grid guide (0.24.0)
pauljd/davidson-ci: Davidson CI / quality (push) Failing after 1m50s
pauljd/davidson-ci: Davidson CI / ai-review (push) Failing after 1m21s

Channels down the side and times across, from each channel's own clock,
replacing the one-channel guide. Live picture-in-picture comes later.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-11-01 22:22:58 +00:00
co-authored by Claude Opus 5.5
parent afa177c550
commit 7e6fbad5d7
8 changed files with 209 additions and 7 deletions
@@ -0,0 +1,42 @@
package tv.orbit.classic
import org.junit.Assert.*
import org.junit.Test
class GuideGridTest {
private val minute = 60_000L
private fun media(id: String, minutes: Long) = ScheduledMedia(SampleItem("Fixture $id", "Movie", minutes, "mkv", id, minutes * minute), "$id-source", minutes * minute)
private val channel = SampleChannel(listOf(media("a", 20), media("b", 50), media("c", 90)), "Fixture", 101)
private val start = guideWindowStart(1_800_000_000_000L, 0)
private val end = start + GUIDE_SLOTS * GUIDE_SLOT_MS
@Test fun cellsFillTheWindowWithNoGapsAndAddUpToIt() {
val cells = guideCells(channel, start, end)
assertEquals(1f, cells.sumOf { it.widthFraction.toDouble() }.toFloat(), .001f)
assertEquals(0f, cells.first().startFraction, .001f)
cells.zipWithNext().forEach { (a, b) -> assertEquals(a.startFraction + a.widthFraction, b.startFraction, .001f) }
}
@Test fun cellsAgreeWithTheChannelClock() {
guideCells(channel, start, end).forEach { cell ->
assertEquals(channel.at(cell.show.startMs).media.item.id, cell.show.media.item.id)
assertTrue(cell.show.startMs < end && cell.show.endMs > start)
}
}
@Test fun aLongFilmIsClippedToTheWindow() {
val longOne = SampleChannel(listOf(media("x", 600), media("y", 600)), "Fixture", 102)
val cells = guideCells(longOne, start, start + GUIDE_SLOT_MS)
assertEquals(1, cells.size); assertEquals(1f, cells[0].widthFraction, .001f)
}
@Test fun theWindowStartsOnTheHalfHourAndMovesBySlots() {
assertEquals(0L, start % GUIDE_SLOT_MS)
assertEquals(start + 2 * GUIDE_SLOT_MS, guideWindowStart(start + minute, 2))
}
@Test fun movingRightGoesToTheNextProgrammeAndLeftNeverPassesNow() {
val now = start + minute
val current = channel.at(now)
assertEquals(current.endMs, guideStep(channel, now, now, true))
assertEquals(now, guideStep(channel, now, now, false))
val later = current.endMs + minute
assertEquals(current.endMs - 1, guideStep(channel, later, now, false))
}
}