Lucas Dupin | 9fedb89 | 2018-05-04 17:42:33 -0700 | [diff] [blame] | 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; |
Jason Monk | a716bac | 2018-12-05 15:48:21 -0500 | [diff] [blame] | 23 | import android.testing.TestableLooper; |
Lucas Dupin | 9fedb89 | 2018-05-04 17:42:33 -0700 | [diff] [blame] | 24 | import android.testing.TestableLooper.RunWithLooper; |
| 25 | import android.view.LayoutInflater; |
Lucas Dupin | 9fedb89 | 2018-05-04 17:42:33 -0700 | [diff] [blame] | 26 | |
Hyunyoung Song | 8f9d34c | 2019-08-30 14:47:43 -0700 | [diff] [blame] | 27 | import com.android.systemui.R; |
Robert Snoeberger | be35b76 | 2019-03-15 14:33:02 -0400 | [diff] [blame] | 28 | import com.android.systemui.SystemUIFactory; |
Lucas Dupin | 9fedb89 | 2018-05-04 17:42:33 -0700 | [diff] [blame] | 29 | import com.android.systemui.SysuiTestCase; |
Jason Monk | a716bac | 2018-12-05 15:48:21 -0500 | [diff] [blame] | 30 | import com.android.systemui.util.Assert; |
Robert Snoeberger | be35b76 | 2019-03-15 14:33:02 -0400 | [diff] [blame] | 31 | import com.android.systemui.util.InjectionInflationController; |
Lucas Dupin | 9fedb89 | 2018-05-04 17:42:33 -0700 | [diff] [blame] | 32 | |
| 33 | import org.junit.Before; |
| 34 | import org.junit.Test; |
| 35 | import org.junit.runner.RunWith; |
| 36 | import org.mockito.InjectMocks; |
| 37 | import org.mockito.Mock; |
| 38 | |
| 39 | @SmallTest |
Jason Monk | a716bac | 2018-12-05 15:48:21 -0500 | [diff] [blame] | 40 | @RunWithLooper |
Lucas Dupin | 9fedb89 | 2018-05-04 17:42:33 -0700 | [diff] [blame] | 41 | @RunWith(AndroidTestingRunner.class) |
| 42 | public class KeyguardStatusViewTest extends SysuiTestCase { |
| 43 | |
| 44 | @Mock |
| 45 | KeyguardSliceView mKeyguardSlice; |
| 46 | @Mock |
Kunhung Li | 29007e6 | 2018-07-30 19:30:25 +0800 | [diff] [blame] | 47 | KeyguardClockSwitch mClockView; |
Lucas Dupin | 9fedb89 | 2018-05-04 17:42:33 -0700 | [diff] [blame] | 48 | @InjectMocks |
| 49 | KeyguardStatusView mKeyguardStatusView; |
| 50 | |
| 51 | @Before |
| 52 | public void setUp() { |
Jason Monk | a716bac | 2018-12-05 15:48:21 -0500 | [diff] [blame] | 53 | Assert.sMainLooper = TestableLooper.get(this).getLooper(); |
Dave Mankoff | e229469 | 2019-08-14 11:53:13 -0400 | [diff] [blame] | 54 | mDependency.injectMockDependency(KeyguardUpdateMonitor.class); |
Robert Snoeberger | be35b76 | 2019-03-15 14:33:02 -0400 | [diff] [blame] | 55 | InjectionInflationController inflationController = new InjectionInflationController( |
| 56 | SystemUIFactory.getInstance().getRootComponent()); |
| 57 | LayoutInflater layoutInflater = inflationController |
| 58 | .injectable(LayoutInflater.from(getContext())); |
Lucas Dupin | 9fedb89 | 2018-05-04 17:42:33 -0700 | [diff] [blame] | 59 | 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 | } |