metadata: enable wordmaker screenshots automation
- Commit
77002bfb7df4b026e754cbb4a65b914f6d4575ca- Author
- Vayun Mathur <[email protected]>
- When
- 2026-07-07 00:55 UTC (5 months ago)
- Parents
56d6d33
Diff
games/wordmaker/build.gradle.kts
diff --git a/games/wordmaker/build.gradle.kts b/games/wordmaker/build.gradle.ktsindex f24b7a02c7..e56153b719 100644--- a/games/wordmaker/build.gradle.kts+++ b/games/wordmaker/build.gradle.kts@@ -1,5 +1,6 @@ plugins { id("common-conventions-app")+ id("common-conventions-metadata") } android {@@ -10,4 +11,4 @@ android { dependencies { implementation(libs.androidx.datastore.preferences)-}\ No newline at end of file+}
games/wordmaker/src/androidTest/java/com/vayunmathur/games/wordmaker/MetadataScreenshots.kt
diff --git a/games/wordmaker/src/androidTest/java/com/vayunmathur/games/wordmaker/MetadataScreenshots.kt b/games/wordmaker/src/androidTest/java/com/vayunmathur/games/wordmaker/MetadataScreenshots.ktnew file mode 100644index 0000000000..4a3eed6a74--- /dev/null+++ b/games/wordmaker/src/androidTest/java/com/vayunmathur/games/wordmaker/MetadataScreenshots.kt@@ -0,0 +1,58 @@+package com.vayunmathur.games.wordmaker++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.onAllNodesWithContentDescription+import androidx.compose.ui.test.onRoot+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:wordmaker:metadata`. Captures the main game+ * screen (crossword grid + circular letter wheel).+ *+ * The app shows a loading spinner until achievements load, and the game screen has small+ * ongoing animations, so we wait for the letter wheel to appear (real-time), then pause+ * the Compose clock to freeze animations for a clean capture.+ */+@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() {+ // Wait (real-time) until the game screen is up — the letter wheel's Shuffle button.+ composeRule.waitUntil(timeoutMillis = 20_000) {+ composeRule.onAllNodesWithContentDescription("Shuffle").fetchSemanticsNodes().isNotEmpty()+ }+ // Freeze the letter-placement animations so the capture settles.+ composeRule.mainClock.autoAdvance = false+ composeRule.mainClock.advanceTimeBy(1500)+ snap(1)+ }+}
metadata_data/photos/games-wordmaker/1.png
diff --git a/metadata_data/photos/games-wordmaker/1.png b/metadata_data/photos/games-wordmaker/1.pngnew file mode 100644index 0000000000..011a437605Binary files /dev/null and b/metadata_data/photos/games-wordmaker/1.png differ