Modern Apps git

← Modern-Apps.git

games-wordmaker: hoist Animatable out of test composition

Commit
703b4f097f9b056a41541189006be4ea56417d3a
Author
Vayun Mathur <[email protected]>
When
2026-11-08 06:04 UTC (28 days ago)
Parents
5917d46
What: in WordMakerComposeTest.overlaysBonusAndDefinitionDialogs, construct
the Animatable(0f) passed as animationProgress before rule.setContent
instead of inline in the composition.

Why: :games:wordmaker:lintDev failed on RememberInComposition — calling a
@RememberInComposition-annotated declaration (Animatable constructor) inside
composition without remember.

Root cause: the inline Animatable(0f) runs on every recomposition, resetting
animation state each time; in this dialog test nothing animates so it only
tripped the lint gate, but the same pattern in an animating test would also
restart the animation every recompose. The neighboring test in the same file
already hoists its Animatables the same way.

Rejected alternatives: wrapping in remember { } inside setContent (keeps
construction in composition and diverges from the file's established hoist
pattern); lint suppression (hides a real recomposition hazard).

User-visible effect: none; test-only change.

Verification: :games:wordmaker:lint green, :games:wordmaker:testDevUnitTest
60/0/0.

Diff

games/wordmaker/src/test/java/com/vayunmathur/games/wordmaker/ui/WordMakerComposeTest.kt
diff --git a/games/wordmaker/src/test/java/com/vayunmathur/games/wordmaker/ui/WordMakerComposeTest.kt b/games/wordmaker/src/test/java/com/vayunmathur/games/wordmaker/ui/WordMakerComposeTest.ktindex a0c6d0aedd..f13924dc0a 100644--- a/games/wordmaker/src/test/java/com/vayunmathur/games/wordmaker/ui/WordMakerComposeTest.kt+++ b/games/wordmaker/src/test/java/com/vayunmathur/games/wordmaker/ui/WordMakerComposeTest.kt@@ -327,12 +327,13 @@ class WordMakerComposeTest {         assertTrue(hinted)     }     @Test fun overlaysBonusAndDefinitionDialogs() {+        val animationProgress = Animatable(0f)         rule.setContent {             DynamicTheme {                 WordGameOverlays(                     showHintDialog = false, onDismissHint = {}, crosswordData = board(), foundWords = emptySet(), revealedHints = emptySet(),                     actions = WordGameActions.Noop, showBonusWordsDialog = true, onDismissBonusWords = {}, bonusWords = setOf("DOG"),-                    wordWithDefinition = null, onDismissDefinition = {}, animatedWord = null, animationProgress = Animatable(0f),+                    wordWithDefinition = null, onDismissDefinition = {}, animatedWord = null, animationProgress = animationProgress,                     wordBoxOffset = Offset.Zero, bonusButtonOffset = Offset.Zero, animatedLetters = emptyList(), scale = 1f,                 )             }