Michal Karpinski | a606a29 | 2019-01-12 17:29:52 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2019 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 | |
| 19 | import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION; |
| 20 | import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR; |
| 21 | import static android.view.WindowManager.LayoutParams.TYPE_TOAST; |
| 22 | |
Garfield Tan | b5910b4 | 2019-03-14 14:50:59 -0700 | [diff] [blame] | 23 | import static org.junit.Assert.assertEquals; |
Michal Karpinski | a606a29 | 2019-01-12 17:29:52 +0000 | [diff] [blame] | 24 | import static org.junit.Assert.assertFalse; |
| 25 | import static org.junit.Assert.assertTrue; |
| 26 | |
Garfield Tan | b5910b4 | 2019-03-14 14:50:59 -0700 | [diff] [blame] | 27 | import android.app.WindowConfiguration; |
Michal Karpinski | a606a29 | 2019-01-12 17:29:52 +0000 | [diff] [blame] | 28 | import android.platform.test.annotations.Presubmit; |
| 29 | |
| 30 | import androidx.test.filters.SmallTest; |
| 31 | |
| 32 | import org.junit.Test; |
| 33 | |
| 34 | /** |
| 35 | * Tests for RootWindowContainer. |
| 36 | * |
| 37 | * Build/Install/Run: |
| 38 | * atest WmTests:RootWindowContainerTests |
| 39 | */ |
| 40 | @SmallTest |
| 41 | @Presubmit |
| 42 | public class RootWindowContainerTests extends WindowTestsBase { |
| 43 | |
| 44 | private static final int FAKE_CALLING_UID = 667; |
| 45 | |
| 46 | @Test |
| 47 | public void testIsAnyNonToastWindowVisibleForUid_oneToastOneNonToastBothVisible() { |
| 48 | final WindowState toastyToast = createWindow(null, TYPE_TOAST, "toast", FAKE_CALLING_UID); |
| 49 | final WindowState app = createWindow(null, TYPE_APPLICATION, "app", FAKE_CALLING_UID); |
| 50 | toastyToast.mHasSurface = true; |
| 51 | app.mHasSurface = true; |
| 52 | |
| 53 | assertTrue(toastyToast.isVisible()); |
| 54 | assertTrue(app.isVisible()); |
| 55 | assertTrue(mWm.mRoot.isAnyNonToastWindowVisibleForUid(FAKE_CALLING_UID)); |
| 56 | } |
| 57 | |
| 58 | @Test |
| 59 | public void testIsAnyNonToastWindowVisibleForUid_onlyToastVisible() { |
| 60 | final WindowState toastyToast = createWindow(null, TYPE_TOAST, "toast", FAKE_CALLING_UID); |
| 61 | toastyToast.mHasSurface = true; |
| 62 | |
| 63 | assertTrue(toastyToast.isVisible()); |
| 64 | assertFalse(mWm.mRoot.isAnyNonToastWindowVisibleForUid(FAKE_CALLING_UID)); |
| 65 | } |
| 66 | |
| 67 | @Test |
| 68 | public void testIsAnyNonToastWindowVisibleForUid_aFewNonToastButNoneVisible() { |
| 69 | final WindowState topBar = createWindow(null, TYPE_STATUS_BAR, "topBar", FAKE_CALLING_UID); |
| 70 | final WindowState app = createWindow(null, TYPE_APPLICATION, "app", FAKE_CALLING_UID); |
| 71 | |
| 72 | assertFalse(topBar.isVisible()); |
| 73 | assertFalse(app.isVisible()); |
| 74 | assertFalse(mWm.mRoot.isAnyNonToastWindowVisibleForUid(FAKE_CALLING_UID)); |
| 75 | } |
Garfield Tan | b5910b4 | 2019-03-14 14:50:59 -0700 | [diff] [blame] | 76 | |
| 77 | @Test |
| 78 | public void testUpdateDefaultDisplayWindowingModeOnSettingsRetrieved() { |
| 79 | synchronized (mWm.mGlobalLock) { |
| 80 | assertEquals(WindowConfiguration.WINDOWING_MODE_FULLSCREEN, |
| 81 | mWm.getDefaultDisplayContentLocked().getWindowingMode()); |
| 82 | |
| 83 | mWm.mIsPc = true; |
| 84 | mWm.mSupportsFreeformWindowManagement = true; |
| 85 | |
| 86 | mWm.mRoot.onSettingsRetrieved(); |
| 87 | |
| 88 | assertEquals(WindowConfiguration.WINDOWING_MODE_FREEFORM, |
| 89 | mWm.getDefaultDisplayContentLocked().getWindowingMode()); |
| 90 | } |
| 91 | } |
Michal Karpinski | a606a29 | 2019-01-12 17:29:52 +0000 | [diff] [blame] | 92 | } |
| 93 | |