extract the artist grid scroll estimate and test it

The index to pixel arithmetic was inline and fiddly (it was missing the row gap), so pull it
out as estimateScrollPx and pin the 2-column cases. ROW_GAP is shared with the grid spacing.
This commit is contained in:
austinried
2026-10-04 00:29:59 +00:00
parent 8d8c8be2a8
commit 7af87d63d9
2 changed files with 54 additions and 9 deletions
@@ -0,0 +1,30 @@
package com.subtracks.ui.library
import org.junit.Assert.assertEquals
import org.junit.Test
class EstimateScrollPxTest {
private val image = 432f
private val album = 200f
private val gap = 16f
@Test
fun theHeroUsesTheRawOffset() {
assertEquals(50f, estimateScrollPx(0, 50f, image, album, gap), 0.01f)
}
@Test
fun theFirstAlbumRowAddsTheHeroAndOneGap() {
assertEquals(image + gap + 10f, estimateScrollPx(1, 10f, image, album, gap), 0.01f)
}
@Test
fun theSecondCellOfARowDoesNotAdvance() {
assertEquals(estimateScrollPx(1, 10f, image, album, gap), estimateScrollPx(2, 10f, image, album, gap), 0.01f)
}
@Test
fun theNextRowAddsACellAndAGap() {
assertEquals(image + gap + (album + gap) + 10f, estimateScrollPx(3, 10f, image, album, gap), 0.01f)
}
}