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

Commit e940d8d0 authored by Ioana Alexandru's avatar Ioana Alexandru Committed by Android (Google) Code Review
Browse files

Merge "Adjust NSSL tests when footer flag is enabled." into main

parents f0f4bc8e 7065d5f1
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ import static kotlinx.coroutines.flow.FlowKt.emptyFlow;
import static kotlinx.coroutines.test.TestCoroutineDispatchersKt.StandardTestDispatcher;

import android.metrics.LogMaker;
import android.platform.test.annotations.DisableFlags;
import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
import android.view.View;
@@ -84,6 +85,7 @@ import com.android.systemui.statusbar.notification.collection.render.SectionHead
import com.android.systemui.statusbar.notification.data.repository.ActiveNotificationListRepository;
import com.android.systemui.statusbar.notification.domain.interactor.ActiveNotificationsInteractor;
import com.android.systemui.statusbar.notification.domain.interactor.SeenNotificationsInteractor;
import com.android.systemui.statusbar.notification.footer.shared.FooterViewRefactor;
import com.android.systemui.statusbar.notification.init.NotificationsController;
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
import com.android.systemui.statusbar.notification.row.NotificationGutsManager;
@@ -218,6 +220,7 @@ public class NotificationStackScrollLayoutControllerTest extends SysuiTestCase {
    }

    @Test
    @DisableFlags(FooterViewRefactor.FLAG_NAME)
    public void testUpdateEmptyShadeView_notificationsVisible_zenHiding() {
        when(mZenModeController.areNotificationsHiddenInShade()).thenReturn(true);
        initController(/* viewIsAttached= */ true);
@@ -238,6 +241,7 @@ public class NotificationStackScrollLayoutControllerTest extends SysuiTestCase {
    }

    @Test
    @DisableFlags(FooterViewRefactor.FLAG_NAME)
    public void testUpdateEmptyShadeView_notificationsHidden_zenNotHiding() {
        when(mZenModeController.areNotificationsHiddenInShade()).thenReturn(false);
        initController(/* viewIsAttached= */ true);
@@ -258,6 +262,7 @@ public class NotificationStackScrollLayoutControllerTest extends SysuiTestCase {
    }

    @Test
    @DisableFlags(FooterViewRefactor.FLAG_NAME)
    public void testUpdateEmptyShadeView_splitShadeMode_alwaysShowEmptyView() {
        when(mZenModeController.areNotificationsHiddenInShade()).thenReturn(false);
        initController(/* viewIsAttached= */ true);
@@ -285,6 +290,7 @@ public class NotificationStackScrollLayoutControllerTest extends SysuiTestCase {
    }

    @Test
    @DisableFlags(FooterViewRefactor.FLAG_NAME)
    public void testUpdateEmptyShadeView_bouncerShowing_flagOff_hideEmptyView() {
        when(mZenModeController.areNotificationsHiddenInShade()).thenReturn(false);
        initController(/* viewIsAttached= */ true);
@@ -306,6 +312,7 @@ public class NotificationStackScrollLayoutControllerTest extends SysuiTestCase {
    }

    @Test
    @DisableFlags(FooterViewRefactor.FLAG_NAME)
    public void testUpdateEmptyShadeView_bouncerShowing_flagOn_hideEmptyView() {
        when(mZenModeController.areNotificationsHiddenInShade()).thenReturn(false);
        initController(/* viewIsAttached= */ true);
@@ -327,6 +334,7 @@ public class NotificationStackScrollLayoutControllerTest extends SysuiTestCase {
    }

    @Test
    @DisableFlags(FooterViewRefactor.FLAG_NAME)
    public void testUpdateEmptyShadeView_bouncerNotShowing_flagOff_showEmptyView() {
        when(mZenModeController.areNotificationsHiddenInShade()).thenReturn(false);
        initController(/* viewIsAttached= */ true);
@@ -348,6 +356,7 @@ public class NotificationStackScrollLayoutControllerTest extends SysuiTestCase {
    }

    @Test
    @DisableFlags(FooterViewRefactor.FLAG_NAME)
    public void testUpdateEmptyShadeView_bouncerNotShowing_flagOn_showEmptyView() {
        when(mZenModeController.areNotificationsHiddenInShade()).thenReturn(false);
        initController(/* viewIsAttached= */ true);
@@ -504,6 +513,7 @@ public class NotificationStackScrollLayoutControllerTest extends SysuiTestCase {
    }

    @Test
    @DisableFlags(FooterViewRefactor.FLAG_NAME)
    public void testSetNotifStats_updatesHasFilteredOutSeenNotifications() {
        initController(/* viewIsAttached= */ true);
        mSeenNotificationsInteractor.setHasFilteredOutSeenNotifications(true);
@@ -545,6 +555,7 @@ public class NotificationStackScrollLayoutControllerTest extends SysuiTestCase {
    }

    @Test
    @DisableFlags(FooterViewRefactor.FLAG_NAME)
    public void updateImportantForAccessibility_noChild_onKeyGuard_notImportantForA11y() {
        // GIVEN: Controller is attached, active notifications is empty,
        // and mNotificationStackScrollLayout.onKeyguard() is true
@@ -561,6 +572,7 @@ public class NotificationStackScrollLayoutControllerTest extends SysuiTestCase {
    }

    @Test
    @DisableFlags(FooterViewRefactor.FLAG_NAME)
    public void updateImportantForAccessibility_hasChild_onKeyGuard_importantForA11y() {
        // GIVEN: Controller is attached, active notifications is not empty,
        // and mNotificationStackScrollLayout.onKeyguard() is true
@@ -584,6 +596,7 @@ public class NotificationStackScrollLayoutControllerTest extends SysuiTestCase {
    }

    @Test
    @DisableFlags(FooterViewRefactor.FLAG_NAME)
    public void updateImportantForAccessibility_hasChild_notOnKeyGuard_importantForA11y() {
        // GIVEN: Controller is attached, active notifications is not empty,
        // and mNotificationStackScrollLayout.onKeyguard() is false
@@ -607,6 +620,7 @@ public class NotificationStackScrollLayoutControllerTest extends SysuiTestCase {
    }

    @Test
    @DisableFlags(FooterViewRefactor.FLAG_NAME)
    public void updateImportantForAccessibility_noChild_notOnKeyGuard_importantForA11y() {
        // GIVEN: Controller is attached, active notifications is empty,
        // and mNotificationStackScrollLayout.onKeyguard() is false
@@ -623,6 +637,7 @@ public class NotificationStackScrollLayoutControllerTest extends SysuiTestCase {
    }

    @Test
    @DisableFlags(FooterViewRefactor.FLAG_NAME)
    public void updateEmptyShadeView_onKeyguardTransitionToAod_hidesView() {
        initController(/* viewIsAttached= */ true);
        mController.onKeyguardTransitionChanged(
@@ -633,6 +648,7 @@ public class NotificationStackScrollLayoutControllerTest extends SysuiTestCase {
    }

    @Test
    @DisableFlags(FooterViewRefactor.FLAG_NAME)
    public void updateEmptyShadeView_onKeyguardOccludedTransitionToAod_hidesView() {
        initController(/* viewIsAttached= */ true);
        mController.onKeyguardTransitionChanged(
+48 −13
Original line number Diff line number Diff line
@@ -51,6 +51,8 @@ import static org.mockito.Mockito.when;

import android.graphics.Insets;
import android.graphics.Rect;
import android.platform.test.annotations.DisableFlags;
import android.platform.test.annotations.EnableFlags;
import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
import android.testing.TestableResources;
@@ -81,6 +83,7 @@ import com.android.systemui.statusbar.SysuiStatusBarStateController;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import com.android.systemui.statusbar.notification.collection.render.GroupExpansionManager;
import com.android.systemui.statusbar.notification.collection.render.GroupMembershipManager;
import com.android.systemui.statusbar.notification.footer.shared.FooterViewRefactor;
import com.android.systemui.statusbar.notification.footer.ui.view.FooterView;
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
import com.android.systemui.statusbar.notification.row.ExpandableView;
@@ -309,7 +312,9 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
    public void updateEmptyView_dndSuppressing() {
        when(mEmptyShadeView.willBeGone()).thenReturn(true);

        mStackScroller.updateEmptyShadeView(true, true);
        mStackScroller.updateEmptyShadeView(/* visible = */ true,
                /* areNotificationsHiddenInShade = */ true,
                /* hasFilteredOutSeenNotifications = */ false);

        verify(mEmptyShadeView).setText(R.string.dnd_suppressing_shade_text);
    }
@@ -319,7 +324,9 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
        mStackScroller.setEmptyShadeView(mEmptyShadeView);
        when(mEmptyShadeView.willBeGone()).thenReturn(true);

        mStackScroller.updateEmptyShadeView(true, false);
        mStackScroller.updateEmptyShadeView(/* visible = */ true,
                /* areNotificationsHiddenInShade = */ false,
                /* hasFilteredOutSeenNotifications = */ false);

        verify(mEmptyShadeView).setText(R.string.empty_shade_text);
    }
@@ -328,10 +335,14 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
    public void updateEmptyView_noNotificationsToDndSuppressing() {
        mStackScroller.setEmptyShadeView(mEmptyShadeView);
        when(mEmptyShadeView.willBeGone()).thenReturn(true);
        mStackScroller.updateEmptyShadeView(true, false);
        mStackScroller.updateEmptyShadeView(/* visible = */ true,
                /* areNotificationsHiddenInShade = */ false,
                /* hasFilteredOutSeenNotifications = */ false);
        verify(mEmptyShadeView).setText(R.string.empty_shade_text);

        mStackScroller.updateEmptyShadeView(true, true);
        mStackScroller.updateEmptyShadeView(/* visible = */ true,
                /* areNotificationsHiddenInShade = */ true,
                /* hasFilteredOutSeenNotifications = */ false);
        verify(mEmptyShadeView).setText(R.string.dnd_suppressing_shade_text);
    }

@@ -385,8 +396,8 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
        mStackScroller.setExpandedHeight(100f);
    }


    @Test
    @DisableFlags(FooterViewRefactor.FLAG_NAME)
    public void manageNotifications_visible() {
        FooterView view = mock(FooterView.class);
        mStackScroller.setFooterView(view);
@@ -399,6 +410,7 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
    }

    @Test
    @DisableFlags(FooterViewRefactor.FLAG_NAME)
    public void clearAll_visible() {
        FooterView view = mock(FooterView.class);
        mStackScroller.setFooterView(view);
@@ -411,6 +423,7 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
    }

    @Test
    @DisableFlags(FooterViewRefactor.FLAG_NAME)
    public void testInflateFooterView() {
        mStackScroller.inflateFooterView();
        ArgumentCaptor<FooterView> captor = ArgumentCaptor.forClass(FooterView.class);
@@ -444,7 +457,7 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
        FooterView view = mock(FooterView.class);
        mStackScroller.setFooterView(view);
        mStackScroller.updateFooter();
        verify(mStackScroller).updateFooterView(false, true, true);
        verify(mStackScroller, atLeastOnce()).updateFooterView(false, true, true);
    }

    @Test
@@ -459,7 +472,7 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
        FooterView view = mock(FooterView.class);
        mStackScroller.setFooterView(view);
        mStackScroller.updateFooter();
        verify(mStackScroller).updateFooterView(false, false, true);
        verify(mStackScroller, atLeastOnce()).updateFooterView(false, false, true);
    }

    @Test
@@ -474,7 +487,7 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
        FooterView view = mock(FooterView.class);
        mStackScroller.setFooterView(view);
        mStackScroller.updateFooter();
        verify(mStackScroller).updateFooterView(true, true, true);
        verify(mStackScroller, atLeastOnce()).updateFooterView(true, true, true);
    }

    @Test
@@ -490,7 +503,7 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
        FooterView view = mock(FooterView.class);
        mStackScroller.setFooterView(view);
        mStackScroller.updateFooter();
        verify(mStackScroller).updateFooterView(true, true, false);
        verify(mStackScroller, atLeastOnce()).updateFooterView(true, true, false);
    }

    @Test
@@ -505,7 +518,7 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
        FooterView view = mock(FooterView.class);
        mStackScroller.setFooterView(view);
        mStackScroller.updateFooter();
        verify(mStackScroller).updateFooterView(false, true, true);
        verify(mStackScroller, atLeastOnce()).updateFooterView(false, true, true);
    }

    @Test
@@ -521,7 +534,7 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
        FooterView view = mock(FooterView.class);
        mStackScroller.setFooterView(view);
        mStackScroller.updateFooter();
        verify(mStackScroller).updateFooterView(true, false, true);
        verify(mStackScroller, atLeastOnce()).updateFooterView(true, false, true);
    }

    @Test
@@ -529,7 +542,8 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
        mStackScroller.setCurrentUserSetup(true);

        // add footer
        mStackScroller.inflateFooterView();
        FooterView view = mock(FooterView.class);
        mStackScroller.setFooterView(view);

        // add notification
        ExpandableNotificationRow row = createClearableRow();
@@ -545,6 +559,7 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
    }

    @Test
    @DisableFlags(FooterViewRefactor.FLAG_NAME)
    public void testReInflatesFooterViews() {
        when(mEmptyShadeView.getTextResource()).thenReturn(R.string.empty_shade_text);
        clearInvocations(mStackScroller);
@@ -553,6 +568,16 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
        verify(mStackScroller).setEmptyShadeView(any());
    }

    @Test
    @EnableFlags(FooterViewRefactor.FLAG_NAME)
    public void testReInflatesEmptyShadeView() {
        when(mEmptyShadeView.getTextResource()).thenReturn(R.string.empty_shade_text);
        clearInvocations(mStackScroller);
        mStackScroller.reinflateViews();
        verify(mStackScroller, never()).setFooterView(any());
        verify(mStackScroller).setEmptyShadeView(any());
    }

    @Test
    public void testSetIsBeingDraggedResetsExposedMenu() {
        mStackScroller.setIsBeingDragged(true);
@@ -601,6 +626,8 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {

    @Test
    public void testClearNotifications_clearAllInProgress() {
        mFeatureFlags.set(Flags.ENABLE_NOTIFICATIONS_SIMULATE_SLOW_MEASURE, false);

        ExpandableNotificationRow row = createClearableRow();
        when(row.getEntry().hasFinishedInitialization()).thenReturn(true);
        doReturn(true).when(mStackScroller).isVisible(row);
@@ -645,6 +672,8 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {

    @Test
    public void testAddNotificationUpdatesSpeedBumpIndex() {
        mFeatureFlags.set(Flags.ENABLE_NOTIFICATIONS_SIMULATE_SLOW_MEASURE, false);

        // initial state calculated == 0
        assertEquals(0, mStackScroller.getSpeedBumpIndex());

@@ -661,6 +690,8 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {

    @Test
    public void testAddAmbientNotificationNoSpeedBumpUpdate() {
        mFeatureFlags.set(Flags.ENABLE_NOTIFICATIONS_SIMULATE_SLOW_MEASURE, false);

        // initial state calculated  == 0
        assertEquals(0, mStackScroller.getSpeedBumpIndex());

@@ -677,6 +708,8 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {

    @Test
    public void testRemoveNotificationUpdatesSpeedBump() {
        mFeatureFlags.set(Flags.ENABLE_NOTIFICATIONS_SIMULATE_SLOW_MEASURE, false);

        // initial state calculated == 0
        assertEquals(0, mStackScroller.getSpeedBumpIndex());

@@ -872,6 +905,7 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
    }

    @Test
    @DisableFlags(FooterViewRefactor.FLAG_NAME)
    public void hasFilteredOutSeenNotifs_updateFooter() {
        mStackScroller.setCurrentUserSetup(true);

@@ -887,6 +921,7 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
    }

    @Test
    @DisableFlags(FooterViewRefactor.FLAG_NAME)
    public void hasFilteredOutSeenNotifs_updateEmptyShadeView() {
        mStackScroller.setHasFilteredOutSeenNotifications(true);
        mStackScroller.updateEmptyShadeView(true, false);