Loading packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java +1 −16 Original line number Diff line number Diff line Loading @@ -94,7 +94,6 @@ public class NotificationShelf extends ActivatableNotificationView { private float mCornerAnimationDistance; private float mActualWidth = -1; private int mMaxIconsOnLockscreen; private int mNotificationScrimPadding; private boolean mCanModifyColorOfNotifications; private boolean mCanInteract; private NotificationStackScrollLayout mHostLayout; Loading Loading @@ -138,7 +137,6 @@ public class NotificationShelf extends ActivatableNotificationView { mStatusBarHeight = SystemBarUtils.getStatusBarHeight(mContext); mPaddingBetweenElements = res.getDimensionPixelSize(R.dimen.notification_divider_height); mMaxIconsOnLockscreen = res.getInteger(R.integer.max_notif_icons_on_lockscreen); mNotificationScrimPadding = res.getDimensionPixelSize(R.dimen.notification_side_paddings); ViewGroup.LayoutParams layoutParams = getLayoutParams(); final int newShelfHeight = res.getDimensionPixelOffset(R.dimen.notification_shelf_height); Loading Loading @@ -265,7 +263,7 @@ public class NotificationShelf extends ActivatableNotificationView { } final float stackBottom = SceneContainerFlag.isEnabled() ? getStackBottom(ambientState) ? ambientState.getStackTop() + ambientState.getStackHeight() : ambientState.getStackY() + ambientState.getStackHeight(); if (viewState.hidden) { Loading @@ -278,19 +276,6 @@ public class NotificationShelf extends ActivatableNotificationView { } } /** * bottom-most position, where we can draw the stack */ private float getStackBottom(AmbientState ambientState) { if (SceneContainerFlag.isUnexpectedlyInLegacyMode()) return 0f; float stackBottom = ambientState.getStackCutoff() - mNotificationScrimPadding; if (ambientState.isExpansionChanging()) { stackBottom = MathUtils.lerp(stackBottom * StackScrollAlgorithm.START_FRACTION, stackBottom, ambientState.getExpansionFraction()); } return stackBottom; } private int getSpeedBumpIndex() { NotificationIconContainerRefactor.assertInLegacyMode(); return mHostLayout.getSpeedBumpIndex(); Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/AmbientState.java +5 −6 Original line number Diff line number Diff line Loading @@ -131,13 +131,13 @@ public class AmbientState implements Dumpable { /** Distance of top of notifications panel from top of screen. */ private float mStackY = 0; /** Height of notifications panel. */ /** Height of notifications panel interpolated by the expansion fraction. */ private float mStackHeight = 0; /** Fraction of shade expansion. */ private float mExpansionFraction; /** Height of the notifications panel without top padding when expansion completes. */ /** Height of the notifications panel when expansion completes. */ private float mStackEndHeight; /** Whether we are swiping up. */ Loading Loading @@ -176,8 +176,7 @@ public class AmbientState implements Dumpable { } /** * @param stackEndHeight Height of the notifications panel without top padding * when expansion completes. * @see #getStackEndHeight() */ public void setStackEndHeight(float stackEndHeight) { mStackEndHeight = stackEndHeight; Loading Loading @@ -257,14 +256,14 @@ public class AmbientState implements Dumpable { } /** * @param stackHeight Height of notifications panel. * @see #getStackHeight() */ public void setStackHeight(float stackHeight) { mStackHeight = stackHeight; } /** * @return Height of notifications panel. * @return Height of notifications panel interpolated by the expansion fraction. */ public float getStackHeight() { return mStackHeight; Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java +25 −7 Original line number Diff line number Diff line Loading @@ -1440,6 +1440,15 @@ public class NotificationStackScrollLayout @VisibleForTesting public void updateStackEndHeightAndStackHeight(float fraction) { final float oldStackHeight = mAmbientState.getStackHeight(); if (SceneContainerFlag.isEnabled()) { final float endHeight; if (!shouldSkipHeightUpdate()) { endHeight = updateStackEndHeight(); } else { endHeight = mAmbientState.getStackEndHeight(); } updateStackHeight(endHeight, fraction); } else { if (mQsExpansionFraction <= 0 && !shouldSkipHeightUpdate()) { final float endHeight = updateStackEndHeight( getHeight(), getEmptyBottomMargin(), getTopPadding()); Loading @@ -1450,12 +1459,21 @@ public class NotificationStackScrollLayout final float endHeight = mAmbientState.getStackEndHeight(); updateStackHeight(endHeight, fraction); } } if (oldStackHeight != mAmbientState.getStackHeight()) { requestChildrenUpdate(); } } private float updateStackEndHeight() { if (SceneContainerFlag.isUnexpectedlyInLegacyMode()) return 0f; float height = Math.max(0f, mAmbientState.getStackCutoff() - mAmbientState.getStackTop()); mAmbientState.setStackEndHeight(height); return height; } private float updateStackEndHeight(float height, float bottomMargin, float topPadding) { SceneContainerFlag.assertInLegacyMode(); final float stackEndHeight; if (mMaxDisplayedNotifications != -1) { // The stack intrinsic height already contains the correct value when there is a limit Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationShelfTest.kt +26 −69 Original line number Diff line number Diff line Loading @@ -367,14 +367,14 @@ open class NotificationShelfTest : SysuiTestCase() { @EnableSceneContainer fun updateState_withViewInShelf_showShelf() { // GIVEN a view is scrolled into the shelf val stackCutoff = 200f val scrimPadding = context.resources.getDimensionPixelSize(R.dimen.notification_side_paddings) val shelfTop = stackCutoff - scrimPadding - shelf.height val stackTop = 200f val stackHeight = 800f whenever(ambientState.stackTop).thenReturn(stackTop) whenever(ambientState.stackHeight).thenReturn(stackHeight) val shelfTop = stackTop + stackHeight - shelf.height val stackScrollAlgorithmState = StackScrollAlgorithmState() val viewInShelf = mock(ExpandableView::class.java) whenever(ambientState.stackCutoff).thenReturn(stackCutoff) whenever(ambientState.isShadeExpanded).thenReturn(true) whenever(ambientState.lastVisibleBackgroundChild).thenReturn(viewInShelf) whenever(viewInShelf.viewState).thenReturn(ExpandableViewState()) Loading @@ -399,59 +399,16 @@ open class NotificationShelfTest : SysuiTestCase() { assertEquals(shelfTop, shelfState.yTranslation) } @Test @EnableSceneContainer fun updateState_withViewInShelfDuringExpansion_showShelf() { // GIVEN a view is scrolled into the shelf val stackCutoff = 200f val scrimPadding = context.resources.getDimensionPixelSize(R.dimen.notification_side_paddings) val stackBottom = stackCutoff - scrimPadding val shelfTop = stackBottom - shelf.height val stackScrollAlgorithmState = StackScrollAlgorithmState() val viewInShelf = mock(ExpandableView::class.java) // AND a shade expansion is in progress val shadeExpansionFraction = 0.5f whenever(ambientState.stackCutoff).thenReturn(stackCutoff) whenever(ambientState.isShadeExpanded).thenReturn(true) whenever(ambientState.lastVisibleBackgroundChild).thenReturn(viewInShelf) whenever(ambientState.isExpansionChanging).thenReturn(true) whenever(ambientState.expansionFraction).thenReturn(shadeExpansionFraction) whenever(viewInShelf.viewState).thenReturn(ExpandableViewState()) whenever(viewInShelf.shelfIcon).thenReturn(mock(StatusBarIconView::class.java)) whenever(viewInShelf.translationY).thenReturn(shelfTop) whenever(viewInShelf.actualHeight).thenReturn(10) whenever(viewInShelf.isInShelf).thenReturn(true) whenever(viewInShelf.minHeight).thenReturn(10) whenever(viewInShelf.shelfTransformationTarget).thenReturn(null) // use translationY whenever(viewInShelf.isInShelf).thenReturn(true) stackScrollAlgorithmState.visibleChildren.add(viewInShelf) stackScrollAlgorithmState.firstViewInShelf = viewInShelf // WHEN Shelf's ViewState is updated shelf.updateState(stackScrollAlgorithmState, ambientState) // THEN the shelf is visible val shelfState = shelf.viewState as NotificationShelf.ShelfState assertEquals(false, shelfState.hidden) assertEquals(shelf.height, shelfState.height) // AND its translation is scaled by the shade expansion assertEquals((stackBottom * 0.75f) - shelf.height, shelfState.yTranslation) } @Test @EnableSceneContainer fun updateState_withNullLastVisibleBackgroundChild_hideShelf_withSceneContainer() { // GIVEN val stackCutoff = 200f val scrimPadding = context.resources.getDimensionPixelSize(R.dimen.notification_side_paddings) val stackTop = 200f val stackHeight = 800f whenever(ambientState.stackTop).thenReturn(stackTop) whenever(ambientState.stackHeight).thenReturn(stackHeight) val paddingBetweenElements = context.resources.getDimensionPixelSize(R.dimen.notification_divider_height) whenever(ambientState.stackCutoff).thenReturn(stackCutoff) whenever(ambientState.isShadeExpanded).thenReturn(true) val lastVisibleBackgroundChild = mock<ExpandableView>() val expandableViewState = ExpandableViewState() Loading @@ -467,7 +424,7 @@ open class NotificationShelfTest : SysuiTestCase() { // THEN val shelfState = shelf.viewState as NotificationShelf.ShelfState assertEquals(true, shelfState.hidden) assertEquals(stackCutoff - scrimPadding + paddingBetweenElements, shelfState.yTranslation) assertEquals(stackTop + stackHeight + paddingBetweenElements, shelfState.yTranslation) } @Test Loading Loading @@ -501,12 +458,12 @@ open class NotificationShelfTest : SysuiTestCase() { @EnableSceneContainer fun updateState_withNullFirstViewInShelf_hideShelf_withSceneContainer() { // GIVEN val stackCutoff = 200f val scrimPadding = context.resources.getDimensionPixelSize(R.dimen.notification_side_paddings) val stackTop = 200f val stackHeight = 800f whenever(ambientState.stackTop).thenReturn(stackTop) whenever(ambientState.stackHeight).thenReturn(stackHeight) val paddingBetweenElements = context.resources.getDimensionPixelSize(R.dimen.notification_divider_height) whenever(ambientState.stackCutoff).thenReturn(stackCutoff) whenever(ambientState.isShadeExpanded).thenReturn(true) val lastVisibleBackgroundChild = mock<ExpandableView>() val expandableViewState = ExpandableViewState() Loading @@ -522,7 +479,7 @@ open class NotificationShelfTest : SysuiTestCase() { // THEN val shelfState = shelf.viewState as NotificationShelf.ShelfState assertEquals(true, shelfState.hidden) assertEquals(stackCutoff - scrimPadding + paddingBetweenElements, shelfState.yTranslation) assertEquals(stackTop + stackHeight + paddingBetweenElements, shelfState.yTranslation) } @Test Loading Loading @@ -556,12 +513,12 @@ open class NotificationShelfTest : SysuiTestCase() { @EnableSceneContainer fun updateState_withCollapsedShade_hideShelf_withSceneContainer() { // GIVEN val stackCutoff = 200f val scrimPadding = context.resources.getDimensionPixelSize(R.dimen.notification_side_paddings) val stackTop = 200f val stackHeight = 800f whenever(ambientState.stackTop).thenReturn(stackTop) whenever(ambientState.stackHeight).thenReturn(stackHeight) val paddingBetweenElements = context.resources.getDimensionPixelSize(R.dimen.notification_divider_height) whenever(ambientState.stackCutoff).thenReturn(stackCutoff) val lastVisibleBackgroundChild = mock<ExpandableView>() val expandableViewState = ExpandableViewState() whenever(lastVisibleBackgroundChild.viewState).thenReturn(expandableViewState) Loading @@ -577,7 +534,7 @@ open class NotificationShelfTest : SysuiTestCase() { // THEN val shelfState = shelf.viewState as NotificationShelf.ShelfState assertEquals(true, shelfState.hidden) assertEquals(stackCutoff - scrimPadding + paddingBetweenElements, shelfState.yTranslation) assertEquals(stackTop + stackHeight + paddingBetweenElements, shelfState.yTranslation) } @Test Loading Loading @@ -609,12 +566,12 @@ open class NotificationShelfTest : SysuiTestCase() { @Test @EnableSceneContainer fun updateState_withHiddenSectionBeforeShelf_hideShelf_withSceneContianer() { fun updateState_withHiddenSectionBeforeShelf_hideShelf_withSceneContainer() { // GIVEN val stackCutoff = 200f whenever(ambientState.stackCutoff).thenReturn(stackCutoff) val scrimPadding = context.resources.getDimensionPixelSize(R.dimen.notification_side_paddings) val stackTop = 200f val stackHeight = 800f whenever(ambientState.stackTop).thenReturn(stackTop) whenever(ambientState.stackHeight).thenReturn(stackHeight) val paddingBetweenElements = context.resources.getDimensionPixelSize(R.dimen.notification_divider_height) whenever(ambientState.isShadeExpanded).thenReturn(true) Loading Loading @@ -646,7 +603,7 @@ open class NotificationShelfTest : SysuiTestCase() { // THEN val shelfState = shelf.viewState as NotificationShelf.ShelfState assertEquals(true, shelfState.hidden) assertEquals(stackCutoff - scrimPadding + paddingBetweenElements, shelfState.yTranslation) assertEquals(stackTop + stackHeight + paddingBetweenElements, shelfState.yTranslation) } @Test Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java +52 −5 Original line number Diff line number Diff line Loading @@ -262,15 +262,62 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase { } @Test public void updateStackEndHeightAndStackHeight_normallyUpdatesBoth() { final float expansionFraction = 0.5f; @EnableSceneContainer public void updateStackEndHeightAndStackHeight_shadeFullyExpanded_withSceneContainer() { final float stackTop = 200f; final float stackCutoff = 1000f; final float stackEndHeight = stackCutoff - stackTop; mAmbientState.setStackTop(stackTop); mAmbientState.setStackCutoff(stackCutoff); mAmbientState.setStatusBarState(StatusBarState.KEYGUARD); clearInvocations(mAmbientState); // WHEN shade is fully expanded mStackScroller.updateStackEndHeightAndStackHeight(/* fraction = */ 1.0f); // THEN stackHeight and stackEndHeight are the same verify(mAmbientState).setStackEndHeight(stackEndHeight); verify(mAmbientState).setStackHeight(stackEndHeight); } // Validate that by default we update everything @Test @EnableSceneContainer public void updateStackEndHeightAndStackHeight_shadeExpanding_withSceneContainer() { final float stackTop = 200f; final float stackCutoff = 1000f; final float stackEndHeight = stackCutoff - stackTop; mAmbientState.setStackTop(stackTop); mAmbientState.setStackCutoff(stackCutoff); mAmbientState.setStatusBarState(StatusBarState.KEYGUARD); clearInvocations(mAmbientState); // WHEN shade is expanding final float expansionFraction = 0.5f; mStackScroller.updateStackEndHeightAndStackHeight(expansionFraction); verify(mAmbientState).setStackEndHeight(anyFloat()); verify(mAmbientState).setStackHeight(anyFloat()); // THEN stackHeight is changed by the expansion frac verify(mAmbientState).setStackEndHeight(stackEndHeight); verify(mAmbientState).setStackHeight(stackEndHeight * 0.75f); } @Test @EnableSceneContainer public void updateStackEndHeightAndStackHeight_shadeOverscrolledToTop_withSceneContainer() { // GIVEN stack scrolled over the top, stack top is negative final float stackTop = -2000f; final float stackCutoff = 1000f; final float stackEndHeight = stackCutoff - stackTop; mAmbientState.setStackTop(stackTop); mAmbientState.setStackCutoff(stackCutoff); mAmbientState.setStatusBarState(StatusBarState.KEYGUARD); clearInvocations(mAmbientState); // WHEN stack is updated mStackScroller.updateStackEndHeightAndStackHeight(/* fraction = */ 1.0f); // THEN stackHeight is measured from the stack top verify(mAmbientState).setStackEndHeight(stackEndHeight); verify(mAmbientState).setStackHeight(stackEndHeight); } @Test Loading Loading
packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java +1 −16 Original line number Diff line number Diff line Loading @@ -94,7 +94,6 @@ public class NotificationShelf extends ActivatableNotificationView { private float mCornerAnimationDistance; private float mActualWidth = -1; private int mMaxIconsOnLockscreen; private int mNotificationScrimPadding; private boolean mCanModifyColorOfNotifications; private boolean mCanInteract; private NotificationStackScrollLayout mHostLayout; Loading Loading @@ -138,7 +137,6 @@ public class NotificationShelf extends ActivatableNotificationView { mStatusBarHeight = SystemBarUtils.getStatusBarHeight(mContext); mPaddingBetweenElements = res.getDimensionPixelSize(R.dimen.notification_divider_height); mMaxIconsOnLockscreen = res.getInteger(R.integer.max_notif_icons_on_lockscreen); mNotificationScrimPadding = res.getDimensionPixelSize(R.dimen.notification_side_paddings); ViewGroup.LayoutParams layoutParams = getLayoutParams(); final int newShelfHeight = res.getDimensionPixelOffset(R.dimen.notification_shelf_height); Loading Loading @@ -265,7 +263,7 @@ public class NotificationShelf extends ActivatableNotificationView { } final float stackBottom = SceneContainerFlag.isEnabled() ? getStackBottom(ambientState) ? ambientState.getStackTop() + ambientState.getStackHeight() : ambientState.getStackY() + ambientState.getStackHeight(); if (viewState.hidden) { Loading @@ -278,19 +276,6 @@ public class NotificationShelf extends ActivatableNotificationView { } } /** * bottom-most position, where we can draw the stack */ private float getStackBottom(AmbientState ambientState) { if (SceneContainerFlag.isUnexpectedlyInLegacyMode()) return 0f; float stackBottom = ambientState.getStackCutoff() - mNotificationScrimPadding; if (ambientState.isExpansionChanging()) { stackBottom = MathUtils.lerp(stackBottom * StackScrollAlgorithm.START_FRACTION, stackBottom, ambientState.getExpansionFraction()); } return stackBottom; } private int getSpeedBumpIndex() { NotificationIconContainerRefactor.assertInLegacyMode(); return mHostLayout.getSpeedBumpIndex(); Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/AmbientState.java +5 −6 Original line number Diff line number Diff line Loading @@ -131,13 +131,13 @@ public class AmbientState implements Dumpable { /** Distance of top of notifications panel from top of screen. */ private float mStackY = 0; /** Height of notifications panel. */ /** Height of notifications panel interpolated by the expansion fraction. */ private float mStackHeight = 0; /** Fraction of shade expansion. */ private float mExpansionFraction; /** Height of the notifications panel without top padding when expansion completes. */ /** Height of the notifications panel when expansion completes. */ private float mStackEndHeight; /** Whether we are swiping up. */ Loading Loading @@ -176,8 +176,7 @@ public class AmbientState implements Dumpable { } /** * @param stackEndHeight Height of the notifications panel without top padding * when expansion completes. * @see #getStackEndHeight() */ public void setStackEndHeight(float stackEndHeight) { mStackEndHeight = stackEndHeight; Loading Loading @@ -257,14 +256,14 @@ public class AmbientState implements Dumpable { } /** * @param stackHeight Height of notifications panel. * @see #getStackHeight() */ public void setStackHeight(float stackHeight) { mStackHeight = stackHeight; } /** * @return Height of notifications panel. * @return Height of notifications panel interpolated by the expansion fraction. */ public float getStackHeight() { return mStackHeight; Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java +25 −7 Original line number Diff line number Diff line Loading @@ -1440,6 +1440,15 @@ public class NotificationStackScrollLayout @VisibleForTesting public void updateStackEndHeightAndStackHeight(float fraction) { final float oldStackHeight = mAmbientState.getStackHeight(); if (SceneContainerFlag.isEnabled()) { final float endHeight; if (!shouldSkipHeightUpdate()) { endHeight = updateStackEndHeight(); } else { endHeight = mAmbientState.getStackEndHeight(); } updateStackHeight(endHeight, fraction); } else { if (mQsExpansionFraction <= 0 && !shouldSkipHeightUpdate()) { final float endHeight = updateStackEndHeight( getHeight(), getEmptyBottomMargin(), getTopPadding()); Loading @@ -1450,12 +1459,21 @@ public class NotificationStackScrollLayout final float endHeight = mAmbientState.getStackEndHeight(); updateStackHeight(endHeight, fraction); } } if (oldStackHeight != mAmbientState.getStackHeight()) { requestChildrenUpdate(); } } private float updateStackEndHeight() { if (SceneContainerFlag.isUnexpectedlyInLegacyMode()) return 0f; float height = Math.max(0f, mAmbientState.getStackCutoff() - mAmbientState.getStackTop()); mAmbientState.setStackEndHeight(height); return height; } private float updateStackEndHeight(float height, float bottomMargin, float topPadding) { SceneContainerFlag.assertInLegacyMode(); final float stackEndHeight; if (mMaxDisplayedNotifications != -1) { // The stack intrinsic height already contains the correct value when there is a limit Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationShelfTest.kt +26 −69 Original line number Diff line number Diff line Loading @@ -367,14 +367,14 @@ open class NotificationShelfTest : SysuiTestCase() { @EnableSceneContainer fun updateState_withViewInShelf_showShelf() { // GIVEN a view is scrolled into the shelf val stackCutoff = 200f val scrimPadding = context.resources.getDimensionPixelSize(R.dimen.notification_side_paddings) val shelfTop = stackCutoff - scrimPadding - shelf.height val stackTop = 200f val stackHeight = 800f whenever(ambientState.stackTop).thenReturn(stackTop) whenever(ambientState.stackHeight).thenReturn(stackHeight) val shelfTop = stackTop + stackHeight - shelf.height val stackScrollAlgorithmState = StackScrollAlgorithmState() val viewInShelf = mock(ExpandableView::class.java) whenever(ambientState.stackCutoff).thenReturn(stackCutoff) whenever(ambientState.isShadeExpanded).thenReturn(true) whenever(ambientState.lastVisibleBackgroundChild).thenReturn(viewInShelf) whenever(viewInShelf.viewState).thenReturn(ExpandableViewState()) Loading @@ -399,59 +399,16 @@ open class NotificationShelfTest : SysuiTestCase() { assertEquals(shelfTop, shelfState.yTranslation) } @Test @EnableSceneContainer fun updateState_withViewInShelfDuringExpansion_showShelf() { // GIVEN a view is scrolled into the shelf val stackCutoff = 200f val scrimPadding = context.resources.getDimensionPixelSize(R.dimen.notification_side_paddings) val stackBottom = stackCutoff - scrimPadding val shelfTop = stackBottom - shelf.height val stackScrollAlgorithmState = StackScrollAlgorithmState() val viewInShelf = mock(ExpandableView::class.java) // AND a shade expansion is in progress val shadeExpansionFraction = 0.5f whenever(ambientState.stackCutoff).thenReturn(stackCutoff) whenever(ambientState.isShadeExpanded).thenReturn(true) whenever(ambientState.lastVisibleBackgroundChild).thenReturn(viewInShelf) whenever(ambientState.isExpansionChanging).thenReturn(true) whenever(ambientState.expansionFraction).thenReturn(shadeExpansionFraction) whenever(viewInShelf.viewState).thenReturn(ExpandableViewState()) whenever(viewInShelf.shelfIcon).thenReturn(mock(StatusBarIconView::class.java)) whenever(viewInShelf.translationY).thenReturn(shelfTop) whenever(viewInShelf.actualHeight).thenReturn(10) whenever(viewInShelf.isInShelf).thenReturn(true) whenever(viewInShelf.minHeight).thenReturn(10) whenever(viewInShelf.shelfTransformationTarget).thenReturn(null) // use translationY whenever(viewInShelf.isInShelf).thenReturn(true) stackScrollAlgorithmState.visibleChildren.add(viewInShelf) stackScrollAlgorithmState.firstViewInShelf = viewInShelf // WHEN Shelf's ViewState is updated shelf.updateState(stackScrollAlgorithmState, ambientState) // THEN the shelf is visible val shelfState = shelf.viewState as NotificationShelf.ShelfState assertEquals(false, shelfState.hidden) assertEquals(shelf.height, shelfState.height) // AND its translation is scaled by the shade expansion assertEquals((stackBottom * 0.75f) - shelf.height, shelfState.yTranslation) } @Test @EnableSceneContainer fun updateState_withNullLastVisibleBackgroundChild_hideShelf_withSceneContainer() { // GIVEN val stackCutoff = 200f val scrimPadding = context.resources.getDimensionPixelSize(R.dimen.notification_side_paddings) val stackTop = 200f val stackHeight = 800f whenever(ambientState.stackTop).thenReturn(stackTop) whenever(ambientState.stackHeight).thenReturn(stackHeight) val paddingBetweenElements = context.resources.getDimensionPixelSize(R.dimen.notification_divider_height) whenever(ambientState.stackCutoff).thenReturn(stackCutoff) whenever(ambientState.isShadeExpanded).thenReturn(true) val lastVisibleBackgroundChild = mock<ExpandableView>() val expandableViewState = ExpandableViewState() Loading @@ -467,7 +424,7 @@ open class NotificationShelfTest : SysuiTestCase() { // THEN val shelfState = shelf.viewState as NotificationShelf.ShelfState assertEquals(true, shelfState.hidden) assertEquals(stackCutoff - scrimPadding + paddingBetweenElements, shelfState.yTranslation) assertEquals(stackTop + stackHeight + paddingBetweenElements, shelfState.yTranslation) } @Test Loading Loading @@ -501,12 +458,12 @@ open class NotificationShelfTest : SysuiTestCase() { @EnableSceneContainer fun updateState_withNullFirstViewInShelf_hideShelf_withSceneContainer() { // GIVEN val stackCutoff = 200f val scrimPadding = context.resources.getDimensionPixelSize(R.dimen.notification_side_paddings) val stackTop = 200f val stackHeight = 800f whenever(ambientState.stackTop).thenReturn(stackTop) whenever(ambientState.stackHeight).thenReturn(stackHeight) val paddingBetweenElements = context.resources.getDimensionPixelSize(R.dimen.notification_divider_height) whenever(ambientState.stackCutoff).thenReturn(stackCutoff) whenever(ambientState.isShadeExpanded).thenReturn(true) val lastVisibleBackgroundChild = mock<ExpandableView>() val expandableViewState = ExpandableViewState() Loading @@ -522,7 +479,7 @@ open class NotificationShelfTest : SysuiTestCase() { // THEN val shelfState = shelf.viewState as NotificationShelf.ShelfState assertEquals(true, shelfState.hidden) assertEquals(stackCutoff - scrimPadding + paddingBetweenElements, shelfState.yTranslation) assertEquals(stackTop + stackHeight + paddingBetweenElements, shelfState.yTranslation) } @Test Loading Loading @@ -556,12 +513,12 @@ open class NotificationShelfTest : SysuiTestCase() { @EnableSceneContainer fun updateState_withCollapsedShade_hideShelf_withSceneContainer() { // GIVEN val stackCutoff = 200f val scrimPadding = context.resources.getDimensionPixelSize(R.dimen.notification_side_paddings) val stackTop = 200f val stackHeight = 800f whenever(ambientState.stackTop).thenReturn(stackTop) whenever(ambientState.stackHeight).thenReturn(stackHeight) val paddingBetweenElements = context.resources.getDimensionPixelSize(R.dimen.notification_divider_height) whenever(ambientState.stackCutoff).thenReturn(stackCutoff) val lastVisibleBackgroundChild = mock<ExpandableView>() val expandableViewState = ExpandableViewState() whenever(lastVisibleBackgroundChild.viewState).thenReturn(expandableViewState) Loading @@ -577,7 +534,7 @@ open class NotificationShelfTest : SysuiTestCase() { // THEN val shelfState = shelf.viewState as NotificationShelf.ShelfState assertEquals(true, shelfState.hidden) assertEquals(stackCutoff - scrimPadding + paddingBetweenElements, shelfState.yTranslation) assertEquals(stackTop + stackHeight + paddingBetweenElements, shelfState.yTranslation) } @Test Loading Loading @@ -609,12 +566,12 @@ open class NotificationShelfTest : SysuiTestCase() { @Test @EnableSceneContainer fun updateState_withHiddenSectionBeforeShelf_hideShelf_withSceneContianer() { fun updateState_withHiddenSectionBeforeShelf_hideShelf_withSceneContainer() { // GIVEN val stackCutoff = 200f whenever(ambientState.stackCutoff).thenReturn(stackCutoff) val scrimPadding = context.resources.getDimensionPixelSize(R.dimen.notification_side_paddings) val stackTop = 200f val stackHeight = 800f whenever(ambientState.stackTop).thenReturn(stackTop) whenever(ambientState.stackHeight).thenReturn(stackHeight) val paddingBetweenElements = context.resources.getDimensionPixelSize(R.dimen.notification_divider_height) whenever(ambientState.isShadeExpanded).thenReturn(true) Loading Loading @@ -646,7 +603,7 @@ open class NotificationShelfTest : SysuiTestCase() { // THEN val shelfState = shelf.viewState as NotificationShelf.ShelfState assertEquals(true, shelfState.hidden) assertEquals(stackCutoff - scrimPadding + paddingBetweenElements, shelfState.yTranslation) assertEquals(stackTop + stackHeight + paddingBetweenElements, shelfState.yTranslation) } @Test Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java +52 −5 Original line number Diff line number Diff line Loading @@ -262,15 +262,62 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase { } @Test public void updateStackEndHeightAndStackHeight_normallyUpdatesBoth() { final float expansionFraction = 0.5f; @EnableSceneContainer public void updateStackEndHeightAndStackHeight_shadeFullyExpanded_withSceneContainer() { final float stackTop = 200f; final float stackCutoff = 1000f; final float stackEndHeight = stackCutoff - stackTop; mAmbientState.setStackTop(stackTop); mAmbientState.setStackCutoff(stackCutoff); mAmbientState.setStatusBarState(StatusBarState.KEYGUARD); clearInvocations(mAmbientState); // WHEN shade is fully expanded mStackScroller.updateStackEndHeightAndStackHeight(/* fraction = */ 1.0f); // THEN stackHeight and stackEndHeight are the same verify(mAmbientState).setStackEndHeight(stackEndHeight); verify(mAmbientState).setStackHeight(stackEndHeight); } // Validate that by default we update everything @Test @EnableSceneContainer public void updateStackEndHeightAndStackHeight_shadeExpanding_withSceneContainer() { final float stackTop = 200f; final float stackCutoff = 1000f; final float stackEndHeight = stackCutoff - stackTop; mAmbientState.setStackTop(stackTop); mAmbientState.setStackCutoff(stackCutoff); mAmbientState.setStatusBarState(StatusBarState.KEYGUARD); clearInvocations(mAmbientState); // WHEN shade is expanding final float expansionFraction = 0.5f; mStackScroller.updateStackEndHeightAndStackHeight(expansionFraction); verify(mAmbientState).setStackEndHeight(anyFloat()); verify(mAmbientState).setStackHeight(anyFloat()); // THEN stackHeight is changed by the expansion frac verify(mAmbientState).setStackEndHeight(stackEndHeight); verify(mAmbientState).setStackHeight(stackEndHeight * 0.75f); } @Test @EnableSceneContainer public void updateStackEndHeightAndStackHeight_shadeOverscrolledToTop_withSceneContainer() { // GIVEN stack scrolled over the top, stack top is negative final float stackTop = -2000f; final float stackCutoff = 1000f; final float stackEndHeight = stackCutoff - stackTop; mAmbientState.setStackTop(stackTop); mAmbientState.setStackCutoff(stackCutoff); mAmbientState.setStatusBarState(StatusBarState.KEYGUARD); clearInvocations(mAmbientState); // WHEN stack is updated mStackScroller.updateStackEndHeightAndStackHeight(/* fraction = */ 1.0f); // THEN stackHeight is measured from the stack top verify(mAmbientState).setStackEndHeight(stackEndHeight); verify(mAmbientState).setStackHeight(stackEndHeight); } @Test Loading