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 import android.widget.TextClock; 26 27 import com.android.systemui.SysuiTestCase; 28 29 import org.junit.Before; 30 import org.junit.Test; 31 import org.junit.runner.RunWith; 32 import org.mockito.InjectMocks; 33 import org.mockito.Mock; 34 35 @SmallTest 36 @RunWithLooper(setAsMainLooper = true) 37 @RunWith(AndroidTestingRunner.class) 38 public class KeyguardStatusViewTest extends SysuiTestCase { 39 40 @Mock 41 KeyguardSliceView mKeyguardSlice; 42 @Mock 43 TextClock mClockView; 44 @InjectMocks 45 KeyguardStatusView mKeyguardStatusView; 46 47 @Before 48 public void setUp() { 49 LayoutInflater layoutInflater = LayoutInflater.from(getContext()); 50 mKeyguardStatusView = 51 (KeyguardStatusView) layoutInflater.inflate(R.layout.keyguard_status_view, null); 52 org.mockito.MockitoAnnotations.initMocks(this); 53 } 54 55 @Test 56 public void dozeTimeTick_updatesSlice() { 57 mKeyguardStatusView.dozeTimeTick(); 58 verify(mKeyguardSlice).refresh(); 59 } 60 61 @Test 62 public void dozeTimeTick_updatesClock() { 63 mKeyguardStatusView.dozeTimeTick(); 64 verify(mClockView).refresh(); 65 } 66 67 } 68