blob: e4b83ccc5125de56792ec4742d21e9e3f8c4a1a6 [file] [log] [blame]
Lucas Dupin9fedb892018-05-04 17:42:33 -07001/*
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
17package com.android.keyguard;
18
19import static org.mockito.Mockito.verify;
20
21import android.test.suitebuilder.annotation.SmallTest;
22import android.testing.AndroidTestingRunner;
Jason Monka716bac2018-12-05 15:48:21 -050023import android.testing.TestableLooper;
Lucas Dupin9fedb892018-05-04 17:42:33 -070024import android.testing.TestableLooper.RunWithLooper;
25import android.view.LayoutInflater;
Lucas Dupin9fedb892018-05-04 17:42:33 -070026
Hyunyoung Song8f9d34c2019-08-30 14:47:43 -070027import com.android.systemui.R;
Robert Snoebergerbe35b762019-03-15 14:33:02 -040028import com.android.systemui.SystemUIFactory;
Lucas Dupin9fedb892018-05-04 17:42:33 -070029import com.android.systemui.SysuiTestCase;
Jason Monka716bac2018-12-05 15:48:21 -050030import com.android.systemui.util.Assert;
Robert Snoebergerbe35b762019-03-15 14:33:02 -040031import com.android.systemui.util.InjectionInflationController;
Lucas Dupin9fedb892018-05-04 17:42:33 -070032
33import org.junit.Before;
34import org.junit.Test;
35import org.junit.runner.RunWith;
36import org.mockito.InjectMocks;
37import org.mockito.Mock;
38
39@SmallTest
Jason Monka716bac2018-12-05 15:48:21 -050040@RunWithLooper
Lucas Dupin9fedb892018-05-04 17:42:33 -070041@RunWith(AndroidTestingRunner.class)
42public class KeyguardStatusViewTest extends SysuiTestCase {
43
44 @Mock
45 KeyguardSliceView mKeyguardSlice;
46 @Mock
Kunhung Li29007e62018-07-30 19:30:25 +080047 KeyguardClockSwitch mClockView;
Lucas Dupin9fedb892018-05-04 17:42:33 -070048 @InjectMocks
49 KeyguardStatusView mKeyguardStatusView;
50
51 @Before
52 public void setUp() {
Jason Monka716bac2018-12-05 15:48:21 -050053 Assert.sMainLooper = TestableLooper.get(this).getLooper();
Dave Mankoffe2294692019-08-14 11:53:13 -040054 mDependency.injectMockDependency(KeyguardUpdateMonitor.class);
Robert Snoebergerbe35b762019-03-15 14:33:02 -040055 InjectionInflationController inflationController = new InjectionInflationController(
56 SystemUIFactory.getInstance().getRootComponent());
57 LayoutInflater layoutInflater = inflationController
58 .injectable(LayoutInflater.from(getContext()));
Lucas Dupin9fedb892018-05-04 17:42:33 -070059 mKeyguardStatusView =
60 (KeyguardStatusView) layoutInflater.inflate(R.layout.keyguard_status_view, null);
61 org.mockito.MockitoAnnotations.initMocks(this);
62 }
63
64 @Test
65 public void dozeTimeTick_updatesSlice() {
66 mKeyguardStatusView.dozeTimeTick();
67 verify(mKeyguardSlice).refresh();
68 }
69
70 @Test
71 public void dozeTimeTick_updatesClock() {
72 mKeyguardStatusView.dozeTimeTick();
73 verify(mClockView).refresh();
74 }
75
76}