commit 5d84efb11393d51b16065840e69390d2a3a52433 equwal <truex@equwal.com> 2026-09-21 05:32:53 -0700 Keep the screen's update loop running while the intent test waits for the answer The screen answers the asking app from its own update loop. In a Compose test that loop runs only while the test asks the rule to wait, so the test must wait for the screen to close before it reads the result. On the tablet the two tests now pass.
app/src/androidTest/kotlin/space/subread/app/AlignIntentTest.kt | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/app/src/androidTest/kotlin/space/subread/app/AlignIntentTest.kt b/app/src/androidTest/kotlin/space/subread/app/AlignIntentTest.kt index d751524..972699b 100644 --- a/app/src/androidTest/kotlin/space/subread/app/AlignIntentTest.kt +++ b/app/src/androidTest/kotlin/space/subread/app/AlignIntentTest.kt @@ -10,6 +10,7 @@ import androidx.compose.ui.test.onAllNodesWithText import androidx.compose.ui.test.onNodeWithText import androidx.core.content.FileProvider import androidx.core.net.toUri +import androidx.lifecycle.Lifecycle import androidx.test.core.app.ActivityScenario import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.platform.app.InstrumentationRegistry @@ -65,6 +66,11 @@ class AlignIntentTest { compose.waitUntil(1_800_000) { Job.status.value.phase == Phase.DONE || Job.status.value.phase == Phase.FAILED } + // A failed job stays on the screen for the user to read, so there is no answer to wait for. + assertEquals(Job.status.value.detail, Phase.DONE, Job.status.value.phase) + // The screen answers from its own update loop, and in a Compose test that loop runs + // only while the test asks the rule to wait. scenario.result alone would block it. + compose.waitUntil(60_000) { scenario.state == Lifecycle.State.DESTROYED } val result = scenario.result assertEquals(Job.status.value.detail, Activity.RESULT_OK, result.resultCode)