1 /* 2 * Copyright (C) 2022 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.systemui.bouncer.domain.interactor 18 19 import android.view.View 20 import androidx.test.ext.junit.runners.AndroidJUnit4 21 import androidx.test.filters.SmallTest 22 import com.android.systemui.RoboPilotTest 23 import com.android.systemui.SysuiTestCase 24 import org.junit.Before 25 import org.junit.Test 26 import org.junit.runner.RunWith 27 import org.mockito.Mock 28 import org.mockito.Mockito.verify 29 import org.mockito.MockitoAnnotations 30 31 @SmallTest 32 @RoboPilotTest 33 @RunWith(AndroidJUnit4::class) 34 class PrimaryBouncerCallbackInteractorTest : SysuiTestCase() { 35 private val mPrimaryBouncerCallbackInteractor = PrimaryBouncerCallbackInteractor() 36 @Mock 37 private lateinit var mPrimaryBouncerExpansionCallback: 38 PrimaryBouncerCallbackInteractor.PrimaryBouncerExpansionCallback 39 @Mock 40 private lateinit var keyguardResetCallback: 41 PrimaryBouncerCallbackInteractor.KeyguardResetCallback 42 43 @Before 44 fun setup() { 45 MockitoAnnotations.initMocks(this) 46 mPrimaryBouncerCallbackInteractor.addBouncerExpansionCallback( 47 mPrimaryBouncerExpansionCallback 48 ) 49 mPrimaryBouncerCallbackInteractor.addKeyguardResetCallback(keyguardResetCallback) 50 } 51 52 @Test 53 fun testOnFullyShown() { 54 mPrimaryBouncerCallbackInteractor.dispatchFullyShown() 55 verify(mPrimaryBouncerExpansionCallback).onFullyShown() 56 } 57 58 @Test 59 fun testOnFullyHidden() { 60 mPrimaryBouncerCallbackInteractor.dispatchFullyHidden() 61 verify(mPrimaryBouncerExpansionCallback).onFullyHidden() 62 } 63 64 @Test 65 fun testOnExpansionChanged() { 66 mPrimaryBouncerCallbackInteractor.dispatchExpansionChanged(5f) 67 verify(mPrimaryBouncerExpansionCallback).onExpansionChanged(5f) 68 } 69 70 @Test 71 fun testOnVisibilityChanged() { 72 mPrimaryBouncerCallbackInteractor.dispatchVisibilityChanged(View.INVISIBLE) 73 verify(mPrimaryBouncerExpansionCallback).onVisibilityChanged(false) 74 } 75 76 @Test 77 fun testOnStartingToHide() { 78 mPrimaryBouncerCallbackInteractor.dispatchStartingToHide() 79 verify(mPrimaryBouncerExpansionCallback).onStartingToHide() 80 } 81 82 @Test 83 fun testOnStartingToShow() { 84 mPrimaryBouncerCallbackInteractor.dispatchStartingToShow() 85 verify(mPrimaryBouncerExpansionCallback).onStartingToShow() 86 } 87 88 @Test 89 fun testOnKeyguardReset() { 90 mPrimaryBouncerCallbackInteractor.dispatchReset() 91 verify(keyguardResetCallback).onKeyguardReset() 92 } 93 } 94