Class ShadowDisplay

    • Constructor Summary

      Constructors 
      Constructor Description
      ShadowDisplay()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      protected void getCurrentSizeRange​(Point outSmallestSize, Point outLargestSize)  
      static 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​(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​(DisplayMetrics outMetrics)
      Deprecated.
      This behavior is deprecated and will be removed in Robolectric 3.7.
      protected void getRealSize​(Point outSize)  
      protected float getRefreshRate()
      Deprecated.
      This behavior is deprecated and will be removed in Robolectric 3.7.
      protected void getSizeInternal​(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 setDisplayCutout​(Object displayCutout)
      Changes the display cutout for this display.
      void setDisplayHdrCapabilities​(int displayId, float maxLuminance, float maxAverageLuminance, float minLuminance, int... supportedHdrTypes)
      Set HDR capabilities to the display sourced with displayId.
      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​(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.
    • Constructor Detail

      • ShadowDisplay

        public ShadowDisplay()
    • Method Detail

      • getDefaultDisplay

        public static Display getDefaultDisplay()
        Returns the default display.
        Returns:
        the default display
      • getDisplayId

        @Deprecated
        @Implementation
        protected int getDisplayId()
        Deprecated.
        This behavior is deprecated and will be removed in Robolectric 3.7.
        If setDisplayId(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.
        If setRefreshRate(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.
        If setPixelFormat(int) has been called, this method will return the specified value.
      • setDensity

        public void setDensity​(float density)
        Changes the density for this display.

        Any registered DisplayManager.DisplayListeners will be notified of the change.

      • setDensityDpi

        public void setDensityDpi​(int densityDpi)
        Changes the density for this display.

        Any registered DisplayManager.DisplayListeners will be notified of the change.

      • setXdpi

        public void setXdpi​(float xdpi)
        Changes the horizontal DPI for this display.

        Any registered DisplayManager.DisplayListeners will be notified of the change.

      • setYdpi

        public void setYdpi​(float ydpi)
        Changes the vertical DPI for this display.

        Any registered DisplayManager.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 registered DisplayManager.DisplayListeners will be notified of the change.

      • setFlags

        public void setFlags​(int flags)
        Changes the flags for this display.

        Any registered DisplayManager.DisplayListeners will be notified of the change.

      • setWidth

        public void setWidth​(int width)
        Changes the width available to the application for this display.

        Any registered DisplayManager.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 registered DisplayManager.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 registered DisplayManager.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 registered DisplayManager.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 registered DisplayManager.DisplayListeners will be notified of the change.

      • 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.
      • setDisplayHdrCapabilities

        public void setDisplayHdrCapabilities​(int displayId,
                                              float maxLuminance,
                                              float maxAverageLuminance,
                                              float minLuminance,
                                              int... supportedHdrTypes)
        Set HDR capabilities to the display sourced with displayId. see Display.HdrCapabilities for supportedHdrTypes.
        Throws:
        UnsupportedOperationException - if the method is called below Android vesrsion N.
      • setDisplayCutout

        public void setDisplayCutout​(Object displayCutout)
        Changes the display cutout for this display.
        Throws:
        UnsupportedOperationException - if the method is called below Android version Q.