Skip to content

Commit

Permalink
Remove unnecessary TimePickerDialog constructor shadow
Browse files Browse the repository at this point in the history
The constructor shadow just calls the original constructor, so it's
redundant and can be removed.

PiperOrigin-RevId: 408776653
  • Loading branch information
hoisie authored and copybara-robolectric committed Nov 12, 2021
1 parent d0d1696 commit e6514bc
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 22 deletions.
Expand Up @@ -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;
Expand Down Expand Up @@ -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() {
Expand Down
Expand Up @@ -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;
Expand Down Expand Up @@ -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+.
*
* <p>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.
*
Expand Down
Expand Up @@ -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;

Expand All @@ -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()
Expand Down

0 comments on commit e6514bc

Please sign in to comment.