Loading packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/MagneticNotificationRowManagerImplTest.kt +14 −0 Original line number Diff line number Diff line Loading @@ -89,6 +89,20 @@ class MagneticNotificationRowManagerImplTest : SysuiTestCase() { assertThat(underTest.currentState).isEqualTo(State.PULLING) } @Test fun setMagneticRowTranslation_whenIdle_doesNotSetMagneticTranslation() = kosmos.testScope.runTest { // GIVEN an IDLE state // WHEN setting a translation for the swiped row val row = children.attachedChildren[childrenNumber / 2] underTest.setMagneticRowTranslation(row, translation = 100f) // THEN no magnetic translations are set val canSetMagneticTranslation = underTest.setMagneticRowTranslation(row, translation = 100f) assertThat(canSetMagneticTranslation).isFalse() } @Test fun setMagneticRowTranslation_whenRowIsNotSwiped_doesNotSetMagneticTranslation() = kosmos.testScope.runTest { Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationRowLogger.kt +15 −0 Original line number Diff line number Diff line Loading @@ -219,6 +219,21 @@ constructor( { "Failed to set magnetic and roundable targets for $str1 on state $str2." }, ) } fun logMagneticRowTranslationNotSet( state: MagneticNotificationRowManagerImpl.State, entry: NotificationEntry, ) { buffer.log( TAG, LogLevel.ERROR, { str1 = entry.logKey str2 = state.name }, { "Failed to set magnetic row translation for $str1 on state $str2." }, ) } } private const val TAG = "NotifRow" packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/MagneticNotificationRowManagerImpl.kt +4 −1 Original line number Diff line number Diff line Loading @@ -112,6 +112,10 @@ constructor( if (!row.isSwipedTarget()) return false when (currentState) { State.IDLE -> { logger.logMagneticRowTranslationNotSet(currentState, row.entry) return false } State.TARGETS_SET -> { pullTargets(translation) currentState = State.PULLING Loading @@ -131,7 +135,6 @@ constructor( val swiped = currentMagneticListeners.swipedListener() swiped?.setMagneticTranslation(translation) } else -> {} } return true } Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/MagneticNotificationRowManagerImplTest.kt +14 −0 Original line number Diff line number Diff line Loading @@ -89,6 +89,20 @@ class MagneticNotificationRowManagerImplTest : SysuiTestCase() { assertThat(underTest.currentState).isEqualTo(State.PULLING) } @Test fun setMagneticRowTranslation_whenIdle_doesNotSetMagneticTranslation() = kosmos.testScope.runTest { // GIVEN an IDLE state // WHEN setting a translation for the swiped row val row = children.attachedChildren[childrenNumber / 2] underTest.setMagneticRowTranslation(row, translation = 100f) // THEN no magnetic translations are set val canSetMagneticTranslation = underTest.setMagneticRowTranslation(row, translation = 100f) assertThat(canSetMagneticTranslation).isFalse() } @Test fun setMagneticRowTranslation_whenRowIsNotSwiped_doesNotSetMagneticTranslation() = kosmos.testScope.runTest { Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationRowLogger.kt +15 −0 Original line number Diff line number Diff line Loading @@ -219,6 +219,21 @@ constructor( { "Failed to set magnetic and roundable targets for $str1 on state $str2." }, ) } fun logMagneticRowTranslationNotSet( state: MagneticNotificationRowManagerImpl.State, entry: NotificationEntry, ) { buffer.log( TAG, LogLevel.ERROR, { str1 = entry.logKey str2 = state.name }, { "Failed to set magnetic row translation for $str1 on state $str2." }, ) } } private const val TAG = "NotifRow"
packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/MagneticNotificationRowManagerImpl.kt +4 −1 Original line number Diff line number Diff line Loading @@ -112,6 +112,10 @@ constructor( if (!row.isSwipedTarget()) return false when (currentState) { State.IDLE -> { logger.logMagneticRowTranslationNotSet(currentState, row.entry) return false } State.TARGETS_SET -> { pullTargets(translation) currentState = State.PULLING Loading @@ -131,7 +135,6 @@ constructor( val swiped = currentMagneticListeners.swipedListener() swiped?.setMagneticTranslation(translation) } else -> {} } return true } Loading