Add adaptive Android grid with automatic source reconciliation

This commit is contained in:
evgeny committed 2026-10-20 17:07:19 +02:00
1 parent 6ca34af869
commit 540d71d4c2
3 files changed
+173 -1

No files matched your search

@@ -0,0 +1,24 @@
package com.utun.chat.data
import org.junit.Assert.*
import org.junit.Test
class StreamGridLayoutTest {
@Test fun portraitAndLandscapeUseDifferentShapes() {
assertEquals(StreamGridShape(1, 2), streamGridShape(2, 400.0, 800.0))
assertEquals(StreamGridShape(2, 1), streamGridShape(2, 1600.0, 600.0))
assertEquals(StreamGridShape(1, 4), streamGridShape(4, 400.0, 800.0))
}
@Test fun everySourceHasACellAcrossCountsAndSizes() {
for (count in 1..40) for ((width, height) in listOf(400.0 to 800.0, 800.0 to 400.0, 900.0 to 900.0)) {
val shape = streamGridShape(count, width, height)
assertTrue(shape.columns > 0 && shape.rows > 0)
assertTrue(shape.columns * shape.rows >= count)
assertEquals((count + shape.columns - 1) / shape.columns, shape.rows)
}
}
@Test fun emptyAndZeroSizedLayoutIsSafe() {
assertEquals(StreamGridShape(1, 1), streamGridShape(0, 400.0, 800.0))
assertEquals(StreamGridShape(1, 1), streamGridShape(4, 0.0, 800.0))
}
}