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
This commit is contained in:
Behnam Heydarshahi
2023-08-02 14:13:35 +00:00
parent a6c8f32a29
commit 8c2ced254a

View File

@@ -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);
}