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

Commit 9a15719f authored by Behnam Heydarshahi's avatar Behnam Heydarshahi Committed by Automerger Merge Worker
Browse files

Merge "Tear down VolumeDialogImplTest cleanly" into udc-qpr-dev am: 0b73a074 am: 7d641daa

parents 03e2e684 7d641daa
Loading
Loading
Loading
Loading
+14 −1
Original line number Diff line number Diff line
@@ -168,6 +168,13 @@ public class VolumeDialogImpl implements VolumeDialog, Dumpable,
    /** Volume dialog slider animation. */
    private static final String TYPE_UPDATE = "update";

    /**
     *  TODO(b/290612381): remove lingering animations or tolerate them
     *  When false, this will cause this class to not listen to animator events and not record jank
     *  events. This should never be false in production code, and only is false for unit tests for
     *  this class. This flag should be true in Scenario/Integration tests.
     */
    private final boolean mShouldListenForJank;
    private final int mDialogShowAnimationDurationMs;
    private final int mDialogHideAnimationDurationMs;
    private int mDialogWidth;
@@ -304,6 +311,7 @@ public class VolumeDialogImpl implements VolumeDialog, Dumpable,
            VolumePanelFactory volumePanelFactory,
            ActivityStarter activityStarter,
            InteractionJankMonitor interactionJankMonitor,
            boolean shouldListenForJank,
            CsdWarningDialog.Factory csdWarningDialogFactory,
            DevicePostureController devicePostureController,
            Looper looper,
@@ -311,6 +319,8 @@ public class VolumeDialogImpl implements VolumeDialog, Dumpable,
        mContext =
                new ContextThemeWrapper(context, R.style.volume_dialog_theme);
        mHandler = new H(looper);

        mShouldListenForJank = shouldListenForJank;
        mController = volumeDialogController;
        mKeyguard = (KeyguardManager) mContext.getSystemService(Context.KEYGUARD_SERVICE);
        mActivityManager = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
@@ -1368,7 +1378,10 @@ public class VolumeDialogImpl implements VolumeDialog, Dumpable,
    }

    private Animator.AnimatorListener getJankListener(View v, String type, long timeout) {
        return new Animator.AnimatorListener() {
        if (!mShouldListenForJank) {
            // TODO(b/290612381): temporary fix to prevent null pointers on leftover JankMonitors
            return null;
        } else return new Animator.AnimatorListener() {
            @Override
            public void onAnimationStart(@NonNull Animator animation) {
                if (!v.isAttachedToWindow()) {
+1 −0
Original line number Diff line number Diff line
@@ -72,6 +72,7 @@ public interface VolumeModule {
                volumePanelFactory,
                activityStarter,
                interactionJankMonitor,
                true, /* should listen for jank */
                csdFactory,
                devicePostureController,
                Looper.getMainLooper(),
+21 −6
Original line number Diff line number Diff line
@@ -142,6 +142,7 @@ public class VolumeDialogImplTest extends SysuiTestCase {
                mVolumePanelFactory,
                mActivityStarter,
                mInteractionJankMonitor,
                false,
                mCsdWarningDialogFactory,
                mPostureController,
                mTestableLooper.getLooper(),
@@ -378,6 +379,7 @@ public class VolumeDialogImplTest extends SysuiTestCase {
                mVolumePanelFactory,
                mActivityStarter,
                mInteractionJankMonitor,
                false,
                mCsdWarningDialogFactory,
                devicePostureController,
                mTestableLooper.getLooper(),
@@ -397,6 +399,8 @@ public class VolumeDialogImplTest extends SysuiTestCase {

        int gravity = dialog.getWindowGravity();
        assertEquals(Gravity.TOP, gravity & Gravity.VERTICAL_GRAVITY_MASK);

        cleanUp(dialog);
    }

    @Test
@@ -415,6 +419,7 @@ public class VolumeDialogImplTest extends SysuiTestCase {
                mVolumePanelFactory,
                mActivityStarter,
                mInteractionJankMonitor,
                false,
                mCsdWarningDialogFactory,
                devicePostureController,
                mTestableLooper.getLooper(),
@@ -433,6 +438,8 @@ public class VolumeDialogImplTest extends SysuiTestCase {

        int gravity = dialog.getWindowGravity();
        assertEquals(Gravity.CENTER_VERTICAL, gravity & Gravity.VERTICAL_GRAVITY_MASK);

        cleanUp(dialog);
    }

    @Test
@@ -451,6 +458,7 @@ public class VolumeDialogImplTest extends SysuiTestCase {
                mVolumePanelFactory,
                mActivityStarter,
                mInteractionJankMonitor,
                false,
                mCsdWarningDialogFactory,
                devicePostureController,
                mTestableLooper.getLooper(),
@@ -469,6 +477,8 @@ public class VolumeDialogImplTest extends SysuiTestCase {

        int gravity = dialog.getWindowGravity();
        assertEquals(Gravity.CENTER_VERTICAL, gravity & Gravity.VERTICAL_GRAVITY_MASK);

        cleanUp(dialog);
    }

    @Test
@@ -489,18 +499,19 @@ public class VolumeDialogImplTest extends SysuiTestCase {
                mVolumePanelFactory,
                mActivityStarter,
                mInteractionJankMonitor,
                false,
                mCsdWarningDialogFactory,
                mPostureController,
                mTestableLooper.getLooper(),
                mDumpManager
        );
                mDumpManager);
        dialog.init(0, null);

        verify(mPostureController, never()).removeCallback(any());

        dialog.destroy();

        verify(mPostureController).removeCallback(any());

        cleanUp(dialog);
    }

    private void setOrientation(int orientation) {
@@ -513,14 +524,18 @@ public class VolumeDialogImplTest extends SysuiTestCase {

    @After
    public void teardown() {
        if (mDialog != null) {
            mDialog.clearInternalHandlerAfterTest();
        }
        cleanUp(mDialog);
        setOrientation(mOriginalOrientation);
        mTestableLooper.processAllMessages();
        reset(mPostureController);
    }

    private void cleanUp(VolumeDialogImpl dialog) {
        if (dialog != null) {
            dialog.clearInternalHandlerAfterTest();
        }
    }

/*
    @Test
    public void testContentDescriptions() {