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.any; 22 import static org.mockito.Mockito.eq; 23 import static org.mockito.Mockito.verify; 24 25 import android.car.settings.CarSettings; 26 import android.os.Handler; 27 import android.os.RemoteException; 28 import android.provider.Settings; 29 import android.testing.AndroidTestingRunner; 30 import android.testing.TestableLooper; 31 import android.view.IWindowManager; 32 33 import androidx.test.filters.SmallTest; 34 35 import com.android.systemui.SysuiTestCase; 36 import com.android.wm.shell.common.DisplayController; 37 import com.android.wm.shell.common.DisplayImeController; 38 import com.android.wm.shell.common.DisplayInsetsController; 39 import com.android.wm.shell.common.TransactionPool; 40 41 import org.junit.Before; 42 import org.junit.Test; 43 import org.junit.runner.RunWith; 44 import org.mockito.Mock; 45 import org.mockito.MockitoAnnotations; 46 47 @RunWith(AndroidTestingRunner.class) 48 @TestableLooper.RunWithLooper 49 @SmallTest 50 public class DisplaySystemBarsControllerTest extends SysuiTestCase { 51 52 private DisplaySystemBarsController mController; 53 54 private static final int DISPLAY_ID = 1; 55 56 @Mock 57 private IWindowManager mIWindowManager; 58 @Mock 59 private DisplayController mDisplayController; 60 @Mock 61 private DisplayInsetsController mDisplayInsetsController; 62 @Mock 63 private Handler mHandler; 64 @Mock 65 private TransactionPool mTransactionPool; 66 67 @Before setUp()68 public void setUp() { 69 MockitoAnnotations.initMocks(this); 70 71 mController = new DisplaySystemBarsController( 72 mContext, 73 mIWindowManager, 74 mDisplayController, 75 mDisplayInsetsController, 76 mHandler, 77 mTransactionPool 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