blob: b4302e79ed6adbe4a0a5ffd19bb1a49a089a01a5 [file] [log] [blame]
Jorim Jaggi956ca412019-01-07 14:49:14 +01001/*
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
17package android.view;
18
19
20import static android.view.InsetsFlags.getAppearance;
21import static android.view.View.NAVIGATION_BAR_TRANSLUCENT;
22import static android.view.View.NAVIGATION_BAR_TRANSPARENT;
23import static android.view.View.STATUS_BAR_TRANSLUCENT;
24import static android.view.View.STATUS_BAR_TRANSPARENT;
25import static android.view.View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
26import static android.view.View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
27import static android.view.View.SYSTEM_UI_FLAG_LOW_PROFILE;
Tiger Huang332793b2019-10-29 23:21:27 +080028import static android.view.WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS;
29import static android.view.WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS;
Jorim Jaggi956ca412019-01-07 14:49:14 +010030import static android.view.WindowInsetsController.APPEARANCE_LOW_PROFILE_BARS;
Tiger Huang332793b2019-10-29 23:21:27 +080031import static android.view.WindowInsetsController.APPEARANCE_OPAQUE_NAVIGATION_BARS;
32import static android.view.WindowInsetsController.APPEARANCE_OPAQUE_STATUS_BARS;
Jorim Jaggi956ca412019-01-07 14:49:14 +010033
34import static org.junit.Assert.assertTrue;
35
36import android.platform.test.annotations.Presubmit;
37import android.view.WindowInsetsController.Appearance;
38
39import androidx.test.runner.AndroidJUnit4;
40
41import org.junit.Test;
42import 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)
55public class InsetsFlagsTest {
56
57 @Test
58 public void testGetAppearance() {
59 assertContainsAppearance(APPEARANCE_LOW_PROFILE_BARS, SYSTEM_UI_FLAG_LOW_PROFILE);
Tiger Huang332793b2019-10-29 23:21:27 +080060 assertContainsAppearance(APPEARANCE_LIGHT_STATUS_BARS, SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
61 assertContainsAppearance(APPEARANCE_LIGHT_NAVIGATION_BARS,
62 SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);
63 assertContainsAppearance(APPEARANCE_OPAQUE_STATUS_BARS,
Jorim Jaggi956ca412019-01-07 14:49:14 +010064 0xffffffff & ~(STATUS_BAR_TRANSLUCENT | STATUS_BAR_TRANSPARENT));
Tiger Huang332793b2019-10-29 23:21:27 +080065 assertContainsAppearance(APPEARANCE_OPAQUE_NAVIGATION_BARS,
Jorim Jaggi956ca412019-01-07 14:49:14 +010066 0xffffffff & ~(NAVIGATION_BAR_TRANSLUCENT | NAVIGATION_BAR_TRANSPARENT));
67 }
68
69 void assertContainsAppearance(@Appearance int appearance, int systemUiVisibility) {
70 assertTrue((getAppearance(systemUiVisibility) & appearance) == appearance);
71 }
72}