metadata: enable alchemist screenshots automation
- Commit
56d6d33852390e9186a2bbfd14adfb0f1d3efd38- Author
- Vayun Mathur <[email protected]>
- When
- 2026-07-07 00:55 UTC (5 months ago)
- Parents
832f007
Diff
games/alchemist/build.gradle.kts
diff --git a/games/alchemist/build.gradle.kts b/games/alchemist/build.gradle.ktsindex 2333b80bdf..3f92e7d7ef 100644--- a/games/alchemist/build.gradle.kts+++ b/games/alchemist/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/alchemist/src/androidTest/java/com/vayunmathur/games/alchemist/MetadataScreenshots.kt
diff --git a/games/alchemist/src/androidTest/java/com/vayunmathur/games/alchemist/MetadataScreenshots.kt b/games/alchemist/src/androidTest/java/com/vayunmathur/games/alchemist/MetadataScreenshots.ktnew file mode 100644index 0000000000..52ede9c5ce--- /dev/null+++ b/games/alchemist/src/androidTest/java/com/vayunmathur/games/alchemist/MetadataScreenshots.kt@@ -0,0 +1,70 @@+package com.vayunmathur.games.alchemist++import android.graphics.Bitmap+import androidx.compose.ui.geometry.Offset+import androidx.compose.ui.graphics.asAndroidBitmap+import androidx.compose.ui.test.captureToImage+import androidx.compose.ui.test.junit4.createAndroidComposeRule+import androidx.compose.ui.test.onRoot+import androidx.lifecycle.ViewModelProvider+import androidx.test.ext.junit.runners.AndroidJUnit4+import androidx.test.platform.app.InstrumentationRegistry+import com.vayunmathur.games.alchemist.data.AlchemyItem+import com.vayunmathur.games.alchemist.util.AlchemistViewModel+import org.junit.Rule+import org.junit.Test+import org.junit.runner.RunWith+import java.io.File++/**+ * Screenshot generator driven by `:games:alchemist:metadata`. Seeds a few base elements+ * onto the crafting play area (via the ViewModel) so the board isn't empty.+ */+@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() {+ val vm = composeRule.runOnUiThread<AlchemistViewModel> {+ ViewModelProvider(composeRule.activity)[AlchemistViewModel::class.java]+ }++ // Base elements are seeded asynchronously on first launch — wait for them.+ var items: List<AlchemyItem> = emptyList()+ for (i in 0 until 25) {+ items = vm.availableItems.value+ if (items.isNotEmpty()) break+ Thread.sleep(200)+ }++ // Scatter a few elements across the play area so the board looks alive.+ val spots = listOf(+ Offset(180f, 380f), Offset(640f, 360f),+ Offset(320f, 760f), Offset(680f, 900f)+ )+ composeRule.runOnUiThread {+ items.take(spots.size).forEachIndexed { i, item -> vm.placeElement(item.id, spots[i]) }+ }+ snap(1) // crafting play area (lead)+ }+}
metadata_data/photos/games-alchemist/1.png
diff --git a/metadata_data/photos/games-alchemist/1.png b/metadata_data/photos/games-alchemist/1.pngnew file mode 100644index 0000000000..b54ba49a59Binary files /dev/null and b/metadata_data/photos/games-alchemist/1.png differ