File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
compose/ui/ui/src/webTest/kotlin/androidx/compose/ui/window Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -54,9 +54,13 @@ class ComposeWindowLifecycleTest : OnCanvasTests {
5454
5555 assertEquals(Lifecycle .State .CREATED , eventsChannel.receive().targetState)
5656 assertEquals(Lifecycle .State .STARTED , eventsChannel.receive().targetState)
57- assertEquals(Lifecycle .State .RESUMED , eventsChannel.receive().targetState)
5857
59- // Dispatch artificial events that would be sent when the window loses and regains focus.
58+ // Dispatch artificial events that would be sent when the window gains and loses focus.
59+ // Starting with a focus event before checking for the initial RESUMED makes this test
60+ // robust in the face of both an actually-focused window and a non-focused window. Then,
61+ // a blur + focus cycle simulates losing focus and regaining it.
62+ window.dispatchEvent(Event (" focus" ))
63+ assertEquals(Lifecycle .State .RESUMED , eventsChannel.receive().targetState)
6064 window.dispatchEvent(Event (" blur" ))
6165 assertEquals(Lifecycle .State .STARTED , eventsChannel.receive().targetState)
6266 window.dispatchEvent(Event (" focus" ))
You can’t perform that action at this time.
0 commit comments