1 package com.android.systemui.qs
2 
3 import android.testing.TestableLooper
4 import android.view.View
5 import android.widget.FrameLayout
6 import androidx.test.ext.junit.runners.AndroidJUnit4
7 import androidx.test.filters.SmallTest
8 import com.android.systemui.res.R
9 import com.android.systemui.SysuiTestCase
10 import com.android.systemui.qs.customize.QSCustomizer
11 import com.android.systemui.util.mockito.eq
12 import org.junit.Before
13 import org.junit.Test
14 import org.junit.runner.RunWith
15 import org.mockito.Mock
16 import org.mockito.Mockito.anyInt
17 import org.mockito.Mockito.verify
18 import org.mockito.MockitoAnnotations
19 import org.mockito.Mockito.`when` as whenever
20 
21 @RunWith(AndroidJUnit4::class)
22 @TestableLooper.RunWithLooper
23 @SmallTest
24 class QSContainerImplTest : SysuiTestCase() {
25 
26     @Mock
27     private lateinit var quickStatusBarHeader: QuickStatusBarHeader
28     @Mock
29     private lateinit var qsCustomizer: QSCustomizer
30     @Mock
31     private lateinit var qsPanelContainer: NonInterceptingScrollView
32     @Mock
33     private lateinit var qsPanelController: QSPanelController
34     @Mock
35     private lateinit var quickStatusBarHeaderController: QuickStatusBarHeaderController
36 
37     private lateinit var qsContainer: QSContainerImpl
38 
39     @Before
setUpnull40     fun setUp() {
41         MockitoAnnotations.initMocks(this)
42 
43         qsContainer = QSContainerImpl(mContext, null)
44 
45         setUpMockView(quickStatusBarHeader, R.id.header)
46         setUpMockView(qsCustomizer, R.id.qs_customize)
47         setUpMockView(qsPanelContainer, R.id.expanded_qs_scroll_view)
48 
49         qsContainer.onFinishInflate()
50     }
51 
setUpMockViewnull52     private fun setUpMockView(view: View, id: Int) {
53         whenever(view.findViewById<View>(id)).thenReturn(view)
54         whenever(view.layoutParams).thenReturn(FrameLayout.LayoutParams(0, 0))
55         qsContainer.addView(view)
56     }
57 
58     @Test
testContainerBottomPaddingnull59     fun testContainerBottomPadding() {
60         val originalPadding = qsPanelContainer.paddingBottom
61         qsContainer.updateResources(
62             qsPanelController,
63             quickStatusBarHeaderController
64         )
65         verify(qsPanelContainer)
66             .setPaddingRelative(
67                 anyInt(),
68                 anyInt(),
69                 anyInt(),
70                 eq(originalPadding)
71             )
72     }
73 }
74