Merge changes Ibd8d1ce0,I9e06ca2b into main
* changes:
[SB][Notif] HeadsUpApperanceControllerTest improvements
[Notif] HeadsUpManagerImplTest: Remove Assert, remove Hungarian notation
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/headsup/HeadsUpManagerImplOldTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/headsup/HeadsUpManagerImplOldTest.kt
index d2a7c61..8b4f53a 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/headsup/HeadsUpManagerImplOldTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/headsup/HeadsUpManagerImplOldTest.kt
@@ -81,9 +81,9 @@
@Mock private val mAccessibilityMgr: AccessibilityManagerWrapper? = null
- protected val mGlobalSettings: FakeGlobalSettings = FakeGlobalSettings()
- protected val mSystemClock: FakeSystemClock = FakeSystemClock()
- protected val mExecutor: FakeExecutor = FakeExecutor(mSystemClock)
+ protected val globalSettings: FakeGlobalSettings = FakeGlobalSettings()
+ protected val systemClock: FakeSystemClock = FakeSystemClock()
+ protected val executor: FakeExecutor = FakeExecutor(systemClock)
@Mock protected var mRow: ExpandableNotificationRow? = null
@@ -96,10 +96,10 @@
GroupMembershipManagerImpl(),
mKosmos.visualStabilityProvider,
mKosmos.configurationController,
- mockExecutorHandler(mExecutor),
- mGlobalSettings,
- mSystemClock,
- mExecutor,
+ mockExecutorHandler(executor),
+ globalSettings,
+ systemClock,
+ executor,
mAccessibilityMgr,
mUiEventLoggerFake,
JavaAdapter(mKosmos.testScope),
@@ -247,7 +247,7 @@
val entry = HeadsUpManagerTestUtil.createEntry(/* id= */ 0, mContext)
alm.showNotification(entry)
- mSystemClock.advanceTime((TEST_AUTO_DISMISS_TIME * 3 / 2).toLong())
+ systemClock.advanceTime((TEST_AUTO_DISMISS_TIME * 3 / 2).toLong())
assertThat(alm.isHeadsUpEntry(entry.key)).isFalse()
}
@@ -324,7 +324,7 @@
useAccessibilityTimeout(false)
hum.showNotification(entry)
- mSystemClock.advanceTime((TEST_TOUCH_ACCEPTANCE_TIME / 2 + TEST_AUTO_DISMISS_TIME).toLong())
+ systemClock.advanceTime((TEST_TOUCH_ACCEPTANCE_TIME / 2 + TEST_AUTO_DISMISS_TIME).toLong())
assertThat(hum.isHeadsUpEntry(entry.key)).isTrue()
}
@@ -336,7 +336,7 @@
useAccessibilityTimeout(false)
hum.showNotification(entry)
- mSystemClock.advanceTime(
+ systemClock.advanceTime(
(TEST_TOUCH_ACCEPTANCE_TIME +
(TEST_AUTO_DISMISS_TIME + TEST_A11Y_AUTO_DISMISS_TIME) / 2)
.toLong()
@@ -352,7 +352,7 @@
useAccessibilityTimeout(false)
hum.showNotification(entry)
- mSystemClock.advanceTime(
+ systemClock.advanceTime(
(TEST_TOUCH_ACCEPTANCE_TIME +
(TEST_AUTO_DISMISS_TIME + TEST_STICKY_AUTO_DISMISS_TIME) / 2)
.toLong()
@@ -368,7 +368,7 @@
useAccessibilityTimeout(false)
hum.showNotification(entry)
- mSystemClock.advanceTime(
+ systemClock.advanceTime(
(TEST_TOUCH_ACCEPTANCE_TIME + 2 * TEST_A11Y_AUTO_DISMISS_TIME).toLong()
)
@@ -382,7 +382,7 @@
useAccessibilityTimeout(true)
hum.showNotification(entry)
- mSystemClock.advanceTime(
+ systemClock.advanceTime(
(TEST_TOUCH_ACCEPTANCE_TIME +
(TEST_AUTO_DISMISS_TIME + TEST_A11Y_AUTO_DISMISS_TIME) / 2)
.toLong()
@@ -398,7 +398,7 @@
useAccessibilityTimeout(true)
hum.showNotification(entry)
- mSystemClock.advanceTime(
+ systemClock.advanceTime(
(TEST_TOUCH_ACCEPTANCE_TIME +
(TEST_STICKY_AUTO_DISMISS_TIME + TEST_A11Y_AUTO_DISMISS_TIME) / 2)
.toLong()
@@ -424,9 +424,7 @@
assertThat(removedImmediately).isFalse()
assertThat(hum.isHeadsUpEntry(entry.key)).isTrue()
- mSystemClock.advanceTime(
- ((TEST_MINIMUM_DISPLAY_TIME + TEST_AUTO_DISMISS_TIME) / 2).toLong()
- )
+ systemClock.advanceTime(((TEST_MINIMUM_DISPLAY_TIME + TEST_AUTO_DISMISS_TIME) / 2).toLong())
assertThat(hum.isHeadsUpEntry(entry.key)).isFalse()
}
@@ -438,9 +436,7 @@
useAccessibilityTimeout(false)
hum.showNotification(entry)
- mSystemClock.advanceTime(
- ((TEST_MINIMUM_DISPLAY_TIME + TEST_AUTO_DISMISS_TIME) / 2).toLong()
- )
+ systemClock.advanceTime(((TEST_MINIMUM_DISPLAY_TIME + TEST_AUTO_DISMISS_TIME) / 2).toLong())
assertThat(hum.isHeadsUpEntry(entry.key)).isTrue()
@@ -633,12 +629,10 @@
hum.onEntryAdded(entryToPin)
assertThat(mUiEventLoggerFake.numLogs()).isEqualTo(2)
- assertThat(
- AvalancheController.ThrottleEvent.AVALANCHE_THROTTLING_HUN_SHOWN.getId(),
- ).isEqualTo(mUiEventLoggerFake.eventId(0))
- assertThat(
- HeadsUpManagerImpl.NotificationPeekEvent.NOTIFICATION_PEEK.id,
- ).isEqualTo(mUiEventLoggerFake.eventId(1))
+ assertThat(AvalancheController.ThrottleEvent.AVALANCHE_THROTTLING_HUN_SHOWN.getId())
+ .isEqualTo(mUiEventLoggerFake.eventId(0))
+ assertThat(HeadsUpManagerImpl.NotificationPeekEvent.NOTIFICATION_PEEK.id)
+ .isEqualTo(mUiEventLoggerFake.eventId(1))
}
@Test
@@ -660,9 +654,8 @@
hum.onEntryAdded(entryToPin)
assertThat(mUiEventLoggerFake.numLogs()).isEqualTo(1)
- assertThat(
- HeadsUpManagerImpl.NotificationPeekEvent.NOTIFICATION_PEEK.id,
- ).isEqualTo(mUiEventLoggerFake.eventId(0))
+ assertThat(HeadsUpManagerImpl.NotificationPeekEvent.NOTIFICATION_PEEK.id)
+ .isEqualTo(mUiEventLoggerFake.eventId(0))
}
@Test
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/headsup/HeadsUpManagerImplTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/headsup/HeadsUpManagerImplTest.kt
index 96f0201..a5fecb8 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/headsup/HeadsUpManagerImplTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/headsup/HeadsUpManagerImplTest.kt
@@ -42,8 +42,6 @@
import com.android.systemui.util.concurrency.mockExecutorHandler
import com.android.systemui.util.kotlin.JavaAdapter
import com.google.common.truth.Truth.assertThat
-import junit.framework.Assert
-import kotlinx.coroutines.test.runTest
import org.junit.Before
import org.junit.Ignore
import org.junit.Test
@@ -58,18 +56,18 @@
@RunWithLooper
class HeadsUpManagerImplTest(flags: FlagsParameterization) : HeadsUpManagerImplOldTest(flags) {
- private val mHeadsUpManagerLogger = HeadsUpManagerLogger(logcatLogBuffer())
+ private val headsUpManagerLogger = HeadsUpManagerLogger(logcatLogBuffer())
private val kosmos = testKosmos().useUnconfinedTestDispatcher()
private val testScope = kosmos.testScope
- private val mGroupManager = mock<GroupMembershipManager>()
- private val mBgHandler = mock<Handler>()
+ private val groupManager = mock<GroupMembershipManager>()
+ private val bgHandler = mock<Handler>()
val statusBarStateController = kosmos.sysuiStatusBarStateController
- private val mJavaAdapter: JavaAdapter = JavaAdapter(testScope.backgroundScope)
+ private val javaAdapter: JavaAdapter = JavaAdapter(testScope.backgroundScope)
- private lateinit var mAvalancheController: AvalancheController
+ private lateinit var avalancheController: AvalancheController
private lateinit var underTest: HeadsUpManagerImpl
@Before
@@ -94,31 +92,31 @@
whenever(kosmos.keyguardBypassController.bypassEnabled).thenReturn(false)
kosmos.visualStabilityProvider.isReorderingAllowed = true
- mAvalancheController =
+ avalancheController =
AvalancheController(
kosmos.dumpManager,
kosmos.uiEventLoggerFake,
- mHeadsUpManagerLogger,
- mBgHandler,
+ headsUpManagerLogger,
+ bgHandler,
)
underTest =
HeadsUpManagerImpl(
mContext,
- mHeadsUpManagerLogger,
+ headsUpManagerLogger,
statusBarStateController,
kosmos.keyguardBypassController,
- mGroupManager,
+ groupManager,
kosmos.visualStabilityProvider,
kosmos.configurationController,
- mockExecutorHandler(mExecutor),
- mGlobalSettings,
- mSystemClock,
- mExecutor,
+ mockExecutorHandler(executor),
+ globalSettings,
+ systemClock,
+ executor,
kosmos.accessibilityManagerWrapper,
kosmos.uiEventLoggerFake,
- mJavaAdapter,
+ javaAdapter,
kosmos.shadeInteractor,
- mAvalancheController,
+ avalancheController,
)
}
@@ -127,7 +125,7 @@
val entry = HeadsUpManagerTestUtil.createEntry(/* id= */ 0, mContext)
underTest.showNotification(entry)
underTest.snooze()
- Assert.assertTrue(underTest.isSnoozed(entry.sbn.packageName))
+ assertThat(underTest.isSnoozed(entry.sbn.packageName)).isTrue()
}
@Test
@@ -143,8 +141,8 @@
/* releaseImmediately= */ false,
/* reason= */ "swipe out",
)
- Assert.assertTrue(removedImmediately)
- Assert.assertFalse(underTest.isHeadsUpEntry(entry.key))
+ assertThat(removedImmediately).isTrue()
+ assertThat(underTest.isHeadsUpEntry(entry.key)).isFalse()
}
@Test
@@ -154,7 +152,7 @@
underTest.addSwipedOutNotification(entry.key)
// Notification is swiped so it can be immediately removed.
- Assert.assertTrue(underTest.canRemoveImmediately(entry.key))
+ assertThat(underTest.canRemoveImmediately(entry.key)).isTrue()
}
@Ignore("b/141538055")
@@ -167,7 +165,7 @@
underTest.showNotification(laterEntry)
// Notification is "behind" a higher priority notification so we can remove it immediately.
- Assert.assertTrue(underTest.canRemoveImmediately(earlierEntry.key))
+ assertThat(underTest.canRemoveImmediately(earlierEntry.key)).isTrue()
}
@Test
@@ -175,8 +173,8 @@
val entry = HeadsUpManagerTestUtil.createEntry(/* id= */ 0, mContext)
underTest.showNotification(entry)
underTest.extendHeadsUp()
- mSystemClock.advanceTime(((TEST_AUTO_DISMISS_TIME + TEST_EXTENSION_TIME) / 2).toLong())
- Assert.assertTrue(underTest.isHeadsUpEntry(entry.key))
+ systemClock.advanceTime(((TEST_AUTO_DISMISS_TIME + TEST_EXTENSION_TIME) / 2).toLong())
+ assertThat(underTest.isHeadsUpEntry(entry.key)).isTrue()
}
@Test
@@ -234,7 +232,7 @@
val entry = HeadsUpManagerTestUtil.createEntry(/* id= */ 0, mContext)
- Assert.assertFalse(underTest.shouldHeadsUpBecomePinned(entry))
+ assertThat(underTest.shouldHeadsUpBecomePinned(entry)).isFalse()
}
@Test
@@ -251,7 +249,7 @@
val headsUpEntry = underTest.getHeadsUpEntry(notifEntry.key)
headsUpEntry!!.mWasUnpinned = false
- Assert.assertTrue(underTest.shouldHeadsUpBecomePinned(notifEntry))
+ assertThat(underTest.shouldHeadsUpBecomePinned(notifEntry)).isTrue()
}
@Test
@@ -268,7 +266,7 @@
val headsUpEntry = underTest.getHeadsUpEntry(notifEntry.key)
headsUpEntry!!.mWasUnpinned = true
- Assert.assertFalse(underTest.shouldHeadsUpBecomePinned(notifEntry))
+ assertThat(underTest.shouldHeadsUpBecomePinned(notifEntry)).isFalse()
}
@Test
@@ -283,7 +281,7 @@
statusBarStateController.setState(StatusBarState.SHADE)
// THEN
- Assert.assertTrue(underTest.shouldHeadsUpBecomePinned(entry))
+ assertThat(underTest.shouldHeadsUpBecomePinned(entry)).isTrue()
}
@Test
@@ -294,7 +292,7 @@
statusBarStateController.setState(StatusBarState.SHADE_LOCKED)
// THEN
- Assert.assertFalse(underTest.shouldHeadsUpBecomePinned(entry))
+ assertThat(underTest.shouldHeadsUpBecomePinned(entry)).isFalse()
}
@Test
@@ -305,7 +303,7 @@
statusBarStateController.setState(1207)
// THEN
- Assert.assertFalse(underTest.shouldHeadsUpBecomePinned(entry))
+ assertThat(underTest.shouldHeadsUpBecomePinned(entry)).isFalse()
}
@Test
@@ -318,7 +316,7 @@
statusBarStateController.setState(StatusBarState.KEYGUARD)
// THEN
- Assert.assertTrue(underTest.shouldHeadsUpBecomePinned(entry))
+ assertThat(underTest.shouldHeadsUpBecomePinned(entry)).isTrue()
}
@Test
@@ -331,7 +329,7 @@
statusBarStateController.setState(StatusBarState.KEYGUARD)
// THEN
- Assert.assertFalse(underTest.shouldHeadsUpBecomePinned(entry))
+ assertThat(underTest.shouldHeadsUpBecomePinned(entry)).isFalse()
}
@Test
@@ -346,7 +344,7 @@
statusBarStateController.setState(StatusBarState.SHADE)
// THEN
- Assert.assertFalse(underTest.shouldHeadsUpBecomePinned(entry))
+ assertThat(underTest.shouldHeadsUpBecomePinned(entry)).isFalse()
}
companion object {
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceControllerTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceControllerTest.kt
index d017402..ccd2d61 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceControllerTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceControllerTest.kt
@@ -56,146 +56,139 @@
@RunWith(AndroidJUnit4::class)
@RunWithLooper
class HeadsUpAppearanceControllerTest : SysuiTestCase() {
- private val mStackScrollerController: NotificationStackScrollLayoutController =
- mock<NotificationStackScrollLayoutController>()
- private val mShadeViewController: ShadeViewController = mock<ShadeViewController>()
- private val mShadeHeadsUpTracker: ShadeHeadsUpTracker = mock<ShadeHeadsUpTracker>()
- private val mDarkIconDispatcher: DarkIconDispatcher = mock<DarkIconDispatcher>()
- private var mHeadsUpAppearanceController: HeadsUpAppearanceController? = null
- private var mTestHelper: NotificationTestHelper? = null
- private var mRow: ExpandableNotificationRow? = null
- private var mEntry: NotificationEntry? = null
- private var mHeadsUpStatusBarView: HeadsUpStatusBarView? = null
- private var mHeadsUpManager: HeadsUpManager? = null
- private var mOperatorNameView: View? = null
- private var mStatusbarStateController: StatusBarStateController? = null
- private var mPhoneStatusBarTransitions: PhoneStatusBarTransitions? = null
- private var mBypassController: KeyguardBypassController? = null
- private var mWakeUpCoordinator: NotificationWakeUpCoordinator? = null
- private var mKeyguardStateController: KeyguardStateController? = null
- private var mCommandQueue: CommandQueue? = null
- private var mNotificationRoundnessManager: NotificationRoundnessManager? = null
+ private val stackScrollerController = mock<NotificationStackScrollLayoutController>()
+ private val shadeViewController = mock<ShadeViewController>()
+ private val shadeHeadsUpTracker = mock<ShadeHeadsUpTracker>()
+ private val darkIconDispatcher = mock<DarkIconDispatcher>()
+ private val statusBarStateController = mock<StatusBarStateController>()
+ private val phoneStatusBarTransitions = mock<PhoneStatusBarTransitions>()
+ private val bypassController = mock<KeyguardBypassController>()
+ private val wakeUpCoordinator = mock<NotificationWakeUpCoordinator>()
+ private val keyguardStateController = mock<KeyguardStateController>()
+ private val commandQueue = mock<CommandQueue>()
+ private val notificationRoundnessManager = mock<NotificationRoundnessManager>()
+ private var headsUpManager = mock<HeadsUpManager>()
+
+ private lateinit var testHelper: NotificationTestHelper
+ private lateinit var row: ExpandableNotificationRow
+ private lateinit var entry: NotificationEntry
+ private lateinit var headsUpStatusBarView: HeadsUpStatusBarView
+ private lateinit var operatorNameView: View
+
+ private lateinit var underTest: HeadsUpAppearanceController
@Before
@Throws(Exception::class)
fun setUp() {
allowTestableLooperAsMainThread()
- mTestHelper = NotificationTestHelper(mContext, mDependency, TestableLooper.get(this))
- mRow = mTestHelper!!.createRow()
- mEntry = mRow!!.entry
- mHeadsUpStatusBarView = HeadsUpStatusBarView(mContext, mock<View>(), mock<TextView>())
- mHeadsUpManager = mock<HeadsUpManager>()
- mOperatorNameView = View(mContext)
- mStatusbarStateController = mock<StatusBarStateController>()
- mPhoneStatusBarTransitions = mock<PhoneStatusBarTransitions>()
- mBypassController = mock<KeyguardBypassController>()
- mWakeUpCoordinator = mock<NotificationWakeUpCoordinator>()
- mKeyguardStateController = mock<KeyguardStateController>()
- mCommandQueue = mock<CommandQueue>()
- mNotificationRoundnessManager = mock<NotificationRoundnessManager>()
- whenever(mShadeViewController.shadeHeadsUpTracker).thenReturn(mShadeHeadsUpTracker)
- mHeadsUpAppearanceController =
+ testHelper = NotificationTestHelper(mContext, mDependency, TestableLooper.get(this))
+ row = testHelper.createRow()
+ entry = row.entry
+ headsUpStatusBarView = HeadsUpStatusBarView(mContext, mock<View>(), mock<TextView>())
+ operatorNameView = View(mContext)
+
+ whenever(shadeViewController.shadeHeadsUpTracker).thenReturn(shadeHeadsUpTracker)
+ underTest =
HeadsUpAppearanceController(
- mHeadsUpManager,
- mStatusbarStateController,
- mPhoneStatusBarTransitions,
- mBypassController,
- mWakeUpCoordinator,
- mDarkIconDispatcher,
- mKeyguardStateController,
- mCommandQueue,
- mStackScrollerController,
- mShadeViewController,
- mNotificationRoundnessManager,
- mHeadsUpStatusBarView,
+ headsUpManager,
+ statusBarStateController,
+ phoneStatusBarTransitions,
+ bypassController,
+ wakeUpCoordinator,
+ darkIconDispatcher,
+ keyguardStateController,
+ commandQueue,
+ stackScrollerController,
+ shadeViewController,
+ notificationRoundnessManager,
+ headsUpStatusBarView,
Clock(mContext, null),
mock<HeadsUpNotificationIconInteractor>(),
- Optional.of(mOperatorNameView!!),
+ Optional.of(operatorNameView),
)
- mHeadsUpAppearanceController!!.setAppearFraction(0.0f, 0.0f)
+ underTest.setAppearFraction(0.0f, 0.0f)
}
@Test
fun testShowinEntryUpdated() {
- mRow!!.setPinnedStatus(PinnedStatus.PinnedBySystem)
- whenever(mHeadsUpManager!!.hasPinnedHeadsUp()).thenReturn(true)
- whenever(mHeadsUpManager!!.getTopEntry()).thenReturn(mEntry)
- mHeadsUpAppearanceController!!.onHeadsUpPinned(mEntry)
- assertThat(mHeadsUpStatusBarView!!.showingEntry).isEqualTo(mRow!!.entry)
+ row.setPinnedStatus(PinnedStatus.PinnedBySystem)
+ whenever(headsUpManager.hasPinnedHeadsUp()).thenReturn(true)
+ whenever(headsUpManager.getTopEntry()).thenReturn(entry)
+ underTest.onHeadsUpPinned(entry)
+ assertThat(headsUpStatusBarView.showingEntry).isEqualTo(row.entry)
- mRow!!.setPinnedStatus(PinnedStatus.NotPinned)
- whenever(mHeadsUpManager!!.hasPinnedHeadsUp()).thenReturn(false)
- mHeadsUpAppearanceController!!.onHeadsUpUnPinned(mEntry)
- assertThat(mHeadsUpStatusBarView!!.showingEntry).isNull()
+ row.setPinnedStatus(PinnedStatus.NotPinned)
+ whenever(headsUpManager.hasPinnedHeadsUp()).thenReturn(false)
+ underTest.onHeadsUpUnPinned(entry)
+ assertThat(headsUpStatusBarView.showingEntry).isNull()
}
@Test
fun testPinnedStatusUpdated() {
- mRow!!.setPinnedStatus(PinnedStatus.PinnedBySystem)
- whenever(mHeadsUpManager!!.hasPinnedHeadsUp()).thenReturn(true)
- whenever(mHeadsUpManager!!.getTopEntry()).thenReturn(mEntry)
- mHeadsUpAppearanceController!!.onHeadsUpPinned(mEntry)
- assertThat(mHeadsUpAppearanceController!!.pinnedStatus)
- .isEqualTo(PinnedStatus.PinnedBySystem)
+ row.setPinnedStatus(PinnedStatus.PinnedBySystem)
+ whenever(headsUpManager.hasPinnedHeadsUp()).thenReturn(true)
+ whenever(headsUpManager.getTopEntry()).thenReturn(entry)
+ underTest.onHeadsUpPinned(entry)
+ assertThat(underTest.pinnedStatus).isEqualTo(PinnedStatus.PinnedBySystem)
- mRow!!.setPinnedStatus(PinnedStatus.NotPinned)
- whenever(mHeadsUpManager!!.hasPinnedHeadsUp()).thenReturn(false)
- mHeadsUpAppearanceController!!.onHeadsUpUnPinned(mEntry)
- assertThat(mHeadsUpAppearanceController!!.pinnedStatus).isEqualTo(PinnedStatus.NotPinned)
+ row.setPinnedStatus(PinnedStatus.NotPinned)
+ whenever(headsUpManager.hasPinnedHeadsUp()).thenReturn(false)
+ underTest.onHeadsUpUnPinned(entry)
+ assertThat(underTest.pinnedStatus).isEqualTo(PinnedStatus.NotPinned)
}
@Test
@DisableFlags(AsyncGroupHeaderViewInflation.FLAG_NAME)
fun testHeaderUpdated() {
- mRow!!.setPinnedStatus(PinnedStatus.PinnedBySystem)
- whenever(mHeadsUpManager!!.hasPinnedHeadsUp()).thenReturn(true)
- whenever(mHeadsUpManager!!.getTopEntry()).thenReturn(mEntry)
- mHeadsUpAppearanceController!!.onHeadsUpPinned(mEntry)
- assertThat(mRow!!.headerVisibleAmount).isEqualTo(0.0f)
+ row.setPinnedStatus(PinnedStatus.PinnedBySystem)
+ whenever(headsUpManager.hasPinnedHeadsUp()).thenReturn(true)
+ whenever(headsUpManager.getTopEntry()).thenReturn(entry)
+ underTest.onHeadsUpPinned(entry)
+ assertThat(row.headerVisibleAmount).isEqualTo(0.0f)
- mRow!!.setPinnedStatus(PinnedStatus.NotPinned)
- whenever(mHeadsUpManager!!.hasPinnedHeadsUp()).thenReturn(false)
- mHeadsUpAppearanceController!!.onHeadsUpUnPinned(mEntry)
- assertThat(mRow!!.headerVisibleAmount).isEqualTo(1.0f)
+ row.setPinnedStatus(PinnedStatus.NotPinned)
+ whenever(headsUpManager.hasPinnedHeadsUp()).thenReturn(false)
+ underTest.onHeadsUpUnPinned(entry)
+ assertThat(row.headerVisibleAmount).isEqualTo(1.0f)
}
@Test
fun testOperatorNameViewUpdated() {
- mHeadsUpAppearanceController!!.setAnimationsEnabled(false)
+ underTest.setAnimationsEnabled(false)
- mRow!!.setPinnedStatus(PinnedStatus.PinnedBySystem)
- whenever(mHeadsUpManager!!.hasPinnedHeadsUp()).thenReturn(true)
- whenever(mHeadsUpManager!!.getTopEntry()).thenReturn(mEntry)
- mHeadsUpAppearanceController!!.onHeadsUpPinned(mEntry)
- assertThat(mOperatorNameView!!.visibility).isEqualTo(View.INVISIBLE)
+ row.setPinnedStatus(PinnedStatus.PinnedBySystem)
+ whenever(headsUpManager.hasPinnedHeadsUp()).thenReturn(true)
+ whenever(headsUpManager.getTopEntry()).thenReturn(entry)
+ underTest.onHeadsUpPinned(entry)
+ assertThat(operatorNameView.visibility).isEqualTo(View.INVISIBLE)
- mRow!!.setPinnedStatus(PinnedStatus.NotPinned)
- whenever(mHeadsUpManager!!.hasPinnedHeadsUp()).thenReturn(false)
- mHeadsUpAppearanceController!!.onHeadsUpUnPinned(mEntry)
- assertThat(mOperatorNameView!!.visibility).isEqualTo(View.VISIBLE)
+ row.setPinnedStatus(PinnedStatus.NotPinned)
+ whenever(headsUpManager.hasPinnedHeadsUp()).thenReturn(false)
+ underTest.onHeadsUpUnPinned(entry)
+ assertThat(operatorNameView.visibility).isEqualTo(View.VISIBLE)
}
@Test
fun constructor_animationValuesUpdated() {
val appearFraction = .75f
val expandedHeight = 400f
- whenever(mStackScrollerController.appearFraction).thenReturn(appearFraction)
- whenever(mStackScrollerController.expandedHeight).thenReturn(expandedHeight)
+ whenever(stackScrollerController.appearFraction).thenReturn(appearFraction)
+ whenever(stackScrollerController.expandedHeight).thenReturn(expandedHeight)
val newController =
HeadsUpAppearanceController(
- mHeadsUpManager,
- mStatusbarStateController,
- mPhoneStatusBarTransitions,
- mBypassController,
- mWakeUpCoordinator,
- mDarkIconDispatcher,
- mKeyguardStateController,
- mCommandQueue,
- mStackScrollerController,
- mShadeViewController,
- mNotificationRoundnessManager,
- mHeadsUpStatusBarView,
+ headsUpManager,
+ statusBarStateController,
+ phoneStatusBarTransitions,
+ bypassController,
+ wakeUpCoordinator,
+ darkIconDispatcher,
+ keyguardStateController,
+ commandQueue,
+ stackScrollerController,
+ shadeViewController,
+ notificationRoundnessManager,
+ headsUpStatusBarView,
Clock(mContext, null),
mock<HeadsUpNotificationIconInteractor>(),
Optional.empty(),
@@ -207,77 +200,77 @@
@Test
fun testDestroy() {
- reset(mHeadsUpManager)
- reset(mDarkIconDispatcher)
- reset(mShadeHeadsUpTracker)
- reset(mStackScrollerController)
+ reset(headsUpManager)
+ reset(darkIconDispatcher)
+ reset(shadeHeadsUpTracker)
+ reset(stackScrollerController)
- mHeadsUpAppearanceController!!.onViewDetached()
+ underTest.onViewDetached()
- verify(mHeadsUpManager!!).removeListener(any())
- verify(mDarkIconDispatcher).removeDarkReceiver(any())
- verify(mShadeHeadsUpTracker).removeTrackingHeadsUpListener(any())
- verify(mShadeHeadsUpTracker).setHeadsUpAppearanceController(null)
- verify(mStackScrollerController).removeOnExpandedHeightChangedListener(any())
+ verify(headsUpManager).removeListener(any())
+ verify(darkIconDispatcher).removeDarkReceiver(any())
+ verify(shadeHeadsUpTracker).removeTrackingHeadsUpListener(any())
+ verify(shadeHeadsUpTracker).setHeadsUpAppearanceController(null)
+ verify(stackScrollerController).removeOnExpandedHeightChangedListener(any())
}
@Test
fun testPulsingRoundness_onUpdateHeadsUpAndPulsingRoundness() {
// Pulsing: Enable flag and dozing
- whenever(mNotificationRoundnessManager!!.shouldRoundNotificationPulsing()).thenReturn(true)
- whenever(mTestHelper!!.statusBarStateController.isDozing).thenReturn(true)
+ whenever(notificationRoundnessManager.shouldRoundNotificationPulsing()).thenReturn(true)
+ whenever(testHelper.statusBarStateController.isDozing).thenReturn(true)
// Pulsing: Enabled
- mRow!!.isHeadsUp = true
- mHeadsUpAppearanceController!!.updateHeadsUpAndPulsingRoundness(mEntry)
+ row.isHeadsUp = true
+ underTest.updateHeadsUpAndPulsingRoundness(entry)
- val debugString: String = mRow!!.roundableState.debugString()
+ val debugString: String = row.roundableState.debugString()
// If Pulsing is enabled, roundness should be set to 1
- assertThat(mRow!!.topRoundness.toDouble()).isWithin(0.001).of(1.0)
+ assertThat(row.topRoundness.toDouble()).isWithin(0.001).of(1.0)
assertThat(debugString).contains("Pulsing")
// Pulsing: Disabled
- mRow!!.isHeadsUp = false
- mHeadsUpAppearanceController!!.updateHeadsUpAndPulsingRoundness(mEntry)
+ row.isHeadsUp = false
+ underTest.updateHeadsUpAndPulsingRoundness(entry)
// If Pulsing is disabled, roundness should be set to 0
- assertThat(mRow!!.topRoundness.toDouble()).isWithin(0.001).of(0.0)
+ assertThat(row.topRoundness.toDouble()).isWithin(0.001).of(0.0)
}
@Test
fun testPulsingRoundness_onHeadsUpStateChanged() {
// Pulsing: Enable flag and dozing
- whenever(mNotificationRoundnessManager!!.shouldRoundNotificationPulsing()).thenReturn(true)
- whenever(mTestHelper!!.statusBarStateController.isDozing).thenReturn(true)
+ whenever(notificationRoundnessManager.shouldRoundNotificationPulsing()).thenReturn(true)
+ whenever(testHelper.statusBarStateController.isDozing).thenReturn(true)
// Pulsing: Enabled
- mEntry!!.setHeadsUp(true)
- mHeadsUpAppearanceController!!.onHeadsUpStateChanged(mEntry!!, true)
+ entry.setHeadsUp(true)
+ underTest.onHeadsUpStateChanged(entry, true)
- val debugString: String = mRow!!.roundableState.debugString()
+ val debugString: String = row.roundableState.debugString()
// If Pulsing is enabled, roundness should be set to 1
- assertThat(mRow!!.topRoundness.toDouble()).isWithin(0.001).of(1.0)
+ assertThat(row.topRoundness.toDouble()).isWithin(0.001).of(1.0)
assertThat(debugString).contains("Pulsing")
// Pulsing: Disabled
- mEntry!!.setHeadsUp(false)
- mHeadsUpAppearanceController!!.onHeadsUpStateChanged(mEntry!!, false)
+ entry.setHeadsUp(false)
+ underTest.onHeadsUpStateChanged(entry, false)
// If Pulsing is disabled, roundness should be set to 0
- assertThat(mRow!!.topRoundness.toDouble()).isWithin(0.001).of(0.0)
+ assertThat(row.topRoundness.toDouble()).isWithin(0.001).of(0.0)
}
@Test
fun onHeadsUpStateChanged_true_transitionsNotified() {
- mHeadsUpAppearanceController!!.onHeadsUpStateChanged(mEntry!!, true)
+ underTest.onHeadsUpStateChanged(entry, true)
- verify(mPhoneStatusBarTransitions!!).onHeadsUpStateChanged(true)
+ verify(phoneStatusBarTransitions).onHeadsUpStateChanged(true)
}
@Test
fun onHeadsUpStateChanged_false_transitionsNotified() {
- mHeadsUpAppearanceController!!.onHeadsUpStateChanged(mEntry!!, false)
+ underTest.onHeadsUpStateChanged(entry, false)
- verify(mPhoneStatusBarTransitions!!).onHeadsUpStateChanged(false)
+ verify(phoneStatusBarTransitions).onHeadsUpStateChanged(false)
}
}