Package org.robolectric.shadows
Class ShadowMotionEvent
java.lang.Object
org.robolectric.shadows.ShadowInputEvent
org.robolectric.shadows.ShadowMotionEvent
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.
- core/jni/android_view_MotionEvent.cpp
-
Field Summary
Fields inherited from class org.robolectric.shadows.ShadowInputEvent
device
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected static void
nativeAddBatch
(int nativePtr, long eventTimeNanos, MotionEvent.PointerCoords[] pointerCoordsObjArray, int metaState) protected static void
nativeAddBatch
(long nativePtr, long eventTimeNanos, MotionEvent.PointerCoords[] pointerCoordsObjArray, int metaState) protected static int
nativeAxisFromString
(String label) protected static String
nativeAxisToString
(int axis) protected static int
nativeCopy
(int destNativePtr, int sourceNativePtr, boolean keepHistory) protected static long
nativeCopy
(long destNativePtr, long sourceNativePtr, boolean keepHistory) protected static void
nativeDispose
(int nativePtr) protected static void
nativeDispose
(long nativePtr) protected static int
nativeFindPointerIndex
(int nativePtr, int pointerId) protected static int
nativeFindPointerIndex
(long nativePtr, int pointerId) protected static int
nativeGetAction
(int nativePtr) protected static int
nativeGetAction
(long nativePtr) protected static int
nativeGetActionButton
(long nativePtr) protected static float
nativeGetAxisValue
(int nativePtr, int axis, int pointerIndex, int historyPos) protected static float
nativeGetAxisValue
(long nativePtr, int axis, int pointerIndex, int historyPos) protected static int
nativeGetButtonState
(int nativePtr) protected static int
nativeGetButtonState
(long nativePtr) protected static int
nativeGetDeviceId
(int nativePtr) protected static int
nativeGetDeviceId
(long nativePtr) protected static long
nativeGetDownTimeNanos
(int nativePtr) protected static long
nativeGetDownTimeNanos
(long nativePtr) protected static int
nativeGetEdgeFlags
(int nativePtr) protected static int
nativeGetEdgeFlags
(long nativePtr) protected static long
nativeGetEventTimeNanos
(int nativePtr, int historyPos) protected static long
nativeGetEventTimeNanos
(long nativePtr, int historyPos) protected static int
nativeGetFlags
(int nativePtr) protected static int
nativeGetFlags
(long nativePtr) protected static int
nativeGetHistorySize
(int nativePtr) protected static int
nativeGetHistorySize
(long nativePtr) protected static int
nativeGetMetaState
(int nativePtr) protected static int
nativeGetMetaState
(long nativePtr) protected static void
nativeGetPointerCoords
(int nativePtr, int pointerIndex, int historyPos, MotionEvent.PointerCoords outPointerCoordsObj) protected static void
nativeGetPointerCoords
(long nativePtr, int pointerIndex, int historyPos, MotionEvent.PointerCoords outPointerCoordsObj) protected static int
nativeGetPointerCount
(int nativePtr) protected static int
nativeGetPointerCount
(long nativePtr) protected static int
nativeGetPointerId
(int nativePtr, int pointerIndex) protected static int
nativeGetPointerId
(long nativePtr, int pointerIndex) protected static void
nativeGetPointerProperties
(int nativePtr, int pointerIndex, MotionEvent.PointerProperties outPointerPropertiesObj) protected static void
nativeGetPointerProperties
(long nativePtr, int pointerIndex, MotionEvent.PointerProperties outPointerPropertiesObj) protected static float
nativeGetRawAxisValue
(int nativePtr, int axis, int pointerIndex, int historyPos) protected static float
nativeGetRawAxisValue
(long nativePtr, int axis, int pointerIndex, int historyPos) protected static int
nativeGetSource
(int nativePtr) protected static int
nativeGetSource
(long nativePtr) protected static int
nativeGetToolType
(int nativePtr, int pointerIndex) protected static int
nativeGetToolType
(long nativePtr, int pointerIndex) protected static float
nativeGetXOffset
(int nativePtr) protected static float
nativeGetXOffset
(long nativePtr) protected static float
nativeGetXPrecision
(int nativePtr) protected static float
nativeGetXPrecision
(long nativePtr) protected static float
nativeGetYOffset
(int nativePtr) protected static float
nativeGetYOffset
(long nativePtr) protected static float
nativeGetYPrecision
(int nativePtr) protected static float
nativeGetYPrecision
(long nativePtr) protected static int
nativeInitialize
(int 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[] pointerIds, MotionEvent.PointerCoords[] pointerCoords) 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) 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) protected static boolean
nativeIsTouchEvent
(int nativePtr) protected static boolean
nativeIsTouchEvent
(long nativePtr) protected static void
nativeOffsetLocation
(int nativePtr, float deltaX, float deltaY) protected static void
nativeOffsetLocation
(long nativePtr, float deltaX, float deltaY) protected static int
nativeReadFromParcel
(int nativePtr, Parcel parcelObj) protected static long
nativeReadFromParcel
(long nativePtr, Parcel parcelObj) protected static void
nativeScale
(int nativePtr, float scale) protected static void
nativeScale
(long nativePtr, float scale) protected static void
nativeSetAction
(int nativePtr, int action) protected static void
nativeSetAction
(long nativePtr, int action) protected static void
nativeSetActionButton
(long nativePtr, int button) protected static void
nativeSetButtonState
(long nativePtr, int buttonState) protected static void
nativeSetDownTimeNanos
(int nativePtr, long downTimeNanos) protected static void
nativeSetDownTimeNanos
(long nativePtr, long downTimeNanos) protected static void
nativeSetEdgeFlags
(int nativePtr, int edgeFlags) protected static void
nativeSetEdgeFlags
(long nativePtr, int edgeFlags) protected static void
nativeSetFlags
(int nativePtr, int flags) protected static void
nativeSetFlags
(long nativePtr, int flags) protected static int
nativeSetSource
(int nativePtr, int source) protected static void
nativeSetSource
(long nativePtr, int source) protected static void
nativeWriteToParcel
(int nativePtr, Parcel parcel) protected static void
nativeWriteToParcel
(long nativePtr, Parcel parcel) static void
reset()
setPointer2
(float pointer1X, float pointer1Y) Deprecated.void
setPointerIds
(int index0PointerId, int index1PointerId) Deprecated.useMotionEvent.obtain()
orMotionEventBuilder
to create a MotionEvent with desired datavoid
setPointerIndex
(int pointerIndex) Deprecated.useMotionEvent.obtain()
orandroidx.test.core.view.MotionEventBuilder#setPointerAction(int, int)
to create a MotionEvent with desired data.protected final void
Methods inherited from class org.robolectric.shadows.ShadowInputEvent
getDevice, setDevice
-
Constructor Details
-
ShadowMotionEvent
public ShadowMotionEvent()
-
-
Method Details
-
reset
-
nativeInitialize
@Implementation(maxSdk=20) @HiddenApi protected static int nativeInitialize(int 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[] pointerIds, MotionEvent.PointerCoords[] pointerCoords) -
nativeInitialize
@Implementation(minSdk=21, 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
-
nativeDispose
-
nativeAddBatch
@Implementation(maxSdk=20) @HiddenApi protected static void nativeAddBatch(int nativePtr, long eventTimeNanos, MotionEvent.PointerCoords[] pointerCoordsObjArray, int metaState) -
nativeAddBatch
@Implementation(minSdk=21) @HiddenApi protected static void nativeAddBatch(long nativePtr, long eventTimeNanos, MotionEvent.PointerCoords[] pointerCoordsObjArray, int metaState) -
nativeGetPointerCoords
@Implementation(maxSdk=20) @HiddenApi protected static void nativeGetPointerCoords(int nativePtr, int pointerIndex, int historyPos, MotionEvent.PointerCoords outPointerCoordsObj) -
nativeGetPointerCoords
@Implementation(minSdk=21) @HiddenApi protected static void nativeGetPointerCoords(long nativePtr, int pointerIndex, int historyPos, MotionEvent.PointerCoords outPointerCoordsObj) -
nativeGetPointerProperties
@Implementation(maxSdk=20) @HiddenApi protected static void nativeGetPointerProperties(int nativePtr, int pointerIndex, MotionEvent.PointerProperties outPointerPropertiesObj) -
nativeGetPointerProperties
@Implementation(minSdk=21) @HiddenApi protected static void nativeGetPointerProperties(long nativePtr, int pointerIndex, MotionEvent.PointerProperties outPointerPropertiesObj) -
nativeReadFromParcel
@Implementation(maxSdk=20) @HiddenApi protected static int nativeReadFromParcel(int nativePtr, Parcel parcelObj) -
nativeReadFromParcel
@Implementation(minSdk=21) @HiddenApi protected static long nativeReadFromParcel(long nativePtr, Parcel parcelObj) -
nativeWriteToParcel
@Implementation(maxSdk=20) @HiddenApi protected static void nativeWriteToParcel(int nativePtr, Parcel parcel) -
nativeWriteToParcel
@Implementation(minSdk=21) @HiddenApi protected static void nativeWriteToParcel(long nativePtr, Parcel parcel) -
nativeAxisToString
-
nativeAxisFromString
-
nativeGetPointerId
@Implementation(maxSdk=20) @HiddenApi protected static int nativeGetPointerId(int nativePtr, int pointerIndex) -
nativeGetPointerId
@Implementation(minSdk=21) @HiddenApi protected static int nativeGetPointerId(long nativePtr, int pointerIndex) -
nativeGetToolType
@Implementation(maxSdk=20) @HiddenApi protected static int nativeGetToolType(int nativePtr, int pointerIndex) -
nativeGetToolType
@Implementation(minSdk=21) @HiddenApi protected static int nativeGetToolType(long nativePtr, int pointerIndex) -
nativeGetEventTimeNanos
@Implementation(maxSdk=20) @HiddenApi protected static long nativeGetEventTimeNanos(int nativePtr, int historyPos) -
nativeGetEventTimeNanos
@Implementation(minSdk=21) @HiddenApi protected static long nativeGetEventTimeNanos(long nativePtr, int historyPos) -
nativeGetRawAxisValue
@Implementation(maxSdk=20) @HiddenApi protected static float nativeGetRawAxisValue(int nativePtr, int axis, int pointerIndex, int historyPos) -
nativeGetRawAxisValue
@Implementation(minSdk=21) @HiddenApi protected static float nativeGetRawAxisValue(long nativePtr, int axis, int pointerIndex, int historyPos) -
nativeGetAxisValue
@Implementation(maxSdk=20) @HiddenApi protected static float nativeGetAxisValue(int nativePtr, int axis, int pointerIndex, int historyPos) -
nativeGetAxisValue
@Implementation(minSdk=21) @HiddenApi protected static float nativeGetAxisValue(long nativePtr, int axis, int pointerIndex, int historyPos) -
nativeCopy
@Implementation(maxSdk=20) @HiddenApi protected static int nativeCopy(int destNativePtr, int sourceNativePtr, boolean keepHistory) -
nativeCopy
@Implementation(minSdk=21) @HiddenApi protected static long nativeCopy(long destNativePtr, long sourceNativePtr, boolean keepHistory) -
nativeGetDeviceId
-
nativeGetDeviceId
-
nativeGetSource
-
nativeGetSource
-
nativeSetSource
@Implementation(maxSdk=20) @HiddenApi protected static int nativeSetSource(int nativePtr, int source) -
nativeSetSource
@Implementation(minSdk=21) @HiddenApi protected static void nativeSetSource(long nativePtr, int source) -
nativeGetAction
-
nativeGetAction
-
nativeSetAction
@Implementation(maxSdk=20) @HiddenApi protected static void nativeSetAction(int nativePtr, int action) -
nativeSetAction
@Implementation(minSdk=21) @HiddenApi protected static void nativeSetAction(long nativePtr, int action) -
nativeGetActionButton
-
nativeSetActionButton
@Implementation(minSdk=23) @HiddenApi protected static void nativeSetActionButton(long nativePtr, int button) -
nativeIsTouchEvent
-
nativeIsTouchEvent
-
nativeGetFlags
-
nativeGetFlags
-
nativeSetFlags
@Implementation(maxSdk=20) @HiddenApi protected static void nativeSetFlags(int nativePtr, int flags) -
nativeSetFlags
@Implementation(minSdk=21) @HiddenApi protected static void nativeSetFlags(long nativePtr, int flags) -
nativeGetEdgeFlags
-
nativeGetEdgeFlags
-
nativeSetEdgeFlags
@Implementation(maxSdk=20) @HiddenApi protected static void nativeSetEdgeFlags(int nativePtr, int edgeFlags) -
nativeSetEdgeFlags
@Implementation(minSdk=21) @HiddenApi protected static void nativeSetEdgeFlags(long nativePtr, int edgeFlags) -
nativeGetMetaState
-
nativeGetMetaState
-
nativeGetButtonState
-
nativeGetButtonState
-
nativeSetButtonState
@Implementation(minSdk=23) @HiddenApi protected static void nativeSetButtonState(long nativePtr, int buttonState) -
nativeOffsetLocation
@Implementation(maxSdk=20) @HiddenApi protected static void nativeOffsetLocation(int nativePtr, float deltaX, float deltaY) -
nativeOffsetLocation
@Implementation(minSdk=21) @HiddenApi protected static void nativeOffsetLocation(long nativePtr, float deltaX, float deltaY) -
nativeGetXOffset
-
nativeGetXOffset
-
nativeGetYOffset
-
nativeGetYOffset
-
nativeGetXPrecision
-
nativeGetXPrecision
-
nativeGetYPrecision
-
nativeGetYPrecision
-
nativeGetDownTimeNanos
-
nativeGetDownTimeNanos
-
nativeSetDownTimeNanos
@Implementation(maxSdk=20) @HiddenApi protected static void nativeSetDownTimeNanos(int nativePtr, long downTimeNanos) -
nativeSetDownTimeNanos
@Implementation(minSdk=21) @HiddenApi protected static void nativeSetDownTimeNanos(long nativePtr, long downTimeNanos) -
nativeGetPointerCount
-
nativeGetPointerCount
-
nativeFindPointerIndex
@Implementation(maxSdk=20) @HiddenApi protected static int nativeFindPointerIndex(int nativePtr, int pointerId) -
nativeFindPointerIndex
@Implementation(minSdk=21) @HiddenApi protected static int nativeFindPointerIndex(long nativePtr, int pointerId) -
nativeGetHistorySize
-
nativeGetHistorySize
-
nativeScale
-
nativeScale
@Implementation(minSdk=21) @HiddenApi protected static void nativeScale(long nativePtr, float scale) -
transform
-
setPointer2
Deprecated.useMotionEvent.obtain()
orandroidx.test.core.view.MotionEventBuilder
to create a MotionEvent with desired data. -
setPointerIndex
Deprecated.useMotionEvent.obtain()
orandroidx.test.core.view.MotionEventBuilder#setPointerAction(int, int)
to create a MotionEvent with desired data. -
setPointerIds
Deprecated.useMotionEvent.obtain()
orMotionEventBuilder
to create a MotionEvent with desired data
-
MotionEvent.obtain()
orandroidx.test.core.view.MotionEventBuilder
to create a MotionEvent with desired data.