Modern Apps git

← Modern-Apps.git

metadata: enable unblockjam screenshots automation

Commit
832f00771d424c7815565176d1af35d73cf9323a
Author
Vayun Mathur <[email protected]>
When
2026-07-07 00:55 UTC (5 months ago)
Parents
5fa3c31

Diff

games/unblockjam/build.gradle.kts
diff --git a/games/unblockjam/build.gradle.kts b/games/unblockjam/build.gradle.ktsindex 6045fcbf05..0b63b846cc 100644--- a/games/unblockjam/build.gradle.kts+++ b/games/unblockjam/build.gradle.kts@@ -1,5 +1,6 @@ plugins {     id("common-conventions-app")+    id("common-conventions-metadata") }  android {@@ -9,4 +10,4 @@ android { }  dependencies {-}\ No newline at end of file+}
games/unblockjam/src/androidTest/java/com/vayunmathur/games/unblockjam/MetadataScreenshots.kt
diff --git a/games/unblockjam/src/androidTest/java/com/vayunmathur/games/unblockjam/MetadataScreenshots.kt b/games/unblockjam/src/androidTest/java/com/vayunmathur/games/unblockjam/MetadataScreenshots.ktnew file mode 100644index 0000000000..84b3568f47--- /dev/null+++ b/games/unblockjam/src/androidTest/java/com/vayunmathur/games/unblockjam/MetadataScreenshots.kt@@ -0,0 +1,59 @@+package com.vayunmathur.games.unblockjam++import android.graphics.Bitmap+import androidx.compose.ui.graphics.asAndroidBitmap+import androidx.compose.ui.test.captureToImage+import androidx.compose.ui.test.junit4.createAndroidComposeRule+import androidx.compose.ui.test.onNodeWithText+import androidx.compose.ui.test.onRoot+import androidx.compose.ui.test.performClick+import androidx.test.ext.junit.runners.AndroidJUnit4+import androidx.test.platform.app.InstrumentationRegistry+import com.vayunmathur.games.unblockjam.data.LevelPack+import org.junit.Rule+import org.junit.Test+import org.junit.runner.RunWith+import java.io.File++/**+ * Screenshot generator driven by `:games:unblockjam:metadata`. Order: gameplay board+ * first, then the level grid, then the pack selector (menu) last.+ */+@RunWith(AndroidJUnit4::class)+class MetadataScreenshots {++    @get:Rule+    val composeRule = createAndroidComposeRule<MainActivity>()++    private val ctx = InstrumentationRegistry.getInstrumentation().targetContext++    private val outDir: File by lazy {+        File(ctx.getExternalFilesDir(null), "metadata_screenshots").apply {+            deleteRecursively()+            mkdirs()+        }+    }++    private fun snap(index: Int) {+        composeRule.waitForIdle()+        val image = composeRule.onRoot().captureToImage()+        File(outDir, "$index.png").outputStream().use { out ->+            image.asAndroidBitmap().compress(Bitmap.CompressFormat.PNG, 100, out)+        }+    }++    @Test+    fun generateStoreScreenshots() {+        LevelPack.init(ctx)+        val firstPack = LevelPack.PACKS[0].name++        // Pack selector is the launch screen — keep it as the last shot.+        snap(3)++        composeRule.onNodeWithText(firstPack).performClick()+        snap(2) // level grid++        composeRule.onNodeWithText("1").performClick()+        snap(1) // gameplay board+    }+}
metadata_data/photos/games-unblockjam/1.png
diff --git a/metadata_data/photos/games-unblockjam/1.png b/metadata_data/photos/games-unblockjam/1.pngnew file mode 100644index 0000000000..cac1f24f8eBinary files /dev/null and b/metadata_data/photos/games-unblockjam/1.png differ
metadata_data/photos/games-unblockjam/2.png
diff --git a/metadata_data/photos/games-unblockjam/2.png b/metadata_data/photos/games-unblockjam/2.pngnew file mode 100644index 0000000000..d91935fe0dBinary files /dev/null and b/metadata_data/photos/games-unblockjam/2.png differ
metadata_data/photos/games-unblockjam/3.png
diff --git a/metadata_data/photos/games-unblockjam/3.png b/metadata_data/photos/games-unblockjam/3.pngnew file mode 100644index 0000000000..a740ebcb16Binary files /dev/null and b/metadata_data/photos/games-unblockjam/3.png differ