From e6514bcba9541d524ace171ad77803b0539209e2 Mon Sep 17 00:00:00 2001 From: hoisie Date: Tue, 9 Nov 2021 20:59:42 -0800 Subject: [PATCH] Remove unnecessary TimePickerDialog constructor shadow The constructor shadow just calls the original constructor, so it's redundant and can be removed. PiperOrigin-RevId: 408776653 --- .../robolectric/shadows/ShadowBuildTest.java | 9 ++++++++ .../org/robolectric/shadows/ShadowBuild.java | 13 +++++++++++ .../shadows/ShadowTimePickerDialog.java | 22 ------------------- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowBuildTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowBuildTest.java index db6aaa572ae..43f0f0363dc 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowBuildTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowBuildTest.java @@ -2,6 +2,8 @@ import static android.os.Build.VERSION_CODES.M; import static android.os.Build.VERSION_CODES.O; +import static android.os.Build.VERSION_CODES.R; +import static android.os.Build.VERSION_CODES.S; import static com.google.common.truth.Truth.assertThat; import android.os.Build; @@ -56,6 +58,13 @@ public void setVersionIncremental() { assertThat(VERSION.INCREMENTAL).isEqualTo("robo_incremental"); } + @Test + @Config(minSdk = S) + public void setVersionMediaPerformanceClass() { + ShadowBuild.setVersionMediaPerformanceClass(R); + assertThat(VERSION.MEDIA_PERFORMANCE_CLASS).isEqualTo(R); + } + @Test @Config(minSdk = M) public void setVersionSecurityPatch() { diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowBuild.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowBuild.java index a859b18ec75..ea00874b1e5 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowBuild.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowBuild.java @@ -3,6 +3,7 @@ import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.M; import static android.os.Build.VERSION_CODES.O; +import static android.os.Build.VERSION_CODES.S; import static org.robolectric.util.reflector.Reflector.reflector; import android.annotation.TargetApi; @@ -110,6 +111,18 @@ public static void setVersionIncremental(String versionIncremental) { ReflectionHelpers.setStaticField(Build.VERSION.class, "INCREMENTAL", versionIncremental); } + /** + * Sets the value of the {@link Build.VERSION#MEDIA_PERFORMANCE_CLASS} field. Available in Android + * S+. + * + *

It will be reset for the next test. + */ + @TargetApi(S) + public static void setVersionMediaPerformanceClass(int performanceClass) { + ReflectionHelpers.setStaticField( + Build.VERSION.class, "MEDIA_PERFORMANCE_CLASS", performanceClass); + } + /** * Sets the value of the {@link Build.VERSION#RELEASE} field. * diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowTimePickerDialog.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowTimePickerDialog.java index 4a4c874d255..0c06e8927c6 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowTimePickerDialog.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowTimePickerDialog.java @@ -3,13 +3,9 @@ import static org.robolectric.util.reflector.Reflector.reflector; import android.app.TimePickerDialog; -import android.content.Context; import android.widget.TimePicker; -import org.robolectric.annotation.Implementation; import org.robolectric.annotation.Implements; import org.robolectric.annotation.RealObject; -import org.robolectric.shadow.api.Shadow; -import org.robolectric.util.ReflectionHelpers.ClassParameter; import org.robolectric.util.reflector.Accessor; import org.robolectric.util.reflector.ForType; @@ -18,24 +14,6 @@ public class ShadowTimePickerDialog extends ShadowAlertDialog { @RealObject protected TimePickerDialog realTimePickerDialog; - @Implementation - protected void __constructor__( - Context context, - int theme, - TimePickerDialog.OnTimeSetListener callBack, - int hourOfDay, - int minute, - boolean is24HourView) { - - Shadow.invokeConstructor(TimePickerDialog.class, realTimePickerDialog, - ClassParameter.from(Context.class, context), - ClassParameter.from(int.class, theme), - ClassParameter.from(TimePickerDialog.OnTimeSetListener.class, callBack), - ClassParameter.from(int.class, hourOfDay), - ClassParameter.from(int.class, minute), - ClassParameter.from(boolean.class, is24HourView)); - } - public int getHourOfDay() { return reflector(TimePickerDialogProvider.class, realTimePickerDialog) .getTimePicker()