photos: idle the main looper while waiting for the video page load
- Commit
6143e77bce0d0a02b5c92d813e08c512c56fa206- Author
- Vayun Mathur <[email protected]>
- When
- 2026-11-17 12:21 UTC (19 days ago)
- Parents
06010a7
CI failed LoadedPagesEditingPass3Test's loaded-video-page-switches-tools-through-the-tab-bar. The test waited with rule.waitUntil(10s) for VideoEditViewModel.photo to become non-null, but loadVideo runs on viewModelScope (Dispatchers.Main), which under Robolectric is the paused main looper, and the compose rule's waitUntil does not pump that looper. Under load the load stayed queued past the wait and the title/name assertions ran against an unloaded page. Other tests in the repo (appstore's TvMainActivityTest, email's EmlViewerSuccessTest) already idle that looper inside their waits for exactly this reason. The wait condition now idles the main looper on each poll before checking the photo. The assertions are unchanged. Verified: LoadedPagesEditingPass3Test passes directly; :photos:testDevUnitTest green sequentially and in one parallel all-module run (a second parallel run flaked on an unrelated GalleryViewModel await, not this test).
Diff
photos/src/test/java/com/vayunmathur/photos/photoslice2/LoadedPagesEditingPass3Test.kt
diff --git a/photos/src/test/java/com/vayunmathur/photos/photoslice2/LoadedPagesEditingPass3Test.kt b/photos/src/test/java/com/vayunmathur/photos/photoslice2/LoadedPagesEditingPass3Test.ktindex b5a0acfff0..610aa6ddae 100644--- a/photos/src/test/java/com/vayunmathur/photos/photoslice2/LoadedPagesEditingPass3Test.kt+++ b/photos/src/test/java/com/vayunmathur/photos/photoslice2/LoadedPagesEditingPass3Test.kt@@ -109,8 +109,14 @@ class LoadedPagesEditingPass3Test { fun `loaded video page switches tools through the tab bar`() { val vm = VideoEditViewModel(app, PhotosRepository.get(app)) rule.setContent { VideoEditPage(vm, 0L, "content://fixture/loaded.mp4") }- // The DB flow falls back to a stand-in photo for the uri.- rule.waitUntil(timeoutMillis = 10_000L) { vm.photo.value != null }+ // The DB flow falls back to a stand-in photo for the uri. Idle the+ // paused Robolectric main looper per poll: loadVideo runs on+ // viewModelScope (Main), and the compose rule's waitUntil does not+ // pump that looper, so under load the load sat queued past the wait.+ rule.waitUntil(timeoutMillis = 10_000L) {+ org.robolectric.Shadows.shadowOf(android.os.Looper.getMainLooper()).idle()+ vm.photo.value != null+ } rule.waitForIdle() rule.onNodeWithText(ctx.getString(com.vayunmathur.photos.R.string.title_edit_video)) .assertIsDisplayed()