1 /*
2  * Copyright (C) 2021 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.statusbar.phone;
18 
19 import static com.google.common.truth.Truth.assertThat;
20 
21 import android.testing.TestableLooper;
22 import android.view.LayoutInflater;
23 import android.view.View;
24 
25 import androidx.test.ext.junit.runners.AndroidJUnit4;
26 import androidx.test.filters.SmallTest;
27 
28 import com.android.systemui.SysuiTestCase;
29 import com.android.systemui.res.R;
30 
31 import org.junit.Before;
32 import org.junit.Test;
33 import org.junit.runner.RunWith;
34 
35 @SmallTest
36 @RunWith(AndroidJUnit4.class)
37 @TestableLooper.RunWithLooper
38 public class KeyguardStatusBarViewTest extends SysuiTestCase {
39 
40     private KeyguardStatusBarView mKeyguardStatusBarView;
41 
42     @Before
setup()43     public void setup() throws Exception {
44         allowTestableLooperAsMainThread();
45         TestableLooper.get(this).runWithLooper(() -> {
46             mKeyguardStatusBarView =
47                     (KeyguardStatusBarView) LayoutInflater.from(mContext)
48                             .inflate(R.layout.keyguard_status_bar, null);
49         });
50     }
51 
52     @Test
userSwitcherChip_defaultVisibilityIsGone()53     public void userSwitcherChip_defaultVisibilityIsGone() {
54         assertThat(mKeyguardStatusBarView.findViewById(
55                 R.id.user_switcher_container).getVisibility()).isEqualTo(
56                 View.GONE);
57     }
58 
59     @Test
setTopClipping_clippingUpdated()60     public void setTopClipping_clippingUpdated() {
61         int topClipping = 40;
62 
63         mKeyguardStatusBarView.setTopClipping(topClipping);
64 
65         assertThat(mKeyguardStatusBarView.getClipBounds().top).isEqualTo(topClipping);
66     }
67 }
68