Wale Ogunwale | 44fbdf5 | 2016-11-16 10:18:45 -0800 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package com.android.server.wm; |
| 18 | |
Wale Ogunwale | 11cc516 | 2017-04-25 20:29:13 -0700 | [diff] [blame] | 19 | import static android.view.Display.DEFAULT_DISPLAY; |
David Stevens | 4693956 | 2017-03-24 13:04:00 -0700 | [diff] [blame] | 20 | import static android.view.View.VISIBLE; |
| 21 | |
Wale Ogunwale | c5cc301 | 2017-01-13 13:26:16 -0800 | [diff] [blame] | 22 | import android.graphics.Rect; |
Andrii Kulian | 367ff7f | 2017-01-25 19:45:34 -0800 | [diff] [blame] | 23 | import android.hardware.display.DisplayManagerGlobal; |
Andrii Kulian | 367ff7f | 2017-01-25 19:45:34 -0800 | [diff] [blame] | 24 | import android.view.Display; |
| 25 | import android.view.DisplayInfo; |
Wale Ogunwale | 44fbdf5 | 2016-11-16 10:18:45 -0800 | [diff] [blame] | 26 | import org.junit.Assert; |
Wale Ogunwale | 17f175c | 2017-02-07 16:54:10 -0800 | [diff] [blame] | 27 | import org.junit.After; |
Wale Ogunwale | 44fbdf5 | 2016-11-16 10:18:45 -0800 | [diff] [blame] | 28 | import org.junit.Before; |
Jorim Jaggi | 9bafc71 | 2017-01-19 17:28:30 +0100 | [diff] [blame] | 29 | import org.mockito.MockitoAnnotations; |
Wale Ogunwale | 44fbdf5 | 2016-11-16 10:18:45 -0800 | [diff] [blame] | 30 | |
| 31 | import android.content.Context; |
Wale Ogunwale | 44fbdf5 | 2016-11-16 10:18:45 -0800 | [diff] [blame] | 32 | import android.support.test.InstrumentationRegistry; |
Wale Ogunwale | 44fbdf5 | 2016-11-16 10:18:45 -0800 | [diff] [blame] | 33 | import android.view.IWindow; |
| 34 | import android.view.WindowManager; |
| 35 | |
| 36 | import static android.app.ActivityManager.StackId.FIRST_DYNAMIC_STACK_ID; |
Winson Chung | 8347163 | 2016-12-13 11:02:12 -0800 | [diff] [blame] | 37 | import static android.app.ActivityManager.StackId.INVALID_STACK_ID; |
Wale Ogunwale | 44fbdf5 | 2016-11-16 10:18:45 -0800 | [diff] [blame] | 38 | import static android.app.AppOpsManager.OP_NONE; |
Andrii Kulian | 367ff7f | 2017-01-25 19:45:34 -0800 | [diff] [blame] | 39 | import static android.view.DisplayAdjustments.DEFAULT_DISPLAY_ADJUSTMENTS; |
Wale Ogunwale | 44fbdf5 | 2016-11-16 10:18:45 -0800 | [diff] [blame] | 40 | import static android.view.WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW; |
Wale Ogunwale | 3424795 | 2017-02-19 11:57:53 -0800 | [diff] [blame] | 41 | import static android.view.WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; |
Wale Ogunwale | 44fbdf5 | 2016-11-16 10:18:45 -0800 | [diff] [blame] | 42 | import static android.view.WindowManager.LayoutParams.LAST_APPLICATION_WINDOW; |
Wale Ogunwale | 3c1170d | 2016-12-02 14:44:52 -0800 | [diff] [blame] | 43 | import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG; |
| 44 | import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA_OVERLAY; |
| 45 | import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION; |
| 46 | import static android.view.WindowManager.LayoutParams.TYPE_DOCK_DIVIDER; |
| 47 | import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD; |
| 48 | import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD_DIALOG; |
| 49 | import static android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR; |
| 50 | import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR; |
| 51 | import static android.view.WindowManager.LayoutParams.TYPE_WALLPAPER; |
Wale Ogunwale | 44fbdf5 | 2016-11-16 10:18:45 -0800 | [diff] [blame] | 52 | import static org.mockito.Mockito.mock; |
| 53 | |
Jorim Jaggi | 9bafc71 | 2017-01-19 17:28:30 +0100 | [diff] [blame] | 54 | import com.android.server.AttributeCache; |
Wale Ogunwale | 17f175c | 2017-02-07 16:54:10 -0800 | [diff] [blame] | 55 | |
| 56 | import java.util.HashSet; |
Wale Ogunwale | 3424795 | 2017-02-19 11:57:53 -0800 | [diff] [blame] | 57 | import java.util.LinkedList; |
Jorim Jaggi | 9bafc71 | 2017-01-19 17:28:30 +0100 | [diff] [blame] | 58 | |
Wale Ogunwale | 44fbdf5 | 2016-11-16 10:18:45 -0800 | [diff] [blame] | 59 | /** |
| 60 | * Common base class for window manager unit test classes. |
| 61 | */ |
Wale Ogunwale | 26c0dfe | 2016-12-14 14:42:30 -0800 | [diff] [blame] | 62 | class WindowTestsBase { |
Wale Ogunwale | 44fbdf5 | 2016-11-16 10:18:45 -0800 | [diff] [blame] | 63 | static WindowManagerService sWm = null; |
Wale Ogunwale | 11cc516 | 2017-04-25 20:29:13 -0700 | [diff] [blame] | 64 | private static final IWindow sIWindow = new TestIWindow(); |
| 65 | private static final Session sMockSession = mock(Session.class); |
Bryce Lee | 310de9e | 2017-03-15 10:18:21 -0700 | [diff] [blame] | 66 | // The default display is removed in {@link #setUp} and then we iterate over all displays to |
| 67 | // make sure we don't collide with any existing display. If we run into no other display, the |
Bryce Lee | 6272c7f | 2017-03-17 17:22:35 -0700 | [diff] [blame] | 68 | // added display should be treated as default. This cannot be the default display |
Wale Ogunwale | 11cc516 | 2017-04-25 20:29:13 -0700 | [diff] [blame] | 69 | private static int sNextDisplayId = DEFAULT_DISPLAY + 1; |
Bryce Lee | af691c0 | 2017-03-20 14:20:22 -0700 | [diff] [blame] | 70 | private static int sNextStackId = FIRST_DYNAMIC_STACK_ID; |
Wale Ogunwale | 44fbdf5 | 2016-11-16 10:18:45 -0800 | [diff] [blame] | 71 | |
Wale Ogunwale | 3c1170d | 2016-12-02 14:44:52 -0800 | [diff] [blame] | 72 | private static boolean sOneTimeSetupDone = false; |
Wale Ogunwale | 11cc516 | 2017-04-25 20:29:13 -0700 | [diff] [blame] | 73 | DisplayContent mDisplayContent; |
| 74 | DisplayInfo mDisplayInfo = new DisplayInfo(); |
| 75 | WindowLayersController mLayersController; |
| 76 | WindowState mWallpaperWindow; |
| 77 | WindowState mImeWindow; |
| 78 | WindowState mImeDialogWindow; |
| 79 | WindowState mStatusBarWindow; |
| 80 | WindowState mDockedDividerWindow; |
| 81 | WindowState mNavBarWindow; |
| 82 | WindowState mAppWindow; |
| 83 | WindowState mChildAppWindowAbove; |
| 84 | WindowState mChildAppWindowBelow; |
| 85 | HashSet<WindowState> mCommonWindows; |
Wale Ogunwale | 3c1170d | 2016-12-02 14:44:52 -0800 | [diff] [blame] | 86 | |
Wale Ogunwale | 44fbdf5 | 2016-11-16 10:18:45 -0800 | [diff] [blame] | 87 | @Before |
| 88 | public void setUp() throws Exception { |
Wale Ogunwale | 11cc516 | 2017-04-25 20:29:13 -0700 | [diff] [blame] | 89 | if (!sOneTimeSetupDone) { |
| 90 | sOneTimeSetupDone = true; |
| 91 | MockitoAnnotations.initMocks(this); |
Wale Ogunwale | 3c1170d | 2016-12-02 14:44:52 -0800 | [diff] [blame] | 92 | } |
Wale Ogunwale | 11cc516 | 2017-04-25 20:29:13 -0700 | [diff] [blame] | 93 | |
Wale Ogunwale | 44fbdf5 | 2016-11-16 10:18:45 -0800 | [diff] [blame] | 94 | final Context context = InstrumentationRegistry.getTargetContext(); |
Jorim Jaggi | 9bafc71 | 2017-01-19 17:28:30 +0100 | [diff] [blame] | 95 | AttributeCache.init(context); |
Wale Ogunwale | 44fbdf5 | 2016-11-16 10:18:45 -0800 | [diff] [blame] | 96 | sWm = TestWindowManagerPolicy.getWindowManagerService(context); |
Wale Ogunwale | 11cc516 | 2017-04-25 20:29:13 -0700 | [diff] [blame] | 97 | mLayersController = new WindowLayersController(sWm); |
Bryce Lee | 6272c7f | 2017-03-17 17:22:35 -0700 | [diff] [blame] | 98 | |
Wale Ogunwale | 11cc516 | 2017-04-25 20:29:13 -0700 | [diff] [blame] | 99 | context.getDisplay().getDisplayInfo(mDisplayInfo); |
| 100 | mDisplayContent = createNewDisplay(); |
Jorim Jaggi | 9bafc71 | 2017-01-19 17:28:30 +0100 | [diff] [blame] | 101 | sWm.mDisplayEnabled = true; |
| 102 | sWm.mDisplayReady = true; |
Wale Ogunwale | 3c1170d | 2016-12-02 14:44:52 -0800 | [diff] [blame] | 103 | |
| 104 | // Set-up some common windows. |
Wale Ogunwale | 11cc516 | 2017-04-25 20:29:13 -0700 | [diff] [blame] | 105 | mCommonWindows = new HashSet(); |
| 106 | mWallpaperWindow = createCommonWindow(null, TYPE_WALLPAPER, "wallpaperWindow"); |
| 107 | mImeWindow = createCommonWindow(null, TYPE_INPUT_METHOD, "mImeWindow"); |
| 108 | sWm.mInputMethodWindow = mImeWindow; |
| 109 | mImeDialogWindow = createCommonWindow(null, TYPE_INPUT_METHOD_DIALOG, "mImeDialogWindow"); |
| 110 | mStatusBarWindow = createCommonWindow(null, TYPE_STATUS_BAR, "mStatusBarWindow"); |
| 111 | mNavBarWindow = createCommonWindow(null, TYPE_NAVIGATION_BAR, "mNavBarWindow"); |
| 112 | mDockedDividerWindow = createCommonWindow(null, TYPE_DOCK_DIVIDER, "mDockedDividerWindow"); |
| 113 | mAppWindow = createCommonWindow(null, TYPE_BASE_APPLICATION, "mAppWindow"); |
| 114 | mChildAppWindowAbove = createCommonWindow(mAppWindow, TYPE_APPLICATION_ATTACHED_DIALOG, |
| 115 | "mChildAppWindowAbove"); |
| 116 | mChildAppWindowBelow = createCommonWindow(mAppWindow, TYPE_APPLICATION_MEDIA_OVERLAY, |
| 117 | "mChildAppWindowBelow"); |
Wale Ogunwale | 17f175c | 2017-02-07 16:54:10 -0800 | [diff] [blame] | 118 | } |
| 119 | |
| 120 | @After |
| 121 | public void tearDown() throws Exception { |
Wale Ogunwale | 3424795 | 2017-02-19 11:57:53 -0800 | [diff] [blame] | 122 | final LinkedList<WindowState> nonCommonWindows = new LinkedList(); |
Wale Ogunwale | 027f475 | 2017-05-12 10:37:16 -0700 | [diff] [blame] | 123 | |
| 124 | synchronized (sWm.mWindowMap) { |
| 125 | sWm.mRoot.forAllWindows(w -> { |
| 126 | if (!mCommonWindows.contains(w)) { |
| 127 | nonCommonWindows.addLast(w); |
| 128 | } |
| 129 | }, true /* traverseTopToBottom */); |
| 130 | |
| 131 | while (!nonCommonWindows.isEmpty()) { |
| 132 | nonCommonWindows.pollLast().removeImmediately(); |
Wale Ogunwale | 17f175c | 2017-02-07 16:54:10 -0800 | [diff] [blame] | 133 | } |
Wale Ogunwale | 3424795 | 2017-02-19 11:57:53 -0800 | [diff] [blame] | 134 | |
Wale Ogunwale | 027f475 | 2017-05-12 10:37:16 -0700 | [diff] [blame] | 135 | mDisplayContent.removeImmediately(); |
| 136 | sWm.mInputMethodTarget = null; |
Wale Ogunwale | 3424795 | 2017-02-19 11:57:53 -0800 | [diff] [blame] | 137 | } |
Wale Ogunwale | 17f175c | 2017-02-07 16:54:10 -0800 | [diff] [blame] | 138 | } |
| 139 | |
Wale Ogunwale | 11cc516 | 2017-04-25 20:29:13 -0700 | [diff] [blame] | 140 | private WindowState createCommonWindow(WindowState parent, int type, String name) { |
Wale Ogunwale | 17f175c | 2017-02-07 16:54:10 -0800 | [diff] [blame] | 141 | final WindowState win = createWindow(parent, type, name); |
Wale Ogunwale | 11cc516 | 2017-04-25 20:29:13 -0700 | [diff] [blame] | 142 | mCommonWindows.add(win); |
Wale Ogunwale | 3424795 | 2017-02-19 11:57:53 -0800 | [diff] [blame] | 143 | // Prevent common windows from been IMe targets |
| 144 | win.mAttrs.flags |= FLAG_NOT_FOCUSABLE; |
Wale Ogunwale | 17f175c | 2017-02-07 16:54:10 -0800 | [diff] [blame] | 145 | return win; |
Wale Ogunwale | 44fbdf5 | 2016-11-16 10:18:45 -0800 | [diff] [blame] | 146 | } |
| 147 | |
| 148 | /** Asserts that the first entry is greater than the second entry. */ |
| 149 | void assertGreaterThan(int first, int second) throws Exception { |
| 150 | Assert.assertTrue("Excepted " + first + " to be greater than " + second, first > second); |
| 151 | } |
| 152 | |
Jorim Jaggi | 9bafc71 | 2017-01-19 17:28:30 +0100 | [diff] [blame] | 153 | /** |
| 154 | * Waits until the main handler for WM has processed all messages. |
| 155 | */ |
Jorim Jaggi | ed7993b | 2017-03-28 18:50:01 +0100 | [diff] [blame] | 156 | void waitUntilHandlersIdle() { |
Jorim Jaggi | 9bafc71 | 2017-01-19 17:28:30 +0100 | [diff] [blame] | 157 | sWm.mH.runWithScissors(() -> { }, 0); |
Jorim Jaggi | ed7993b | 2017-03-28 18:50:01 +0100 | [diff] [blame] | 158 | sWm.mAnimationHandler.runWithScissors(() -> { }, 0); |
Jorim Jaggi | 9bafc71 | 2017-01-19 17:28:30 +0100 | [diff] [blame] | 159 | } |
| 160 | |
Wale Ogunwale | 11cc516 | 2017-04-25 20:29:13 -0700 | [diff] [blame] | 161 | private WindowToken createWindowToken(DisplayContent dc, int stackId, int type) { |
Wale Ogunwale | 44fbdf5 | 2016-11-16 10:18:45 -0800 | [diff] [blame] | 162 | if (type < FIRST_APPLICATION_WINDOW || type > LAST_APPLICATION_WINDOW) { |
Bryce Lee | af691c0 | 2017-03-20 14:20:22 -0700 | [diff] [blame] | 163 | return new WindowTestUtils.TestWindowToken(type, dc); |
Wale Ogunwale | 44fbdf5 | 2016-11-16 10:18:45 -0800 | [diff] [blame] | 164 | } |
| 165 | |
Winson Chung | 8347163 | 2016-12-13 11:02:12 -0800 | [diff] [blame] | 166 | final TaskStack stack = stackId == INVALID_STACK_ID |
| 167 | ? createTaskStackOnDisplay(dc) |
| 168 | : createStackControllerOnStackOnDisplay(stackId, dc).mContainer; |
Andrii Kulian | d276563 | 2016-12-12 22:26:34 -0800 | [diff] [blame] | 169 | final Task task = createTaskInStack(stack, 0 /* userId */); |
Bryce Lee | af691c0 | 2017-03-20 14:20:22 -0700 | [diff] [blame] | 170 | final WindowTestUtils.TestAppWindowToken token = new WindowTestUtils.TestAppWindowToken(dc); |
Wale Ogunwale | 72919d2 | 2016-12-08 18:58:50 -0800 | [diff] [blame] | 171 | task.addChild(token, 0); |
Wale Ogunwale | 44fbdf5 | 2016-11-16 10:18:45 -0800 | [diff] [blame] | 172 | return token; |
| 173 | } |
| 174 | |
Wale Ogunwale | 11cc516 | 2017-04-25 20:29:13 -0700 | [diff] [blame] | 175 | WindowState createWindow(WindowState parent, int type, String name) { |
Wale Ogunwale | 805d9ec | 2016-12-07 12:22:08 -0800 | [diff] [blame] | 176 | return (parent == null) |
Wale Ogunwale | 11cc516 | 2017-04-25 20:29:13 -0700 | [diff] [blame] | 177 | ? createWindow(parent, type, mDisplayContent, name) |
Wale Ogunwale | 805d9ec | 2016-12-07 12:22:08 -0800 | [diff] [blame] | 178 | : createWindow(parent, type, parent.mToken, name); |
| 179 | } |
| 180 | |
Wale Ogunwale | 11cc516 | 2017-04-25 20:29:13 -0700 | [diff] [blame] | 181 | WindowState createWindowOnStack(WindowState parent, int stackId, int type, |
Winson Chung | 8347163 | 2016-12-13 11:02:12 -0800 | [diff] [blame] | 182 | DisplayContent dc, String name) { |
| 183 | final WindowToken token = createWindowToken(dc, stackId, type); |
| 184 | return createWindow(parent, type, token, name); |
| 185 | } |
| 186 | |
Jorim Jaggi | 02886a8 | 2016-12-06 09:10:06 -0800 | [diff] [blame] | 187 | WindowState createAppWindow(Task task, int type, String name) { |
Wale Ogunwale | 11cc516 | 2017-04-25 20:29:13 -0700 | [diff] [blame] | 188 | final AppWindowToken token = new WindowTestUtils.TestAppWindowToken(mDisplayContent); |
Jorim Jaggi | 02886a8 | 2016-12-06 09:10:06 -0800 | [diff] [blame] | 189 | task.addChild(token, 0); |
| 190 | return createWindow(null, type, token, name); |
| 191 | } |
| 192 | |
Wale Ogunwale | 11cc516 | 2017-04-25 20:29:13 -0700 | [diff] [blame] | 193 | WindowState createWindow(WindowState parent, int type, DisplayContent dc, String name) { |
Winson Chung | 8347163 | 2016-12-13 11:02:12 -0800 | [diff] [blame] | 194 | final WindowToken token = createWindowToken(dc, INVALID_STACK_ID, type); |
Wale Ogunwale | 44fbdf5 | 2016-11-16 10:18:45 -0800 | [diff] [blame] | 195 | return createWindow(parent, type, token, name); |
| 196 | } |
| 197 | |
Wale Ogunwale | 11cc516 | 2017-04-25 20:29:13 -0700 | [diff] [blame] | 198 | WindowState createWindow(WindowState parent, int type, DisplayContent dc, String name, |
Wale Ogunwale | 17f175c | 2017-02-07 16:54:10 -0800 | [diff] [blame] | 199 | boolean ownerCanAddInternalSystemWindow) { |
Winson Chung | 8347163 | 2016-12-13 11:02:12 -0800 | [diff] [blame] | 200 | final WindowToken token = createWindowToken(dc, INVALID_STACK_ID, type); |
Wale Ogunwale | 17f175c | 2017-02-07 16:54:10 -0800 | [diff] [blame] | 201 | return createWindow(parent, type, token, name, ownerCanAddInternalSystemWindow); |
| 202 | } |
| 203 | |
Jorim Jaggi | 9bafc71 | 2017-01-19 17:28:30 +0100 | [diff] [blame] | 204 | static WindowState createWindow(WindowState parent, int type, WindowToken token, String name) { |
Wale Ogunwale | 17f175c | 2017-02-07 16:54:10 -0800 | [diff] [blame] | 205 | return createWindow(parent, type, token, name, false /* ownerCanAddInternalSystemWindow */); |
| 206 | } |
| 207 | |
| 208 | static WindowState createWindow(WindowState parent, int type, WindowToken token, String name, |
| 209 | boolean ownerCanAddInternalSystemWindow) { |
Wale Ogunwale | 44fbdf5 | 2016-11-16 10:18:45 -0800 | [diff] [blame] | 210 | final WindowManager.LayoutParams attrs = new WindowManager.LayoutParams(type); |
| 211 | attrs.setTitle(name); |
| 212 | |
Wale Ogunwale | 8e44f6c | 2017-03-09 15:25:10 -0800 | [diff] [blame] | 213 | final WindowState w = new WindowState(sWm, sMockSession, sIWindow, token, parent, OP_NONE, |
David Stevens | 4693956 | 2017-03-24 13:04:00 -0700 | [diff] [blame] | 214 | 0, attrs, VISIBLE, 0, ownerCanAddInternalSystemWindow); |
Wale Ogunwale | 44fbdf5 | 2016-11-16 10:18:45 -0800 | [diff] [blame] | 215 | // TODO: Probably better to make this call in the WindowState ctor to avoid errors with |
| 216 | // adding it to the token... |
| 217 | token.addWindow(w); |
| 218 | return w; |
| 219 | } |
Wale Ogunwale | 3d0bfd9 | 2016-12-05 11:38:02 -0800 | [diff] [blame] | 220 | |
Andrii Kulian | d276563 | 2016-12-12 22:26:34 -0800 | [diff] [blame] | 221 | /** Creates a {@link TaskStack} and adds it to the specified {@link DisplayContent}. */ |
Wale Ogunwale | 11cc516 | 2017-04-25 20:29:13 -0700 | [diff] [blame] | 222 | TaskStack createTaskStackOnDisplay(DisplayContent dc) { |
Wale Ogunwale | 1666e31 | 2016-12-16 11:27:18 -0800 | [diff] [blame] | 223 | return createStackControllerOnDisplay(dc).mContainer; |
| 224 | } |
| 225 | |
Wale Ogunwale | 11cc516 | 2017-04-25 20:29:13 -0700 | [diff] [blame] | 226 | StackWindowController createStackControllerOnDisplay(DisplayContent dc) { |
Wale Ogunwale | 1666e31 | 2016-12-16 11:27:18 -0800 | [diff] [blame] | 227 | final int stackId = ++sNextStackId; |
Winson Chung | 8347163 | 2016-12-13 11:02:12 -0800 | [diff] [blame] | 228 | return createStackControllerOnStackOnDisplay(stackId, dc); |
| 229 | } |
| 230 | |
Wale Ogunwale | 11cc516 | 2017-04-25 20:29:13 -0700 | [diff] [blame] | 231 | StackWindowController createStackControllerOnStackOnDisplay(int stackId, |
Winson Chung | 8347163 | 2016-12-13 11:02:12 -0800 | [diff] [blame] | 232 | DisplayContent dc) { |
Wale Ogunwale | 1666e31 | 2016-12-16 11:27:18 -0800 | [diff] [blame] | 233 | return new StackWindowController(stackId, null, dc.getDisplayId(), |
| 234 | true /* onTop */, new Rect(), sWm); |
Andrii Kulian | d276563 | 2016-12-12 22:26:34 -0800 | [diff] [blame] | 235 | } |
| 236 | |
Andrii Kulian | 367ff7f | 2017-01-25 19:45:34 -0800 | [diff] [blame] | 237 | /** Creates a {@link Task} and adds it to the specified {@link TaskStack}. */ |
Wale Ogunwale | 11cc516 | 2017-04-25 20:29:13 -0700 | [diff] [blame] | 238 | Task createTaskInStack(TaskStack stack, int userId) { |
Bryce Lee | af691c0 | 2017-03-20 14:20:22 -0700 | [diff] [blame] | 239 | return WindowTestUtils.createTaskInStack(sWm, stack, userId); |
Andrii Kulian | d276563 | 2016-12-12 22:26:34 -0800 | [diff] [blame] | 240 | } |
| 241 | |
Andrii Kulian | 367ff7f | 2017-01-25 19:45:34 -0800 | [diff] [blame] | 242 | /** Creates a {@link DisplayContent} and adds it to the system. */ |
| 243 | DisplayContent createNewDisplay() { |
| 244 | final int displayId = sNextDisplayId++; |
| 245 | final Display display = new Display(DisplayManagerGlobal.getInstance(), displayId, |
Wale Ogunwale | 11cc516 | 2017-04-25 20:29:13 -0700 | [diff] [blame] | 246 | mDisplayInfo, DEFAULT_DISPLAY_ADJUSTMENTS); |
| 247 | return new DisplayContent(display, sWm, mLayersController, new WallpaperController(sWm)); |
Andrii Kulian | 367ff7f | 2017-01-25 19:45:34 -0800 | [diff] [blame] | 248 | } |
| 249 | |
Bryce Lee | af691c0 | 2017-03-20 14:20:22 -0700 | [diff] [blame] | 250 | /** Creates a {@link com.android.server.wm.WindowTestUtils.TestWindowState} */ |
| 251 | WindowTestUtils.TestWindowState createWindowState(WindowManager.LayoutParams attrs, |
| 252 | WindowToken token) { |
| 253 | return new WindowTestUtils.TestWindowState(sWm, sMockSession, sIWindow, attrs, token); |
Wale Ogunwale | 3d0bfd9 | 2016-12-05 11:38:02 -0800 | [diff] [blame] | 254 | } |
| 255 | |
Wale Ogunwale | 44fbdf5 | 2016-11-16 10:18:45 -0800 | [diff] [blame] | 256 | } |