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

Commit 5376d558 authored by András Kurucz's avatar András Kurucz Committed by Automerger Merge Worker
Browse files

Merge "Re-enable and fix failing tests in NotificationStackScrollLayoutTest"...

Merge "Re-enable and fix failing tests in NotificationStackScrollLayoutTest" into udc-dev am: 149fed16

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/23601987



Change-Id: I220ea9e421573206e4b635d32576f3a4f582ef60
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 98eeb067 149fed16
Loading
Loading
Loading
Loading
+5 −28
Original line number Diff line number Diff line
@@ -61,7 +61,6 @@ import android.view.WindowInsets;
import android.view.WindowInsetsAnimation;
import android.widget.TextView;

import androidx.test.annotation.UiThreadTest;
import androidx.test.filters.SmallTest;

import com.android.keyguard.BouncerPanelExpansionCalculator;
@@ -84,12 +83,11 @@ import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow
import com.android.systemui.statusbar.notification.row.FooterView;
import com.android.systemui.statusbar.phone.CentralSurfaces;
import com.android.systemui.statusbar.phone.KeyguardBypassController;
import com.android.systemui.statusbar.phone.ScreenOffAnimationController;
import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager;
import com.android.systemui.statusbar.phone.UnlockedScreenOffAnimationController;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -103,7 +101,6 @@ import java.util.ArrayList;
/**
 * Tests for {@link NotificationStackScrollLayout}.
 */
@Ignore("b/255552856")
@SmallTest
@RunWith(AndroidTestingRunner.class)
@TestableLooper.RunWithLooper
@@ -113,7 +110,6 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
    private NotificationStackScrollLayout mStackScrollerInternal;  // See explanation below
    private AmbientState mAmbientState;
    private TestableResources mTestableResources;

    @Rule public MockitoRule mockito = MockitoJUnit.rule();
    @Mock private CentralSurfaces mCentralSurfaces;
    @Mock private SysuiStatusBarStateController mBarState;
@@ -128,7 +124,7 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
    @Mock private NotificationSection mNotificationSection;
    @Mock private NotificationSwipeHelper mNotificationSwipeHelper;
    @Mock private NotificationStackScrollLayoutController mStackScrollLayoutController;
    @Mock private UnlockedScreenOffAnimationController mUnlockedScreenOffAnimationController;
    @Mock private ScreenOffAnimationController mScreenOffAnimationController;
    @Mock private NotificationShelf mNotificationShelf;
    @Mock private NotificationStackSizeCalculator mNotificationStackSizeCalculator;
    @Mock private StatusBarKeyguardViewManager mStatusBarKeyguardViewManager;
@@ -136,7 +132,6 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
    @Mock private FeatureFlags mFeatureFlags;

    @Before
    @UiThreadTest
    public void setUp() throws Exception {
        allowTestableLooperAsMainThread();
        mTestableResources = mContext.getOrCreateTestableResources();
@@ -162,7 +157,7 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
        mDependency.injectTestDependency(AmbientState.class, mAmbientState);
        mDependency.injectTestDependency(NotificationShelf.class, mNotificationShelf);
        mDependency.injectTestDependency(
                UnlockedScreenOffAnimationController.class, mUnlockedScreenOffAnimationController);
                ScreenOffAnimationController.class, mScreenOffAnimationController);

        NotificationShelfController notificationShelfController =
                mock(NotificationShelfController.class);
@@ -364,7 +359,6 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
    }

    @Test
    @UiThreadTest
    public void testSetExpandedHeight_listenerReceivedCallbacks() {
        final float expectedHeight = 0f;

@@ -374,20 +368,6 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
        mStackScroller.setExpandedHeight(expectedHeight);
    }

    @Test
    public void testAppearFractionCalculation() {
        // appear start position
        when(mNotificationShelf.getIntrinsicHeight()).thenReturn(100);
        // because it's the same as shelf height, appear start position equals shelf height
        mStackScroller.mStatusBarHeight = 100;
        // appear end position
        when(mEmptyShadeView.getHeight()).thenReturn(200);

        assertEquals(0f, mStackScroller.calculateAppearFraction(100));
        assertEquals(1f, mStackScroller.calculateAppearFraction(200));
        assertEquals(0.5f, mStackScroller.calculateAppearFraction(150));
    }

    @Test
    public void testAppearFractionCalculationIsNotNegativeWhenShelfBecomesSmaller() {
        // this situation might occur if status bar height is defined in pixels while shelf height
@@ -405,7 +385,6 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
    }

    @Test
    @UiThreadTest
    public void testSetExpandedHeight_withSplitShade_doesntInterpolateStackHeight() {
        mTestableResources
                .addOverride(R.bool.config_use_split_notification_shade, /* value= */ true);
@@ -590,6 +569,7 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {

    @Test
    public void testReInflatesFooterViews() {
        when(mEmptyShadeView.getTextResource()).thenReturn(R.string.empty_shade_text);
        clearInvocations(mStackScroller);
        mStackScroller.reinflateViews();
        verify(mStackScroller).setFooterView(any());
@@ -597,21 +577,18 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
    }

    @Test
    @UiThreadTest
    public void testSetIsBeingDraggedResetsExposedMenu() {
        mStackScroller.setIsBeingDragged(true);
        verify(mNotificationSwipeHelper).resetExposedMenuView(true, true);
    }

    @Test
    @UiThreadTest
    public void testPanelTrackingStartResetsExposedMenu() {
        mStackScroller.onPanelTrackingStarted();
        verify(mNotificationSwipeHelper).resetExposedMenuView(true, true);
    }

    @Test
    @UiThreadTest
    public void testDarkModeResetsExposedMenu() {
        mStackScroller.setHideAmount(0.1f, 0.1f);
        verify(mNotificationSwipeHelper).resetExposedMenuView(true, true);
@@ -916,7 +893,7 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
        mStackScroller.setHasFilteredOutSeenNotifications(true);
        mStackScroller.updateEmptyShadeView(true, false);

        verify(mEmptyShadeView).setFooterText(not(0));
        verify(mEmptyShadeView).setFooterText(not(eq(0)));
    }

    @Test