metadata: enable solitaire screenshots automation
- Commit
5fa3c316e4d3f876bc0a9d03dcbccc5e3e05d622- Author
- Vayun Mathur <[email protected]>
- When
- 2026-07-07 00:55 UTC (5 months ago)
- Parents
0b02835
Diff
games/solitaire/build.gradle.kts
diff --git a/games/solitaire/build.gradle.kts b/games/solitaire/build.gradle.ktsindex df9fdebcb3..9266c0efe3 100644--- a/games/solitaire/build.gradle.kts+++ b/games/solitaire/build.gradle.kts@@ -1,5 +1,6 @@ plugins { id("common-conventions-app")+ id("common-conventions-metadata") } android {
games/solitaire/src/androidTest/java/com/vayunmathur/games/solitaire/MetadataScreenshots.kt
diff --git a/games/solitaire/src/androidTest/java/com/vayunmathur/games/solitaire/MetadataScreenshots.kt b/games/solitaire/src/androidTest/java/com/vayunmathur/games/solitaire/MetadataScreenshots.ktnew file mode 100644index 0000000000..65b8128641--- /dev/null+++ b/games/solitaire/src/androidTest/java/com/vayunmathur/games/solitaire/MetadataScreenshots.kt@@ -0,0 +1,62 @@+package com.vayunmathur.games.solitaire++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 org.junit.Rule+import org.junit.Test+import org.junit.runner.RunWith+import java.io.File++/**+ * Screenshot generator driven by `:games:solitaire:metadata`. Leads with the dealt+ * Klondike board, then the home menu with per-mode stats.+ *+ * The game screen runs a 1s timer that keeps Compose perpetually busy, so the test clock+ * is paused (autoAdvance = false) and advanced manually so captures settle.+ */+@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() {+ composeRule.mainClock.autoAdvance = false++ // Home menu is up at launch — keep it as the second shot.+ snap(2)++ // Start a Klondike (Draw 1) game to lead with the dealt board. Match the unique+ // "Draw 1" substring to avoid depending on the em-dash in the full button label.+ composeRule.onNodeWithText(ctx.getString(R.string.new_game)).performClick()+ composeRule.mainClock.advanceTimeBy(500)+ composeRule.onNodeWithText(ctx.getString(R.string.draw_one), substring = true).performClick()+ composeRule.mainClock.advanceTimeBy(2000)+ snap(1)+ }+}
metadata_data/photos/games-solitaire/1.png
diff --git a/metadata_data/photos/games-solitaire/1.png b/metadata_data/photos/games-solitaire/1.pngnew file mode 100644index 0000000000..abd1845cb2Binary files /dev/null and b/metadata_data/photos/games-solitaire/1.png differ
metadata_data/photos/games-solitaire/2.png
diff --git a/metadata_data/photos/games-solitaire/2.png b/metadata_data/photos/games-solitaire/2.pngnew file mode 100644index 0000000000..b8cfbc1220Binary files /dev/null and b/metadata_data/photos/games-solitaire/2.png differ