Loading tests/FlickerTests/test-apps/app-helpers/src/com/android/server/wm/flicker/helpers/DesktopModeAppHelper.kt +1 −5 Original line number Diff line number Diff line Loading @@ -109,11 +109,7 @@ open class DesktopModeAppHelper(private val innerHelper: IStandardAppHelper) : if (motionEventHelper.inputMethod == TOUCH && Flags.enableHoldToDragAppHandle()) { // Touch requires hold-to-drag. val downTime = SystemClock.uptimeMillis() motionEventHelper.actionDown(startX, startY, time = downTime) SystemClock.sleep(100L) // hold for 100ns before starting the move. motionEventHelper.actionMove(startX, startY, startX, endY, 100, downTime = downTime) motionEventHelper.actionUp(startX, endY, downTime = downTime) motionEventHelper.holdToDrag(startX, startY, startX, endY, steps = 100) } else { device.drag(startX, startY, startX, endY, 100) } Loading tests/FlickerTests/test-apps/app-helpers/src/com/android/server/wm/flicker/helpers/MotionEventHelper.kt +38 −1 Original line number Diff line number Diff line Loading @@ -54,7 +54,15 @@ class MotionEventHelper( injectMotionEvent(ACTION_UP, x, y, downTime = downTime) } fun actionMove(startX: Int, startY: Int, endX: Int, endY: Int, steps: Int, downTime: Long) { fun actionMove( startX: Int, startY: Int, endX: Int, endY: Int, steps: Int, downTime: Long, withMotionEventInjectDelay: Boolean = false ) { val incrementX = (endX - startX).toFloat() / (steps - 1) val incrementY = (endY - startY).toFloat() / (steps - 1) Loading @@ -65,9 +73,33 @@ class MotionEventHelper( val moveEvent = getMotionEvent(downTime, time, ACTION_MOVE, x, y) injectMotionEvent(moveEvent) if (withMotionEventInjectDelay) { SystemClock.sleep(MOTION_EVENT_INJECTION_DELAY_MILLIS) } } } /** * Drag from [startX], [startY] to [endX], [endY] with a "hold" period after touching down * and before moving. */ fun holdToDrag(startX: Int, startY: Int, endX: Int, endY: Int, steps: Int) { val downTime = SystemClock.uptimeMillis() actionDown(startX, startY, time = downTime) SystemClock.sleep(100L) // Hold before dragging. actionMove( startX, startY, endX, endY, steps, downTime, withMotionEventInjectDelay = true ) SystemClock.sleep(REGULAR_CLICK_LENGTH) actionUp(startX, endX, downTime) } private fun injectMotionEvent( action: Int, x: Int, Loading Loading @@ -120,4 +152,9 @@ class MotionEventHelper( event.displayId = 0 return event } companion object { private const val MOTION_EVENT_INJECTION_DELAY_MILLIS = 5L private const val REGULAR_CLICK_LENGTH = 100L } } No newline at end of file Loading
tests/FlickerTests/test-apps/app-helpers/src/com/android/server/wm/flicker/helpers/DesktopModeAppHelper.kt +1 −5 Original line number Diff line number Diff line Loading @@ -109,11 +109,7 @@ open class DesktopModeAppHelper(private val innerHelper: IStandardAppHelper) : if (motionEventHelper.inputMethod == TOUCH && Flags.enableHoldToDragAppHandle()) { // Touch requires hold-to-drag. val downTime = SystemClock.uptimeMillis() motionEventHelper.actionDown(startX, startY, time = downTime) SystemClock.sleep(100L) // hold for 100ns before starting the move. motionEventHelper.actionMove(startX, startY, startX, endY, 100, downTime = downTime) motionEventHelper.actionUp(startX, endY, downTime = downTime) motionEventHelper.holdToDrag(startX, startY, startX, endY, steps = 100) } else { device.drag(startX, startY, startX, endY, 100) } Loading
tests/FlickerTests/test-apps/app-helpers/src/com/android/server/wm/flicker/helpers/MotionEventHelper.kt +38 −1 Original line number Diff line number Diff line Loading @@ -54,7 +54,15 @@ class MotionEventHelper( injectMotionEvent(ACTION_UP, x, y, downTime = downTime) } fun actionMove(startX: Int, startY: Int, endX: Int, endY: Int, steps: Int, downTime: Long) { fun actionMove( startX: Int, startY: Int, endX: Int, endY: Int, steps: Int, downTime: Long, withMotionEventInjectDelay: Boolean = false ) { val incrementX = (endX - startX).toFloat() / (steps - 1) val incrementY = (endY - startY).toFloat() / (steps - 1) Loading @@ -65,9 +73,33 @@ class MotionEventHelper( val moveEvent = getMotionEvent(downTime, time, ACTION_MOVE, x, y) injectMotionEvent(moveEvent) if (withMotionEventInjectDelay) { SystemClock.sleep(MOTION_EVENT_INJECTION_DELAY_MILLIS) } } } /** * Drag from [startX], [startY] to [endX], [endY] with a "hold" period after touching down * and before moving. */ fun holdToDrag(startX: Int, startY: Int, endX: Int, endY: Int, steps: Int) { val downTime = SystemClock.uptimeMillis() actionDown(startX, startY, time = downTime) SystemClock.sleep(100L) // Hold before dragging. actionMove( startX, startY, endX, endY, steps, downTime, withMotionEventInjectDelay = true ) SystemClock.sleep(REGULAR_CLICK_LENGTH) actionUp(startX, endX, downTime) } private fun injectMotionEvent( action: Int, x: Int, Loading Loading @@ -120,4 +152,9 @@ class MotionEventHelper( event.displayId = 0 return event } companion object { private const val MOTION_EVENT_INJECTION_DELAY_MILLIS = 5L private const val REGULAR_CLICK_LENGTH = 100L } } No newline at end of file