1 /*
2  * Copyright (C) 2018 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.keyguard;
18 
19 import static org.mockito.Mockito.verify;
20 
21 import android.test.suitebuilder.annotation.SmallTest;
22 import android.testing.AndroidTestingRunner;
23 import android.testing.TestableLooper.RunWithLooper;
24 import android.view.LayoutInflater;
25 
26 import com.android.systemui.R;
27 import com.android.systemui.SystemUIFactory;
28 import com.android.systemui.SysuiTestCase;
29 import com.android.systemui.util.InjectionInflationController;
30 
31 import org.junit.Before;
32 import org.junit.Test;
33 import org.junit.runner.RunWith;
34 import org.mockito.InjectMocks;
35 import org.mockito.Mock;
36 
37 @SmallTest
38 @RunWithLooper
39 @RunWith(AndroidTestingRunner.class)
40 public class KeyguardStatusViewTest extends SysuiTestCase {
41 
42     @Mock
43     KeyguardSliceView mKeyguardSlice;
44     @Mock
45     KeyguardClockSwitch mClockView;
46     @InjectMocks
47     KeyguardStatusView mKeyguardStatusView;
48 
49     @Before
setUp()50     public void setUp() {
51         allowTestableLooperAsMainThread();
52         mDependency.injectMockDependency(KeyguardUpdateMonitor.class);
53         InjectionInflationController inflationController = new InjectionInflationController(
54                 SystemUIFactory.getInstance().getRootComponent());
55         LayoutInflater layoutInflater = inflationController
56                 .injectable(LayoutInflater.from(getContext()));
57         mKeyguardStatusView =
58                 (KeyguardStatusView) layoutInflater.inflate(R.layout.keyguard_status_view, null);
59         org.mockito.MockitoAnnotations.initMocks(this);
60     }
61 
62     @Test
dozeTimeTick_updatesSlice()63     public void dozeTimeTick_updatesSlice() {
64         mKeyguardStatusView.dozeTimeTick();
65         verify(mKeyguardSlice).refresh();
66     }
67 
68     @Test
dozeTimeTick_updatesClock()69     public void dozeTimeTick_updatesClock() {
70         mKeyguardStatusView.dozeTimeTick();
71         verify(mClockView).refresh();
72     }
73 
74 }
75