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 | |
David Stevens | 4693956 | 2017-03-24 13:04:00 -0700 | [diff] [blame] | 19 | import static android.view.View.VISIBLE; |
| 20 | |
Jorim Jaggi | 829b9cd | 2017-01-23 16:20:53 +0100 | [diff] [blame] | 21 | import android.app.ActivityManager.TaskDescription; |
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; |
Jorim Jaggi | 9bafc71 | 2017-01-19 17:28:30 +0100 | [diff] [blame] | 64 | static TestWindowManagerPolicy sPolicy = null; |
Wale Ogunwale | 8e44f6c | 2017-03-09 15:25:10 -0800 | [diff] [blame] | 65 | private final static IWindow sIWindow = new TestIWindow(); |
Jorim Jaggi | 9bafc71 | 2017-01-19 17:28:30 +0100 | [diff] [blame] | 66 | private final static Session sMockSession = mock(Session.class); |
Bryce Lee | 310de9e | 2017-03-15 10:18:21 -0700 | [diff] [blame] | 67 | // The default display is removed in {@link #setUp} and then we iterate over all displays to |
| 68 | // 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] | 69 | // added display should be treated as default. This cannot be the default display |
| 70 | private static int sNextDisplayId = Display.DEFAULT_DISPLAY + 1; |
Bryce Lee | af691c0 | 2017-03-20 14:20:22 -0700 | [diff] [blame^] | 71 | private static int sNextStackId = FIRST_DYNAMIC_STACK_ID; |
Wale Ogunwale | 44fbdf5 | 2016-11-16 10:18:45 -0800 | [diff] [blame] | 72 | |
Wale Ogunwale | 3c1170d | 2016-12-02 14:44:52 -0800 | [diff] [blame] | 73 | private static boolean sOneTimeSetupDone = false; |
Wale Ogunwale | 26c0dfe | 2016-12-14 14:42:30 -0800 | [diff] [blame] | 74 | static DisplayContent sDisplayContent; |
Andrii Kulian | 367ff7f | 2017-01-25 19:45:34 -0800 | [diff] [blame] | 75 | static DisplayInfo sDisplayInfo = new DisplayInfo(); |
Wale Ogunwale | 26c0dfe | 2016-12-14 14:42:30 -0800 | [diff] [blame] | 76 | static WindowLayersController sLayersController; |
| 77 | static WindowState sWallpaperWindow; |
| 78 | static WindowState sImeWindow; |
| 79 | static WindowState sImeDialogWindow; |
| 80 | static WindowState sStatusBarWindow; |
| 81 | static WindowState sDockedDividerWindow; |
| 82 | static WindowState sNavBarWindow; |
| 83 | static WindowState sAppWindow; |
| 84 | static WindowState sChildAppWindowAbove; |
| 85 | static WindowState sChildAppWindowBelow; |
Wale Ogunwale | 17f175c | 2017-02-07 16:54:10 -0800 | [diff] [blame] | 86 | static HashSet<WindowState> sCommonWindows; |
Wale Ogunwale | 3c1170d | 2016-12-02 14:44:52 -0800 | [diff] [blame] | 87 | |
Wale Ogunwale | 44fbdf5 | 2016-11-16 10:18:45 -0800 | [diff] [blame] | 88 | @Before |
| 89 | public void setUp() throws Exception { |
Wale Ogunwale | 3c1170d | 2016-12-02 14:44:52 -0800 | [diff] [blame] | 90 | if (sOneTimeSetupDone) { |
| 91 | return; |
| 92 | } |
| 93 | sOneTimeSetupDone = true; |
Jorim Jaggi | 9bafc71 | 2017-01-19 17:28:30 +0100 | [diff] [blame] | 94 | MockitoAnnotations.initMocks(this); |
Wale Ogunwale | 44fbdf5 | 2016-11-16 10:18:45 -0800 | [diff] [blame] | 95 | final Context context = InstrumentationRegistry.getTargetContext(); |
Jorim Jaggi | 9bafc71 | 2017-01-19 17:28:30 +0100 | [diff] [blame] | 96 | AttributeCache.init(context); |
Wale Ogunwale | 44fbdf5 | 2016-11-16 10:18:45 -0800 | [diff] [blame] | 97 | sWm = TestWindowManagerPolicy.getWindowManagerService(context); |
Jorim Jaggi | 9bafc71 | 2017-01-19 17:28:30 +0100 | [diff] [blame] | 98 | sPolicy = (TestWindowManagerPolicy) sWm.mPolicy; |
Wale Ogunwale | 3c1170d | 2016-12-02 14:44:52 -0800 | [diff] [blame] | 99 | sLayersController = new WindowLayersController(sWm); |
Bryce Lee | 6272c7f | 2017-03-17 17:22:35 -0700 | [diff] [blame] | 100 | |
Andrii Kulian | 367ff7f | 2017-01-25 19:45:34 -0800 | [diff] [blame] | 101 | // Make sure that display ids don't overlap, so there won't be several displays with same |
| 102 | // ids among RootWindowContainer children. |
| 103 | for (DisplayContent dc : sWm.mRoot.mChildren) { |
| 104 | if (dc.getDisplayId() >= sNextDisplayId) { |
| 105 | sNextDisplayId = dc.getDisplayId() + 1; |
| 106 | } |
Bryce Lee | 6272c7f | 2017-03-17 17:22:35 -0700 | [diff] [blame] | 107 | |
| 108 | // The default display must be preserved as some tests require it to function |
| 109 | // (such as policy rotation). |
| 110 | if (dc.getDisplayId() != Display.DEFAULT_DISPLAY) { |
| 111 | // It is safe to remove these displays as new displays will always be created with |
| 112 | // new ids. |
| 113 | dc.removeImmediately(); |
| 114 | } |
Andrii Kulian | 367ff7f | 2017-01-25 19:45:34 -0800 | [diff] [blame] | 115 | } |
Bryce Lee | 6272c7f | 2017-03-17 17:22:35 -0700 | [diff] [blame] | 116 | |
Andrii Kulian | 367ff7f | 2017-01-25 19:45:34 -0800 | [diff] [blame] | 117 | context.getDisplay().getDisplayInfo(sDisplayInfo); |
| 118 | sDisplayContent = createNewDisplay(); |
Jorim Jaggi | 9bafc71 | 2017-01-19 17:28:30 +0100 | [diff] [blame] | 119 | sWm.mDisplayEnabled = true; |
| 120 | sWm.mDisplayReady = true; |
Wale Ogunwale | 3c1170d | 2016-12-02 14:44:52 -0800 | [diff] [blame] | 121 | |
| 122 | // Set-up some common windows. |
Wale Ogunwale | 17f175c | 2017-02-07 16:54:10 -0800 | [diff] [blame] | 123 | sCommonWindows = new HashSet(); |
| 124 | sWallpaperWindow = createCommonWindow(null, TYPE_WALLPAPER, "wallpaperWindow"); |
| 125 | sImeWindow = createCommonWindow(null, TYPE_INPUT_METHOD, "sImeWindow"); |
Wale Ogunwale | 3424795 | 2017-02-19 11:57:53 -0800 | [diff] [blame] | 126 | sWm.mInputMethodWindow = sImeWindow; |
Wale Ogunwale | 17f175c | 2017-02-07 16:54:10 -0800 | [diff] [blame] | 127 | sImeDialogWindow = createCommonWindow(null, TYPE_INPUT_METHOD_DIALOG, "sImeDialogWindow"); |
| 128 | sStatusBarWindow = createCommonWindow(null, TYPE_STATUS_BAR, "sStatusBarWindow"); |
| 129 | sNavBarWindow = createCommonWindow(null, TYPE_NAVIGATION_BAR, "sNavBarWindow"); |
| 130 | sDockedDividerWindow = createCommonWindow(null, TYPE_DOCK_DIVIDER, "sDockedDividerWindow"); |
| 131 | sAppWindow = createCommonWindow(null, TYPE_BASE_APPLICATION, "sAppWindow"); |
| 132 | sChildAppWindowAbove = createCommonWindow(sAppWindow, TYPE_APPLICATION_ATTACHED_DIALOG, |
| 133 | "sChildAppWindowAbove"); |
| 134 | sChildAppWindowBelow = createCommonWindow(sAppWindow, TYPE_APPLICATION_MEDIA_OVERLAY, |
| 135 | "sChildAppWindowBelow"); |
| 136 | } |
| 137 | |
| 138 | @After |
| 139 | public void tearDown() throws Exception { |
Wale Ogunwale | 3424795 | 2017-02-19 11:57:53 -0800 | [diff] [blame] | 140 | final LinkedList<WindowState> nonCommonWindows = new LinkedList(); |
Wale Ogunwale | 17f175c | 2017-02-07 16:54:10 -0800 | [diff] [blame] | 141 | sWm.mRoot.forAllWindows(w -> { |
| 142 | if (!sCommonWindows.contains(w)) { |
Wale Ogunwale | 3424795 | 2017-02-19 11:57:53 -0800 | [diff] [blame] | 143 | nonCommonWindows.addLast(w); |
Wale Ogunwale | 17f175c | 2017-02-07 16:54:10 -0800 | [diff] [blame] | 144 | } |
| 145 | }, true /* traverseTopToBottom */); |
Wale Ogunwale | 3424795 | 2017-02-19 11:57:53 -0800 | [diff] [blame] | 146 | |
| 147 | while (!nonCommonWindows.isEmpty()) { |
| 148 | nonCommonWindows.pollLast().removeImmediately(); |
| 149 | } |
| 150 | |
| 151 | sWm.mInputMethodTarget = null; |
Wale Ogunwale | 17f175c | 2017-02-07 16:54:10 -0800 | [diff] [blame] | 152 | } |
| 153 | |
| 154 | private static WindowState createCommonWindow(WindowState parent, int type, String name) { |
| 155 | final WindowState win = createWindow(parent, type, name); |
| 156 | sCommonWindows.add(win); |
Wale Ogunwale | 3424795 | 2017-02-19 11:57:53 -0800 | [diff] [blame] | 157 | // Prevent common windows from been IMe targets |
| 158 | win.mAttrs.flags |= FLAG_NOT_FOCUSABLE; |
Wale Ogunwale | 17f175c | 2017-02-07 16:54:10 -0800 | [diff] [blame] | 159 | return win; |
Wale Ogunwale | 44fbdf5 | 2016-11-16 10:18:45 -0800 | [diff] [blame] | 160 | } |
| 161 | |
| 162 | /** Asserts that the first entry is greater than the second entry. */ |
| 163 | void assertGreaterThan(int first, int second) throws Exception { |
| 164 | Assert.assertTrue("Excepted " + first + " to be greater than " + second, first > second); |
| 165 | } |
| 166 | |
Jorim Jaggi | 9bafc71 | 2017-01-19 17:28:30 +0100 | [diff] [blame] | 167 | /** |
| 168 | * Waits until the main handler for WM has processed all messages. |
| 169 | */ |
| 170 | void waitUntilHandlerIdle() { |
| 171 | sWm.mH.runWithScissors(() -> { }, 0); |
| 172 | } |
| 173 | |
Winson Chung | 8347163 | 2016-12-13 11:02:12 -0800 | [diff] [blame] | 174 | private static WindowToken createWindowToken(DisplayContent dc, int stackId, int type) { |
Wale Ogunwale | 44fbdf5 | 2016-11-16 10:18:45 -0800 | [diff] [blame] | 175 | if (type < FIRST_APPLICATION_WINDOW || type > LAST_APPLICATION_WINDOW) { |
Bryce Lee | af691c0 | 2017-03-20 14:20:22 -0700 | [diff] [blame^] | 176 | return new WindowTestUtils.TestWindowToken(type, dc); |
Wale Ogunwale | 44fbdf5 | 2016-11-16 10:18:45 -0800 | [diff] [blame] | 177 | } |
| 178 | |
Winson Chung | 8347163 | 2016-12-13 11:02:12 -0800 | [diff] [blame] | 179 | final TaskStack stack = stackId == INVALID_STACK_ID |
| 180 | ? createTaskStackOnDisplay(dc) |
| 181 | : createStackControllerOnStackOnDisplay(stackId, dc).mContainer; |
Andrii Kulian | d276563 | 2016-12-12 22:26:34 -0800 | [diff] [blame] | 182 | final Task task = createTaskInStack(stack, 0 /* userId */); |
Bryce Lee | af691c0 | 2017-03-20 14:20:22 -0700 | [diff] [blame^] | 183 | final WindowTestUtils.TestAppWindowToken token = new WindowTestUtils.TestAppWindowToken(dc); |
Wale Ogunwale | 72919d2 | 2016-12-08 18:58:50 -0800 | [diff] [blame] | 184 | task.addChild(token, 0); |
Wale Ogunwale | 44fbdf5 | 2016-11-16 10:18:45 -0800 | [diff] [blame] | 185 | return token; |
| 186 | } |
| 187 | |
Jorim Jaggi | 9bafc71 | 2017-01-19 17:28:30 +0100 | [diff] [blame] | 188 | static WindowState createWindow(WindowState parent, int type, String name) { |
Wale Ogunwale | 805d9ec | 2016-12-07 12:22:08 -0800 | [diff] [blame] | 189 | return (parent == null) |
| 190 | ? createWindow(parent, type, sDisplayContent, name) |
| 191 | : createWindow(parent, type, parent.mToken, name); |
| 192 | } |
| 193 | |
Winson Chung | 8347163 | 2016-12-13 11:02:12 -0800 | [diff] [blame] | 194 | static WindowState createWindowOnStack(WindowState parent, int stackId, int type, |
| 195 | DisplayContent dc, String name) { |
| 196 | final WindowToken token = createWindowToken(dc, stackId, type); |
| 197 | return createWindow(parent, type, token, name); |
| 198 | } |
| 199 | |
Jorim Jaggi | 02886a8 | 2016-12-06 09:10:06 -0800 | [diff] [blame] | 200 | WindowState createAppWindow(Task task, int type, String name) { |
Bryce Lee | af691c0 | 2017-03-20 14:20:22 -0700 | [diff] [blame^] | 201 | final AppWindowToken token = new WindowTestUtils.TestAppWindowToken(sDisplayContent); |
Jorim Jaggi | 02886a8 | 2016-12-06 09:10:06 -0800 | [diff] [blame] | 202 | task.addChild(token, 0); |
| 203 | return createWindow(null, type, token, name); |
| 204 | } |
| 205 | |
Jorim Jaggi | 9bafc71 | 2017-01-19 17:28:30 +0100 | [diff] [blame] | 206 | static WindowState createWindow(WindowState parent, int type, DisplayContent dc, String name) { |
Winson Chung | 8347163 | 2016-12-13 11:02:12 -0800 | [diff] [blame] | 207 | final WindowToken token = createWindowToken(dc, INVALID_STACK_ID, type); |
Wale Ogunwale | 44fbdf5 | 2016-11-16 10:18:45 -0800 | [diff] [blame] | 208 | return createWindow(parent, type, token, name); |
| 209 | } |
| 210 | |
Wale Ogunwale | 17f175c | 2017-02-07 16:54:10 -0800 | [diff] [blame] | 211 | static WindowState createWindow(WindowState parent, int type, DisplayContent dc, String name, |
| 212 | boolean ownerCanAddInternalSystemWindow) { |
Winson Chung | 8347163 | 2016-12-13 11:02:12 -0800 | [diff] [blame] | 213 | final WindowToken token = createWindowToken(dc, INVALID_STACK_ID, type); |
Wale Ogunwale | 17f175c | 2017-02-07 16:54:10 -0800 | [diff] [blame] | 214 | return createWindow(parent, type, token, name, ownerCanAddInternalSystemWindow); |
| 215 | } |
| 216 | |
Jorim Jaggi | 9bafc71 | 2017-01-19 17:28:30 +0100 | [diff] [blame] | 217 | static WindowState createWindow(WindowState parent, int type, WindowToken token, String name) { |
Wale Ogunwale | 17f175c | 2017-02-07 16:54:10 -0800 | [diff] [blame] | 218 | return createWindow(parent, type, token, name, false /* ownerCanAddInternalSystemWindow */); |
| 219 | } |
| 220 | |
| 221 | static WindowState createWindow(WindowState parent, int type, WindowToken token, String name, |
| 222 | boolean ownerCanAddInternalSystemWindow) { |
Wale Ogunwale | 44fbdf5 | 2016-11-16 10:18:45 -0800 | [diff] [blame] | 223 | final WindowManager.LayoutParams attrs = new WindowManager.LayoutParams(type); |
| 224 | attrs.setTitle(name); |
| 225 | |
Wale Ogunwale | 8e44f6c | 2017-03-09 15:25:10 -0800 | [diff] [blame] | 226 | final WindowState w = new WindowState(sWm, sMockSession, sIWindow, token, parent, OP_NONE, |
David Stevens | 4693956 | 2017-03-24 13:04:00 -0700 | [diff] [blame] | 227 | 0, attrs, VISIBLE, 0, ownerCanAddInternalSystemWindow); |
Wale Ogunwale | 44fbdf5 | 2016-11-16 10:18:45 -0800 | [diff] [blame] | 228 | // TODO: Probably better to make this call in the WindowState ctor to avoid errors with |
| 229 | // adding it to the token... |
| 230 | token.addWindow(w); |
| 231 | return w; |
| 232 | } |
Wale Ogunwale | 3d0bfd9 | 2016-12-05 11:38:02 -0800 | [diff] [blame] | 233 | |
Andrii Kulian | d276563 | 2016-12-12 22:26:34 -0800 | [diff] [blame] | 234 | /** Creates a {@link TaskStack} and adds it to the specified {@link DisplayContent}. */ |
Jorim Jaggi | 9bafc71 | 2017-01-19 17:28:30 +0100 | [diff] [blame] | 235 | static TaskStack createTaskStackOnDisplay(DisplayContent dc) { |
Wale Ogunwale | 1666e31 | 2016-12-16 11:27:18 -0800 | [diff] [blame] | 236 | return createStackControllerOnDisplay(dc).mContainer; |
| 237 | } |
| 238 | |
| 239 | static StackWindowController createStackControllerOnDisplay(DisplayContent dc) { |
| 240 | final int stackId = ++sNextStackId; |
Winson Chung | 8347163 | 2016-12-13 11:02:12 -0800 | [diff] [blame] | 241 | return createStackControllerOnStackOnDisplay(stackId, dc); |
| 242 | } |
| 243 | |
| 244 | static StackWindowController createStackControllerOnStackOnDisplay(int stackId, |
| 245 | DisplayContent dc) { |
Wale Ogunwale | 1666e31 | 2016-12-16 11:27:18 -0800 | [diff] [blame] | 246 | return new StackWindowController(stackId, null, dc.getDisplayId(), |
| 247 | true /* onTop */, new Rect(), sWm); |
Andrii Kulian | d276563 | 2016-12-12 22:26:34 -0800 | [diff] [blame] | 248 | } |
| 249 | |
Andrii Kulian | 367ff7f | 2017-01-25 19:45:34 -0800 | [diff] [blame] | 250 | /** Creates a {@link Task} and adds it to the specified {@link TaskStack}. */ |
Jorim Jaggi | 9bafc71 | 2017-01-19 17:28:30 +0100 | [diff] [blame] | 251 | static Task createTaskInStack(TaskStack stack, int userId) { |
Bryce Lee | af691c0 | 2017-03-20 14:20:22 -0700 | [diff] [blame^] | 252 | return WindowTestUtils.createTaskInStack(sWm, stack, userId); |
Andrii Kulian | d276563 | 2016-12-12 22:26:34 -0800 | [diff] [blame] | 253 | } |
| 254 | |
Andrii Kulian | 367ff7f | 2017-01-25 19:45:34 -0800 | [diff] [blame] | 255 | /** Creates a {@link DisplayContent} and adds it to the system. */ |
| 256 | DisplayContent createNewDisplay() { |
| 257 | final int displayId = sNextDisplayId++; |
| 258 | final Display display = new Display(DisplayManagerGlobal.getInstance(), displayId, |
| 259 | sDisplayInfo, DEFAULT_DISPLAY_ADJUSTMENTS); |
| 260 | return new DisplayContent(display, sWm, sLayersController, new WallpaperController(sWm)); |
| 261 | } |
| 262 | |
Bryce Lee | af691c0 | 2017-03-20 14:20:22 -0700 | [diff] [blame^] | 263 | /** Creates a {@link com.android.server.wm.WindowTestUtils.TestWindowState} */ |
| 264 | WindowTestUtils.TestWindowState createWindowState(WindowManager.LayoutParams attrs, |
| 265 | WindowToken token) { |
| 266 | return new WindowTestUtils.TestWindowState(sWm, sMockSession, sIWindow, attrs, token); |
Wale Ogunwale | 3d0bfd9 | 2016-12-05 11:38:02 -0800 | [diff] [blame] | 267 | } |
| 268 | |
Wale Ogunwale | 44fbdf5 | 2016-11-16 10:18:45 -0800 | [diff] [blame] | 269 | } |