Package org.robolectric.shadows
Class ShadowDisplay
- java.lang.Object
-
- org.robolectric.shadows.ShadowDisplay
-
@Implements(android.view.Display.class) public class ShadowDisplay extends java.lang.ObjectIt is possible to override some display properties using setters onShadowDisplay; however, this behavior is deprecated as of Robolectric 3.6 and will be removed in 3.7.- See Also:
- device configuration for details.
-
-
Constructor Summary
Constructors Constructor Description ShadowDisplay()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected voidgetCurrentSizeRange(android.graphics.Point outSmallestSize, android.graphics.Point outLargestSize)static android.view.DisplaygetDefaultDisplay()Returns the default display.protected intgetDisplayId()Deprecated.This behavior is deprecated and will be removed in Robolectric 3.7.protected voidgetMetrics(android.util.DisplayMetrics outMetrics)Deprecated.This behavior is deprecated and will be removed in Robolectric 3.7.protected intgetPixelFormat()Deprecated.This behavior is deprecated and will be removed in Robolectric 3.7.protected voidgetRealMetrics(android.util.DisplayMetrics outMetrics)Deprecated.This behavior is deprecated and will be removed in Robolectric 3.7.protected voidgetRealSize(android.graphics.Point outSize)protected floatgetRefreshRate()Deprecated.This behavior is deprecated and will be removed in Robolectric 3.7.protected voidgetSizeInternal(android.graphics.Point outSize, boolean doCompat)voidsetDensity(float density)Changes the density for this display.voidsetDensityDpi(int densityDpi)Changes the density for this display.voidsetDisplayId(int displayId)Deprecated.This method is deprecated and will be removed in Robolectric 3.7.voidsetFlags(int flags)Changes the flags for this display.voidsetHeight(int height)Changes the height available to the application for this display.voidsetName(java.lang.String name)Changes the name for this display.voidsetPixelFormat(int pixelFormat)Deprecated.This method is deprecated and will be removed in Robolectric 3.7.voidsetRealHeight(int height)Changes the simulated physical height for this display.voidsetRealWidth(int width)Changes the simulated physical width for this display.voidsetRefreshRate(float refreshRate)Changes the refresh rate for this display.voidsetRotation(int rotation)Changes the rotation for this display.voidsetScaledDensity(float scaledDensity)Deprecated.This method is deprecated and will be removed in Robolectric 3.7.voidsetState(int state)Changes the simulated state for this display, such as whether it is on or off Any registeredDisplayManager.DisplayListeners will be notified of the change.voidsetWidth(int width)Changes the width available to the application for this display.voidsetXdpi(float xdpi)Changes the horizontal DPI for this display.voidsetYdpi(float ydpi)Changes the vertical DPI for this display.
-
-
-
Method Detail
-
getDefaultDisplay
public static android.view.Display getDefaultDisplay()
Returns the default display.- Returns:
- the default display
-
getMetrics
@Deprecated @Implementation protected void getMetrics(android.util.DisplayMetrics outMetrics)
Deprecated.This behavior is deprecated and will be removed in Robolectric 3.7.IfsetScaledDensity(float)has been called,DisplayMetrics.scaledDensitywill be modified to reflect the value specified. Note that this is not a realistic state.
-
getRealMetrics
@Deprecated @Implementation protected void getRealMetrics(android.util.DisplayMetrics outMetrics)
Deprecated.This behavior is deprecated and will be removed in Robolectric 3.7.IfsetScaledDensity(float)has been called,DisplayMetrics.scaledDensitywill be modified to reflect the value specified. Note that this is not a realistic state.
-
getDisplayId
@Deprecated @Implementation protected int getDisplayId()
Deprecated.This behavior is deprecated and will be removed in Robolectric 3.7.IfsetDisplayId(int)has been called, this method will return the specified value.
-
getRefreshRate
@Deprecated @Implementation protected float getRefreshRate()
Deprecated.This behavior is deprecated and will be removed in Robolectric 3.7.IfsetRefreshRate(float)has been called, this method will return the specified value.
-
getPixelFormat
@Deprecated @Implementation protected int getPixelFormat()
Deprecated.This behavior is deprecated and will be removed in Robolectric 3.7.IfsetPixelFormat(int)has been called, this method will return the specified value.
-
getSizeInternal
@Implementation(maxSdk=16) protected void getSizeInternal(android.graphics.Point outSize, boolean doCompat)
-
getCurrentSizeRange
@Implementation(maxSdk=16) protected void getCurrentSizeRange(android.graphics.Point outSmallestSize, android.graphics.Point outLargestSize)
-
getRealSize
@Implementation(maxSdk=16) protected void getRealSize(android.graphics.Point outSize)
-
setDensity
public void setDensity(float density)
Changes the density for this display. Any registeredDisplayManager.DisplayListeners will be notified of the change.
-
setDensityDpi
public void setDensityDpi(int densityDpi)
Changes the density for this display. Any registeredDisplayManager.DisplayListeners will be notified of the change.
-
setXdpi
public void setXdpi(float xdpi)
Changes the horizontal DPI for this display. Any registeredDisplayManager.DisplayListeners will be notified of the change.
-
setYdpi
public void setYdpi(float ydpi)
Changes the vertical DPI for this display. Any registeredDisplayManager.DisplayListeners will be notified of the change.
-
setScaledDensity
@Deprecated public void setScaledDensity(float scaledDensity)
Deprecated.This method is deprecated and will be removed in Robolectric 3.7.Changes the scaled density for this display.
-
setDisplayId
@Deprecated public void setDisplayId(int displayId)
Deprecated.This method is deprecated and will be removed in Robolectric 3.7.Changes the ID for this display. Any registeredDisplayManager.DisplayListeners will be notified of the change.
-
setName
public void setName(java.lang.String name)
Changes the name for this display. Any registeredDisplayManager.DisplayListeners will be notified of the change.
-
setFlags
public void setFlags(int flags)
Changes the flags for this display. Any registeredDisplayManager.DisplayListeners will be notified of the change.
-
setWidth
public void setWidth(int width)
Changes the width available to the application for this display. Any registeredDisplayManager.DisplayListeners will be notified of the change.- Parameters:
width- the new width in pixels
-
setHeight
public void setHeight(int height)
Changes the height available to the application for this display. Any registeredDisplayManager.DisplayListeners will be notified of the change.- Parameters:
height- new height in pixels
-
setRealWidth
public void setRealWidth(int width)
Changes the simulated physical width for this display. Any registeredDisplayManager.DisplayListeners will be notified of the change.- Parameters:
width- the new width in pixels
-
setRealHeight
public void setRealHeight(int height)
Changes the simulated physical height for this display. Any registeredDisplayManager.DisplayListeners will be notified of the change.- Parameters:
height- the new height in pixels
-
setRefreshRate
public void setRefreshRate(float refreshRate)
Changes the refresh rate for this display. Any registeredDisplayManager.DisplayListeners will be notified of the change.
-
setRotation
public void setRotation(int rotation)
Changes the rotation for this display. Any registeredDisplayManager.DisplayListeners will be notified of the change.- Parameters:
rotation- one ofSurface.ROTATION_0,Surface.ROTATION_90,Surface.ROTATION_180,Surface.ROTATION_270
-
setPixelFormat
@Deprecated public void setPixelFormat(int pixelFormat)
Deprecated.This method is deprecated and will be removed in Robolectric 3.7.Changes the pixel format for this display.
-
setState
public void setState(int state)
Changes the simulated state for this display, such as whether it is on or off Any registeredDisplayManager.DisplayListeners will be notified of the change.- Parameters:
state- the new state: one ofDisplay.STATE_OFF,Display.STATE_ON,Display.STATE_DOZE,Display.STATE_DOZE_SUSPEND, orDisplay.STATE_UNKNOWN.
-
-