Jorim Jaggi | f96c90a | 2018-09-26 16:55:15 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2018 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 | |
Tiger Huang | 0f5347e | 2020-03-06 17:09:41 +0800 | [diff] [blame] | 19 | import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM; |
Winson Chung | 8a16890 | 2020-03-12 22:39:22 -0700 | [diff] [blame] | 20 | import static android.app.WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW; |
Tiger Huang | 0f5347e | 2020-03-06 17:09:41 +0800 | [diff] [blame] | 21 | import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED; |
Tiger Huang | 57e2e1c | 2020-03-13 22:54:36 +0800 | [diff] [blame] | 22 | import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY; |
Tiger Huang | 332793b | 2019-10-29 23:21:27 +0800 | [diff] [blame] | 23 | import static android.view.InsetsState.ITYPE_IME; |
| 24 | import static android.view.InsetsState.ITYPE_NAVIGATION_BAR; |
| 25 | import static android.view.InsetsState.ITYPE_STATUS_BAR; |
Yunfan Chen | b04dc00 | 2019-02-14 17:08:39 +0900 | [diff] [blame] | 26 | import static android.view.ViewRootImpl.NEW_INSETS_MODE_FULL; |
Tiger Huang | 57e2e1c | 2020-03-13 22:54:36 +0800 | [diff] [blame] | 27 | import static android.view.WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM; |
Tiger Huang | a1663403 | 2020-02-05 17:10:03 +0800 | [diff] [blame] | 28 | import static android.view.WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; |
Jorim Jaggi | f96c90a | 2018-09-26 16:55:15 +0200 | [diff] [blame] | 29 | import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION; |
Tiger Huang | a1663403 | 2020-02-05 17:10:03 +0800 | [diff] [blame] | 30 | |
Jorim Jaggi | f96c90a | 2018-09-26 16:55:15 +0200 | [diff] [blame] | 31 | import static org.junit.Assert.assertEquals; |
Jorim Jaggi | 2862047 | 2019-01-02 23:21:49 +0100 | [diff] [blame] | 32 | import static org.junit.Assert.assertNotEquals; |
Jorim Jaggi | f96c90a | 2018-09-26 16:55:15 +0200 | [diff] [blame] | 33 | import static org.junit.Assert.assertNotNull; |
Jorim Jaggi | b603095 | 2018-10-23 18:31:52 +0200 | [diff] [blame] | 34 | import static org.junit.Assert.assertNull; |
Tiger Huang | 53c8eb8 | 2020-03-31 18:22:05 +0800 | [diff] [blame] | 35 | import static org.mockito.Mockito.atLeast; |
| 36 | import static org.mockito.Mockito.clearInvocations; |
| 37 | import static org.mockito.Mockito.spy; |
| 38 | import static org.mockito.Mockito.verify; |
Jorim Jaggi | f96c90a | 2018-09-26 16:55:15 +0200 | [diff] [blame] | 39 | |
Jorim Jaggi | 9b4f420 | 2020-01-28 17:05:06 +0100 | [diff] [blame] | 40 | import android.graphics.Rect; |
Jorim Jaggi | f96c90a | 2018-09-26 16:55:15 +0200 | [diff] [blame] | 41 | import android.platform.test.annotations.Presubmit; |
Jorim Jaggi | 2862047 | 2019-01-02 23:21:49 +0100 | [diff] [blame] | 42 | import android.view.InsetsSource; |
Jorim Jaggi | b603095 | 2018-10-23 18:31:52 +0200 | [diff] [blame] | 43 | import android.view.InsetsSourceControl; |
Jorim Jaggi | f96c90a | 2018-09-26 16:55:15 +0200 | [diff] [blame] | 44 | import android.view.InsetsState; |
Jorim Jaggi | 2862047 | 2019-01-02 23:21:49 +0100 | [diff] [blame] | 45 | import android.view.test.InsetsModeSession; |
Jorim Jaggi | f96c90a | 2018-09-26 16:55:15 +0200 | [diff] [blame] | 46 | |
Tiger Huang | a1663403 | 2020-02-05 17:10:03 +0800 | [diff] [blame] | 47 | import androidx.test.filters.FlakyTest; |
| 48 | import androidx.test.filters.SmallTest; |
| 49 | |
Yunfan Chen | b04dc00 | 2019-02-14 17:08:39 +0900 | [diff] [blame] | 50 | import org.junit.AfterClass; |
| 51 | import org.junit.BeforeClass; |
Tadashi G. Takaoka | bf0d57b | 2018-11-19 16:09:58 +0900 | [diff] [blame] | 52 | import org.junit.Test; |
Jorim Jaggi | 2862047 | 2019-01-02 23:21:49 +0100 | [diff] [blame] | 53 | import org.junit.runner.RunWith; |
Tadashi G. Takaoka | bf0d57b | 2018-11-19 16:09:58 +0900 | [diff] [blame] | 54 | |
Jorim Jaggi | f96c90a | 2018-09-26 16:55:15 +0200 | [diff] [blame] | 55 | @SmallTest |
Jorim Jaggi | f96c90a | 2018-09-26 16:55:15 +0200 | [diff] [blame] | 56 | @Presubmit |
Jorim Jaggi | 2862047 | 2019-01-02 23:21:49 +0100 | [diff] [blame] | 57 | @RunWith(WindowTestRunner.class) |
Jorim Jaggi | f96c90a | 2018-09-26 16:55:15 +0200 | [diff] [blame] | 58 | public class InsetsStateControllerTest extends WindowTestsBase { |
Jorim Jaggi | 2862047 | 2019-01-02 23:21:49 +0100 | [diff] [blame] | 59 | private static InsetsModeSession sInsetsModeSession; |
Yunfan Chen | b04dc00 | 2019-02-14 17:08:39 +0900 | [diff] [blame] | 60 | |
| 61 | @BeforeClass |
| 62 | public static void setUpOnce() { |
Yunfan Chen | b04dc00 | 2019-02-14 17:08:39 +0900 | [diff] [blame] | 63 | // To let the insets provider control the insets visibility, the insets mode has to be |
| 64 | // NEW_INSETS_MODE_FULL. |
Jorim Jaggi | 2862047 | 2019-01-02 23:21:49 +0100 | [diff] [blame] | 65 | sInsetsModeSession = new InsetsModeSession(NEW_INSETS_MODE_FULL); |
Yunfan Chen | b04dc00 | 2019-02-14 17:08:39 +0900 | [diff] [blame] | 66 | } |
| 67 | |
| 68 | @AfterClass |
| 69 | public static void tearDownOnce() { |
Jorim Jaggi | 2862047 | 2019-01-02 23:21:49 +0100 | [diff] [blame] | 70 | sInsetsModeSession.close(); |
Yunfan Chen | b04dc00 | 2019-02-14 17:08:39 +0900 | [diff] [blame] | 71 | } |
Jorim Jaggi | f96c90a | 2018-09-26 16:55:15 +0200 | [diff] [blame] | 72 | |
| 73 | @Test |
| 74 | public void testStripForDispatch_notOwn() { |
Tiger Huang | 332793b | 2019-10-29 23:21:27 +0800 | [diff] [blame] | 75 | final WindowState statusBar = createWindow(null, TYPE_APPLICATION, "statusBar"); |
Jorim Jaggi | 2862047 | 2019-01-02 23:21:49 +0100 | [diff] [blame] | 76 | final WindowState app = createWindow(null, TYPE_APPLICATION, "app"); |
Jorim Jaggi | 9b4f420 | 2020-01-28 17:05:06 +0100 | [diff] [blame] | 77 | getController().getSourceProvider(ITYPE_STATUS_BAR).setWindow(statusBar, null, null); |
Tiger Huang | 332793b | 2019-10-29 23:21:27 +0800 | [diff] [blame] | 78 | statusBar.setControllableInsetProvider(getController().getSourceProvider(ITYPE_STATUS_BAR)); |
Tiger Huang | 0f5347e | 2020-03-06 17:09:41 +0800 | [diff] [blame] | 79 | assertNotNull(getController().getInsetsForDispatch(app).peekSource(ITYPE_STATUS_BAR)); |
Jorim Jaggi | f96c90a | 2018-09-26 16:55:15 +0200 | [diff] [blame] | 80 | } |
| 81 | |
| 82 | @Test |
| 83 | public void testStripForDispatch_own() { |
Tiger Huang | 332793b | 2019-10-29 23:21:27 +0800 | [diff] [blame] | 84 | final WindowState statusBar = createWindow(null, TYPE_APPLICATION, "statusBar"); |
| 85 | mDisplayContent.getInsetsStateController().getSourceProvider(ITYPE_STATUS_BAR) |
Jorim Jaggi | 9b4f420 | 2020-01-28 17:05:06 +0100 | [diff] [blame] | 86 | .setWindow(statusBar, null, null); |
Tiger Huang | 332793b | 2019-10-29 23:21:27 +0800 | [diff] [blame] | 87 | statusBar.setControllableInsetProvider(getController().getSourceProvider(ITYPE_STATUS_BAR)); |
| 88 | final InsetsState state = getController().getInsetsForDispatch(statusBar); |
Jorim Jaggi | 2862047 | 2019-01-02 23:21:49 +0100 | [diff] [blame] | 89 | for (int i = state.getSourcesCount() - 1; i >= 0; i--) { |
| 90 | final InsetsSource source = state.sourceAt(i); |
Tiger Huang | 332793b | 2019-10-29 23:21:27 +0800 | [diff] [blame] | 91 | assertNotEquals(ITYPE_STATUS_BAR, source.getType()); |
Jorim Jaggi | 2862047 | 2019-01-02 23:21:49 +0100 | [diff] [blame] | 92 | } |
Jorim Jaggi | f96c90a | 2018-09-26 16:55:15 +0200 | [diff] [blame] | 93 | } |
| 94 | |
| 95 | @Test |
| 96 | public void testStripForDispatch_navBar() { |
Jorim Jaggi | 2862047 | 2019-01-02 23:21:49 +0100 | [diff] [blame] | 97 | final WindowState navBar = createWindow(null, TYPE_APPLICATION, "navBar"); |
Tiger Huang | 332793b | 2019-10-29 23:21:27 +0800 | [diff] [blame] | 98 | final WindowState statusBar = createWindow(null, TYPE_APPLICATION, "statusBar"); |
Jorim Jaggi | 2862047 | 2019-01-02 23:21:49 +0100 | [diff] [blame] | 99 | final WindowState ime = createWindow(null, TYPE_APPLICATION, "ime"); |
Tiger Huang | a1663403 | 2020-02-05 17:10:03 +0800 | [diff] [blame] | 100 | |
| 101 | // IME cannot be the IME target. |
| 102 | ime.mAttrs.flags |= FLAG_NOT_FOCUSABLE; |
| 103 | |
Jorim Jaggi | 9b4f420 | 2020-01-28 17:05:06 +0100 | [diff] [blame] | 104 | getController().getSourceProvider(ITYPE_STATUS_BAR).setWindow(statusBar, null, null); |
| 105 | getController().getSourceProvider(ITYPE_NAVIGATION_BAR).setWindow(navBar, null, null); |
| 106 | getController().getSourceProvider(ITYPE_IME).setWindow(ime, null, null); |
Jorim Jaggi | 963c5c2 | 2020-04-01 22:53:42 +0200 | [diff] [blame] | 107 | assertNull(getController().getInsetsForDispatch(navBar).peekSource(ITYPE_IME)); |
| 108 | assertNull(getController().getInsetsForDispatch(navBar).peekSource(ITYPE_STATUS_BAR)); |
Jorim Jaggi | b603095 | 2018-10-23 18:31:52 +0200 | [diff] [blame] | 109 | } |
| 110 | |
| 111 | @Test |
Tiger Huang | 0f5347e | 2020-03-06 17:09:41 +0800 | [diff] [blame] | 112 | public void testStripForDispatch_pip() { |
| 113 | final WindowState statusBar = createWindow(null, TYPE_APPLICATION, "statusBar"); |
| 114 | final WindowState navBar = createWindow(null, TYPE_APPLICATION, "navBar"); |
| 115 | final WindowState app = createWindow(null, TYPE_APPLICATION, "app"); |
| 116 | |
| 117 | getController().getSourceProvider(ITYPE_STATUS_BAR).setWindow(statusBar, null, null); |
| 118 | getController().getSourceProvider(ITYPE_NAVIGATION_BAR).setWindow(navBar, null, null); |
| 119 | app.setWindowingMode(WINDOWING_MODE_PINNED); |
| 120 | |
| 121 | assertNull(getController().getInsetsForDispatch(app).peekSource(ITYPE_STATUS_BAR)); |
| 122 | assertNull(getController().getInsetsForDispatch(app).peekSource(ITYPE_NAVIGATION_BAR)); |
| 123 | } |
| 124 | |
| 125 | @Test |
| 126 | public void testStripForDispatch_freeform() { |
| 127 | final WindowState statusBar = createWindow(null, TYPE_APPLICATION, "statusBar"); |
| 128 | final WindowState navBar = createWindow(null, TYPE_APPLICATION, "navBar"); |
| 129 | final WindowState app = createWindow(null, TYPE_APPLICATION, "app"); |
| 130 | |
| 131 | getController().getSourceProvider(ITYPE_STATUS_BAR).setWindow(statusBar, null, null); |
| 132 | getController().getSourceProvider(ITYPE_NAVIGATION_BAR).setWindow(navBar, null, null); |
| 133 | app.setWindowingMode(WINDOWING_MODE_FREEFORM); |
| 134 | |
| 135 | assertNull(getController().getInsetsForDispatch(app).peekSource(ITYPE_STATUS_BAR)); |
| 136 | assertNull(getController().getInsetsForDispatch(app).peekSource(ITYPE_NAVIGATION_BAR)); |
| 137 | } |
| 138 | |
| 139 | @Test |
Winson Chung | 8a16890 | 2020-03-12 22:39:22 -0700 | [diff] [blame] | 140 | public void testStripForDispatch_multiwindow_alwaysOnTop() { |
| 141 | final WindowState statusBar = createWindow(null, TYPE_APPLICATION, "statusBar"); |
| 142 | final WindowState navBar = createWindow(null, TYPE_APPLICATION, "navBar"); |
| 143 | final WindowState app = createWindow(null, TYPE_APPLICATION, "app"); |
| 144 | |
| 145 | getController().getSourceProvider(ITYPE_STATUS_BAR).setWindow(statusBar, null, null); |
| 146 | getController().getSourceProvider(ITYPE_NAVIGATION_BAR).setWindow(navBar, null, null); |
| 147 | app.setWindowingMode(WINDOWING_MODE_MULTI_WINDOW); |
| 148 | app.setAlwaysOnTop(true); |
| 149 | |
| 150 | assertNull(getController().getInsetsForDispatch(app).peekSource(ITYPE_STATUS_BAR)); |
| 151 | assertNull(getController().getInsetsForDispatch(app).peekSource(ITYPE_NAVIGATION_BAR)); |
| 152 | } |
| 153 | |
| 154 | @Test |
Tiger Huang | 57e2e1c | 2020-03-13 22:54:36 +0800 | [diff] [blame] | 155 | public void testStripForDispatch_belowIme() { |
| 156 | final WindowState app = createWindow(null, TYPE_APPLICATION, "app"); |
| 157 | final WindowState ime = createWindow(null, TYPE_APPLICATION, "ime"); |
| 158 | |
| 159 | getController().getSourceProvider(ITYPE_IME).setWindow(ime, null, null); |
| 160 | |
| 161 | assertNotNull(getController().getInsetsForDispatch(app).peekSource(ITYPE_IME)); |
| 162 | } |
| 163 | |
| 164 | @Test |
| 165 | public void testStripForDispatch_aboveIme() { |
| 166 | final WindowState ime = createWindow(null, TYPE_APPLICATION, "ime"); |
| 167 | final WindowState app = createWindow(null, TYPE_APPLICATION, "app"); |
| 168 | |
| 169 | getController().getSourceProvider(ITYPE_IME).setWindow(ime, null, null); |
| 170 | |
| 171 | assertNull(getController().getInsetsForDispatch(app).peekSource(ITYPE_IME)); |
| 172 | } |
| 173 | |
| 174 | @Test |
Tiger Huang | 53c8eb8 | 2020-03-31 18:22:05 +0800 | [diff] [blame] | 175 | public void testStripForDispatch_imeOrderChanged() { |
| 176 | getController().getSourceProvider(ITYPE_IME).setWindow(mImeWindow, null, null); |
| 177 | |
| 178 | // This window can be the IME target while app cannot be the IME target. |
| 179 | createWindow(null, TYPE_APPLICATION, "base"); |
| 180 | |
| 181 | // Send our spy window (app) into the system so that we can detect the invocation. |
| 182 | final WindowState win = createWindow(null, TYPE_APPLICATION, "app"); |
| 183 | final WindowToken parent = win.mToken; |
| 184 | parent.removeChild(win); |
| 185 | final WindowState app = spy(win); |
| 186 | parent.addWindow(app); |
| 187 | |
| 188 | // Adding FLAG_NOT_FOCUSABLE makes app above IME. |
| 189 | app.mAttrs.flags |= FLAG_NOT_FOCUSABLE; |
| 190 | mDisplayContent.computeImeTarget(true); |
| 191 | mDisplayContent.setLayoutNeeded(); |
| 192 | mDisplayContent.applySurfaceChangesTransaction(); |
| 193 | |
| 194 | // app won't get IME insets while above IME. |
| 195 | assertNull(getController().getInsetsForDispatch(app).peekSource(ITYPE_IME)); |
| 196 | |
| 197 | // Reset invocation counter. |
| 198 | clearInvocations(app); |
| 199 | |
| 200 | // Removing FLAG_NOT_FOCUSABLE makes app below IME. |
| 201 | app.mAttrs.flags &= ~FLAG_NOT_FOCUSABLE; |
| 202 | mDisplayContent.computeImeTarget(true); |
| 203 | mDisplayContent.setLayoutNeeded(); |
| 204 | mDisplayContent.applySurfaceChangesTransaction(); |
| 205 | |
| 206 | // Make sure app got notified. |
| 207 | verify(app, atLeast(1)).notifyInsetsChanged(); |
| 208 | |
| 209 | // app will get IME insets while below IME. |
| 210 | assertNotNull(getController().getInsetsForDispatch(app).peekSource(ITYPE_IME)); |
| 211 | } |
| 212 | |
| 213 | @Test |
Tiger Huang | 57e2e1c | 2020-03-13 22:54:36 +0800 | [diff] [blame] | 214 | public void testStripForDispatch_childWindow_altFocusable() { |
| 215 | final WindowState app = createWindow(null, TYPE_APPLICATION, "app"); |
| 216 | |
| 217 | final WindowState child = createWindow(app, TYPE_APPLICATION, "child"); |
| 218 | child.mAttrs.flags |= FLAG_ALT_FOCUSABLE_IM; |
| 219 | |
| 220 | final WindowState ime = createWindow(null, TYPE_APPLICATION, "ime"); |
| 221 | |
| 222 | // IME cannot be the IME target. |
| 223 | ime.mAttrs.flags |= FLAG_NOT_FOCUSABLE; |
| 224 | |
| 225 | getController().getSourceProvider(ITYPE_IME).setWindow(ime, null, null); |
| 226 | |
| 227 | assertNull(getController().getInsetsForDispatch(child).peekSource(ITYPE_IME)); |
| 228 | } |
| 229 | |
| 230 | @Test |
| 231 | public void testStripForDispatch_childWindow_splitScreen() { |
| 232 | final WindowState app = createWindow(null, TYPE_APPLICATION, "app"); |
| 233 | |
| 234 | final WindowState child = createWindow(app, TYPE_APPLICATION, "child"); |
| 235 | child.mAttrs.flags |= FLAG_NOT_FOCUSABLE; |
| 236 | child.setWindowingMode(WINDOWING_MODE_SPLIT_SCREEN_PRIMARY); |
| 237 | |
| 238 | final WindowState ime = createWindow(null, TYPE_APPLICATION, "ime"); |
| 239 | |
| 240 | // IME cannot be the IME target. |
| 241 | ime.mAttrs.flags |= FLAG_NOT_FOCUSABLE; |
| 242 | |
| 243 | getController().getSourceProvider(ITYPE_IME).setWindow(ime, null, null); |
| 244 | |
| 245 | assertNull(getController().getInsetsForDispatch(child).peekSource(ITYPE_IME)); |
| 246 | } |
| 247 | |
| 248 | @Test |
Jorim Jaggi | 9b4f420 | 2020-01-28 17:05:06 +0100 | [diff] [blame] | 249 | public void testImeForDispatch() { |
| 250 | final WindowState statusBar = createWindow(null, TYPE_APPLICATION, "statusBar"); |
| 251 | final WindowState ime = createWindow(null, TYPE_APPLICATION, "ime"); |
Tiger Huang | a1663403 | 2020-02-05 17:10:03 +0800 | [diff] [blame] | 252 | |
| 253 | // IME cannot be the IME target. |
| 254 | ime.mAttrs.flags |= FLAG_NOT_FOCUSABLE; |
| 255 | |
Jorim Jaggi | 9b4f420 | 2020-01-28 17:05:06 +0100 | [diff] [blame] | 256 | InsetsSourceProvider statusBarProvider = |
| 257 | getController().getSourceProvider(ITYPE_STATUS_BAR); |
| 258 | statusBarProvider.setWindow(statusBar, null, ((displayFrames, windowState, rect) -> |
| 259 | rect.set(0, 1, 2, 3))); |
| 260 | getController().getSourceProvider(ITYPE_IME).setWindow(ime, null, null); |
| 261 | statusBar.setControllableInsetProvider(statusBarProvider); |
| 262 | |
| 263 | statusBarProvider.onPostLayout(); |
| 264 | |
| 265 | final InsetsState state = getController().getInsetsForDispatch(ime); |
| 266 | assertEquals(new Rect(0, 1, 2, 3), state.getSource(ITYPE_STATUS_BAR).getFrame()); |
| 267 | } |
| 268 | |
| 269 | @Test |
Jorim Jaggi | b603095 | 2018-10-23 18:31:52 +0200 | [diff] [blame] | 270 | public void testBarControllingWinChanged() { |
Jorim Jaggi | 2862047 | 2019-01-02 23:21:49 +0100 | [diff] [blame] | 271 | final WindowState navBar = createWindow(null, TYPE_APPLICATION, "navBar"); |
Tiger Huang | 332793b | 2019-10-29 23:21:27 +0800 | [diff] [blame] | 272 | final WindowState statusBar = createWindow(null, TYPE_APPLICATION, "statusBar"); |
Jorim Jaggi | 2862047 | 2019-01-02 23:21:49 +0100 | [diff] [blame] | 273 | final WindowState app = createWindow(null, TYPE_APPLICATION, "app"); |
Jorim Jaggi | 9b4f420 | 2020-01-28 17:05:06 +0100 | [diff] [blame] | 274 | getController().getSourceProvider(ITYPE_STATUS_BAR).setWindow(statusBar, null, null); |
| 275 | getController().getSourceProvider(ITYPE_NAVIGATION_BAR).setWindow(navBar, null, null); |
Jorim Jaggi | 956ca41 | 2019-01-07 14:49:14 +0100 | [diff] [blame] | 276 | getController().onBarControlTargetChanged(app, null, app, null); |
Jorim Jaggi | b603095 | 2018-10-23 18:31:52 +0200 | [diff] [blame] | 277 | InsetsSourceControl[] controls = getController().getControlsForDispatch(app); |
| 278 | assertEquals(2, controls.length); |
| 279 | } |
| 280 | |
| 281 | @Test |
| 282 | public void testControlRevoked() { |
Tiger Huang | 332793b | 2019-10-29 23:21:27 +0800 | [diff] [blame] | 283 | final WindowState statusBar = createWindow(null, TYPE_APPLICATION, "statusBar"); |
Jorim Jaggi | 2862047 | 2019-01-02 23:21:49 +0100 | [diff] [blame] | 284 | final WindowState app = createWindow(null, TYPE_APPLICATION, "app"); |
Jorim Jaggi | 9b4f420 | 2020-01-28 17:05:06 +0100 | [diff] [blame] | 285 | getController().getSourceProvider(ITYPE_STATUS_BAR).setWindow(statusBar, null, null); |
Jorim Jaggi | 956ca41 | 2019-01-07 14:49:14 +0100 | [diff] [blame] | 286 | getController().onBarControlTargetChanged(app, null, null, null); |
Jorim Jaggi | b603095 | 2018-10-23 18:31:52 +0200 | [diff] [blame] | 287 | assertNotNull(getController().getControlsForDispatch(app)); |
Jorim Jaggi | 956ca41 | 2019-01-07 14:49:14 +0100 | [diff] [blame] | 288 | getController().onBarControlTargetChanged(null, null, null, null); |
Jorim Jaggi | b603095 | 2018-10-23 18:31:52 +0200 | [diff] [blame] | 289 | assertNull(getController().getControlsForDispatch(app)); |
| 290 | } |
| 291 | |
| 292 | @Test |
| 293 | public void testControlRevoked_animation() { |
Tiger Huang | 332793b | 2019-10-29 23:21:27 +0800 | [diff] [blame] | 294 | final WindowState statusBar = createWindow(null, TYPE_APPLICATION, "statusBar"); |
Jorim Jaggi | 2862047 | 2019-01-02 23:21:49 +0100 | [diff] [blame] | 295 | final WindowState app = createWindow(null, TYPE_APPLICATION, "app"); |
Jorim Jaggi | 9b4f420 | 2020-01-28 17:05:06 +0100 | [diff] [blame] | 296 | getController().getSourceProvider(ITYPE_STATUS_BAR).setWindow(statusBar, null, null); |
Jorim Jaggi | 956ca41 | 2019-01-07 14:49:14 +0100 | [diff] [blame] | 297 | getController().onBarControlTargetChanged(app, null, null, null); |
Jorim Jaggi | b603095 | 2018-10-23 18:31:52 +0200 | [diff] [blame] | 298 | assertNotNull(getController().getControlsForDispatch(app)); |
Tiger Huang | 332793b | 2019-10-29 23:21:27 +0800 | [diff] [blame] | 299 | statusBar.cancelAnimation(); |
Jorim Jaggi | b603095 | 2018-10-23 18:31:52 +0200 | [diff] [blame] | 300 | assertNull(getController().getControlsForDispatch(app)); |
| 301 | } |
| 302 | |
| 303 | private InsetsStateController getController() { |
| 304 | return mDisplayContent.getInsetsStateController(); |
Jorim Jaggi | f96c90a | 2018-09-26 16:55:15 +0200 | [diff] [blame] | 305 | } |
| 306 | } |