Jorim Jaggi | 956ca41 | 2019-01-07 14:49:14 +0100 | [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 android.view; |
| 18 | |
| 19 | |
| 20 | import static android.view.InsetsFlags.getAppearance; |
| 21 | import static android.view.View.NAVIGATION_BAR_TRANSLUCENT; |
| 22 | import static android.view.View.NAVIGATION_BAR_TRANSPARENT; |
| 23 | import static android.view.View.STATUS_BAR_TRANSLUCENT; |
| 24 | import static android.view.View.STATUS_BAR_TRANSPARENT; |
| 25 | import static android.view.View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR; |
| 26 | import static android.view.View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR; |
| 27 | import static android.view.View.SYSTEM_UI_FLAG_LOW_PROFILE; |
| 28 | import static android.view.WindowInsetsController.APPEARANCE_LIGHT_SIDE_BARS; |
| 29 | import static android.view.WindowInsetsController.APPEARANCE_LIGHT_TOP_BAR; |
| 30 | import static android.view.WindowInsetsController.APPEARANCE_LOW_PROFILE_BARS; |
| 31 | import static android.view.WindowInsetsController.APPEARANCE_OPAQUE_SIDE_BARS; |
| 32 | import static android.view.WindowInsetsController.APPEARANCE_OPAQUE_TOP_BAR; |
| 33 | |
| 34 | import static org.junit.Assert.assertTrue; |
| 35 | |
| 36 | import android.platform.test.annotations.Presubmit; |
| 37 | import android.view.WindowInsetsController.Appearance; |
| 38 | |
| 39 | import androidx.test.runner.AndroidJUnit4; |
| 40 | |
| 41 | import org.junit.Test; |
| 42 | import org.junit.runner.RunWith; |
| 43 | |
| 44 | /** |
| 45 | * Tests for {@link InsetsFlags}. |
| 46 | * |
| 47 | * <p>Build/Install/Run: |
| 48 | * atest FrameworksCoreTests:InsetsFlagsTest |
| 49 | * |
| 50 | * <p>This test class is a part of Window Manager Service tests and specified in |
| 51 | * {@link com.android.server.wm.test.filters.FrameworksTestsFilter}. |
| 52 | */ |
| 53 | @Presubmit |
| 54 | @RunWith(AndroidJUnit4.class) |
| 55 | public class InsetsFlagsTest { |
| 56 | |
| 57 | @Test |
| 58 | public void testGetAppearance() { |
| 59 | assertContainsAppearance(APPEARANCE_LOW_PROFILE_BARS, SYSTEM_UI_FLAG_LOW_PROFILE); |
| 60 | assertContainsAppearance(APPEARANCE_LIGHT_TOP_BAR, SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); |
| 61 | assertContainsAppearance(APPEARANCE_LIGHT_SIDE_BARS, SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); |
| 62 | assertContainsAppearance(APPEARANCE_OPAQUE_TOP_BAR, |
| 63 | 0xffffffff & ~(STATUS_BAR_TRANSLUCENT | STATUS_BAR_TRANSPARENT)); |
| 64 | assertContainsAppearance(APPEARANCE_OPAQUE_SIDE_BARS, |
| 65 | 0xffffffff & ~(NAVIGATION_BAR_TRANSLUCENT | NAVIGATION_BAR_TRANSPARENT)); |
| 66 | } |
| 67 | |
| 68 | void assertContainsAppearance(@Appearance int appearance, int systemUiVisibility) { |
| 69 | assertTrue((getAppearance(systemUiVisibility) & appearance) == appearance); |
| 70 | } |
| 71 | } |