TouchUtils
open classTouchUtils
kotlin.Any | |
↳ | android.test.TouchUtils |
Reusable methods for generating touch events. These methods can be used with InstrumentationTestCase or ActivityInstrumentationTestCase2 to simulate user interaction with the application through a touch screen.
Summary
Public constructors | |
---|---|
Public methods | |
---|---|
open static Unit | clickView(test: InstrumentationTestCase!, v: View!) Simulate touching the center of a view and releasing. |
open static Unit | drag(test: ActivityInstrumentationTestCase<Activity!>!, fromX: Float, toX: Float, fromY: Float, toY: Float, stepCount: Int) Simulate touching a specific location and dragging to a new location. |
open static Unit | drag(test: InstrumentationTestCase!, fromX: Float, toX: Float, fromY: Float, toY: Float, stepCount: Int) Simulate touching a specific location and dragging to a new location. |
open static Unit | Simulate touching in the center of the screen and dragging one quarter of the way down |
open static Unit | dragQuarterScreenDown(test: InstrumentationTestCase!, activity: Activity!) Simulate touching in the center of the screen and dragging one quarter of the way down |
open static Unit | Simulate touching in the center of the screen and dragging one quarter of the way up |
open static Unit | dragQuarterScreenUp(test: InstrumentationTestCase!, activity: Activity!) Simulate touching in the center of the screen and dragging one quarter of the way up |
open static Int | dragViewBy(test: ActivityInstrumentationTestCase<Activity!>!, v: View!, gravity: Int, deltaX: Int, deltaY: Int) Simulate touching a view and dragging it by the specified amount. |
open static Int | dragViewBy(test: InstrumentationTestCase!, v: View!, gravity: Int, deltaX: Int, deltaY: Int) Simulate touching a view and dragging it by the specified amount. |
open static Int | dragViewTo(test: ActivityInstrumentationTestCase<Activity!>!, v: View!, gravity: Int, toX: Int, toY: Int) Simulate touching a view and dragging it to a specified location. |
open static Int | dragViewTo(test: InstrumentationTestCase!, v: View!, gravity: Int, toX: Int, toY: Int) Simulate touching a view and dragging it to a specified location. |
open static Unit | dragViewToBottom(test: ActivityInstrumentationTestCase<Activity!>!, v: View!) Simulate touching the center of a view and dragging to the bottom of the screen. |
open static Unit | dragViewToBottom(test: ActivityInstrumentationTestCase<Activity!>!, v: View!, stepCount: Int) Simulate touching the center of a view and dragging to the bottom of the screen. |
open static Unit | dragViewToBottom(test: InstrumentationTestCase!, activity: Activity!, v: View!) Simulate touching the center of a view and dragging to the bottom of the screen. |
open static Unit | dragViewToBottom(test: InstrumentationTestCase!, activity: Activity!, v: View!, stepCount: Int) Simulate touching the center of a view and dragging to the bottom of the screen. |
open static Unit | dragViewToTop(test: ActivityInstrumentationTestCase<Activity!>!, v: View!) Simulate touching the center of a view and dragging to the top of the screen. |
open static Unit | dragViewToTop(test: ActivityInstrumentationTestCase<Activity!>!, v: View!, stepCount: Int) Simulate touching the center of a view and dragging to the top of the screen. |
open static Unit | dragViewToTop(test: InstrumentationTestCase!, v: View!) Simulate touching the center of a view and dragging to the top of the screen. |
open static Unit | dragViewToTop(test: InstrumentationTestCase!, v: View!, stepCount: Int) Simulate touching the center of a view and dragging to the top of the screen. |
open static Int | dragViewToX(test: ActivityInstrumentationTestCase<Activity!>!, v: View!, gravity: Int, toX: Int) Simulate touching a view and dragging it to a specified location. |
open static Int | dragViewToX(test: InstrumentationTestCase!, v: View!, gravity: Int, toX: Int) Simulate touching a view and dragging it to a specified location. |
open static Int | dragViewToY(test: ActivityInstrumentationTestCase<Activity!>!, v: View!, gravity: Int, toY: Int) Simulate touching a view and dragging it to a specified location. |
open static Int | dragViewToY(test: InstrumentationTestCase!, v: View!, gravity: Int, toY: Int) Simulate touching a view and dragging it to a specified location. |
open static Unit | longClickView(test: ActivityInstrumentationTestCase<Activity!>!, v: View!) Simulate touching the center of a view, holding until it is a long press, and then releasing. |
open static Unit | longClickView(test: InstrumentationTestCase!, v: View!) Simulate touching the center of a view, holding until it is a long press, and then releasing. |
open static Unit | scrollToBottom(test: ActivityInstrumentationTestCase<Activity!>!, v: ViewGroup!) Scroll a ViewGroup to the bottom by repeatedly calling |
open static Unit | scrollToBottom(test: InstrumentationTestCase!, activity: Activity!, v: ViewGroup!) Scroll a ViewGroup to the bottom by repeatedly calling |
open static Unit | scrollToTop(test: ActivityInstrumentationTestCase<Activity!>!, v: ViewGroup!) Scroll a ViewGroup to the top by repeatedly calling |
open static Unit | scrollToTop(test: InstrumentationTestCase!, activity: Activity!, v: ViewGroup!) Scroll a ViewGroup to the top by repeatedly calling |
open static Unit | tapView(test: InstrumentationTestCase!, v: View!) Simulate touching the center of a view and releasing quickly (before the tap timeout). |
open static Unit | touchAndCancelView(test: InstrumentationTestCase!, v: View!) Simulate touching the center of a view and cancelling (so no onClick should fire, etc). |
Public constructors
TouchUtils
TouchUtils()
Public methods
clickView
open static funclickView(
test: InstrumentationTestCase!,
v: View!
): Unit
Deprecated: Deprecated in Java.
Simulate touching the center of a view and releasing.
Parameters | |
---|---|
test | InstrumentationTestCase!: The test case that is being run |
v | View!: The view that should be clicked |
drag
open static fundrag(
test: ActivityInstrumentationTestCase<Activity!>!,
fromX: Float,
toX: Float,
fromY: Float,
toY: Float,
stepCount: Int
): Unit
Deprecated: android.test.ActivityInstrumentationTestCase
is deprecated in favor of android.test.ActivityInstrumentationTestCase2
, which provides more options for configuring the Activity under test
Simulate touching a specific location and dragging to a new location.
Parameters | |
---|---|
test | ActivityInstrumentationTestCase<Activity!>!: The test case that is being run |
fromX | Float: X coordinate of the initial touch, in screen coordinates |
toX | Float: Xcoordinate of the drag destination, in screen coordinates |
fromY | Float: X coordinate of the initial touch, in screen coordinates |
toY | Float: Y coordinate of the drag destination, in screen coordinates |
stepCount | Int: How many move steps to include in the drag |
drag
open static fundrag(
test: InstrumentationTestCase!,
fromX: Float,
toX: Float,
fromY: Float,
toY: Float,
stepCount: Int
): Unit
Deprecated: Deprecated in Java.
Simulate touching a specific location and dragging to a new location.
Parameters | |
---|---|
test | InstrumentationTestCase!: The test case that is being run |
fromX | Float: X coordinate of the initial touch, in screen coordinates |
toX | Float: Xcoordinate of the drag destination, in screen coordinates |
fromY | Float: X coordinate of the initial touch, in screen coordinates |
toY | Float: Y coordinate of the drag destination, in screen coordinates |
stepCount | Int: How many move steps to include in the drag |
dragQuarterScreenDown
open static fundragQuarterScreenDown(test: ActivityInstrumentationTestCase<Activity!>!): Unit
Deprecated: android.test.ActivityInstrumentationTestCase
is deprecated in favor of android.test.ActivityInstrumentationTestCase2
, which provides more options for configuring the Activity under test
Simulate touching in the center of the screen and dragging one quarter of the way down
Parameters | |
---|---|
test | ActivityInstrumentationTestCase<Activity!>!: The test case that is being run |
dragQuarterScreenDown
open static fundragQuarterScreenDown(
test: InstrumentationTestCase!,
activity: Activity!
): Unit
Deprecated: Deprecated in Java.
Simulate touching in the center of the screen and dragging one quarter of the way down
Parameters | |
---|---|
test | InstrumentationTestCase!: The test case that is being run |
activity | Activity!: The activity that is in the foreground of the test case |
dragQuarterScreenUp
open static fundragQuarterScreenUp(test: ActivityInstrumentationTestCase<Activity!>!): Unit
Deprecated: android.test.ActivityInstrumentationTestCase
is deprecated in favor of android.test.ActivityInstrumentationTestCase2
, which provides more options for configuring the Activity under test
Simulate touching in the center of the screen and dragging one quarter of the way up
Parameters | |
---|---|
test | ActivityInstrumentationTestCase<Activity!>!: The test case that is being run |
dragQuarterScreenUp
open static fundragQuarterScreenUp(
test: InstrumentationTestCase!,
activity: Activity!
): Unit
Deprecated: Deprecated in Java.
Simulate touching in the center of the screen and dragging one quarter of the way up
Parameters | |
---|---|
test | InstrumentationTestCase!: The test case that is being run |
activity | Activity!: The activity that is in the foreground of the test case |
dragViewBy
open static fundragViewBy(
test: ActivityInstrumentationTestCase<Activity!>!,
v: View!,
gravity: Int,
deltaX: Int,
deltaY: Int
): Int
Deprecated: android.test.ActivityInstrumentationTestCase
is deprecated in favor of android.test.ActivityInstrumentationTestCase2
, which provides more options for configuring the Activity under test
Simulate touching a view and dragging it by the specified amount.
Parameters | |
---|---|
test | ActivityInstrumentationTestCase<Activity!>!: The test case that is being run |
v | View!: The view that should be dragged |
gravity | Int: Which part of the view to use for the initial down event. A combination of (TOP, CENTER_VERTICAL, BOTTOM) and (LEFT, CENTER_HORIZONTAL, RIGHT) |
deltaX | Int: Amount to drag horizontally in pixels |
deltaY | Int: Amount to drag vertically in pixels |
Return | |
---|---|
Int | distance in pixels covered by the drag |
dragViewBy
open static fundragViewBy(
test: InstrumentationTestCase!,
v: View!,
gravity: Int,
deltaX: Int,
deltaY: Int
): Int
Deprecated: android.test.ActivityInstrumentationTestCase
is deprecated in favor of android.test.ActivityInstrumentationTestCase2
, which provides more options for configuring the Activity under test
Simulate touching a view and dragging it by the specified amount.
Parameters | |
---|---|
test | InstrumentationTestCase!: The test case that is being run |
v | View!: The view that should be dragged |
gravity | Int: Which part of the view to use for the initial down event. A combination of (TOP, CENTER_VERTICAL, BOTTOM) and (LEFT, CENTER_HORIZONTAL, RIGHT) |
deltaX | Int: Amount to drag horizontally in pixels |
deltaY | Int: Amount to drag vertically in pixels |
Return | |
---|---|
Int | distance in pixels covered by the drag |
dragViewTo
open static fundragViewTo(
test: ActivityInstrumentationTestCase<Activity!>!,
v: View!,
gravity: Int,
toX: Int,
toY: Int
): Int
Deprecated: android.test.ActivityInstrumentationTestCase
is deprecated in favor of android.test.ActivityInstrumentationTestCase2
, which provides more options for configuring the Activity under test
Simulate touching a view and dragging it to a specified location.
Parameters | |
---|---|
test | ActivityInstrumentationTestCase<Activity!>!: The test case that is being run |
v | View!: The view that should be dragged |
gravity | Int: Which part of the view to use for the initial down event. A combination of (TOP, CENTER_VERTICAL, BOTTOM) and (LEFT, CENTER_HORIZONTAL, RIGHT) |
toX | Int: Final location of the view after dragging |
toY | Int: Final location of the view after dragging |
Return | |
---|---|
Int | distance in pixels covered by the drag |
dragViewTo
open static fundragViewTo(
test: InstrumentationTestCase!,
v: View!,
gravity: Int,
toX: Int,
toY: Int
): Int
Deprecated: Deprecated in Java.
Simulate touching a view and dragging it to a specified location.
Parameters | |
---|---|
test | InstrumentationTestCase!: The test case that is being run |
v | View!: The view that should be dragged |
gravity | Int: Which part of the view to use for the initial down event. A combination of (TOP, CENTER_VERTICAL, BOTTOM) and (LEFT, CENTER_HORIZONTAL, RIGHT) |
toX | Int: Final location of the view after dragging |
toY | Int: Final location of the view after dragging |
Return | |
---|---|
Int | distance in pixels covered by the drag |
dragViewToBottom
open static fundragViewToBottom(
test: ActivityInstrumentationTestCase<Activity!>!,
v: View!
): Unit
Deprecated: android.test.ActivityInstrumentationTestCase
is deprecated in favor of android.test.ActivityInstrumentationTestCase2
, which provides more options for configuring the Activity under test
Simulate touching the center of a view and dragging to the bottom of the screen.
Parameters | |
---|---|
test | ActivityInstrumentationTestCase<Activity!>!: The test case that is being run |
v | View!: The view that should be dragged |
dragViewToBottom
open static fundragViewToBottom(
test: ActivityInstrumentationTestCase<Activity!>!,
v: View!,
stepCount: Int
): Unit
Deprecated: android.test.ActivityInstrumentationTestCase
is deprecated in favor of android.test.ActivityInstrumentationTestCase2
, which provides more options for configuring the Activity under test
Simulate touching the center of a view and dragging to the bottom of the screen.
Parameters | |
---|---|
test | ActivityInstrumentationTestCase<Activity!>!: The test case that is being run |
v | View!: The view that should be dragged |
stepCount | Int: How many move steps to include in the drag |
dragViewToBottom
open static fundragViewToBottom(
test: InstrumentationTestCase!,
activity: Activity!,
v: View!
): Unit
Deprecated: Deprecated in Java.
Simulate touching the center of a view and dragging to the bottom of the screen.
Parameters | |
---|---|
test | InstrumentationTestCase!: The test case that is being run |
activity | Activity!: The activity that is in the foreground of the test case |
v | View!: The view that should be dragged |
dragViewToBottom
open static fundragViewToBottom(
test: InstrumentationTestCase!,
activity: Activity!,
v: View!,
stepCount: Int
): Unit
Deprecated: Deprecated in Java.
Simulate touching the center of a view and dragging to the bottom of the screen.
Parameters | |
---|---|
test | InstrumentationTestCase!: The test case that is being run |
activity | Activity!: The activity that is in the foreground of the test case |
v | View!: The view that should be dragged |
stepCount | Int: How many move steps to include in the drag |
dragViewToTop
open static fundragViewToTop(
test: ActivityInstrumentationTestCase<Activity!>!,
v: View!
): Unit
Deprecated: android.test.ActivityInstrumentationTestCase
is deprecated in favor of android.test.ActivityInstrumentationTestCase2
, which provides more options for configuring the Activity under test
Simulate touching the center of a view and dragging to the top of the screen.
Parameters | |
---|---|
test | ActivityInstrumentationTestCase<Activity!>!: The test case that is being run |
v | View!: The view that should be dragged |
dragViewToTop
open static fundragViewToTop(
test: ActivityInstrumentationTestCase<Activity!>!,
v: View!,
stepCount: Int
): Unit
Deprecated: android.test.ActivityInstrumentationTestCase
is deprecated in favor of android.test.ActivityInstrumentationTestCase2
, which provides more options for configuring the Activity under test
Simulate touching the center of a view and dragging to the top of the screen.
Parameters | |
---|---|
test | ActivityInstrumentationTestCase<Activity!>!: The test case that is being run |
v | View!: The view that should be dragged |
stepCount | Int: How many move steps to include in the drag |
dragViewToTop
open static fundragViewToTop(
test: InstrumentationTestCase!,
v: View!
): Unit
Deprecated: Deprecated in Java.
Simulate touching the center of a view and dragging to the top of the screen.
Parameters | |
---|---|
test | InstrumentationTestCase!: The test case that is being run |
v | View!: The view that should be dragged |
dragViewToTop
open static fundragViewToTop(
test: InstrumentationTestCase!,
v: View!,
stepCount: Int
): Unit
Deprecated: Deprecated in Java.
Simulate touching the center of a view and dragging to the top of the screen.
Parameters | |
---|---|
test | InstrumentationTestCase!: The test case that is being run |
v | View!: The view that should be dragged |
stepCount | Int: How many move steps to include in the drag |
dragViewToX
open static fundragViewToX(
test: ActivityInstrumentationTestCase<Activity!>!,
v: View!,
gravity: Int,
toX: Int
): Int
Deprecated: android.test.ActivityInstrumentationTestCase
is deprecated in favor of android.test.ActivityInstrumentationTestCase2
, which provides more options for configuring the Activity under test
Simulate touching a view and dragging it to a specified location. Only moves horizontally.
Parameters | |
---|---|
test | ActivityInstrumentationTestCase<Activity!>!: The test case that is being run |
v | View!: The view that should be dragged |
gravity | Int: Which part of the view to use for the initial down event. A combination of (TOP, CENTER_VERTICAL, BOTTOM) and (LEFT, CENTER_HORIZONTAL, RIGHT) |
toX | Int: Final location of the view after dragging |
Return | |
---|---|
Int | distance in pixels covered by the drag |
dragViewToX
open static fundragViewToX(
test: InstrumentationTestCase!,
v: View!,
gravity: Int,
toX: Int
): Int
Deprecated: Deprecated in Java.
Simulate touching a view and dragging it to a specified location. Only moves horizontally.
Parameters | |
---|---|
test | InstrumentationTestCase!: The test case that is being run |
v | View!: The view that should be dragged |
gravity | Int: Which part of the view to use for the initial down event. A combination of (TOP, CENTER_VERTICAL, BOTTOM) and (LEFT, CENTER_HORIZONTAL, RIGHT) |
toX | Int: Final location of the view after dragging |
Return | |
---|---|
Int | distance in pixels covered by the drag |
dragViewToY
open static fundragViewToY(
test: ActivityInstrumentationTestCase<Activity!>!,
v: View!,
gravity: Int,
toY: Int
): Int
Deprecated: android.test.ActivityInstrumentationTestCase
is deprecated in favor of android.test.ActivityInstrumentationTestCase2
, which provides more options for configuring the Activity under test
Simulate touching a view and dragging it to a specified location. Only moves vertically.
Parameters | |
---|---|
test | ActivityInstrumentationTestCase<Activity!>!: The test case that is being run |
v | View!: The view that should be dragged |
gravity | Int: Which part of the view to use for the initial down event. A combination of (TOP, CENTER_VERTICAL, BOTTOM) and (LEFT, CENTER_HORIZONTAL, RIGHT) |
toY | Int: Final location of the view after dragging |
Return | |
---|---|
Int | distance in pixels covered by the drag |
dragViewToY
open static fundragViewToY(
test: InstrumentationTestCase!,
v: View!,
gravity: Int,
toY: Int
): Int
Deprecated: Deprecated in Java.
Simulate touching a view and dragging it to a specified location. Only moves vertically.
Parameters | |
---|---|
test | InstrumentationTestCase!: The test case that is being run |
v | View!: The view that should be dragged |
gravity | Int: Which part of the view to use for the initial down event. A combination of (TOP, CENTER_VERTICAL, BOTTOM) and (LEFT, CENTER_HORIZONTAL, RIGHT) |
toY | Int: Final location of the view after dragging |
Return | |
---|---|
Int | distance in pixels covered by the drag |
longClickView
open static funlongClickView(
test: ActivityInstrumentationTestCase<Activity!>!,
v: View!
): Unit
Deprecated: android.test.ActivityInstrumentationTestCase
is deprecated in favor of android.test.ActivityInstrumentationTestCase2
, which provides more options for configuring the Activity under test
Simulate touching the center of a view, holding until it is a long press, and then releasing.
Parameters | |
---|---|
test | ActivityInstrumentationTestCase<Activity!>!: The test case that is being run |
v | View!: The view that should be clicked |
longClickView
open static funlongClickView(
test: InstrumentationTestCase!,
v: View!
): Unit
Deprecated: Deprecated in Java.
Simulate touching the center of a view, holding until it is a long press, and then releasing.
Parameters | |
---|---|
test | InstrumentationTestCase!: The test case that is being run |
v | View!: The view that should be clicked |
scrollToBottom
open static funscrollToBottom(
test: ActivityInstrumentationTestCase<Activity!>!,
v: ViewGroup!
): Unit
Deprecated: android.test.ActivityInstrumentationTestCase
is deprecated in favor of android.test.ActivityInstrumentationTestCase2
, which provides more options for configuring the Activity under test
Scroll a ViewGroup to the bottom by repeatedly calling dragQuarterScreenUp(android.test.InstrumentationTestCase,android.app.Activity)
Parameters | |
---|---|
test | ActivityInstrumentationTestCase<Activity!>!: The test case that is being run |
v | ViewGroup!: The ViewGroup that should be dragged |
scrollToBottom
open static funscrollToBottom(
test: InstrumentationTestCase!,
activity: Activity!,
v: ViewGroup!
): Unit
Deprecated: Deprecated in Java.
Scroll a ViewGroup to the bottom by repeatedly calling dragQuarterScreenUp(android.test.InstrumentationTestCase,android.app.Activity)
Parameters | |
---|---|
test | InstrumentationTestCase!: The test case that is being run |
activity | Activity!: The activity that is in the foreground of the test case |
v | ViewGroup!: The ViewGroup that should be dragged |
scrollToTop
open static funscrollToTop(
test: ActivityInstrumentationTestCase<Activity!>!,
v: ViewGroup!
): Unit
Deprecated: android.test.ActivityInstrumentationTestCase
is deprecated in favor of android.test.ActivityInstrumentationTestCase2
, which provides more options for configuring the Activity under test
Scroll a ViewGroup to the top by repeatedly calling dragQuarterScreenDown(android.test.InstrumentationTestCase,android.app.Activity)
Parameters | |
---|---|
test | ActivityInstrumentationTestCase<Activity!>!: The test case that is being run |
v | ViewGroup!: The ViewGroup that should be dragged |
scrollToTop
open static funscrollToTop(
test: InstrumentationTestCase!,
activity: Activity!,
v: ViewGroup!
): Unit
Deprecated: Deprecated in Java.
Scroll a ViewGroup to the top by repeatedly calling dragQuarterScreenDown(android.test.InstrumentationTestCase,android.app.Activity)
Parameters | |
---|---|
test | InstrumentationTestCase!: The test case that is being run |
activity | Activity!: The activity that is in the foreground of the test case |
v | ViewGroup!: The ViewGroup that should be dragged |
tapView
open static funtapView(
test: InstrumentationTestCase!,
v: View!
): Unit
Deprecated: Deprecated in Java.
Simulate touching the center of a view and releasing quickly (before the tap timeout).
Parameters | |
---|---|
test | InstrumentationTestCase!: The test case that is being run |
v | View!: The view that should be clicked |
touchAndCancelView
open static funtouchAndCancelView(
test: InstrumentationTestCase!,
v: View!
): Unit
Deprecated: Deprecated in Java.
Simulate touching the center of a view and cancelling (so no onClick should fire, etc).
Parameters | |
---|---|
test | InstrumentationTestCase!: The test case that is being run |
v | View!: The view that should be clicked |