blob: dd2636803b9493cdbd77f175249e0bdb55573f52 [file] [log] [blame]
Jason Monkb5b092012017-01-05 11:35:34 -05001/*
2 * Copyright (C) 2017 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 * except in compliance with the License. You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software distributed under the
10 * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
11 * KIND, either express or implied. See the License for the specific language governing
12 * permissions and limitations under the License.
13 */
14
15package com.android.systemui.statusbar;
16
Charles Chen24e7a9f2018-11-21 11:59:07 +080017import static android.view.Display.DEFAULT_DISPLAY;
18
Charles Chenf3d295c2018-11-30 18:15:21 +080019import static org.mockito.ArgumentMatchers.anyInt;
Jason Monkb5b092012017-01-05 11:35:34 -050020import static org.mockito.Matchers.eq;
21import static org.mockito.Mockito.mock;
22import static org.mockito.Mockito.verify;
23import static org.mockito.Mockito.verifyNoMoreInteractions;
24
25import android.content.ComponentName;
26import android.graphics.Rect;
27import android.os.Bundle;
Brett Chabot84151d92019-02-27 15:37:59 -080028
29import androidx.test.filters.SmallTest;
Jason Monkb5b092012017-01-05 11:35:34 -050030
31import com.android.internal.statusbar.StatusBarIcon;
32import com.android.systemui.SysuiTestCase;
33import com.android.systemui.statusbar.CommandQueue.Callbacks;
34
35import org.junit.After;
36import org.junit.Before;
37import org.junit.Test;
38
Jason Monkfba8faf2017-05-23 10:42:59 -040039@SmallTest
Jason Monkb5b092012017-01-05 11:35:34 -050040public class CommandQueueTest extends SysuiTestCase {
41
42 private CommandQueue mCommandQueue;
43 private Callbacks mCallbacks;
44
45 @Before
46 public void setup() {
Charles Chenf3d295c2018-11-30 18:15:21 +080047 mCommandQueue = new CommandQueue(mContext);
Jason Monkb5b092012017-01-05 11:35:34 -050048 mCallbacks = mock(Callbacks.class);
Jason Monkd7c98552018-12-04 11:14:50 -050049 mCommandQueue.addCallback(mCallbacks);
Charles Chenf3d295c2018-11-30 18:15:21 +080050 verify(mCallbacks).disable(anyInt(), eq(0), eq(0), eq(false));
Jason Monkb5b092012017-01-05 11:35:34 -050051 }
52
53 @After
54 public void tearDown() {
55 verifyNoMoreInteractions(mCallbacks);
56 }
57
58 @Test
59 public void testIcon() {
60 String slot = "testSlot";
61 StatusBarIcon icon = mock(StatusBarIcon.class);
62 mCommandQueue.setIcon(slot, icon);
63 waitForIdleSync();
64 verify(mCallbacks).setIcon(eq(slot), eq(icon));
65
66 mCommandQueue.removeIcon(slot);
67 waitForIdleSync();
68 verify(mCallbacks).removeIcon(eq(slot));
69 }
70
Charles Chen24e7a9f2018-11-21 11:59:07 +080071 // TODO(b/117478341): add test case for multi-display
Jason Monkb5b092012017-01-05 11:35:34 -050072 @Test
73 public void testDisable() {
74 int state1 = 14;
75 int state2 = 42;
Charles Chen24e7a9f2018-11-21 11:59:07 +080076 mCommandQueue.disable(DEFAULT_DISPLAY, state1, state2);
Jason Monkb5b092012017-01-05 11:35:34 -050077 waitForIdleSync();
Charles Chenf3d295c2018-11-30 18:15:21 +080078 verify(mCallbacks).disable(eq(DEFAULT_DISPLAY), eq(state1), eq(state2), eq(true));
Jason Monkb5b092012017-01-05 11:35:34 -050079 }
80
81 @Test
82 public void testExpandNotifications() {
83 mCommandQueue.animateExpandNotificationsPanel();
84 waitForIdleSync();
85 verify(mCallbacks).animateExpandNotificationsPanel();
86 }
87
88 @Test
89 public void testCollapsePanels() {
90 mCommandQueue.animateCollapsePanels();
91 waitForIdleSync();
Jason Monk297c04e2018-08-23 17:16:59 -040092 verify(mCallbacks).animateCollapsePanels(eq(0), eq(false));
Jason Monkb5b092012017-01-05 11:35:34 -050093 }
94
95 @Test
96 public void testExpandSettings() {
97 String panel = "some_panel";
98 mCommandQueue.animateExpandSettingsPanel(panel);
99 waitForIdleSync();
100 verify(mCallbacks).animateExpandSettingsPanel(eq(panel));
101 }
102
Charles Chen24e7a9f2018-11-21 11:59:07 +0800103 // TODO(b/117478341): add test case for multi-display
Jason Monkb5b092012017-01-05 11:35:34 -0500104 @Test
105 public void testSetSystemUiVisibility() {
106 Rect r = new Rect();
Charles Chen24e7a9f2018-11-21 11:59:07 +0800107 mCommandQueue.setSystemUiVisibility(DEFAULT_DISPLAY, 1, 2, 3, 4, null, r);
Jason Monkb5b092012017-01-05 11:35:34 -0500108 waitForIdleSync();
Charles Chenf3d295c2018-11-30 18:15:21 +0800109 verify(mCallbacks).setSystemUiVisibility(eq(DEFAULT_DISPLAY), eq(1), eq(2), eq(3), eq(4),
110 eq(null), eq(r));
Jason Monkb5b092012017-01-05 11:35:34 -0500111 }
112
Charles Chen24e7a9f2018-11-21 11:59:07 +0800113 // TODO(b/117478341): add test case for multi-display
Jason Monkb5b092012017-01-05 11:35:34 -0500114 @Test
115 public void testTopAppWindowChanged() {
Charles Chen24e7a9f2018-11-21 11:59:07 +0800116 mCommandQueue.topAppWindowChanged(DEFAULT_DISPLAY, true);
Jason Monkb5b092012017-01-05 11:35:34 -0500117 waitForIdleSync();
Charles Chenf3d295c2018-11-30 18:15:21 +0800118 verify(mCallbacks).topAppWindowChanged(eq(DEFAULT_DISPLAY), eq(true));
Jason Monkb5b092012017-01-05 11:35:34 -0500119 }
120
Charles Chen24e7a9f2018-11-21 11:59:07 +0800121 // TODO(b/117478341): add test case for multi-display
Jason Monkb5b092012017-01-05 11:35:34 -0500122 @Test
123 public void testShowImeButton() {
Charles Chen24e7a9f2018-11-21 11:59:07 +0800124 mCommandQueue.setImeWindowStatus(DEFAULT_DISPLAY, null, 1, 2, true);
Jason Monkb5b092012017-01-05 11:35:34 -0500125 waitForIdleSync();
Charles Chenf3d295c2018-11-30 18:15:21 +0800126 verify(mCallbacks).setImeWindowStatus(
127 eq(DEFAULT_DISPLAY), eq(null), eq(1), eq(2), eq(true));
Jason Monkb5b092012017-01-05 11:35:34 -0500128 }
129
130 @Test
131 public void testShowRecentApps() {
Winson Chungdff7a732017-12-11 12:17:06 -0800132 mCommandQueue.showRecentApps(true);
Jason Monkb5b092012017-01-05 11:35:34 -0500133 waitForIdleSync();
Winson Chungdff7a732017-12-11 12:17:06 -0800134 verify(mCallbacks).showRecentApps(eq(true));
Jason Monkb5b092012017-01-05 11:35:34 -0500135 }
136
137 @Test
138 public void testHideRecentApps() {
139 mCommandQueue.hideRecentApps(true, false);
140 waitForIdleSync();
141 verify(mCallbacks).hideRecentApps(eq(true), eq(false));
142 }
143
144 @Test
145 public void testToggleRecentApps() {
146 mCommandQueue.toggleRecentApps();
147 waitForIdleSync();
148 verify(mCallbacks).toggleRecentApps();
149 }
150
151 @Test
152 public void testPreloadRecentApps() {
153 mCommandQueue.preloadRecentApps();
154 waitForIdleSync();
155 verify(mCallbacks).preloadRecentApps();
156 }
157
158 @Test
159 public void testCancelPreloadRecentApps() {
160 mCommandQueue.cancelPreloadRecentApps();
161 waitForIdleSync();
162 verify(mCallbacks).cancelPreloadRecentApps();
163 }
164
165 @Test
166 public void testDismissKeyboardShortcuts() {
167 mCommandQueue.dismissKeyboardShortcutsMenu();
168 waitForIdleSync();
169 verify(mCallbacks).dismissKeyboardShortcutsMenu();
170 }
171
172 @Test
173 public void testToggleKeyboardShortcuts() {
174 mCommandQueue.toggleKeyboardShortcutsMenu(1);
175 waitForIdleSync();
176 verify(mCallbacks).toggleKeyboardShortcutsMenu(eq(1));
177 }
178
Charles Chen24e7a9f2018-11-21 11:59:07 +0800179 // TODO(b/117478341): add test case for multi-display
Jason Monkb5b092012017-01-05 11:35:34 -0500180 @Test
181 public void testSetWindowState() {
Charles Chen24e7a9f2018-11-21 11:59:07 +0800182 mCommandQueue.setWindowState(DEFAULT_DISPLAY, 1, 2);
Jason Monkb5b092012017-01-05 11:35:34 -0500183 waitForIdleSync();
Charles Chenf3d295c2018-11-30 18:15:21 +0800184 verify(mCallbacks).setWindowState(eq(DEFAULT_DISPLAY), eq(1), eq(2));
Jason Monkb5b092012017-01-05 11:35:34 -0500185 }
186
187 @Test
Jason Monkb5b092012017-01-05 11:35:34 -0500188 public void testScreenPinRequest() {
189 mCommandQueue.showScreenPinningRequest(1);
190 waitForIdleSync();
191 verify(mCallbacks).showScreenPinningRequest(eq(1));
192 }
193
Charles Chen24e7a9f2018-11-21 11:59:07 +0800194 // TODO(b/117478341): add test case for multi-display
Jason Monkb5b092012017-01-05 11:35:34 -0500195 @Test
196 public void testAppTransitionPending() {
Charles Chen24e7a9f2018-11-21 11:59:07 +0800197 mCommandQueue.appTransitionPending(DEFAULT_DISPLAY);
Jason Monkb5b092012017-01-05 11:35:34 -0500198 waitForIdleSync();
Charles Chenf3d295c2018-11-30 18:15:21 +0800199 verify(mCallbacks).appTransitionPending(eq(DEFAULT_DISPLAY), eq(false));
Jason Monkb5b092012017-01-05 11:35:34 -0500200 }
201
Charles Chen24e7a9f2018-11-21 11:59:07 +0800202 // TODO(b/117478341): add test case for multi-display
Jason Monkb5b092012017-01-05 11:35:34 -0500203 @Test
204 public void testAppTransitionCancelled() {
Charles Chen24e7a9f2018-11-21 11:59:07 +0800205 mCommandQueue.appTransitionCancelled(DEFAULT_DISPLAY);
Jason Monkb5b092012017-01-05 11:35:34 -0500206 waitForIdleSync();
Charles Chenf3d295c2018-11-30 18:15:21 +0800207 verify(mCallbacks).appTransitionCancelled(eq(DEFAULT_DISPLAY));
Jason Monkb5b092012017-01-05 11:35:34 -0500208 }
209
Charles Chen24e7a9f2018-11-21 11:59:07 +0800210 // TODO(b/117478341): add test case for multi-display
Jason Monkb5b092012017-01-05 11:35:34 -0500211 @Test
212 public void testAppTransitionStarting() {
Charles Chen24e7a9f2018-11-21 11:59:07 +0800213 mCommandQueue.appTransitionStarting(DEFAULT_DISPLAY, 1, 2);
Jason Monkb5b092012017-01-05 11:35:34 -0500214 waitForIdleSync();
Charles Chenf3d295c2018-11-30 18:15:21 +0800215 verify(mCallbacks).appTransitionStarting(
216 eq(DEFAULT_DISPLAY), eq(1L), eq(2L), eq(false));
Jason Monkb5b092012017-01-05 11:35:34 -0500217 }
218
Charles Chen24e7a9f2018-11-21 11:59:07 +0800219 // TODO(b/117478341): add test case for multi-display
Jason Monkb5b092012017-01-05 11:35:34 -0500220 @Test
221 public void testAppTransitionFinished() {
Charles Chen24e7a9f2018-11-21 11:59:07 +0800222 mCommandQueue.appTransitionFinished(DEFAULT_DISPLAY);
Jason Monkb5b092012017-01-05 11:35:34 -0500223 waitForIdleSync();
Charles Chenf3d295c2018-11-30 18:15:21 +0800224 verify(mCallbacks).appTransitionFinished(eq(DEFAULT_DISPLAY));
Jason Monkb5b092012017-01-05 11:35:34 -0500225 }
226
227 @Test
228 public void testAssistDisclosure() {
229 mCommandQueue.showAssistDisclosure();
230 waitForIdleSync();
231 verify(mCallbacks).showAssistDisclosure();
232 }
233
234 @Test
235 public void testStartAssist() {
236 Bundle b = new Bundle();
237 mCommandQueue.startAssist(b);
238 waitForIdleSync();
239 verify(mCallbacks).startAssist(eq(b));
240 }
241
242 @Test
243 public void testCameraLaunchGesture() {
244 mCommandQueue.onCameraLaunchGestureDetected(1);
245 waitForIdleSync();
246 verify(mCallbacks).onCameraLaunchGestureDetected(eq(1));
247 }
248
249 @Test
Winson Chungac52f282017-03-30 14:44:52 -0700250 public void testShowPipMenu() {
251 mCommandQueue.showPictureInPictureMenu();
Jason Monkb5b092012017-01-05 11:35:34 -0500252 waitForIdleSync();
Winson Chungac52f282017-03-30 14:44:52 -0700253 verify(mCallbacks).showPictureInPictureMenu();
Jason Monkb5b092012017-01-05 11:35:34 -0500254 }
255
256 @Test
257 public void testAddQsTile() {
258 ComponentName c = new ComponentName("testpkg", "testcls");
259 mCommandQueue.addQsTile(c);
260 waitForIdleSync();
261 verify(mCallbacks).addQsTile(eq(c));
262 }
263
264 @Test
265 public void testRemoveQsTile() {
266 ComponentName c = new ComponentName("testpkg", "testcls");
267 mCommandQueue.remQsTile(c);
268 waitForIdleSync();
269 verify(mCallbacks).remQsTile(eq(c));
270 }
271
272 @Test
273 public void testClickQsTile() {
274 ComponentName c = new ComponentName("testpkg", "testcls");
275 mCommandQueue.clickQsTile(c);
276 waitForIdleSync();
277 verify(mCallbacks).clickTile(eq(c));
278 }
279
280 @Test
281 public void testToggleAppSplitScreen() {
282 mCommandQueue.toggleSplitScreen();
283 waitForIdleSync();
284 verify(mCallbacks).toggleSplitScreen();
285 }
286
287 @Test
Philip Quinnc3a503d2017-07-18 23:23:41 -0700288 public void testHandleSysKey() {
289 mCommandQueue.handleSystemKey(1);
Jason Monkb5b092012017-01-05 11:35:34 -0500290 waitForIdleSync();
Philip Quinnc3a503d2017-07-18 23:23:41 -0700291 verify(mCallbacks).handleSystemKey(eq(1));
Jason Monkb5b092012017-01-05 11:35:34 -0500292 }
293}