From 845fa16d3079f38a282a27993e4574833ec8b872 Mon Sep 17 00:00:00 2001 From: Jeff DeCew Date: Tue, 8 Aug 2023 14:20:42 -0400 Subject: [PATCH] Clean up some AnimatorTestRule usages Bug: 291645410 Test: atest SystemUITests Change-Id: I76bdcfce2ec02315b26ac26fa4a9434896fa6d28 --- .../phone/fragment/CollapsedStatusBarFragmentTest.java | 6 +++--- .../systemui/statusbar/policy/RemoteInputViewTest.java | 6 +++--- .../com/android/systemui/volume/VolumeDialogImplTest.java | 4 ---- .../tests/utils/src/android/animation/AnimatorTestRule.java | 4 ++-- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragmentTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragmentTest.java index 823155b0d7e62..b8f2cab3019e5 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragmentTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragmentTest.java @@ -81,7 +81,7 @@ import com.android.systemui.util.settings.SecureSettings; import com.android.systemui.util.time.FakeSystemClock; import org.junit.Before; -import org.junit.ClassRule; +import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; @@ -136,8 +136,8 @@ public class CollapsedStatusBarFragmentTest extends SysuiBaseFragmentTest { private StatusBarWindowStateController mStatusBarWindowStateController; @Mock private KeyguardUpdateMonitor mKeyguardUpdateMonitor; - @ClassRule - public static AnimatorTestRule mAnimatorTestRule = new AnimatorTestRule(); + @Rule + public final AnimatorTestRule mAnimatorTestRule = new AnimatorTestRule(); private List mStatusBarWindowStateListeners = new ArrayList<>(); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/RemoteInputViewTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/RemoteInputViewTest.java index ef39ff8ed521a..79feb417a0629 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/RemoteInputViewTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/RemoteInputViewTest.java @@ -82,7 +82,7 @@ import com.android.systemui.statusbar.phone.LightBarController; import org.junit.After; import org.junit.Before; -import org.junit.ClassRule; +import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; @@ -111,8 +111,8 @@ public class RemoteInputViewTest extends SysuiTestCase { private BlockingQueueIntentReceiver mReceiver; private final UiEventLoggerFake mUiEventLoggerFake = new UiEventLoggerFake(); - @ClassRule - public static AnimatorTestRule mAnimatorTestRule = new AnimatorTestRule(); + @Rule + public final AnimatorTestRule mAnimatorTestRule = new AnimatorTestRule(); @Before public void setUp() throws Exception { diff --git a/packages/SystemUI/tests/src/com/android/systemui/volume/VolumeDialogImplTest.java b/packages/SystemUI/tests/src/com/android/systemui/volume/VolumeDialogImplTest.java index fa18e575220c5..d35036edbd574 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/volume/VolumeDialogImplTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/volume/VolumeDialogImplTest.java @@ -38,7 +38,6 @@ 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; @@ -85,8 +84,6 @@ 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; View mDrawerContainer; @@ -727,7 +724,6 @@ public class VolumeDialogImplTest extends SysuiTestCase { public void teardown() { cleanUp(mDialog); setOrientation(mOriginalOrientation); - sAnimatorTestRule.advanceTimeBy(mLongestHideShowAnimationDuration); mTestableLooper.moveTimeForward(mLongestHideShowAnimationDuration); mTestableLooper.processAllMessages(); reset(mPostureController); diff --git a/packages/SystemUI/tests/utils/src/android/animation/AnimatorTestRule.java b/packages/SystemUI/tests/utils/src/android/animation/AnimatorTestRule.java index 19c68e86e5dc0..41dbc147dfc52 100644 --- a/packages/SystemUI/tests/utils/src/android/animation/AnimatorTestRule.java +++ b/packages/SystemUI/tests/utils/src/android/animation/AnimatorTestRule.java @@ -49,7 +49,7 @@ import java.util.function.Consumer; * public class SampleAnimatorTest { * * {@literal @}Rule - * public AnimatorTestRule sAnimatorTestRule = new AnimatorTestRule(); + * public final AnimatorTestRule mAnimatorTestRule = new AnimatorTestRule(); * * {@literal @}UiThreadTest * {@literal @}Test @@ -58,7 +58,7 @@ import java.util.function.Consumer; * animator.setDuration(1000L); * assertThat(animator.getAnimatedValue(), is(0)); * animator.start(); - * sAnimatorTestRule.advanceTimeBy(500L); + * mAnimatorTestRule.advanceTimeBy(500L); * assertThat(animator.getAnimatedValue(), is(500)); * } * }