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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected org.robolectric.shadows.NativeInput.MotionEventprotected static org.robolectric.shadows.NativeInput.MotionEventgetNativeMotionEvent(long nativePtr) protected static voidnativeAddBatch(long nativePtr, long eventTimeNanos, MotionEvent.PointerCoords[] pointerCoordsObjArray, int metaState) protected static intnativeAxisFromString(String label) protected static StringnativeAxisToString(int axis) protected static longnativeCopy(long destNativePtr, long sourceNativePtr, boolean keepHistory) protected static voidnativeDispose(long nativePtr) protected static intnativeFindPointerIndex(long nativePtr, int pointerId) protected static intnativeGetAction(long nativePtr) protected static intnativeGetActionButton(long nativePtr) protected static floatnativeGetAxisValue(long nativePtr, int axis, int pointerIndex, int historyPos) protected static intnativeGetButtonState(long nativePtr) protected static intnativeGetDeviceId(long nativePtr) protected static longnativeGetDownTimeNanos(long nativePtr) protected static intnativeGetEdgeFlags(long nativePtr) protected static longnativeGetEventTimeNanos(long nativePtr, int historyPos) protected static intnativeGetFlags(long nativePtr) protected static intnativeGetHistorySize(long nativePtr) protected static intnativeGetMetaState(long nativePtr) protected static voidnativeGetPointerCoords(long nativePtr, int pointerIndex, int historyPos, MotionEvent.PointerCoords outPointerCoordsObj) protected static intnativeGetPointerCount(long nativePtr) protected static intnativeGetPointerId(long nativePtr, int pointerIndex) protected static voidnativeGetPointerProperties(long nativePtr, int pointerIndex, MotionEvent.PointerProperties outPointerPropertiesObj) protected static floatnativeGetRawAxisValue(long nativePtr, int axis, int pointerIndex, int historyPos) protected static floatnativeGetRawXOffset(long nativePtr) protected static floatnativeGetRawYOffset(long nativePtr) protected static intnativeGetSource(long nativePtr) protected static intnativeGetToolType(long nativePtr, int pointerIndex) protected static floatnativeGetXOffset(long nativePtr) protected static floatnativeGetXPrecision(long nativePtr) protected static floatnativeGetYOffset(long nativePtr) protected static floatnativeGetYPrecision(long nativePtr) protected static longnativeInitialize(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 longnativeInitialize(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 booleannativeIsTouchEvent(long nativePtr) protected static voidnativeOffsetLocation(long nativePtr, float deltaX, float deltaY) protected static longnativeReadFromParcel(long nativePtr, Parcel parcelObj) protected static voidnativeScale(long nativePtr, float scale) protected static voidnativeSetAction(long nativePtr, int action) protected static voidnativeSetActionButton(long nativePtr, int button) protected static voidnativeSetButtonState(long nativePtr, int buttonState) protected static voidnativeSetDownTimeNanos(long nativePtr, long downTimeNanos) protected static voidnativeSetEdgeFlags(long nativePtr, int edgeFlags) protected static voidnativeSetFlags(long nativePtr, int flags) protected static voidnativeSetSource(long nativePtr, int source) protected static voidnativeWriteToParcel(long nativePtr, Parcel parcel) static voidreset()setPointer2(float pointer1X, float pointer1Y) Deprecated.voidsetPointerIds(int index0PointerId, int index1PointerId) Deprecated.useMotionEvent.obtain()orMotionEventBuilderto create a MotionEvent with desired datavoidsetPointerIndex(int pointerIndex) Deprecated.useMotionEvent.obtain()orandroidx.test.core.view.MotionEventBuilder#setPointerAction(int, int)to create a MotionEvent with desired data.protected final MotionEventsplit(int idBits) protected voidMethods 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.MotionEventBuilderto 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()orMotionEventBuilderto create a MotionEvent with desired data
-
MotionEvent.obtain()orandroidx.test.core.view.MotionEventBuilderto create a MotionEvent with desired data.