Updates naming style in test file. am: 696ef143aa

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/19170716

Change-Id: I96c931a3cac43ba19b160ecb3677deb2c5b38d02
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Alejandro Nijamkin
2022-07-12 21:29:52 +00:00
committed by Automerger Merge Worker

View File

@@ -37,94 +37,94 @@ import com.android.systemui.statusbar.phone.panelstate.PanelExpansionStateManage
import com.android.systemui.statusbar.window.StatusBarWindowStateController import com.android.systemui.statusbar.window.StatusBarWindowStateController
import com.android.systemui.tuner.TunerService import com.android.systemui.tuner.TunerService
import com.google.common.truth.Truth.assertThat import com.google.common.truth.Truth.assertThat
import java.util.Optional
import org.junit.Before import org.junit.Before
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith import org.junit.runner.RunWith
import org.mockito.ArgumentCaptor import org.mockito.ArgumentCaptor
import org.mockito.ArgumentMatchers import org.mockito.ArgumentMatchers
import org.mockito.Mock import org.mockito.Mock
import org.mockito.MockitoAnnotations
import org.mockito.Mockito.anyFloat import org.mockito.Mockito.anyFloat
import org.mockito.Mockito.never import org.mockito.Mockito.never
import org.mockito.Mockito.verify import org.mockito.Mockito.verify
import java.util.Optional
import org.mockito.Mockito.`when` as whenever import org.mockito.Mockito.`when` as whenever
import org.mockito.MockitoAnnotations
@RunWith(AndroidTestingRunner::class) @RunWith(AndroidTestingRunner::class)
@RunWithLooper(setAsMainLooper = true) @RunWithLooper(setAsMainLooper = true)
@SmallTest @SmallTest
class NotificationShadeWindowViewControllerTest : SysuiTestCase() { class NotificationShadeWindowViewControllerTest : SysuiTestCase() {
private lateinit var mController: NotificationShadeWindowViewController
@Mock @Mock
private lateinit var mView: NotificationShadeWindowView private lateinit var view: NotificationShadeWindowView
@Mock @Mock
private lateinit var mTunerService: TunerService private lateinit var tunserService: TunerService
@Mock @Mock
private lateinit var mStatusBarStateController: SysuiStatusBarStateController private lateinit var sysuiStatusBarStateController: SysuiStatusBarStateController
@Mock @Mock
private lateinit var mCentralSurfaces: CentralSurfaces private lateinit var centralSurfaces: CentralSurfaces
@Mock @Mock
private lateinit var mDockManager: DockManager private lateinit var dockManager: DockManager
@Mock @Mock
private lateinit var mNotificationPanelViewController: NotificationPanelViewController private lateinit var notificationPanelViewController: NotificationPanelViewController
@Mock @Mock
private lateinit var mNotificationShadeDepthController: NotificationShadeDepthController private lateinit var notificationShadeDepthController: NotificationShadeDepthController
@Mock @Mock
private lateinit var mNotificationShadeWindowController: NotificationShadeWindowController private lateinit var notificationShadeWindowController: NotificationShadeWindowController
@Mock @Mock
private lateinit var mKeyguardUnlockAnimationController: KeyguardUnlockAnimationController private lateinit var keyguardUnlockAnimationController: KeyguardUnlockAnimationController
@Mock @Mock
private lateinit var mAmbientState: AmbientState private lateinit var ambientState: AmbientState
@Mock @Mock
private lateinit var stackScrollLayoutController: NotificationStackScrollLayoutController private lateinit var stackScrollLayoutController: NotificationStackScrollLayoutController
@Mock @Mock
private lateinit var mStatusBarKeyguardViewManager: StatusBarKeyguardViewManager private lateinit var statusBarKeyguardViewManager: StatusBarKeyguardViewManager
@Mock @Mock
private lateinit var mStatusBarWindowStateController: StatusBarWindowStateController private lateinit var statusBarWindowStateController: StatusBarWindowStateController
@Mock @Mock
private lateinit var mLockscreenShadeTransitionController: LockscreenShadeTransitionController private lateinit var lockscreenShadeTransitionController: LockscreenShadeTransitionController
@Mock @Mock
private lateinit var mLockIconViewController: LockIconViewController private lateinit var lockIconViewController: LockIconViewController
@Mock @Mock
private lateinit var mPhoneStatusBarViewController: PhoneStatusBarViewController private lateinit var phoneStatusBarViewController: PhoneStatusBarViewController
@Mock @Mock
private lateinit var mLowLightClockController: LowLightClockController private lateinit var lowLightClockController: LowLightClockController
private lateinit var mInteractionEventHandlerCaptor: ArgumentCaptor<InteractionEventHandler> private lateinit var interactionEventHandlerCaptor: ArgumentCaptor<InteractionEventHandler>
private lateinit var mInteractionEventHandler: InteractionEventHandler private lateinit var interactionEventHandler: InteractionEventHandler
private lateinit var underTest: NotificationShadeWindowViewController
@Before @Before
fun setUp() { fun setUp() {
MockitoAnnotations.initMocks(this) MockitoAnnotations.initMocks(this)
whenever(mView.bottom).thenReturn(VIEW_BOTTOM) whenever(view.bottom).thenReturn(VIEW_BOTTOM)
mController = NotificationShadeWindowViewController( underTest = NotificationShadeWindowViewController(
mLockscreenShadeTransitionController, lockscreenShadeTransitionController,
FalsingCollectorFake(), FalsingCollectorFake(),
mTunerService, tunserService,
mStatusBarStateController, sysuiStatusBarStateController,
mDockManager, dockManager,
mNotificationShadeDepthController, notificationShadeDepthController,
mView, view,
mNotificationPanelViewController, notificationPanelViewController,
PanelExpansionStateManager(), PanelExpansionStateManager(),
stackScrollLayoutController, stackScrollLayoutController,
mStatusBarKeyguardViewManager, statusBarKeyguardViewManager,
mStatusBarWindowStateController, statusBarWindowStateController,
mLockIconViewController, lockIconViewController,
Optional.of(mLowLightClockController), Optional.of(lowLightClockController),
mCentralSurfaces, centralSurfaces,
mNotificationShadeWindowController, notificationShadeWindowController,
mKeyguardUnlockAnimationController, keyguardUnlockAnimationController,
mAmbientState ambientState
) )
mController.setupExpandedStatusBar() underTest.setupExpandedStatusBar()
mInteractionEventHandlerCaptor = interactionEventHandlerCaptor =
ArgumentCaptor.forClass(InteractionEventHandler::class.java) ArgumentCaptor.forClass(InteractionEventHandler::class.java)
verify(mView).setInteractionEventHandler(mInteractionEventHandlerCaptor.capture()) verify(view).setInteractionEventHandler(interactionEventHandlerCaptor.capture())
mInteractionEventHandler = mInteractionEventHandlerCaptor.value interactionEventHandler = interactionEventHandlerCaptor.value
} }
// Note: So far, these tests only cover interactions with the status bar view controller. More // Note: So far, these tests only cover interactions with the status bar view controller. More
@@ -132,148 +132,148 @@ class NotificationShadeWindowViewControllerTest : SysuiTestCase() {
@Test @Test
fun handleDispatchTouchEvent_nullStatusBarViewController_returnsFalse() { fun handleDispatchTouchEvent_nullStatusBarViewController_returnsFalse() {
mController.setStatusBarViewController(null) underTest.setStatusBarViewController(null)
val returnVal = mInteractionEventHandler.handleDispatchTouchEvent(downEv) val returnVal = interactionEventHandler.handleDispatchTouchEvent(downEv)
assertThat(returnVal).isFalse() assertThat(returnVal).isFalse()
} }
@Test @Test
fun handleDispatchTouchEvent_downTouchBelowView_sendsTouchToSb() { fun handleDispatchTouchEvent_downTouchBelowView_sendsTouchToSb() {
mController.setStatusBarViewController(mPhoneStatusBarViewController) underTest.setStatusBarViewController(phoneStatusBarViewController)
val ev = MotionEvent.obtain(0L, 0L, MotionEvent.ACTION_DOWN, 0f, VIEW_BOTTOM + 4f, 0) val ev = MotionEvent.obtain(0L, 0L, MotionEvent.ACTION_DOWN, 0f, VIEW_BOTTOM + 4f, 0)
whenever(mPhoneStatusBarViewController.sendTouchToView(ev)).thenReturn(true) whenever(phoneStatusBarViewController.sendTouchToView(ev)).thenReturn(true)
val returnVal = mInteractionEventHandler.handleDispatchTouchEvent(ev) val returnVal = interactionEventHandler.handleDispatchTouchEvent(ev)
verify(mPhoneStatusBarViewController).sendTouchToView(ev) verify(phoneStatusBarViewController).sendTouchToView(ev)
assertThat(returnVal).isTrue() assertThat(returnVal).isTrue()
} }
@Test @Test
fun handleDispatchTouchEvent_downTouchBelowViewThenAnotherTouch_sendsTouchToSb() { fun handleDispatchTouchEvent_downTouchBelowViewThenAnotherTouch_sendsTouchToSb() {
mController.setStatusBarViewController(mPhoneStatusBarViewController) underTest.setStatusBarViewController(phoneStatusBarViewController)
val downEvBelow = MotionEvent.obtain( val downEvBelow = MotionEvent.obtain(
0L, 0L, MotionEvent.ACTION_DOWN, 0f, VIEW_BOTTOM + 4f, 0 0L, 0L, MotionEvent.ACTION_DOWN, 0f, VIEW_BOTTOM + 4f, 0
) )
mInteractionEventHandler.handleDispatchTouchEvent(downEvBelow) interactionEventHandler.handleDispatchTouchEvent(downEvBelow)
val nextEvent = MotionEvent.obtain( val nextEvent = MotionEvent.obtain(
0L, 0L, MotionEvent.ACTION_MOVE, 0f, VIEW_BOTTOM + 5f, 0 0L, 0L, MotionEvent.ACTION_MOVE, 0f, VIEW_BOTTOM + 5f, 0
) )
whenever(mPhoneStatusBarViewController.sendTouchToView(nextEvent)).thenReturn(true) whenever(phoneStatusBarViewController.sendTouchToView(nextEvent)).thenReturn(true)
val returnVal = mInteractionEventHandler.handleDispatchTouchEvent(nextEvent) val returnVal = interactionEventHandler.handleDispatchTouchEvent(nextEvent)
verify(mPhoneStatusBarViewController).sendTouchToView(nextEvent) verify(phoneStatusBarViewController).sendTouchToView(nextEvent)
assertThat(returnVal).isTrue() assertThat(returnVal).isTrue()
} }
@Test @Test
fun handleDispatchTouchEvent_downAndPanelCollapsedAndInSbBoundAndSbWindowShow_sendsTouchToSb() { fun handleDispatchTouchEvent_downAndPanelCollapsedAndInSbBoundAndSbWindowShow_sendsTouchToSb() {
mController.setStatusBarViewController(mPhoneStatusBarViewController) underTest.setStatusBarViewController(phoneStatusBarViewController)
whenever(mStatusBarWindowStateController.windowIsShowing()).thenReturn(true) whenever(statusBarWindowStateController.windowIsShowing()).thenReturn(true)
whenever(mNotificationPanelViewController.isFullyCollapsed).thenReturn(true) whenever(notificationPanelViewController.isFullyCollapsed).thenReturn(true)
whenever(mPhoneStatusBarViewController.touchIsWithinView(anyFloat(), anyFloat())) whenever(phoneStatusBarViewController.touchIsWithinView(anyFloat(), anyFloat()))
.thenReturn(true) .thenReturn(true)
whenever(mPhoneStatusBarViewController.sendTouchToView(downEv)).thenReturn(true) whenever(phoneStatusBarViewController.sendTouchToView(downEv)).thenReturn(true)
val returnVal = mInteractionEventHandler.handleDispatchTouchEvent(downEv) val returnVal = interactionEventHandler.handleDispatchTouchEvent(downEv)
verify(mPhoneStatusBarViewController).sendTouchToView(downEv) verify(phoneStatusBarViewController).sendTouchToView(downEv)
assertThat(returnVal).isTrue() assertThat(returnVal).isTrue()
} }
@Test @Test
fun handleDispatchTouchEvent_panelNotCollapsed_returnsNull() { fun handleDispatchTouchEvent_panelNotCollapsed_returnsNull() {
mController.setStatusBarViewController(mPhoneStatusBarViewController) underTest.setStatusBarViewController(phoneStatusBarViewController)
whenever(mStatusBarWindowStateController.windowIsShowing()).thenReturn(true) whenever(statusBarWindowStateController.windowIsShowing()).thenReturn(true)
whenever(mPhoneStatusBarViewController.touchIsWithinView(anyFloat(), anyFloat())) whenever(phoneStatusBarViewController.touchIsWithinView(anyFloat(), anyFloat()))
.thenReturn(true) .thenReturn(true)
// Item we're testing // Item we're testing
whenever(mNotificationPanelViewController.isFullyCollapsed).thenReturn(false) whenever(notificationPanelViewController.isFullyCollapsed).thenReturn(false)
val returnVal = mInteractionEventHandler.handleDispatchTouchEvent(downEv) val returnVal = interactionEventHandler.handleDispatchTouchEvent(downEv)
verify(mPhoneStatusBarViewController, never()).sendTouchToView(downEv) verify(phoneStatusBarViewController, never()).sendTouchToView(downEv)
assertThat(returnVal).isNull() assertThat(returnVal).isNull()
} }
@Test @Test
fun handleDispatchTouchEvent_touchNotInSbBounds_returnsNull() { fun handleDispatchTouchEvent_touchNotInSbBounds_returnsNull() {
mController.setStatusBarViewController(mPhoneStatusBarViewController) underTest.setStatusBarViewController(phoneStatusBarViewController)
whenever(mStatusBarWindowStateController.windowIsShowing()).thenReturn(true) whenever(statusBarWindowStateController.windowIsShowing()).thenReturn(true)
whenever(mNotificationPanelViewController.isFullyCollapsed).thenReturn(true) whenever(notificationPanelViewController.isFullyCollapsed).thenReturn(true)
// Item we're testing // Item we're testing
whenever(mPhoneStatusBarViewController.touchIsWithinView(anyFloat(), anyFloat())) whenever(phoneStatusBarViewController.touchIsWithinView(anyFloat(), anyFloat()))
.thenReturn(false) .thenReturn(false)
val returnVal = mInteractionEventHandler.handleDispatchTouchEvent(downEv) val returnVal = interactionEventHandler.handleDispatchTouchEvent(downEv)
verify(mPhoneStatusBarViewController, never()).sendTouchToView(downEv) verify(phoneStatusBarViewController, never()).sendTouchToView(downEv)
assertThat(returnVal).isNull() assertThat(returnVal).isNull()
} }
@Test @Test
fun handleDispatchTouchEvent_sbWindowNotShowing_noSendTouchToSbAndReturnsTrue() { fun handleDispatchTouchEvent_sbWindowNotShowing_noSendTouchToSbAndReturnsTrue() {
mController.setStatusBarViewController(mPhoneStatusBarViewController) underTest.setStatusBarViewController(phoneStatusBarViewController)
whenever(mNotificationPanelViewController.isFullyCollapsed).thenReturn(true) whenever(notificationPanelViewController.isFullyCollapsed).thenReturn(true)
whenever(mPhoneStatusBarViewController.touchIsWithinView(anyFloat(), anyFloat())) whenever(phoneStatusBarViewController.touchIsWithinView(anyFloat(), anyFloat()))
.thenReturn(true) .thenReturn(true)
// Item we're testing // Item we're testing
whenever(mStatusBarWindowStateController.windowIsShowing()).thenReturn(false) whenever(statusBarWindowStateController.windowIsShowing()).thenReturn(false)
val returnVal = mInteractionEventHandler.handleDispatchTouchEvent(downEv) val returnVal = interactionEventHandler.handleDispatchTouchEvent(downEv)
verify(mPhoneStatusBarViewController, never()).sendTouchToView(downEv) verify(phoneStatusBarViewController, never()).sendTouchToView(downEv)
assertThat(returnVal).isTrue() assertThat(returnVal).isTrue()
} }
@Test @Test
fun handleDispatchTouchEvent_downEventSentToSbThenAnotherEvent_sendsTouchToSb() { fun handleDispatchTouchEvent_downEventSentToSbThenAnotherEvent_sendsTouchToSb() {
mController.setStatusBarViewController(mPhoneStatusBarViewController) underTest.setStatusBarViewController(phoneStatusBarViewController)
whenever(mStatusBarWindowStateController.windowIsShowing()).thenReturn(true) whenever(statusBarWindowStateController.windowIsShowing()).thenReturn(true)
whenever(mNotificationPanelViewController.isFullyCollapsed).thenReturn(true) whenever(notificationPanelViewController.isFullyCollapsed).thenReturn(true)
whenever(mPhoneStatusBarViewController.touchIsWithinView(anyFloat(), anyFloat())) whenever(phoneStatusBarViewController.touchIsWithinView(anyFloat(), anyFloat()))
.thenReturn(true) .thenReturn(true)
// Down event first // Down event first
mInteractionEventHandler.handleDispatchTouchEvent(downEv) interactionEventHandler.handleDispatchTouchEvent(downEv)
// Then another event // Then another event
val nextEvent = MotionEvent.obtain(0L, 0L, MotionEvent.ACTION_MOVE, 0f, 0f, 0) val nextEvent = MotionEvent.obtain(0L, 0L, MotionEvent.ACTION_MOVE, 0f, 0f, 0)
whenever(mPhoneStatusBarViewController.sendTouchToView(nextEvent)).thenReturn(true) whenever(phoneStatusBarViewController.sendTouchToView(nextEvent)).thenReturn(true)
val returnVal = mInteractionEventHandler.handleDispatchTouchEvent(nextEvent) val returnVal = interactionEventHandler.handleDispatchTouchEvent(nextEvent)
verify(mPhoneStatusBarViewController).sendTouchToView(nextEvent) verify(phoneStatusBarViewController).sendTouchToView(nextEvent)
assertThat(returnVal).isTrue() assertThat(returnVal).isTrue()
} }
@Test @Test
fun testLowLightClockAttachedWhenExpandedStatusBarSetup() { fun testLowLightClockAttachedWhenExpandedStatusBarSetup() {
verify(mLowLightClockController).attachLowLightClockView(ArgumentMatchers.any()) verify(lowLightClockController).attachLowLightClockView(ArgumentMatchers.any())
} }
@Test @Test
fun testLowLightClockShownWhenDozing() { fun testLowLightClockShownWhenDozing() {
mController.setDozing(true) underTest.setDozing(true)
verify(mLowLightClockController).showLowLightClock(true) verify(lowLightClockController).showLowLightClock(true)
} }
@Test @Test
fun testLowLightClockDozeTimeTickCalled() { fun testLowLightClockDozeTimeTickCalled() {
mController.dozeTimeTick() underTest.dozeTimeTick()
verify(mLowLightClockController).dozeTimeTick() verify(lowLightClockController).dozeTimeTick()
} }
@Test @Test
fun testLowLightClockHiddenWhenNotDozing() { fun testLowLightClockHiddenWhenNotDozing() {
mController.setDozing(true) underTest.setDozing(true)
verify(mLowLightClockController).showLowLightClock(true) verify(lowLightClockController).showLowLightClock(true)
mController.setDozing(false) underTest.setDozing(false)
verify(mLowLightClockController).showLowLightClock(false) verify(lowLightClockController).showLowLightClock(false)
} }
} }