diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowDisplayTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowDisplayTest.java index 361312110ac..b5ce3c3ed67 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowDisplayTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowDisplayTest.java @@ -42,7 +42,6 @@ public void setUp() throws Exception { public void shouldProvideDisplayMetrics() { shadow.setDensity(1.5f); shadow.setDensityDpi(DisplayMetrics.DENSITY_HIGH); - shadow.setScaledDensity(1.6f); shadow.setWidth(1024); shadow.setHeight(600); shadow.setRealWidth(1400); @@ -57,7 +56,6 @@ public void shouldProvideDisplayMetrics() { assertEquals(1.5f, metrics.density, 0.05); assertEquals(DisplayMetrics.DENSITY_HIGH, metrics.densityDpi); - assertEquals(1.6f, metrics.scaledDensity, 0.05); assertEquals(1024, metrics.widthPixels); assertEquals(600, metrics.heightPixels); assertEquals(183.0f, metrics.xdpi, 0.05); @@ -69,7 +67,6 @@ public void shouldProvideDisplayMetrics() { assertEquals(1.5f, metrics.density, 0.05); assertEquals(DisplayMetrics.DENSITY_HIGH, metrics.densityDpi); - assertEquals(1.6f, metrics.scaledDensity, 0.05); assertEquals(1400, metrics.widthPixels); assertEquals(900, metrics.heightPixels); assertEquals(183.0f, metrics.xdpi, 0.05); diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowDisplay.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowDisplay.java index 97ab21cd1dc..a48808476e9 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowDisplay.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowDisplay.java @@ -1,11 +1,8 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.JELLY_BEAN; import static org.robolectric.util.reflector.Reflector.reflector; import android.content.Context; -import android.content.res.Configuration; -import android.graphics.Point; import android.os.Build; import android.os.Build.VERSION_CODES; import android.util.DisplayMetrics; @@ -46,61 +43,6 @@ public static Display getDefaultDisplay() { private Float refreshRate; - // the following fields are used only for Jelly Bean... - private String name; - private Integer displayId; - private Integer width; - private Integer height; - private Integer realWidth; - private Integer realHeight; - private Integer densityDpi; - private Float xdpi; - private Float ydpi; - private Float scaledDensity; - private Integer rotation; - private Integer pixelFormat; - - /** - * If {@link #setScaledDensity(float)} has been called, {@link DisplayMetrics#scaledDensity} will - * be modified to reflect the value specified. Note that this is not a realistic state. - * - * @deprecated This behavior is deprecated and will be removed in Robolectric 3.7. - */ - @Deprecated - @Implementation - protected void getMetrics(DisplayMetrics outMetrics) { - reflector(_Display_.class, realObject).getMetrics(outMetrics); - if (scaledDensity != null) { - outMetrics.scaledDensity = scaledDensity; - } - } - - /** - * If {@link #setScaledDensity(float)} has been called, {@link DisplayMetrics#scaledDensity} will - * be modified to reflect the value specified. Note that this is not a realistic state. - * - * @deprecated This behavior is deprecated and will be removed in Robolectric 3.7. - */ - @Deprecated - @Implementation - protected void getRealMetrics(DisplayMetrics outMetrics) { - reflector(_Display_.class, realObject).getRealMetrics(outMetrics); - if (scaledDensity != null) { - outMetrics.scaledDensity = scaledDensity; - } - } - - /** - * If {@link #setDisplayId(int)} has been called, this method will return the specified value. - * - * @deprecated This behavior is deprecated and will be removed in Robolectric 3.7. - */ - @Deprecated - @Implementation - protected int getDisplayId() { - return displayId == null ? reflector(_Display_.class, realObject).getDisplayId() : displayId; - } - /** * If {@link #setRefreshRate(float)} has been called, this method will return the specified value. * @@ -120,38 +62,6 @@ protected float getRefreshRate() { return realRefreshRate; } - /** - * If {@link #setPixelFormat(int)} has been called, this method will return the specified value. - * - * @deprecated This behavior is deprecated and will be removed in Robolectric 3.7. - */ - @Deprecated - @Implementation - protected int getPixelFormat() { - return pixelFormat == null - ? reflector(_Display_.class, realObject).getPixelFormat() - : pixelFormat; - } - - @Implementation(maxSdk = JELLY_BEAN) - protected void getSizeInternal(Point outSize, boolean doCompat) { - outSize.x = width; - outSize.y = height; - } - - @Implementation(maxSdk = JELLY_BEAN) - protected void getCurrentSizeRange(Point outSmallestSize, Point outLargestSize) { - int minimum = Math.min(width, height); - int maximum = Math.max(width, height); - outSmallestSize.set(minimum, minimum); - outLargestSize.set(maximum, maximum); - } - - @Implementation(maxSdk = JELLY_BEAN) - protected void getRealSize(Point outSize) { - outSize.set(realWidth, realHeight); - } - /** * Changes the density for this display. * @@ -193,29 +103,6 @@ public void setYdpi(float ydpi) { ShadowDisplayManager.changeDisplay(realObject.getDisplayId(), di -> di.physicalYDpi = ydpi); } - /** - * Changes the scaled density for this display. - * - * @deprecated This method is deprecated and will be removed in Robolectric 3.7. - */ - @Deprecated - public void setScaledDensity(float scaledDensity) { - this.scaledDensity = scaledDensity; - } - - /** - * Changes the ID for this display. - * - *

Any registered {@link android.hardware.display.DisplayManager.DisplayListener}s will be - * notified of the change. - * - * @deprecated This method is deprecated and will be removed in Robolectric 3.7. - */ - @Deprecated - public void setDisplayId(int displayId) { - this.displayId = displayId; - } - /** * Changes the name for this display. * @@ -309,16 +196,6 @@ public void setRotation(int rotation) { ShadowDisplayManager.changeDisplay(realObject.getDisplayId(), di -> di.rotation = rotation); } - /** - * Changes the pixel format for this display. - * - * @deprecated This method is deprecated and will be removed in Robolectric 3.7. - */ - @Deprecated - public void setPixelFormat(int pixelFormat) { - this.pixelFormat = pixelFormat; - } - /** * Changes the simulated state for this display, such as whether it is on or off * @@ -393,45 +270,13 @@ public void setDisplayCutout(Object displayCutout) { realObject.getDisplayId(), displayConfig -> displayConfig.displayCutout = displayCutout); } - void configureForJBOnly(Configuration configuration, DisplayMetrics displayMetrics) { - int widthPx = (int) (configuration.screenWidthDp * displayMetrics.density); - int heightPx = (int) (configuration.screenHeightDp * displayMetrics.density); - - name = "Built-in screen"; - displayId = 0; - width = widthPx; - height = heightPx; - realWidth = widthPx; - realHeight = heightPx; - densityDpi = displayMetrics.densityDpi; - xdpi = (float) displayMetrics.densityDpi; - ydpi = (float) displayMetrics.densityDpi; - scaledDensity = displayMetrics.densityDpi * DisplayMetrics.DENSITY_DEFAULT_SCALE; - rotation = - configuration.orientation == Configuration.ORIENTATION_PORTRAIT - ? Surface.ROTATION_0 - : Surface.ROTATION_90; - } - /** Reflector interface for {@link Display}'s internals. */ @ForType(Display.class) interface _Display_ { - @Direct - void getMetrics(DisplayMetrics outMetrics); - - @Direct - void getRealMetrics(DisplayMetrics outMetrics); - - @Direct - int getDisplayId(); - @Direct float getRefreshRate(); - @Direct - int getPixelFormat(); - @Accessor("mFlags") void setFlags(int flags); }