• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2020 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.systemui.wm;
18 
19 import static com.google.common.truth.Truth.assertThat;
20 
21 import static org.mockito.ArgumentMatchers.anyInt;
22 import static org.mockito.Mockito.when;
23 
24 import android.car.settings.CarSettings;
25 import android.os.Handler;
26 import android.provider.Settings;
27 import android.testing.TestableLooper;
28 import android.view.IWindowManager;
29 
30 import androidx.test.ext.junit.runners.AndroidJUnit4;
31 import androidx.test.filters.SmallTest;
32 
33 import com.android.systemui.CarSysuiTestCase;
34 import com.android.systemui.car.CarSystemUiTest;
35 import com.android.wm.shell.common.DisplayController;
36 import com.android.wm.shell.common.DisplayInsetsController;
37 import com.android.wm.shell.common.DisplayLayout;
38 
39 import org.junit.Before;
40 import org.junit.Test;
41 import org.junit.runner.RunWith;
42 import org.mockito.Mock;
43 import org.mockito.MockitoAnnotations;
44 
45 @CarSystemUiTest
46 @RunWith(AndroidJUnit4.class)
47 @TestableLooper.RunWithLooper
48 @SmallTest
49 public class DisplaySystemBarsControllerTest extends CarSysuiTestCase {
50 
51     private DisplaySystemBarsController mController;
52 
53     private static final int DISPLAY_ID = 1;
54 
55     @Mock
56     private IWindowManager mIWindowManager;
57     @Mock
58     private DisplayController mDisplayController;
59     @Mock
60     private DisplayLayout mDisplayLayout;
61     @Mock
62     private DisplayInsetsController mDisplayInsetsController;
63     @Mock
64     private Handler mHandler;
65 
66     @Before
setUp()67     public void setUp() {
68         MockitoAnnotations.initMocks(this);
69         when(mDisplayLayout.rotation()).thenReturn(0);
70         when(mDisplayController.getDisplayLayout(anyInt())).thenReturn(mDisplayLayout);
71 
72         mController = new DisplaySystemBarsController(
73                 mContext,
74                 mIWindowManager,
75                 mDisplayController,
76                 mDisplayInsetsController,
77                 mHandler
78         );
79     }
80 
81     @Test
onDisplayAdded_loadsBarControlPolicyFilters()82     public void onDisplayAdded_loadsBarControlPolicyFilters() {
83         String text = "sample text";
84         Settings.Global.putString(
85                 mContext.getContentResolver(),
86                 CarSettings.Global.SYSTEM_BAR_VISIBILITY_OVERRIDE,
87                 text
88         );
89 
90         mController.onDisplayAdded(DISPLAY_ID);
91 
92         assertThat(BarControlPolicy.sSettingValue).isEqualTo(text);
93     }
94 }
95