Skip to content

Commit 9a8ca4d

Browse files
Material Design Teamdsn5ft
authored andcommitted
[Internal] Robolectric cleanup
PiperOrigin-RevId: 676981992
1 parent 20ee1ed commit 9a8ca4d

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

lib/javatests/com/google/android/material/motion/MotionUtilsTest.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
import android.animation.TimeInterpolator;
2424
import android.os.Build.VERSION_CODES;
2525
import androidx.appcompat.app.AppCompatActivity;
26+
import android.view.animation.AccelerateInterpolator;
27+
import android.view.animation.AnimationUtils;
2628
import android.view.animation.Interpolator;
2729
import android.view.animation.LinearInterpolator;
2830
import android.view.animation.PathInterpolator;
@@ -37,6 +39,7 @@
3739
import org.robolectric.android.controller.ActivityController;
3840
import org.robolectric.annotation.Config;
3941
import org.robolectric.annotation.internal.DoNotInstrument;
42+
import org.robolectric.shadow.api.Shadow;
4043

4144
@RunWith(RobolectricTestRunner.class)
4245
@Config(sdk = VERSION_CODES.LOLLIPOP)
@@ -53,23 +56,23 @@ public void testResolvesThemeInterpolator() {
5356
assertThemeInterpolatorIsInstanceOf(
5457
R.style.Theme_Material3_DayNight,
5558
R.attr.motionEasingStandardInterpolator,
56-
LinearInterpolator.class);
59+
isAnimationUtilsShadowed() ? LinearInterpolator.class : PathInterpolator.class);
5760
}
5861

5962
@Test
6063
public void testCustomInterpolator_resolvesThemeInterpolator() {
6164
assertThemeInterpolatorIsInstanceOf(
6265
R.style.Theme_Material3_DayNight_CustomInterpolator,
6366
R.attr.motionEasingStandardInterpolator,
64-
LinearInterpolator.class);
67+
isAnimationUtilsShadowed() ? LinearInterpolator.class : PathInterpolator.class);
6568
}
6669

6770
@Test
6871
public void testCustomAnimInterpolator_resolvesThemeInterpolator() {
6972
assertThemeInterpolatorIsInstanceOf(
7073
R.style.Theme_Material3_DayNight_CustomAnimInterpolator,
7174
R.attr.motionEasingStandardInterpolator,
72-
LinearInterpolator.class);
75+
isAnimationUtilsShadowed() ? LinearInterpolator.class : AccelerateInterpolator.class);
7376
}
7477

7578
@Test
@@ -125,6 +128,10 @@ public void testMaterialComponentsThemeIncorrectLegacyFormatting_shouldThrowExce
125128
new DefaultDummyInterpolator());
126129
}
127130

131+
private boolean isAnimationUtilsShadowed() {
132+
return Shadow.extract(new AnimationUtils()) != null;
133+
}
134+
128135
private void createActivityAndSetTheme(int themeId) {
129136
ApplicationProvider.getApplicationContext().setTheme(themeId);
130137
activityController = Robolectric.buildActivity(AppCompatActivity.class).create();

0 commit comments

Comments
 (0)