1 /* 2 * Copyright (C) 2024 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.reardisplay 18 19 import android.testing.TestableLooper 20 import android.view.View 21 import androidx.test.filters.SmallTest 22 import com.android.systemui.SysuiTestCase 23 import com.android.systemui.res.R 24 import com.android.systemui.statusbar.phone.systemUIDialogDotFactory 25 import com.android.systemui.testKosmos 26 import junit.framework.Assert.assertFalse 27 import junit.framework.Assert.assertTrue 28 import org.junit.Test 29 import org.mockito.Mockito.verify 30 import org.mockito.kotlin.mock 31 32 /** atest SystemUITests:com.android.systemui.reardisplay.RearDisplayInnerDialogDelegateTest */ 33 @SmallTest 34 @TestableLooper.RunWithLooper 35 class RearDisplayInnerDialogDelegateTest : SysuiTestCase() { 36 37 private val kosmos = testKosmos() 38 39 @Test testShowAndDismissDialognull40 fun testShowAndDismissDialog() { 41 val dialogDelegate = 42 RearDisplayInnerDialogDelegate(kosmos.systemUIDialogDotFactory, mContext) {} 43 44 val dialog = dialogDelegate.createDialog() 45 dialog.show() 46 assertTrue(dialog.isShowing) 47 48 dialog.dismiss() 49 assertFalse(dialog.isShowing) 50 } 51 52 @Test testCancelnull53 fun testCancel() { 54 val mockCallback = mock<Runnable>() 55 RearDisplayInnerDialogDelegate(kosmos.systemUIDialogDotFactory, mContext) { 56 mockCallback.run() 57 } 58 .createDialog() 59 .apply { 60 show() 61 findViewById<View>(R.id.button_cancel).performClick() 62 verify(mockCallback).run() 63 } 64 } 65 } 66