blob: 9f113ad3137eb4e5de6231df522179225e36f4e0 [file] [log] [blame]
Wale Ogunwaleb699ce02016-07-18 12:05:30 -07001/*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License
15 */
16
17package com.android.server.wm;
18
Adrian Roos0e7b70a2018-06-07 15:29:34 +020019import android.graphics.Rect;
20import android.view.SurfaceControl;
Bryce Leeae73ba42017-05-05 09:58:25 -070021import android.view.WindowManager;
Wale Ogunwalea7e3b642016-08-29 10:15:34 -070022import org.junit.Test;
23import org.junit.runner.RunWith;
24
Wale Ogunwale5fc70962016-09-09 22:36:19 -070025import android.platform.test.annotations.Presubmit;
chaviw4f0f3482018-03-01 15:47:56 -080026import android.support.test.filters.FlakyTest;
Wale Ogunwalea7e3b642016-08-29 10:15:34 -070027import android.support.test.filters.SmallTest;
28import android.support.test.runner.AndroidJUnit4;
Wale Ogunwaleb699ce02016-07-18 12:05:30 -070029
Wale Ogunwale34247952017-02-19 11:57:53 -080030import java.util.LinkedList;
31
chaviwb28de1f2018-03-02 10:42:36 -080032import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD;
33import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
Adrian Roos0e7b70a2018-06-07 15:29:34 +020034import static android.hardware.camera2.params.OutputConfiguration.ROTATION_90;
35import static android.view.Surface.ROTATION_0;
Wale Ogunwaleb699ce02016-07-18 12:05:30 -070036import static android.view.WindowManager.LayoutParams.FIRST_SUB_WINDOW;
Wale Ogunwale805d9ec2016-12-07 12:22:08 -080037import static android.view.WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM;
38import static android.view.WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
Wale Ogunwaleb699ce02016-07-18 12:05:30 -070039import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION;
Wale Ogunwale34247952017-02-19 11:57:53 -080040import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_ABOVE_SUB_PANEL;
41import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG;
42import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA;
43import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA_OVERLAY;
Suprabh Shukla69c71422018-04-02 18:39:01 -070044import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
Wale Ogunwale34247952017-02-19 11:57:53 -080045import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_SUB_PANEL;
Wale Ogunwale805d9ec2016-12-07 12:22:08 -080046import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD;
chaviwebcbc342018-02-07 13:19:00 -080047
Adrian Roos5251b1d2018-03-23 18:57:43 +010048import static org.hamcrest.Matchers.is;
49import static org.hamcrest.Matchers.not;
Wale Ogunwalea7e3b642016-08-29 10:15:34 -070050import static org.junit.Assert.assertEquals;
51import static org.junit.Assert.assertFalse;
52import static org.junit.Assert.assertNull;
Adrian Roos5251b1d2018-03-23 18:57:43 +010053import static org.junit.Assert.assertThat;
Wale Ogunwalea7e3b642016-08-29 10:15:34 -070054import static org.junit.Assert.assertTrue;
Adrian Roos0e7b70a2018-06-07 15:29:34 +020055import static org.mockito.ArgumentMatchers.any;
chaviw40234662018-02-07 09:37:16 -080056import static org.mockito.ArgumentMatchers.anyLong;
57import static org.mockito.ArgumentMatchers.anyString;
Adrian Roos0e7b70a2018-06-07 15:29:34 +020058import static org.mockito.Mockito.mock;
chaviwb28de1f2018-03-02 10:42:36 -080059import static org.mockito.Mockito.never;
chaviw40234662018-02-07 09:37:16 -080060import static org.mockito.Mockito.reset;
Suprabh Shukla69c71422018-04-02 18:39:01 -070061import static org.mockito.Mockito.spy;
chaviw40234662018-02-07 09:37:16 -080062import static org.mockito.Mockito.verify;
Wale Ogunwaleb699ce02016-07-18 12:05:30 -070063
64/**
65 * Tests for the {@link WindowState} class.
66 *
Jorim Jaggi72207752018-01-08 13:16:59 +010067 * atest FrameworksServicesTests:com.android.server.wm.WindowStateTests
Wale Ogunwaleb699ce02016-07-18 12:05:30 -070068 */
Wale Ogunwaleadde52e2016-07-16 13:11:55 -070069@SmallTest
chaviw36d0a342018-03-01 17:29:21 -080070@FlakyTest(bugId = 74078662)
Wale Ogunwale5fc70962016-09-09 22:36:19 -070071@Presubmit
Wale Ogunwalea7e3b642016-08-29 10:15:34 -070072@RunWith(AndroidJUnit4.class)
Wale Ogunwale44fbdf52016-11-16 10:18:45 -080073public class WindowStateTests extends WindowTestsBase {
Wale Ogunwaleb699ce02016-07-18 12:05:30 -070074
Wale Ogunwalea7e3b642016-08-29 10:15:34 -070075 @Test
Wale Ogunwale9d147902016-07-16 11:58:55 -070076 public void testIsParentWindowHidden() throws Exception {
Wale Ogunwale805d9ec2016-12-07 12:22:08 -080077 final WindowState parentWindow = createWindow(null, TYPE_APPLICATION, "parentWindow");
78 final WindowState child1 = createWindow(parentWindow, FIRST_SUB_WINDOW, "child1");
79 final WindowState child2 = createWindow(parentWindow, FIRST_SUB_WINDOW, "child2");
Wale Ogunwale9d147902016-07-16 11:58:55 -070080
chaviwebcbc342018-02-07 13:19:00 -080081 // parentWindow is initially set to hidden.
82 assertTrue(parentWindow.mHidden);
83 assertFalse(parentWindow.isParentWindowHidden());
84 assertTrue(child1.isParentWindowHidden());
85 assertTrue(child2.isParentWindowHidden());
86
87 parentWindow.mHidden = false;
Wale Ogunwale9d147902016-07-16 11:58:55 -070088 assertFalse(parentWindow.isParentWindowHidden());
89 assertFalse(child1.isParentWindowHidden());
90 assertFalse(child2.isParentWindowHidden());
91
Wale Ogunwale9d147902016-07-16 11:58:55 -070092 }
93
Wale Ogunwalea7e3b642016-08-29 10:15:34 -070094 @Test
Wale Ogunwaleadde52e2016-07-16 13:11:55 -070095 public void testIsChildWindow() throws Exception {
Wale Ogunwale805d9ec2016-12-07 12:22:08 -080096 final WindowState parentWindow = createWindow(null, TYPE_APPLICATION, "parentWindow");
97 final WindowState child1 = createWindow(parentWindow, FIRST_SUB_WINDOW, "child1");
98 final WindowState child2 = createWindow(parentWindow, FIRST_SUB_WINDOW, "child2");
99 final WindowState randomWindow = createWindow(null, TYPE_APPLICATION, "randomWindow");
Wale Ogunwaleadde52e2016-07-16 13:11:55 -0700100
101 assertFalse(parentWindow.isChildWindow());
102 assertTrue(child1.isChildWindow());
103 assertTrue(child2.isChildWindow());
104 assertFalse(randomWindow.isChildWindow());
105 }
106
Wale Ogunwalea7e3b642016-08-29 10:15:34 -0700107 @Test
Wale Ogunwaleadde52e2016-07-16 13:11:55 -0700108 public void testHasChild() throws Exception {
Wale Ogunwale805d9ec2016-12-07 12:22:08 -0800109 final WindowState win1 = createWindow(null, TYPE_APPLICATION, "win1");
110 final WindowState win11 = createWindow(win1, FIRST_SUB_WINDOW, "win11");
111 final WindowState win12 = createWindow(win1, FIRST_SUB_WINDOW, "win12");
112 final WindowState win2 = createWindow(null, TYPE_APPLICATION, "win2");
113 final WindowState win21 = createWindow(win2, FIRST_SUB_WINDOW, "win21");
114 final WindowState randomWindow = createWindow(null, TYPE_APPLICATION, "randomWindow");
Wale Ogunwaleadde52e2016-07-16 13:11:55 -0700115
116 assertTrue(win1.hasChild(win11));
117 assertTrue(win1.hasChild(win12));
118 assertTrue(win2.hasChild(win21));
119
120 assertFalse(win1.hasChild(win21));
121 assertFalse(win1.hasChild(randomWindow));
122
123 assertFalse(win2.hasChild(win11));
124 assertFalse(win2.hasChild(win12));
125 assertFalse(win2.hasChild(randomWindow));
126 }
127
Wale Ogunwalea7e3b642016-08-29 10:15:34 -0700128 @Test
Wale Ogunwalecaa53af2016-07-17 14:50:26 -0700129 public void testGetParentWindow() throws Exception {
Wale Ogunwale805d9ec2016-12-07 12:22:08 -0800130 final WindowState parentWindow = createWindow(null, TYPE_APPLICATION, "parentWindow");
131 final WindowState child1 = createWindow(parentWindow, FIRST_SUB_WINDOW, "child1");
132 final WindowState child2 = createWindow(parentWindow, FIRST_SUB_WINDOW, "child2");
Wale Ogunwalecaa53af2016-07-17 14:50:26 -0700133
134 assertNull(parentWindow.getParentWindow());
135 assertEquals(parentWindow, child1.getParentWindow());
136 assertEquals(parentWindow, child2.getParentWindow());
137 }
138
Wale Ogunwalea7e3b642016-08-29 10:15:34 -0700139 @Test
Suprabh Shukla69c71422018-04-02 18:39:01 -0700140 public void testOverlayWindowHiddenWhenSuspended() {
141 final WindowState overlayWindow = spy(createWindow(null, TYPE_APPLICATION_OVERLAY,
142 "overlayWindow"));
143 overlayWindow.setHiddenWhileSuspended(true);
144 verify(overlayWindow).hideLw(true, true);
145 overlayWindow.setHiddenWhileSuspended(false);
146 verify(overlayWindow).showLw(true, true);
147 }
148
149 @Test
Wale Ogunwalecaa53af2016-07-17 14:50:26 -0700150 public void testGetTopParentWindow() throws Exception {
Wale Ogunwale805d9ec2016-12-07 12:22:08 -0800151 final WindowState root = createWindow(null, TYPE_APPLICATION, "root");
152 final WindowState child1 = createWindow(root, FIRST_SUB_WINDOW, "child1");
153 final WindowState child2 = createWindow(child1, FIRST_SUB_WINDOW, "child2");
Wale Ogunwalecaa53af2016-07-17 14:50:26 -0700154
155 assertEquals(root, root.getTopParentWindow());
156 assertEquals(root, child1.getTopParentWindow());
157 assertEquals(child1, child2.getParentWindow());
158 assertEquals(root, child2.getTopParentWindow());
Wale Ogunwaleea92d972016-12-08 07:33:13 -0800159
160 // Test case were child is detached from parent.
161 root.removeChild(child1);
162 assertEquals(child1, child1.getTopParentWindow());
163 assertEquals(child1, child2.getParentWindow());
Wale Ogunwalecaa53af2016-07-17 14:50:26 -0700164 }
165
Jorim Jaggiaf221d12016-11-15 14:59:57 -0800166 @Test
167 public void testIsOnScreen_hiddenByPolicy() {
Wale Ogunwale805d9ec2016-12-07 12:22:08 -0800168 final WindowState window = createWindow(null, TYPE_APPLICATION, "window");
Jorim Jaggiaf221d12016-11-15 14:59:57 -0800169 window.setHasSurface(true);
170 assertTrue(window.isOnScreen());
171 window.hideLw(false /* doAnimation */);
172 assertFalse(window.isOnScreen());
173 }
Wale Ogunwale805d9ec2016-12-07 12:22:08 -0800174
175 @Test
176 public void testCanBeImeTarget() throws Exception {
177 final WindowState appWindow = createWindow(null, TYPE_APPLICATION, "appWindow");
178 final WindowState imeWindow = createWindow(null, TYPE_INPUT_METHOD, "imeWindow");
179
180 // Setting FLAG_NOT_FOCUSABLE without FLAG_ALT_FOCUSABLE_IM prevents the window from being
181 // an IME target.
182 appWindow.mAttrs.flags |= FLAG_NOT_FOCUSABLE;
183 imeWindow.mAttrs.flags |= FLAG_NOT_FOCUSABLE;
184
185 // Make windows visible
186 appWindow.setHasSurface(true);
187 imeWindow.setHasSurface(true);
188
189 // Windows without flags (FLAG_NOT_FOCUSABLE|FLAG_ALT_FOCUSABLE_IM) can't be IME targets
190 assertFalse(appWindow.canBeImeTarget());
191 assertFalse(imeWindow.canBeImeTarget());
192
193 // Add IME target flags
194 appWindow.mAttrs.flags |= (FLAG_NOT_FOCUSABLE | FLAG_ALT_FOCUSABLE_IM);
195 imeWindow.mAttrs.flags |= (FLAG_NOT_FOCUSABLE | FLAG_ALT_FOCUSABLE_IM);
196
197 // Visible app window with flags can be IME target while an IME window can never be an IME
198 // target regardless of its visibility or flags.
199 assertTrue(appWindow.canBeImeTarget());
200 assertFalse(imeWindow.canBeImeTarget());
201
202 // Make windows invisible
203 appWindow.hideLw(false /* doAnimation */);
204 imeWindow.hideLw(false /* doAnimation */);
205
206 // Invisible window can't be IME targets even if they have the right flags.
207 assertFalse(appWindow.canBeImeTarget());
208 assertFalse(imeWindow.canBeImeTarget());
209 }
Wale Ogunwale34247952017-02-19 11:57:53 -0800210
211 @Test
212 public void testGetWindow() throws Exception {
213 final WindowState root = createWindow(null, TYPE_APPLICATION, "root");
214 final WindowState mediaChild = createWindow(root, TYPE_APPLICATION_MEDIA, "mediaChild");
215 final WindowState mediaOverlayChild = createWindow(root,
216 TYPE_APPLICATION_MEDIA_OVERLAY, "mediaOverlayChild");
217 final WindowState attachedDialogChild = createWindow(root,
218 TYPE_APPLICATION_ATTACHED_DIALOG, "attachedDialogChild");
219 final WindowState subPanelChild = createWindow(root,
220 TYPE_APPLICATION_SUB_PANEL, "subPanelChild");
221 final WindowState aboveSubPanelChild = createWindow(root,
222 TYPE_APPLICATION_ABOVE_SUB_PANEL, "aboveSubPanelChild");
223
224 final LinkedList<WindowState> windows = new LinkedList();
225
226 root.getWindow(w -> {
227 windows.addLast(w);
228 return false;
229 });
230
231 // getWindow should have returned candidate windows in z-order.
232 assertEquals(aboveSubPanelChild, windows.pollFirst());
233 assertEquals(subPanelChild, windows.pollFirst());
234 assertEquals(attachedDialogChild, windows.pollFirst());
235 assertEquals(root, windows.pollFirst());
236 assertEquals(mediaOverlayChild, windows.pollFirst());
237 assertEquals(mediaChild, windows.pollFirst());
238 assertTrue(windows.isEmpty());
239 }
Bryce Leeae73ba42017-05-05 09:58:25 -0700240
241 @Test
242 public void testPrepareWindowToDisplayDuringRelayout() throws Exception {
243 testPrepareWindowToDisplayDuringRelayout(false /*wasVisible*/);
244 testPrepareWindowToDisplayDuringRelayout(true /*wasVisible*/);
chaviwb28de1f2018-03-02 10:42:36 -0800245
246 // Call prepareWindowToDisplayDuringRelayout for a window without FLAG_TURN_SCREEN_ON
247 // before calling prepareWindowToDisplayDuringRelayout for windows with flag in the same
248 // appWindowToken.
249 final AppWindowToken appWindowToken = createAppWindowToken(mDisplayContent,
250 WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD);
251 final WindowState first = createWindow(null, TYPE_APPLICATION, appWindowToken, "first");
252 final WindowState second = createWindow(null, TYPE_APPLICATION, appWindowToken, "second");
253 second.mAttrs.flags |= WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON;
254
255 reset(mPowerManagerWrapper);
256 first.prepareWindowToDisplayDuringRelayout(false /*wasVisible*/);
257 verify(mPowerManagerWrapper, never()).wakeUp(anyLong(), anyString());
258 assertTrue(appWindowToken.canTurnScreenOn());
259
260 reset(mPowerManagerWrapper);
261 second.prepareWindowToDisplayDuringRelayout(false /*wasVisible*/);
262 verify(mPowerManagerWrapper).wakeUp(anyLong(), anyString());
263 assertFalse(appWindowToken.canTurnScreenOn());
264
265 // Call prepareWindowToDisplayDuringRelayout for two window that have FLAG_TURN_SCREEN_ON
266 // from the same appWindowToken. Only one should trigger the wakeup.
267 appWindowToken.setCanTurnScreenOn(true);
268 first.mAttrs.flags |= WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON;
269 second.mAttrs.flags |= WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON;
270
271 reset(mPowerManagerWrapper);
272 first.prepareWindowToDisplayDuringRelayout(false /*wasVisible*/);
273 verify(mPowerManagerWrapper).wakeUp(anyLong(), anyString());
274 assertFalse(appWindowToken.canTurnScreenOn());
275
276 reset(mPowerManagerWrapper);
277 second.prepareWindowToDisplayDuringRelayout(false /*wasVisible*/);
278 verify(mPowerManagerWrapper, never()).wakeUp(anyLong(), anyString());
279 assertFalse(appWindowToken.canTurnScreenOn());
280
281 // Call prepareWindowToDisplayDuringRelayout for a windows that are not children of an
282 // appWindowToken. Both windows have the FLAG_TURNS_SCREEN_ON so both should call wakeup
chaviw97d28202018-02-27 16:23:53 -0800283 final WindowToken windowToken = WindowTestUtils.createTestWindowToken(FIRST_SUB_WINDOW,
chaviwb28de1f2018-03-02 10:42:36 -0800284 mDisplayContent);
285 final WindowState firstWindow = createWindow(null, TYPE_APPLICATION, windowToken,
286 "firstWindow");
287 final WindowState secondWindow = createWindow(null, TYPE_APPLICATION, windowToken,
288 "secondWindow");
289 firstWindow.mAttrs.flags |= WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON;
290 secondWindow.mAttrs.flags |= WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON;
291
292 reset(mPowerManagerWrapper);
293 firstWindow.prepareWindowToDisplayDuringRelayout(false /*wasVisible*/);
294 verify(mPowerManagerWrapper).wakeUp(anyLong(), anyString());
295
296 reset(mPowerManagerWrapper);
297 secondWindow.prepareWindowToDisplayDuringRelayout(false /*wasVisible*/);
298 verify(mPowerManagerWrapper).wakeUp(anyLong(), anyString());
Bryce Leeae73ba42017-05-05 09:58:25 -0700299 }
300
Jorim Jaggi72207752018-01-08 13:16:59 +0100301 @Test
302 public void testCanAffectSystemUiFlags() throws Exception {
303 final WindowState app = createWindow(null, TYPE_APPLICATION, "app");
304 app.mToken.setHidden(false);
305 assertTrue(app.canAffectSystemUiFlags());
306 app.mToken.setHidden(true);
307 assertFalse(app.canAffectSystemUiFlags());
308 app.mToken.setHidden(false);
309 app.mAttrs.alpha = 0.0f;
310 assertFalse(app.canAffectSystemUiFlags());
Jorim Jaggi50bf59c2018-03-09 17:29:48 +0100311
312 }
313
314 @Test
315 public void testCanAffectSystemUiFlags_disallow() throws Exception {
316 final WindowState app = createWindow(null, TYPE_APPLICATION, "app");
317 app.mToken.setHidden(false);
318 assertTrue(app.canAffectSystemUiFlags());
319 app.getTask().setCanAffectSystemUiFlags(false);
320 assertFalse(app.canAffectSystemUiFlags());
Jorim Jaggi72207752018-01-08 13:16:59 +0100321 }
322
Jorim Jaggi4876b4a2018-01-11 15:43:49 +0100323 @Test
324 public void testIsSelfOrAncestorWindowAnimating() throws Exception {
325 final WindowState root = createWindow(null, TYPE_APPLICATION, "root");
326 final WindowState child1 = createWindow(root, FIRST_SUB_WINDOW, "child1");
327 final WindowState child2 = createWindow(child1, FIRST_SUB_WINDOW, "child2");
328 assertFalse(child2.isSelfOrAncestorWindowAnimatingExit());
329 child2.mAnimatingExit = true;
330 assertTrue(child2.isSelfOrAncestorWindowAnimatingExit());
331 child2.mAnimatingExit = false;
332 root.mAnimatingExit = true;
333 assertTrue(child2.isSelfOrAncestorWindowAnimatingExit());
334 }
335
Adrian Roos5251b1d2018-03-23 18:57:43 +0100336 @Test
337 public void testLayoutSeqResetOnReparent() throws Exception {
338 final WindowState app = createWindow(null, TYPE_APPLICATION, "app");
339 app.mLayoutSeq = 1;
340 mDisplayContent.mLayoutSeq = 1;
341
342 app.onDisplayChanged(mDisplayContent);
343
344 assertThat(app.mLayoutSeq, not(is(mDisplayContent.mLayoutSeq)));
345 }
346
Brad Stenningaf596412018-04-02 12:03:19 -0700347 @Test
348 public void testDisplayIdUpdatedOnReparent() throws Exception {
349 final WindowState app = createWindow(null, TYPE_APPLICATION, "app");
350 // fake a different display
351 app.mInputWindowHandle.displayId = mDisplayContent.getDisplayId() + 1;
352 app.onDisplayChanged(mDisplayContent);
353
354 assertThat(app.mInputWindowHandle.displayId, is(mDisplayContent.getDisplayId()));
355 assertThat(app.getDisplayId(), is(mDisplayContent.getDisplayId()));
356 }
357
Adrian Roos0e7b70a2018-06-07 15:29:34 +0200358 @Test
359 public void testSeamlesslyRotateWindow() {
360 final WindowState app = createWindow(null, TYPE_APPLICATION, "app");
361 final SurfaceControl.Transaction t = mock(SurfaceControl.Transaction.class);
362
363 app.mHasSurface = true;
364 app.mSurfaceControl = mock(SurfaceControl.class);
365 app.mWinAnimator.mSurfaceController = mock(WindowSurfaceController.class);
366 try {
367 app.mFrame.set(10, 20, 60, 80);
368
369 app.seamlesslyRotate(t, ROTATION_0, ROTATION_90);
370
371 assertTrue(app.mSeamlesslyRotated);
372 assertEquals(new Rect(20, mDisplayInfo.logicalWidth - 60,
373 80, mDisplayInfo.logicalWidth - 10), app.mFrame);
374
375 verify(t).setPosition(app.mSurfaceControl, app.mFrame.left, app.mFrame.top);
376 verify(app.mWinAnimator.mSurfaceController).setPosition(t, 0, 50, false);
377 verify(app.mWinAnimator.mSurfaceController).setMatrix(t, 0, -1, 1, 0, false);
378 } finally {
379 app.mSurfaceControl = null;
380 app.mHasSurface = false;
381 }
382 }
383
Bryce Leeae73ba42017-05-05 09:58:25 -0700384 private void testPrepareWindowToDisplayDuringRelayout(boolean wasVisible) {
chaviw40234662018-02-07 09:37:16 -0800385 reset(mPowerManagerWrapper);
Bryce Leeae73ba42017-05-05 09:58:25 -0700386 final WindowState root = createWindow(null, TYPE_APPLICATION, "root");
387 root.mAttrs.flags |= WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON;
Bryce Leeae73ba42017-05-05 09:58:25 -0700388
Bryce Leef858b572017-06-29 14:03:33 -0700389 root.prepareWindowToDisplayDuringRelayout(wasVisible /*wasVisible*/);
chaviw40234662018-02-07 09:37:16 -0800390 verify(mPowerManagerWrapper).wakeUp(anyLong(), anyString());
Bryce Leeae73ba42017-05-05 09:58:25 -0700391 }
Wale Ogunwaleb699ce02016-07-18 12:05:30 -0700392}