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

Commit 8c2ced25 authored by Behnam Heydarshahi's avatar Behnam Heydarshahi
Browse files

Process lingering animators after volume tests

The Animator inside dismissH has an endAction that postDelays on
handler. Previously we only cleared the handler queue. This CL removes
the endAction of the animator. It also advances looper time, to make
sure there are no future messages left after test tear down.

Bug: b/290612381
Test: atest VolumeDialogImplTest
Change-Id: I0518f7323eb0900bf734cdc55cf8132bd0b5523b
parent a6c8f32a
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import android.animation.AnimatorTestRule;
import android.app.KeyguardManager;
import android.content.res.Configuration;
import android.media.AudioManager;
@@ -84,6 +85,7 @@ import java.util.function.Predicate;
@RunWith(AndroidTestingRunner.class)
@TestableLooper.RunWithLooper
public class VolumeDialogImplTest extends SysuiTestCase {
    private static final AnimatorTestRule sAnimatorTestRule = new AnimatorTestRule();

    VolumeDialogImpl mDialog;
    View mActiveRinger;
@@ -126,6 +128,7 @@ public class VolumeDialogImplTest extends SysuiTestCase {
    };

    private FakeFeatureFlags mFeatureFlags;
    private int mLongestHideShowAnimationDuration = 250;

    @Before
    public void setup() throws Exception {
@@ -138,6 +141,13 @@ public class VolumeDialogImplTest extends SysuiTestCase {
        when(mPostureController.getDevicePosture())
                .thenReturn(DevicePostureController.DEVICE_POSTURE_CLOSED);

        int hideDialogDuration = mContext.getResources()
                .getInteger(R.integer.config_dialogHideAnimationDurationMs);
        int showDialogDuration = mContext.getResources()
                .getInteger(R.integer.config_dialogShowAnimationDurationMs);

        mLongestHideShowAnimationDuration = Math.max(hideDialogDuration, showDialogDuration);

        mOriginalOrientation = mContext.getResources().getConfiguration().orientation;

        mConfigurationController = new FakeConfigurationController();
@@ -717,6 +727,8 @@ public class VolumeDialogImplTest extends SysuiTestCase {
    public void teardown() {
        cleanUp(mDialog);
        setOrientation(mOriginalOrientation);
        sAnimatorTestRule.advanceTimeBy(mLongestHideShowAnimationDuration);
        mTestableLooper.moveTimeForward(mLongestHideShowAnimationDuration);
        mTestableLooper.processAllMessages();
        reset(mPostureController);
    }