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 org.robolectric.shadows.NativeInput.MotionEvent
protected static org.robolectric.shadows.NativeInput.MotionEvent
getNativeMotionEvent
(long nativePtr) 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 long
nativeCopy
(long destNativePtr, long sourceNativePtr, boolean keepHistory) protected static void
nativeDispose
(long nativePtr) protected static int
nativeFindPointerIndex
(long nativePtr, int pointerId) protected static int
nativeGetAction
(long nativePtr) protected static int
nativeGetActionButton
(long nativePtr) protected static float
nativeGetAxisValue
(long nativePtr, int axis, int pointerIndex, int historyPos) protected static int
nativeGetButtonState
(long nativePtr) protected static int
nativeGetDeviceId
(long nativePtr) protected static long
nativeGetDownTimeNanos
(long nativePtr) protected static int
nativeGetEdgeFlags
(long nativePtr) protected static long
nativeGetEventTimeNanos
(long nativePtr, int historyPos) protected static int
nativeGetFlags
(long nativePtr) protected static int
nativeGetHistorySize
(long nativePtr) protected static int
nativeGetMetaState
(long nativePtr) protected static void
nativeGetPointerCoords
(long nativePtr, int pointerIndex, int historyPos, MotionEvent.PointerCoords outPointerCoordsObj) protected static int
nativeGetPointerCount
(long nativePtr) protected static int
nativeGetPointerId
(long nativePtr, int pointerIndex) protected static void
nativeGetPointerProperties
(long nativePtr, int pointerIndex, MotionEvent.PointerProperties outPointerPropertiesObj) protected static float
nativeGetRawAxisValue
(long nativePtr, int axis, int pointerIndex, int historyPos) protected static float
nativeGetRawXOffset
(long nativePtr) protected static float
nativeGetRawYOffset
(long nativePtr) protected static int
nativeGetSource
(long nativePtr) protected static int
nativeGetToolType
(long nativePtr, int pointerIndex) protected static float
nativeGetXOffset
(long nativePtr) protected static float
nativeGetXPrecision
(long nativePtr) protected static float
nativeGetYOffset
(long nativePtr) protected static float
nativeGetYPrecision
(long nativePtr) 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
(long nativePtr) protected static void
nativeOffsetLocation
(long nativePtr, float deltaX, float deltaY) protected static long
nativeReadFromParcel
(long nativePtr, Parcel parcelObj) protected static void
nativeScale
(long nativePtr, float scale) 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
(long nativePtr, long downTimeNanos) protected static void
nativeSetEdgeFlags
(long nativePtr, int edgeFlags) protected static void
nativeSetFlags
(long nativePtr, int flags) protected static void
nativeSetSource
(long nativePtr, int source) 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 MotionEvent
split
(int idBits) protected void
Methods inherited from class org.robolectric.shadows.ShadowInputEvent
getDevice, setDevice
-
Constructor Details
-
ShadowMotionEvent
public ShadowMotionEvent()
-
-
Method Details
-
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
-
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
-
nativeAxisToString
-
nativeAxisFromString
-
nativeGetPointerId
@Implementation @HiddenApi protected static int nativeGetPointerId(long nativePtr, int pointerIndex) -
nativeGetToolType
-
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
-
nativeGetSource
-
nativeSetSource
-
nativeGetAction
-
nativeSetAction
-
nativeGetActionButton
-
nativeSetActionButton
@Implementation(minSdk=23) @HiddenApi protected static void nativeSetActionButton(long nativePtr, int button) -
nativeIsTouchEvent
-
nativeGetFlags
-
nativeSetFlags
-
nativeGetEdgeFlags
-
nativeSetEdgeFlags
-
nativeGetMetaState
-
nativeGetButtonState
-
nativeSetButtonState
@Implementation(minSdk=23) @HiddenApi protected static void nativeSetButtonState(long nativePtr, int buttonState) -
nativeOffsetLocation
@Implementation @HiddenApi protected static void nativeOffsetLocation(long nativePtr, float deltaX, float deltaY) -
nativeGetXOffset
@Implementation(maxSdk=34) @HiddenApi @InDevelopment protected static float nativeGetXOffset(long nativePtr) -
nativeGetYOffset
@Implementation(maxSdk=34) @HiddenApi @InDevelopment protected static float nativeGetYOffset(long nativePtr) -
split
-
nativeGetRawXOffset
@Implementation(minSdk=35) @HiddenApi @InDevelopment protected static float nativeGetRawXOffset(long nativePtr) -
nativeGetRawYOffset
@Implementation(minSdk=35) @HiddenApi @InDevelopment protected static float nativeGetRawYOffset(long nativePtr) -
nativeGetXPrecision
-
nativeGetYPrecision
-
nativeGetDownTimeNanos
-
nativeSetDownTimeNanos
@Implementation @HiddenApi protected static void nativeSetDownTimeNanos(long nativePtr, long downTimeNanos) -
nativeGetPointerCount
-
nativeFindPointerIndex
@Implementation @HiddenApi protected static int nativeFindPointerIndex(long nativePtr, int pointerId) -
nativeGetHistorySize
-
nativeScale
-
getNativeMotionEvent
protected static org.robolectric.shadows.NativeInput.MotionEvent getNativeMotionEvent(long nativePtr) -
transform
-
getNativeMotionEvent
protected org.robolectric.shadows.NativeInput.MotionEvent getNativeMotionEvent() -
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.