@Implements(value=android.view.Display.class) public class ShadowDisplay extends java.lang.Object
It is possible to override some display properties using setters on ShadowDisplay
; however, this behavior is deprecated as of Robolectric 3.6 and will be removed in 3.7.
Use device configuration to set up your display properties instead.
Constructor and Description |
---|
ShadowDisplay() |
Modifier and Type | Method and Description |
---|---|
protected void |
getCurrentSizeRange(android.graphics.Point outSmallestSize,
android.graphics.Point outLargestSize) |
static android.view.Display |
getDefaultDisplay()
Returns the default display.
|
protected int |
getDisplayId()
Deprecated.
This behavior is deprecated and will be removed in Robolectric 3.7.
|
protected void |
getMetrics(android.util.DisplayMetrics outMetrics)
Deprecated.
This behavior is deprecated and will be removed in Robolectric 3.7.
|
protected int |
getPixelFormat()
Deprecated.
This behavior is deprecated and will be removed in Robolectric 3.7.
|
protected void |
getRealMetrics(android.util.DisplayMetrics outMetrics)
Deprecated.
This behavior is deprecated and will be removed in Robolectric 3.7.
|
protected void |
getRealSize(android.graphics.Point outSize) |
protected float |
getRefreshRate()
Deprecated.
This behavior is deprecated and will be removed in Robolectric 3.7.
|
protected void |
getSizeInternal(android.graphics.Point outSize,
boolean doCompat) |
void |
setDensity(float density)
Changes the density for this display.
|
void |
setDensityDpi(int densityDpi)
Changes the density for this display.
|
void |
setDisplayId(int displayId)
Deprecated.
This method is deprecated and will be removed in Robolectric 3.7.
|
void |
setFlags(int flags)
Changes the flags for this display.
|
void |
setHeight(int height)
Changes the height available to the application for this display.
|
void |
setName(java.lang.String name)
Changes the name for this display.
|
void |
setPixelFormat(int pixelFormat)
Deprecated.
This method is deprecated and will be removed in Robolectric 3.7.
|
void |
setRealHeight(int height)
Changes the simulated physical height for this display.
|
void |
setRealWidth(int width)
Changes the simulated physical width for this display.
|
void |
setRefreshRate(float refreshRate)
Changes the refresh rate for this display.
|
void |
setRotation(int rotation)
Changes the rotation for this display.
|
void |
setScaledDensity(float scaledDensity)
Deprecated.
This method is deprecated and will be removed in Robolectric 3.7.
|
void |
setState(int state)
Changes the simulated state for this display, such as whether it is on or off
|
void |
setWidth(int width)
Changes the width available to the application for this display.
|
void |
setXdpi(float xdpi)
Changes the horizontal DPI for this display.
|
void |
setYdpi(float ydpi)
Changes the vertical DPI for this display.
|
public static android.view.Display getDefaultDisplay()
Returns the default display.
@Deprecated @Implementation protected void getMetrics(android.util.DisplayMetrics outMetrics)
If setScaledDensity(float)
has been called, DisplayMetrics.scaledDensity
will be modified to reflect the value specified. Note that this is not a realistic state.
@Deprecated @Implementation protected void getRealMetrics(android.util.DisplayMetrics outMetrics)
If setScaledDensity(float)
has been called, DisplayMetrics.scaledDensity
will be modified to reflect the value specified. Note that this is not a realistic state.
@Deprecated @Implementation protected int getDisplayId()
If setDisplayId(int)
has been called, this method will return the specified value.
@Deprecated @Implementation protected float getRefreshRate()
If setRefreshRate(float)
has been called, this method will return the specified value.
@Deprecated @Implementation protected int getPixelFormat()
If setPixelFormat(int)
has been called, this method will return the specified value.
@Implementation(maxSdk=16) protected void getSizeInternal(android.graphics.Point outSize, boolean doCompat)
@Implementation(maxSdk=16) protected void getCurrentSizeRange(android.graphics.Point outSmallestSize, android.graphics.Point outLargestSize)
@Implementation(maxSdk=16) protected void getRealSize(android.graphics.Point outSize)
public void setDensity(float density)
Changes the density for this display.
Any registered DisplayManager.DisplayListener
s will be notified of the change.
public void setDensityDpi(int densityDpi)
Changes the density for this display.
Any registered DisplayManager.DisplayListener
s will be notified of the change.
public void setXdpi(float xdpi)
Changes the horizontal DPI for this display.
Any registered DisplayManager.DisplayListener
s will be notified of the change.
public void setYdpi(float ydpi)
Changes the vertical DPI for this display.
Any registered DisplayManager.DisplayListener
s will be notified of the change.
@Deprecated public void setScaledDensity(float scaledDensity)
Changes the scaled density for this display.
@Deprecated public void setDisplayId(int displayId)
Changes the ID for this display.
Any registered DisplayManager.DisplayListener
s will be notified of the change.
public void setName(java.lang.String name)
Changes the name for this display.
Any registered DisplayManager.DisplayListener
s will be notified of the change.
public void setFlags(int flags)
Changes the flags for this display.
Any registered DisplayManager.DisplayListener
s will be notified of the change.
public void setWidth(int width)
Changes the width available to the application for this display.
Any registered DisplayManager.DisplayListener
s will be notified of the change.
width
- the new width in pixelspublic void setHeight(int height)
Changes the height available to the application for this display.
Any registered DisplayManager.DisplayListener
s will be notified of the change.
height
- new height in pixelspublic void setRealWidth(int width)
Changes the simulated physical width for this display.
Any registered DisplayManager.DisplayListener
s will be notified of the change.
width
- the new width in pixelspublic void setRealHeight(int height)
Changes the simulated physical height for this display.
Any registered DisplayManager.DisplayListener
s will be notified of the change.
height
- the new height in pixelspublic void setRefreshRate(float refreshRate)
Changes the refresh rate for this display.
Any registered DisplayManager.DisplayListener
s will be notified of the change.
public void setRotation(int rotation)
Changes the rotation for this display.
Any registered DisplayManager.DisplayListener
s will be notified of the change.
rotation
- one of Surface.ROTATION_0
, Surface.ROTATION_90
, Surface.ROTATION_180
, Surface.ROTATION_270
@Deprecated public void setPixelFormat(int pixelFormat)
Changes the pixel format for this display.
public void setState(int state)
Changes the simulated state for this display, such as whether it is on or off
Any registered DisplayManager.DisplayListener
s will be notified of the change.
state
- the new state: one of Display.STATE_OFF
, Display.STATE_ON
, Display.STATE_DOZE
, Display.STATE_DOZE_SUSPEND
, or Display.STATE_UNKNOWN
.