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; 24 import android.testing.TestableLooper.RunWithLooper; 25 import android.view.LayoutInflater; 26 27 import com.android.systemui.SystemUIFactory; 28 import com.android.systemui.SysuiTestCase; 29 import com.android.systemui.util.Assert; 30 import com.android.systemui.util.InjectionInflationController; 31 32 import org.junit.Before; 33 import org.junit.Test; 34 import org.junit.runner.RunWith; 35 import org.mockito.InjectMocks; 36 import org.mockito.Mock; 37 38 @SmallTest 39 @RunWithLooper 40 @RunWith(AndroidTestingRunner.class) 41 public class KeyguardStatusViewTest extends SysuiTestCase { 42 43 @Mock 44 KeyguardSliceView mKeyguardSlice; 45 @Mock 46 KeyguardClockSwitch mClockView; 47 @InjectMocks 48 KeyguardStatusView mKeyguardStatusView; 49 50 @Before 51 public void setUp() { 52 Assert.sMainLooper = TestableLooper.get(this).getLooper(); 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 63 public void dozeTimeTick_updatesSlice() { 64 mKeyguardStatusView.dozeTimeTick(); 65 verify(mKeyguardSlice).refresh(); 66 } 67 68 @Test 69 public void dozeTimeTick_updatesClock() { 70 mKeyguardStatusView.dozeTimeTick(); 71 verify(mClockView).refresh(); 72 } 73 74 } 75