Skip to content

Commit d88d9ee

Browse files
runningcodeclaude
andcommitted
feat(snapshot): Include full preview configuration in sidecar metadata
Add nightMode, fontScale, locale, device, apiLevel, widthDp, heightDp, showSystemUi, showBackground, previewName, and group fields to the sidecar JSON. Non-default values are included to keep the file compact. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 84ad2f7 commit d88d9ee

1 file changed

Lines changed: 32 additions & 4 deletions

File tree

plugin-build/src/main/kotlin/io/sentry/android/gradle/snapshot/GenerateSnapshotTestsTask.kt

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -350,12 +350,40 @@ class $CLASS_NAME(
350350
val parts = mutableListOf<String>()
351351
parts.add(q + "display_name" + q + ": " + q + escapeJson(screenshotId) + q)
352352
parts.add(q + "image_file_name" + q + ": " + q + escapeJson(screenshotId) + q)
353-
val group = info.group
354-
if (group.isNotBlank()) {
355-
parts.add(q + "group" + q + ": " + q + escapeJson(group) + q)
356-
}
357353
parts.add(q + "className" + q + ": " + q + escapeJson(preview.declaringClass) + q)
358354
parts.add(q + "methodName" + q + ": " + q + escapeJson(preview.methodName) + q)
355+
if (info.group.isNotBlank()) {
356+
parts.add(q + "group" + q + ": " + q + escapeJson(info.group) + q)
357+
}
358+
if (info.name.isNotBlank()) {
359+
parts.add(q + "previewName" + q + ": " + q + escapeJson(info.name) + q)
360+
}
361+
if (info.locale.isNotBlank()) {
362+
parts.add(q + "locale" + q + ": " + q + escapeJson(info.locale) + q)
363+
}
364+
if (info.device.isNotBlank()) {
365+
parts.add(q + "device" + q + ": " + q + escapeJson(info.device) + q)
366+
}
367+
val nightMode = info.uiMode and 0x30 == 0x20
368+
parts.add(q + "nightMode" + q + ": " + if (nightMode) "true" else "false")
369+
if (info.fontScale != 1f) {
370+
parts.add(q + "fontScale" + q + ": " + info.fontScale)
371+
}
372+
if (info.apiLevel != -1) {
373+
parts.add(q + "apiLevel" + q + ": " + info.apiLevel)
374+
}
375+
if (info.widthDp > 0) {
376+
parts.add(q + "widthDp" + q + ": " + info.widthDp)
377+
}
378+
if (info.heightDp > 0) {
379+
parts.add(q + "heightDp" + q + ": " + info.heightDp)
380+
}
381+
if (info.showSystemUi) {
382+
parts.add(q + "showSystemUi" + q + ": true")
383+
}
384+
if (info.showBackground) {
385+
parts.add(q + "showBackground" + q + ": true")
386+
}
359387
val json = parts.joinToString(",\n ", prefix = "{\n ", postfix = "\n}")
360388
val sidecarName = "Paparazzi_Preview_Test_" +
361389
screenshotId.lowercase(Locale.US).replace("\\s".toRegex(), "_")

0 commit comments

Comments
 (0)