Class ShadowUiAutomation

java.lang.Object
org.robolectric.shadows.ShadowUiAutomation

@Implements(android.app.UiAutomation.class) public class ShadowUiAutomation extends Object
Shadow for UiAutomation.
  • Constructor Details

    • ShadowUiAutomation

      public ShadowUiAutomation()
  • Method Details

    • setAnimationScaleCompat

      public static void setAnimationScaleCompat(float scale)
      Sets the animation scale, see UiAutomation.setAnimationScale(float). Provides backwards compatible access to SDKs invalid input: '<' T.
    • grantRuntimePermission

      @Implementation(minSdk=28) protected void grantRuntimePermission(String packageName, String permission)
    • setAnimationScale

      @Implementation(minSdk=33) protected void setAnimationScale(float scale)
    • setRotation

      @Implementation protected boolean setRotation(int rotation)
    • throwIfNotConnectedLocked

      @Implementation protected void throwIfNotConnectedLocked()
    • takeScreenshot

      @Implementation protected Bitmap takeScreenshot() throws Exception
      Real Android will via a series of IPCs that eventually obtain an image from SurfaceFlinger.

      Since Robolectric doesn't run any of those backend services, this shadow simulates the result by capturing an image from each active Window listed in WindowManager, and stiches them together into a resuting image.

      Also unlike real Android, this method can be called from on and outside the main Looper thread.

      Returns:
      a Bitmap of the display
      Throws:
      Exception
    • injectInputEvent

      public static boolean injectInputEvent(InputEvent event)
      Injects a motion event into the appropriate window, see UiAutomation.injectInputEvent(InputEvent, boolean). This can be used through the UiAutomation API, this method is provided for backwards compatibility with SDK invalid input: '<' 18.
    • injectInputEvent

      @Implementation protected boolean injectInputEvent(InputEvent event, boolean sync)