Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bcd1f529 authored by András Kurucz's avatar András Kurucz Committed by Android (Google) Code Review
Browse files

Merge "[flexiglass] Update NSSL stack height on child height changes" into main

parents c8e86757 cd2db86e
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -2630,6 +2630,7 @@ public class NotificationStackScrollLayout
    private void updateContentHeight() {
        if (SceneContainerFlag.isEnabled()) {
            updateIntrinsicStackHeight();
            updateStackEndHeightAndStackHeight(mAmbientState.getExpansionFraction());
            return;
        }

+31 −0
Original line number Diff line number Diff line
@@ -1274,6 +1274,37 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
        assertThat(mAmbientState.getStackEndHeight()).isEqualTo(stackViewPortHeight);
    }

    @Test
    @EnableSceneContainer
    public void testChildHeightUpdated_whenMaxDisplayedNotificationsSet_updatesStackHeight() {
        ExpandableNotificationRow row = mock(ExpandableNotificationRow.class);
        int maxNotifs = 1; // any non-zero limit
        float stackTop = 100;
        float stackCutoff = 1100;
        mStackScroller.setStackTop(stackTop);
        mStackScroller.setStackCutoff(stackCutoff);

        // Given we have a limit on max displayed notifications
        int stackHeightBeforeUpdate = 100;
        when(mStackSizeCalculator.computeHeight(eq(mStackScroller), eq(maxNotifs), anyFloat()))
                .thenReturn((float) stackHeightBeforeUpdate);
        mStackScroller.setMaxDisplayedNotifications(maxNotifs);

        // And the stack heights are set
        assertThat(mStackScroller.getIntrinsicStackHeight()).isEqualTo(stackHeightBeforeUpdate);
        assertThat(mAmbientState.getStackEndHeight()).isEqualTo(stackHeightBeforeUpdate);

        // When a child changes its height
        int stackHeightAfterUpdate = 300;
        when(mStackSizeCalculator.computeHeight(eq(mStackScroller), eq(maxNotifs), anyFloat()))
                .thenReturn((float) stackHeightAfterUpdate);
        mStackScroller.onChildHeightChanged(row, /* needsAnimation = */ false);

        // Then the stack heights are updated
        assertThat(mStackScroller.getIntrinsicStackHeight()).isEqualTo(stackHeightAfterUpdate);
        assertThat(mAmbientState.getStackEndHeight()).isEqualTo(stackHeightAfterUpdate);
    }

    @Test
    @DisableSceneContainer
    public void testSetMaxDisplayedNotifications_notifiesListeners() {