solitaire: updated automated screenshot generation
- Commit
6dad839d3caaacdd59738c3384fdd7d91746f468- Author
- Vayun Mathur <[email protected]>
- When
- 2026-07-07 05:32 UTC (5 months ago)
- Parents
c7c9ce9
Diff
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.ktindex 65b8128641..f8441cc371 100644--- a/games/solitaire/src/androidTest/java/com/vayunmathur/games/solitaire/MetadataScreenshots.kt+++ b/games/solitaire/src/androidTest/java/com/vayunmathur/games/solitaire/MetadataScreenshots.kt@@ -3,6 +3,8 @@ 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.hasClickAction+import androidx.compose.ui.test.hasText import androidx.compose.ui.test.junit4.createAndroidComposeRule import androidx.compose.ui.test.onNodeWithText import androidx.compose.ui.test.onRoot@@ -15,11 +17,14 @@ 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.+ * Screenshot generator driven by `:games:solitaire:metadata`. Captures a dealt board for+ * each of the three game types: Klondike, Spider, and FreeCell. *- * 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.+ * The game screen runs a 1s timer that keeps Compose perpetually busy, so the clock is only+ * paused while a board is on screen (to let captures settle). The Home screen and the+ * New Game dialog have no such timer but do play navigation/dialog animations, so the clock+ * must be auto-advancing there — otherwise a paused nav transition leaves buttons frozen+ * mid-slide and taps miss them. */ @RunWith(AndroidJUnit4::class) class MetadataScreenshots {@@ -36,7 +41,11 @@ class MetadataScreenshots { } } - private fun snap(index: Int) {+ /** Captures a board: pauses the perpetual game timer, settles, then snaps. Leaves the+ * clock paused since giveUp() runs next on the still-busy game screen. */+ private fun snapBoard(index: Int) {+ composeRule.mainClock.autoAdvance = false+ composeRule.mainClock.advanceTimeBy(1500) composeRule.waitForIdle() val image = composeRule.onRoot().captureToImage() File(outDir, "$index.png").outputStream().use { out ->@@ -44,19 +53,36 @@ class MetadataScreenshots { } } + /**+ * Opens the New Game dialog and starts the game whose button matches [buttonText]. Runs+ * with the clock auto-advancing so the dialog and the nav transition into the board settle.+ */+ private fun startGame(buttonText: String) {+ composeRule.onNodeWithText(ctx.getString(R.string.new_game)).performClick()+ composeRule.waitForIdle()+ // The mode names also appear on the home stats cards, so match the clickable+ // dialog button specifically (substring for Klondike's "Draw 1" variant).+ composeRule.onNode(hasText(buttonText, substring = true) and hasClickAction()).performClick()+ }++ /** Gives up the current board (clock paused so waitForIdle doesn't hang on the timer). */+ private fun giveUp() {+ composeRule.onNodeWithText(ctx.getString(R.string.give_up)).performClick()+ composeRule.mainClock.autoAdvance = true+ composeRule.waitForIdle()+ }+ @Test fun generateStoreScreenshots() {- composeRule.mainClock.autoAdvance = false+ startGame(ctx.getString(R.string.draw_one))+ snapBoard(1) // Klondike board - // Home menu is up at launch — keep it as the second shot.- snap(2)+ giveUp()+ startGame(ctx.getString(R.string.spider))+ snapBoard(2) // Spider board - // 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)+ giveUp()+ startGame(ctx.getString(R.string.freecell))+ snapBoard(3) // FreeCell board } }
games/solitaire/src/main/ic_launcher-playstore.png
diff --git a/games/solitaire/src/main/ic_launcher-playstore.png b/games/solitaire/src/main/ic_launcher-playstore.pngindex 6a4111c096..70f357103e 100644Binary files a/games/solitaire/src/main/ic_launcher-playstore.png and b/games/solitaire/src/main/ic_launcher-playstore.png differ
metadata_data/photos/games-solitaire/1.png
diff --git a/metadata_data/photos/games-solitaire/1.png b/metadata_data/photos/games-solitaire/1.pngindex abd1845cb2..319552cd56 100644Binary files a/metadata_data/photos/games-solitaire/1.png 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.pngindex b8cfbc1220..6a4d08476c 100644Binary files a/metadata_data/photos/games-solitaire/2.png and b/metadata_data/photos/games-solitaire/2.png differ
metadata_data/photos/games-solitaire/3.png
diff --git a/metadata_data/photos/games-solitaire/3.png b/metadata_data/photos/games-solitaire/3.pngnew file mode 100644index 0000000000..de9084dd39Binary files /dev/null and b/metadata_data/photos/games-solitaire/3.png differ