Screenshots on the JVM: Robolectric + Roborazzi, uploaded by CI
CI / check (push) Canceled after 0s

Test-only dependencies (nothing in the APK). shoot() renders a composable in the
Shire and Moria themes at a phone's size and writes app/build/screenshots/*.png;
CI uploads them as llembas-android-screenshots-<run>. The first shot is the
transcript's existing blocks, to prove the loop before the redesign.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
HomerandClaude Opus 5.5 committed 2026-11-09 12:36:36 +00:00
1 parent f3b78be5ab
commit 6589a14073
6 files changed
+115

No files matched your search

@@ -0,0 +1,14 @@
package eu.llembas.android.shots
import eu.llembas.android.api.LembasJson
import eu.llembas.android.api.Message
import eu.llembas.android.api.ModelList
/** Made-up data for the screenshots: the server's own contract files where they fit. */
object Fakes {
private fun text(name: String): String = requireNotNull(javaClass.classLoader!!.getResource("$name.json")).readText()
val models = LembasJson.decodeFromString(ModelList.serializer(), text("models")).models
val question = LembasJson.decodeFromString(Message.serializer(), text("message_user"))
val answer = LembasJson.decodeFromString(Message.serializer(), text("message_assistant"))
}
@@ -0,0 +1,28 @@
package eu.llembas.android.shots
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.padding
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import eu.llembas.android.ui.chat.Steps
import eu.llembas.android.ui.chat.UserBubble
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
import org.robolectric.annotation.Config
import org.robolectric.annotation.GraphicsMode
/** The app's screens with made-up data ([Fakes]), as a phone shows them. See [shoot]. */
@RunWith(RobolectricTestRunner::class)
@GraphicsMode(GraphicsMode.Mode.NATIVE)
@Config(sdk = [35], qualifiers = "xhdpi")
class ScreenShots {
@Test
fun transcript() = shoot("transcript") {
Column(Modifier.padding(16.dp), verticalArrangement = Arrangement.spacedBy(16.dp)) {
UserBubble(Fakes.question)
Steps(Fakes.answer.steps)
}
}
}
@@ -0,0 +1,43 @@
@file:OptIn(ExperimentalRoborazziApi::class)
package eu.llembas.android.shots
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import com.github.takahirom.roborazzi.ExperimentalRoborazziApi
import com.github.takahirom.roborazzi.RoborazziComposeOptions
import com.github.takahirom.roborazzi.captureRoboImage
import com.github.takahirom.roborazzi.fontScale
import com.github.takahirom.roborazzi.size
import eu.llembas.android.ui.theme.LembasTheme
/** The phones the screens are looked at on: a large one, and a small one where things crowd. */
enum class Phone(val tag: String, val widthDp: Int, val heightDp: Int) {
Large("411x891", 411, 891),
Small("360x640", 360, 640),
}
/**
* Render [content] in the app's theme, light (Shire) and dark (Moria), at [phone]'s size and
* write each to `app/build/screenshots/<phone>-<name>-<theme>.png`, which CI uploads. These are
* for looking at -- by a person, or by an agent reading the PNGs -- not compared against
* anything: a design change is meant to change them.
*/
fun shoot(name: String, phone: Phone = Phone.Large, fontScale: Float = 1f, content: @Composable () -> Unit) {
for ((theme, choice) in listOf("light" to "shire", "dark" to "moria")) {
val font = if (fontScale != 1f) "-font$fontScale" else ""
captureRoboImage(
filePath = "build/screenshots/${phone.tag}-$name-$theme$font.png",
roborazziComposeOptions = RoborazziComposeOptions {
size(phone.widthDp, phone.heightDp)
if (fontScale != 1f) fontScale(fontScale)
},
) {
LembasTheme(choice) {
Surface(Modifier.fillMaxSize()) { content() }
}
}
}
}