1package io.flutter.embedding.engine.systemchannels;
3import static org.junit.Assert.assertEquals;
4import static org.mockito.ArgumentMatchers.any;
5import static org.mockito.Mockito.mock;
6import static org.mockito.Mockito.times;
7import static org.mockito.Mockito.verify;
9import androidx.test.ext.junit.runners.AndroidJUnit4;
10import io.flutter.plugin.common.BasicMessageChannel;
11import org.junit.Before;
13import org.junit.runner.RunWith;
14import org.mockito.ArgumentCaptor;
15import org.robolectric.annotation.Config;
18@RunWith(AndroidJUnit4.class)
32 ArgumentCaptor<String> stringArgumentCaptor = ArgumentCaptor.forClass(String.class);
33 verify(mockChannel,
times(1)).send(stringArgumentCaptor.capture());
34 assertEquals(
"AppLifecycleState.resumed", stringArgumentCaptor.getValue());
37 stringArgumentCaptor = ArgumentCaptor.forClass(String.class);
38 verify(mockChannel,
times(2)).send(stringArgumentCaptor.capture());
39 assertEquals(
"AppLifecycleState.inactive", stringArgumentCaptor.getValue());
42 stringArgumentCaptor = ArgumentCaptor.forClass(String.class);
43 verify(mockChannel,
times(3)).send(stringArgumentCaptor.capture());
44 assertEquals(
"AppLifecycleState.resumed", stringArgumentCaptor.getValue());
48 verify(mockChannel,
times(4)).send(
any(String.class));
52 verify(mockChannel,
times(5)).send(
any(String.class));
55 stringArgumentCaptor = ArgumentCaptor.forClass(String.class);
56 verify(mockChannel,
times(5)).send(stringArgumentCaptor.capture());
57 assertEquals(
"AppLifecycleState.resumed", stringArgumentCaptor.getValue());
63 ArgumentCaptor<String> stringArgumentCaptor = ArgumentCaptor.forClass(String.class);
64 verify(mockChannel,
times(1)).send(stringArgumentCaptor.capture());
65 assertEquals(
"AppLifecycleState.inactive", stringArgumentCaptor.getValue());
69 verify(mockChannel,
times(1)).send(
any(String.class));
73 verify(mockChannel,
times(1)).send(
any(String.class));
77 stringArgumentCaptor = ArgumentCaptor.forClass(String.class);
78 verify(mockChannel,
times(2)).send(stringArgumentCaptor.capture());
79 assertEquals(
"AppLifecycleState.resumed", stringArgumentCaptor.getValue());
86 ArgumentCaptor<String> stringArgumentCaptor = ArgumentCaptor.forClass(String.class);
87 verify(mockChannel,
times(1)).send(stringArgumentCaptor.capture());
88 assertEquals(
"AppLifecycleState.paused", stringArgumentCaptor.getValue());
92 verify(mockChannel,
times(1)).send(
any(String.class));
95 verify(mockChannel,
times(1)).send(
any(String.class));
98 stringArgumentCaptor = ArgumentCaptor.forClass(String.class);
99 verify(mockChannel,
times(2)).send(stringArgumentCaptor.capture());
100 assertEquals(
"AppLifecycleState.inactive", stringArgumentCaptor.getValue());
103 stringArgumentCaptor = ArgumentCaptor.forClass(String.class);
104 verify(mockChannel,
times(3)).send(stringArgumentCaptor.capture());
105 assertEquals(
"AppLifecycleState.resumed", stringArgumentCaptor.getValue());
112 ArgumentCaptor<String> stringArgumentCaptor = ArgumentCaptor.forClass(String.class);
113 verify(mockChannel,
times(1)).send(stringArgumentCaptor.capture());
114 assertEquals(
"AppLifecycleState.detached", stringArgumentCaptor.getValue());
118 verify(mockChannel,
times(1)).send(
any(String.class));
121 verify(mockChannel,
times(1)).send(
any(String.class));
124 stringArgumentCaptor = ArgumentCaptor.forClass(String.class);
125 verify(mockChannel,
times(2)).send(stringArgumentCaptor.capture());
126 assertEquals(
"AppLifecycleState.inactive", stringArgumentCaptor.getValue());
129 stringArgumentCaptor = ArgumentCaptor.forClass(String.class);
130 verify(mockChannel,
times(3)).send(stringArgumentCaptor.capture());
131 assertEquals(
"AppLifecycleState.resumed", stringArgumentCaptor.getValue());
static SkISize times(const SkISize &size, float factor)
void lifecycleChannel_handlesInactive()
void lifecycleChannel_handlesPaused()
LifecycleChannel lifecycleChannel
void lifecycleChannel_handlesDetached()
BasicMessageChannel< String > mockChannel
void lifecycleChannel_handlesResumed()
void noWindowsAreFocused()
SIT bool any(const Vec< 1, T > &x)