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 {
54
54
55
55
assertEquals(Lifecycle .State .CREATED , eventsChannel.receive().targetState)
56
56
assertEquals(Lifecycle .State .STARTED , eventsChannel.receive().targetState)
57
- assertEquals(Lifecycle .State .RESUMED , eventsChannel.receive().targetState)
58
57
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)
60
64
window.dispatchEvent(Event (" blur" ))
61
65
assertEquals(Lifecycle .State .STARTED , eventsChannel.receive().targetState)
62
66
window.dispatchEvent(Event (" focus" ))
You can’t perform that action at this time.
0 commit comments