Class ShadowMotionEvent

java.lang.Object
org.robolectric.shadows.ShadowInputEvent
org.robolectric.shadows.ShadowMotionEvent

@Implements(android.view.MotionEvent.class) public class ShadowMotionEvent extends ShadowInputEvent
Shadow of MotionEvent.

The Android framework stores motion events in a pool of native objects. All motion event data is stored natively, and accessed via a series of static native methods following the pattern nativeGetXXXX(mNativePtr, ...)

This shadow mirrors this design, but has java equivalents of each native object. Most of the contents of this class were transliterated from oreo-mr1 (SDK 27) frameworks/base/core/jni/android_view_MotionEvent.cpp

See Also:
  • core/jni/android_view_MotionEvent.cpp

    Tests should not reference this class directly. MotionEvents should be created via one of the MotionEvent.obtain methods or via MotionEventBuilder.

  • Constructor Details

    • ShadowMotionEvent

      public ShadowMotionEvent()
  • Method Details

    • reset

      @Resetter public static void reset()
    • nativeInitialize

      @Implementation(maxSdk=28) @HiddenApi protected static long nativeInitialize(long nativePtr, int deviceId, int source, int action, int flags, int edgeFlags, int metaState, int buttonState, float xOffset, float yOffset, float xPrecision, float yPrecision, long downTimeNanos, long eventTimeNanos, int pointerCount, MotionEvent.PointerProperties[] pointerPropertiesObjArray, MotionEvent.PointerCoords[] pointerCoordsObjArray)
    • nativeInitialize

      @Implementation(minSdk=29) @HiddenApi protected static long nativeInitialize(long nativePtr, int deviceId, int source, int displayId, int action, int flags, int edgeFlags, int metaState, int buttonState, int classification, float xOffset, float yOffset, float xPrecision, float yPrecision, long downTimeNanos, long eventTimeNanos, int pointerCount, MotionEvent.PointerProperties[] pointerIds, MotionEvent.PointerCoords[] pointerCoords)
    • nativeDispose

      @Implementation @HiddenApi protected static void nativeDispose(long nativePtr)
    • nativeAddBatch

      @Implementation @HiddenApi protected static void nativeAddBatch(long nativePtr, long eventTimeNanos, MotionEvent.PointerCoords[] pointerCoordsObjArray, int metaState)
    • nativeGetPointerCoords

      @Implementation @HiddenApi protected static void nativeGetPointerCoords(long nativePtr, int pointerIndex, int historyPos, MotionEvent.PointerCoords outPointerCoordsObj)
    • nativeGetPointerProperties

      @Implementation @HiddenApi protected static void nativeGetPointerProperties(long nativePtr, int pointerIndex, MotionEvent.PointerProperties outPointerPropertiesObj)
    • nativeReadFromParcel

      @Implementation @HiddenApi protected static long nativeReadFromParcel(long nativePtr, Parcel parcelObj)
    • nativeWriteToParcel

      @Implementation @HiddenApi protected static void nativeWriteToParcel(long nativePtr, Parcel parcel)
    • nativeAxisToString

      @Implementation @HiddenApi protected static String nativeAxisToString(int axis)
    • nativeAxisFromString

      @Implementation @HiddenApi protected static int nativeAxisFromString(String label)
    • nativeGetPointerId

      @Implementation @HiddenApi protected static int nativeGetPointerId(long nativePtr, int pointerIndex)
    • nativeGetToolType

      @Implementation @HiddenApi protected static int nativeGetToolType(long nativePtr, int pointerIndex)
    • nativeGetEventTimeNanos

      @Implementation @HiddenApi protected static long nativeGetEventTimeNanos(long nativePtr, int historyPos)
    • nativeGetRawAxisValue

      @Implementation @HiddenApi protected static float nativeGetRawAxisValue(long nativePtr, int axis, int pointerIndex, int historyPos)
    • nativeGetAxisValue

      @Implementation @HiddenApi protected static float nativeGetAxisValue(long nativePtr, int axis, int pointerIndex, int historyPos)
    • nativeCopy

      @Implementation @HiddenApi protected static long nativeCopy(long destNativePtr, long sourceNativePtr, boolean keepHistory)
    • nativeGetDeviceId

      @Implementation @HiddenApi protected static int nativeGetDeviceId(long nativePtr)
    • nativeGetSource

      @Implementation @HiddenApi protected static int nativeGetSource(long nativePtr)
    • nativeSetSource

      @Implementation @HiddenApi protected static void nativeSetSource(long nativePtr, int source)
    • nativeGetAction

      @Implementation @HiddenApi protected static int nativeGetAction(long nativePtr)
    • nativeSetAction

      @Implementation @HiddenApi protected static void nativeSetAction(long nativePtr, int action)
    • nativeGetActionButton

      @Implementation(minSdk=23) @HiddenApi protected static int nativeGetActionButton(long nativePtr)
    • nativeSetActionButton

      @Implementation(minSdk=23) @HiddenApi protected static void nativeSetActionButton(long nativePtr, int button)
    • nativeIsTouchEvent

      @Implementation @HiddenApi protected static boolean nativeIsTouchEvent(long nativePtr)
    • nativeGetFlags

      @Implementation @HiddenApi protected static int nativeGetFlags(long nativePtr)
    • nativeSetFlags

      @Implementation @HiddenApi protected static void nativeSetFlags(long nativePtr, int flags)
    • nativeGetEdgeFlags

      @Implementation @HiddenApi protected static int nativeGetEdgeFlags(long nativePtr)
    • nativeSetEdgeFlags

      @Implementation @HiddenApi protected static void nativeSetEdgeFlags(long nativePtr, int edgeFlags)
    • nativeGetMetaState

      @Implementation @HiddenApi protected static int nativeGetMetaState(long nativePtr)
    • nativeGetButtonState

      @Implementation @HiddenApi protected static int nativeGetButtonState(long nativePtr)
    • nativeSetButtonState

      @Implementation(minSdk=23) @HiddenApi protected static void nativeSetButtonState(long nativePtr, int buttonState)
    • nativeGetClassification

      @Implementation(minSdk=29) @HiddenApi protected static int nativeGetClassification(long nativePtr)
    • nativeOffsetLocation

      @Implementation @HiddenApi protected static void nativeOffsetLocation(long nativePtr, float deltaX, float deltaY)
    • nativeGetXOffset

      @Implementation(maxSdk=34) @HiddenApi protected static float nativeGetXOffset(long nativePtr)
    • nativeGetYOffset

      @Implementation(maxSdk=34) @HiddenApi protected static float nativeGetYOffset(long nativePtr)
    • split

      @Implementation(minSdk=35) protected final MotionEvent split(int idBits)
    • nativeGetRawXOffset

      @Implementation(minSdk=35) @HiddenApi protected static float nativeGetRawXOffset(long nativePtr)
    • nativeGetRawYOffset

      @Implementation(minSdk=35) @HiddenApi protected static float nativeGetRawYOffset(long nativePtr)
    • nativeGetXPrecision

      @Implementation @HiddenApi protected static float nativeGetXPrecision(long nativePtr)
    • nativeGetYPrecision

      @Implementation @HiddenApi protected static float nativeGetYPrecision(long nativePtr)
    • nativeGetDownTimeNanos

      @Implementation @HiddenApi protected static long nativeGetDownTimeNanos(long nativePtr)
    • nativeSetDownTimeNanos

      @Implementation @HiddenApi protected static void nativeSetDownTimeNanos(long nativePtr, long downTimeNanos)
    • nativeGetPointerCount

      @Implementation @HiddenApi protected static int nativeGetPointerCount(long nativePtr)
    • nativeFindPointerIndex

      @Implementation @HiddenApi protected static int nativeFindPointerIndex(long nativePtr, int pointerId)
    • nativeGetHistorySize

      @Implementation @HiddenApi protected static int nativeGetHistorySize(long nativePtr)
    • nativeScale

      @Implementation @HiddenApi protected static void nativeScale(long nativePtr, float scale)
    • getNativeMotionEvent

      protected static org.robolectric.shadows.NativeInput.MotionEvent getNativeMotionEvent(long nativePtr)
    • transform

      @Implementation protected void transform(Matrix matrix)
    • getNativeMotionEvent

      protected org.robolectric.shadows.NativeInput.MotionEvent getNativeMotionEvent()
    • setPointer2

      @Deprecated public MotionEvent setPointer2(float pointer1X, float pointer1Y)
      Deprecated.
      use MotionEvent.obtain() or
      invalid reference
      androidx.test.core.view.MotionEventBuilder
      to create a MotionEvent with desired data.
    • setPointerIndex

      @Deprecated public void setPointerIndex(int pointerIndex)
      Deprecated.
      use MotionEvent.obtain() or
      invalid reference
      androidx.test.core.view.MotionEventBuilder#setPointerAction(int, int)
      to create a MotionEvent with desired data.
    • setPointerIds

      @Deprecated public void setPointerIds(int index0PointerId, int index1PointerId)
      Deprecated.
      use MotionEvent.obtain() or
      invalid reference
      MotionEventBuilder
      to create a MotionEvent with desired data