Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class LifecycleChannel {

private String lastAndroidState = "";
private String lastFlutterState = "";
private boolean lastFocus = false;
private boolean lastFocus = true;

@NonNull private final BasicMessageChannel<String> channel;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,29 +31,29 @@ public void lifecycleChannel_handlesResumed() {
lifecycleChannel.appIsResumed();
ArgumentCaptor<String> stringArgumentCaptor = ArgumentCaptor.forClass(String.class);
verify(mockChannel, times(1)).send(stringArgumentCaptor.capture());
assertEquals("AppLifecycleState.inactive", stringArgumentCaptor.getValue());
assertEquals("AppLifecycleState.resumed", stringArgumentCaptor.getValue());

lifecycleChannel.aWindowIsFocused();
lifecycleChannel.noWindowsAreFocused();
stringArgumentCaptor = ArgumentCaptor.forClass(String.class);
verify(mockChannel, times(2)).send(stringArgumentCaptor.capture());
assertEquals("AppLifecycleState.resumed", stringArgumentCaptor.getValue());
assertEquals("AppLifecycleState.inactive", stringArgumentCaptor.getValue());

lifecycleChannel.noWindowsAreFocused();
lifecycleChannel.aWindowIsFocused();
stringArgumentCaptor = ArgumentCaptor.forClass(String.class);
verify(mockChannel, times(3)).send(stringArgumentCaptor.capture());
assertEquals("AppLifecycleState.inactive", stringArgumentCaptor.getValue());
assertEquals("AppLifecycleState.resumed", stringArgumentCaptor.getValue());

// Stays inactive, so no event is sent.
lifecycleChannel.appIsInactive();
verify(mockChannel, times(3)).send(any(String.class));
verify(mockChannel, times(4)).send(any(String.class));

// Stays inactive, so no event is sent.
lifecycleChannel.appIsResumed();
verify(mockChannel, times(3)).send(any(String.class));
verify(mockChannel, times(5)).send(any(String.class));

lifecycleChannel.aWindowIsFocused();
stringArgumentCaptor = ArgumentCaptor.forClass(String.class);
verify(mockChannel, times(4)).send(stringArgumentCaptor.capture());
verify(mockChannel, times(5)).send(stringArgumentCaptor.capture());
assertEquals("AppLifecycleState.resumed", stringArgumentCaptor.getValue());
}

Expand Down