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

Commit 7065d5f1 authored by Ioana Alexandru's avatar Ioana Alexandru
Browse files

Adjust NSSL tests when footer flag is enabled.

Some tests in the NSSL were failing if the footer refactor flag was
enabled. Added a @DisableFlags annotation for all the tests where the
behaviour is already implemented (and tested) in the refactored stack.
All of these tests have an equivalent inside FooterViewModelTest or
NotificationListViewModelTest.

The footer visibility is not yet refactored, so those tests should
remain for now, but I adjusted them a bit so they work with the flag
both on and off (added atLeastOnce() since when the flag is on there's
an extra call to updateFooter). These will eventually have DisableFlags
as well, and later be deleted.

A few more tests complained about the
enable_notifications_simulate_slow_measure classic flag not being set,
so I fixed that as well.

Bug: 293167744
Test: ran the tests with the flag on to make sure they pass
Flag: N/A
Change-Id: I21e67ea9a1b27c8e18d52f9dfc6e010f2f29f819
parent 55a29646
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);