# TouchUtils

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Deprecated in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Summary:[Ctors](https://developer.android.com/reference/android/test/TouchUtils#pubctors)\|[Methods](https://developer.android.com/reference/android/test/TouchUtils#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/test/TouchUtils#inhmethods)  

# TouchUtils

*** ** * ** ***

[Kotlin](https://developer.android.com/reference/kotlin/android/test/TouchUtils "View this page in Kotlin")\|Java

`
public


class
TouchUtils
`  
`

extends `[Object](https://developer.android.com/reference/java/lang/Object)`


``


`

|---|-------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.test.TouchUtils |

<br />

*** ** * ** ***

<br />

**This class was deprecated in API level 24.**   
Use[Espresso UI testing framework](https://developer.android.com/training/testing/ui-testing/espresso-testing)instead. New tests should be written using the[Android Testing Support Library](https://developer.android.com/tools/testing-support-library).

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                                        ||
|----------------------------------------------------------------------------------------------------|---|
| ` `[TouchUtils](https://developer.android.com/reference/android/test/TouchUtils#TouchUtils())`() ` |

|                                                                                                                                                                                                                                                                                                                                                                                                                                                          ### Public methods                                                                                                                                                                                                                                                                                                                                                                                                                                                          ||
|----------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` static void` | ` `[clickView](https://developer.android.com/reference/android/test/TouchUtils#clickView(android.test.InstrumentationTestCase,%20android.view.View))`(`[InstrumentationTestCase](https://developer.android.com/reference/android/test/InstrumentationTestCase)` test, `[View](https://developer.android.com/reference/android/view/View)` v) ` Simulate touching the center of a view and releasing.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| ` static void` | ` `[drag](https://developer.android.com/reference/android/test/TouchUtils#drag(android.test.InstrumentationTestCase,%20float,%20float,%20float,%20float,%20int))`(`[InstrumentationTestCase](https://developer.android.com/reference/android/test/InstrumentationTestCase)` test, float fromX, float toX, float fromY, float toY, int stepCount) ` Simulate touching a specific location and dragging to a new location.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| ` static void` | ` `[drag](https://developer.android.com/reference/android/test/TouchUtils#drag(android.test.ActivityInstrumentationTestCase,%20float,%20float,%20float,%20float,%20int))`(`[ActivityInstrumentationTestCase](https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase)`<T extends `[Activity](https://developer.android.com/reference/android/app/Activity)`> test, float fromX, float toX, float fromY, float toY, int stepCount) ` *This method was deprecated in API level 15.[ActivityInstrumentationTestCase](https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase)is deprecated in favor of[ActivityInstrumentationTestCase2](https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase2), which provides more options for configuring the Activity under test*                                                         |
| ` static void` | ` `[dragQuarterScreenDown](https://developer.android.com/reference/android/test/TouchUtils#dragQuarterScreenDown(android.test.InstrumentationTestCase,%20android.app.Activity))`(`[InstrumentationTestCase](https://developer.android.com/reference/android/test/InstrumentationTestCase)` test, `[Activity](https://developer.android.com/reference/android/app/Activity)` activity) ` Simulate touching in the center of the screen and dragging one quarter of the way down                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| ` static void` | ` `[dragQuarterScreenDown](https://developer.android.com/reference/android/test/TouchUtils#dragQuarterScreenDown(android.test.ActivityInstrumentationTestCase))`(`[ActivityInstrumentationTestCase](https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase)`<T extends `[Activity](https://developer.android.com/reference/android/app/Activity)`> test) ` *This method was deprecated in API level 15.[ActivityInstrumentationTestCase](https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase)is deprecated in favor of[ActivityInstrumentationTestCase2](https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase2), which provides more options for configuring the Activity under test*                                                                                                                                 |
| ` static void` | ` `[dragQuarterScreenUp](https://developer.android.com/reference/android/test/TouchUtils#dragQuarterScreenUp(android.test.ActivityInstrumentationTestCase))`(`[ActivityInstrumentationTestCase](https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase)`<T extends `[Activity](https://developer.android.com/reference/android/app/Activity)`> test) ` *This method was deprecated in API level 15.[ActivityInstrumentationTestCase](https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase)is deprecated in favor of[ActivityInstrumentationTestCase2](https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase2), which provides more options for configuring the Activity under test*                                                                                                                                     |
| ` static void` | ` `[dragQuarterScreenUp](https://developer.android.com/reference/android/test/TouchUtils#dragQuarterScreenUp(android.test.InstrumentationTestCase,%20android.app.Activity))`(`[InstrumentationTestCase](https://developer.android.com/reference/android/test/InstrumentationTestCase)` test, `[Activity](https://developer.android.com/reference/android/app/Activity)` activity) ` Simulate touching in the center of the screen and dragging one quarter of the way up                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| ` static int`  | ` `[dragViewBy](https://developer.android.com/reference/android/test/TouchUtils#dragViewBy(android.test.InstrumentationTestCase,%20android.view.View,%20int,%20int,%20int))`(`[InstrumentationTestCase](https://developer.android.com/reference/android/test/InstrumentationTestCase)` test, `[View](https://developer.android.com/reference/android/view/View)` v, int gravity, int deltaX, int deltaY) ` *This method was deprecated in API level 15.[ActivityInstrumentationTestCase](https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase)is deprecated in favor of[ActivityInstrumentationTestCase2](https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase2), which provides more options for configuring the Activity under test*                                                                                                               |
| ` static int`  | ` `[dragViewBy](https://developer.android.com/reference/android/test/TouchUtils#dragViewBy(android.test.ActivityInstrumentationTestCase,%20android.view.View,%20int,%20int,%20int))`(`[ActivityInstrumentationTestCase](https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase)`<T extends `[Activity](https://developer.android.com/reference/android/app/Activity)`> test, `[View](https://developer.android.com/reference/android/view/View)` v, int gravity, int deltaX, int deltaY) ` *This method was deprecated in API level 15.[ActivityInstrumentationTestCase](https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase)is deprecated in favor of[ActivityInstrumentationTestCase2](https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase2), which provides more options for configuring the Activity under test* |
| ` static int`  | ` `[dragViewTo](https://developer.android.com/reference/android/test/TouchUtils#dragViewTo(android.test.ActivityInstrumentationTestCase,%20android.view.View,%20int,%20int,%20int))`(`[ActivityInstrumentationTestCase](https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase)`<T extends `[Activity](https://developer.android.com/reference/android/app/Activity)`> test, `[View](https://developer.android.com/reference/android/view/View)` v, int gravity, int toX, int toY) ` *This method was deprecated in API level 15.[ActivityInstrumentationTestCase](https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase)is deprecated in favor of[ActivityInstrumentationTestCase2](https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase2), which provides more options for configuring the Activity under test*       |
| ` static int`  | ` `[dragViewTo](https://developer.android.com/reference/android/test/TouchUtils#dragViewTo(android.test.InstrumentationTestCase,%20android.view.View,%20int,%20int,%20int))`(`[InstrumentationTestCase](https://developer.android.com/reference/android/test/InstrumentationTestCase)` test, `[View](https://developer.android.com/reference/android/view/View)` v, int gravity, int toX, int toY) ` Simulate touching a view and dragging it to a specified location.                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| ` static void` | ` `[dragViewToBottom](https://developer.android.com/reference/android/test/TouchUtils#dragViewToBottom(android.test.ActivityInstrumentationTestCase,%20android.view.View))`(`[ActivityInstrumentationTestCase](https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase)`<T extends `[Activity](https://developer.android.com/reference/android/app/Activity)`> test, `[View](https://developer.android.com/reference/android/view/View)` v) ` *This method was deprecated in API level 15.[ActivityInstrumentationTestCase](https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase)is deprecated in favor of[ActivityInstrumentationTestCase2](https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase2), which provides more options for configuring the Activity under test*                                               |
| ` static void` | ` `[dragViewToBottom](https://developer.android.com/reference/android/test/TouchUtils#dragViewToBottom(android.test.InstrumentationTestCase,%20android.app.Activity,%20android.view.View,%20int))`(`[InstrumentationTestCase](https://developer.android.com/reference/android/test/InstrumentationTestCase)` test, `[Activity](https://developer.android.com/reference/android/app/Activity)` activity, `[View](https://developer.android.com/reference/android/view/View)` v, int stepCount) ` Simulate touching the center of a view and dragging to the bottom of the screen.                                                                                                                                                                                                                                                                                                                                     |
| ` static void` | ` `[dragViewToBottom](https://developer.android.com/reference/android/test/TouchUtils#dragViewToBottom(android.test.ActivityInstrumentationTestCase,%20android.view.View,%20int))`(`[ActivityInstrumentationTestCase](https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase)`<T extends `[Activity](https://developer.android.com/reference/android/app/Activity)`> test, `[View](https://developer.android.com/reference/android/view/View)` v, int stepCount) ` *This method was deprecated in API level 15.[ActivityInstrumentationTestCase](https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase)is deprecated in favor of[ActivityInstrumentationTestCase2](https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase2), which provides more options for configuring the Activity under test*                         |
| ` static void` | ` `[dragViewToBottom](https://developer.android.com/reference/android/test/TouchUtils#dragViewToBottom(android.test.InstrumentationTestCase,%20android.app.Activity,%20android.view.View))`(`[InstrumentationTestCase](https://developer.android.com/reference/android/test/InstrumentationTestCase)` test, `[Activity](https://developer.android.com/reference/android/app/Activity)` activity, `[View](https://developer.android.com/reference/android/view/View)` v) ` Simulate touching the center of a view and dragging to the bottom of the screen.                                                                                                                                                                                                                                                                                                                                                           |
| ` static void` | ` `[dragViewToTop](https://developer.android.com/reference/android/test/TouchUtils#dragViewToTop(android.test.InstrumentationTestCase,%20android.view.View))`(`[InstrumentationTestCase](https://developer.android.com/reference/android/test/InstrumentationTestCase)` test, `[View](https://developer.android.com/reference/android/view/View)` v) ` Simulate touching the center of a view and dragging to the top of the screen.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| ` static void` | ` `[dragViewToTop](https://developer.android.com/reference/android/test/TouchUtils#dragViewToTop(android.test.ActivityInstrumentationTestCase,%20android.view.View))`(`[ActivityInstrumentationTestCase](https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase)`<T extends `[Activity](https://developer.android.com/reference/android/app/Activity)`> test, `[View](https://developer.android.com/reference/android/view/View)` v) ` *This method was deprecated in API level 15.[ActivityInstrumentationTestCase](https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase)is deprecated in favor of[ActivityInstrumentationTestCase2](https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase2), which provides more options for configuring the Activity under test*                                                     |
| ` static void` | ` `[dragViewToTop](https://developer.android.com/reference/android/test/TouchUtils#dragViewToTop(android.test.InstrumentationTestCase,%20android.view.View,%20int))`(`[InstrumentationTestCase](https://developer.android.com/reference/android/test/InstrumentationTestCase)` test, `[View](https://developer.android.com/reference/android/view/View)` v, int stepCount) ` Simulate touching the center of a view and dragging to the top of the screen.                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| ` static void` | ` `[dragViewToTop](https://developer.android.com/reference/android/test/TouchUtils#dragViewToTop(android.test.ActivityInstrumentationTestCase,%20android.view.View,%20int))`(`[ActivityInstrumentationTestCase](https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase)`<T extends `[Activity](https://developer.android.com/reference/android/app/Activity)`> test, `[View](https://developer.android.com/reference/android/view/View)` v, int stepCount) ` *This method was deprecated in API level 15.[ActivityInstrumentationTestCase](https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase)is deprecated in favor of[ActivityInstrumentationTestCase2](https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase2), which provides more options for configuring the Activity under test*                               |
| ` static int`  | ` `[dragViewToX](https://developer.android.com/reference/android/test/TouchUtils#dragViewToX(android.test.InstrumentationTestCase,%20android.view.View,%20int,%20int))`(`[InstrumentationTestCase](https://developer.android.com/reference/android/test/InstrumentationTestCase)` test, `[View](https://developer.android.com/reference/android/view/View)` v, int gravity, int toX) ` Simulate touching a view and dragging it to a specified location.                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| ` static int`  | ` `[dragViewToX](https://developer.android.com/reference/android/test/TouchUtils#dragViewToX(android.test.ActivityInstrumentationTestCase,%20android.view.View,%20int,%20int))`(`[ActivityInstrumentationTestCase](https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase)`<T extends `[Activity](https://developer.android.com/reference/android/app/Activity)`> test, `[View](https://developer.android.com/reference/android/view/View)` v, int gravity, int toX) ` *This method was deprecated in API level 15.[ActivityInstrumentationTestCase](https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase)is deprecated in favor of[ActivityInstrumentationTestCase2](https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase2), which provides more options for configuring the Activity under test*                     |
| ` static int`  | ` `[dragViewToY](https://developer.android.com/reference/android/test/TouchUtils#dragViewToY(android.test.ActivityInstrumentationTestCase,%20android.view.View,%20int,%20int))`(`[ActivityInstrumentationTestCase](https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase)`<T extends `[Activity](https://developer.android.com/reference/android/app/Activity)`> test, `[View](https://developer.android.com/reference/android/view/View)` v, int gravity, int toY) ` *This method was deprecated in API level 15.[ActivityInstrumentationTestCase](https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase)is deprecated in favor of[ActivityInstrumentationTestCase2](https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase2), which provides more options for configuring the Activity under test*                     |
| ` static int`  | ` `[dragViewToY](https://developer.android.com/reference/android/test/TouchUtils#dragViewToY(android.test.InstrumentationTestCase,%20android.view.View,%20int,%20int))`(`[InstrumentationTestCase](https://developer.android.com/reference/android/test/InstrumentationTestCase)` test, `[View](https://developer.android.com/reference/android/view/View)` v, int gravity, int toY) ` Simulate touching a view and dragging it to a specified location.                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| ` static void` | ` `[longClickView](https://developer.android.com/reference/android/test/TouchUtils#longClickView(android.test.ActivityInstrumentationTestCase,%20android.view.View))`(`[ActivityInstrumentationTestCase](https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase)`<T extends `[Activity](https://developer.android.com/reference/android/app/Activity)`> test, `[View](https://developer.android.com/reference/android/view/View)` v) ` *This method was deprecated in API level 15.[ActivityInstrumentationTestCase](https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase)is deprecated in favor of[ActivityInstrumentationTestCase2](https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase2), which provides more options for configuring the Activity under test*                                                     |
| ` static void` | ` `[longClickView](https://developer.android.com/reference/android/test/TouchUtils#longClickView(android.test.InstrumentationTestCase,%20android.view.View))`(`[InstrumentationTestCase](https://developer.android.com/reference/android/test/InstrumentationTestCase)` test, `[View](https://developer.android.com/reference/android/view/View)` v) ` Simulate touching the center of a view, holding until it is a long press, and then releasing.                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| ` static void` | ` `[scrollToBottom](https://developer.android.com/reference/android/test/TouchUtils#scrollToBottom(android.test.ActivityInstrumentationTestCase,%20android.view.ViewGroup))`(`[ActivityInstrumentationTestCase](https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase)`<T extends `[Activity](https://developer.android.com/reference/android/app/Activity)`> test, `[ViewGroup](https://developer.android.com/reference/android/view/ViewGroup)` v) ` *This method was deprecated in API level 15.[ActivityInstrumentationTestCase](https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase)is deprecated in favor of[ActivityInstrumentationTestCase2](https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase2), which provides more options for configuring the Activity under test*                                    |
| ` static void` | ` `[scrollToBottom](https://developer.android.com/reference/android/test/TouchUtils#scrollToBottom(android.test.InstrumentationTestCase,%20android.app.Activity,%20android.view.ViewGroup))`(`[InstrumentationTestCase](https://developer.android.com/reference/android/test/InstrumentationTestCase)` test, `[Activity](https://developer.android.com/reference/android/app/Activity)` activity, `[ViewGroup](https://developer.android.com/reference/android/view/ViewGroup)` v) ` Scroll a ViewGroup to the bottom by repeatedly calling[dragQuarterScreenUp(android.test.InstrumentationTestCase, android.app.Activity)](https://developer.android.com/reference/android/test/TouchUtils#dragQuarterScreenUp(android.test.InstrumentationTestCase,%20android.app.Activity))                                                                                                                                      |
| ` static void` | ` `[scrollToTop](https://developer.android.com/reference/android/test/TouchUtils#scrollToTop(android.test.ActivityInstrumentationTestCase,%20android.view.ViewGroup))`(`[ActivityInstrumentationTestCase](https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase)`<T extends `[Activity](https://developer.android.com/reference/android/app/Activity)`> test, `[ViewGroup](https://developer.android.com/reference/android/view/ViewGroup)` v) ` *This method was deprecated in API level 15.[ActivityInstrumentationTestCase](https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase)is deprecated in favor of[ActivityInstrumentationTestCase2](https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase2), which provides more options for configuring the Activity under test*                                          |
| ` static void` | ` `[scrollToTop](https://developer.android.com/reference/android/test/TouchUtils#scrollToTop(android.test.InstrumentationTestCase,%20android.app.Activity,%20android.view.ViewGroup))`(`[InstrumentationTestCase](https://developer.android.com/reference/android/test/InstrumentationTestCase)` test, `[Activity](https://developer.android.com/reference/android/app/Activity)` activity, `[ViewGroup](https://developer.android.com/reference/android/view/ViewGroup)` v) ` Scroll a ViewGroup to the top by repeatedly calling[dragQuarterScreenDown(android.test.InstrumentationTestCase, android.app.Activity)](https://developer.android.com/reference/android/test/TouchUtils#dragQuarterScreenDown(android.test.InstrumentationTestCase,%20android.app.Activity))                                                                                                                                           |
| ` static void` | ` `[tapView](https://developer.android.com/reference/android/test/TouchUtils#tapView(android.test.InstrumentationTestCase,%20android.view.View))`(`[InstrumentationTestCase](https://developer.android.com/reference/android/test/InstrumentationTestCase)` test, `[View](https://developer.android.com/reference/android/view/View)` v) ` Simulate touching the center of a view and releasing quickly (before the tap timeout).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| ` static void` | ` `[touchAndCancelView](https://developer.android.com/reference/android/test/TouchUtils#touchAndCancelView(android.test.InstrumentationTestCase,%20android.view.View))`(`[InstrumentationTestCase](https://developer.android.com/reference/android/test/InstrumentationTestCase)` test, `[View](https://developer.android.com/reference/android/view/View)` v) ` Simulate touching the center of a view and cancelling (so no onClick should fire, etc).                                                                                                                                                                                                                                                                                                                                                                                                                                                             |

| ### Inherited methods |
|-----------------------|---|
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](https://developer.android.com/reference/java/lang/Object#finalize())`() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.                                                          | | ` final `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long,%20int))`(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed. | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long))`(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed.                   | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait())`() ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*.                                                                                             | ||

## Public constructors

### TouchUtils

```
public TouchUtils ()
```

<br />

<br />

## Public methods

### clickView

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static void clickView (InstrumentationTestCase test, 
                View v)
```

Simulate touching the center of a view and releasing.

<br />

|                                Parameters                                 ||
|--------|-------------------------------------------------------------------|
| `test` | `InstrumentationTestCase`: The test case that is being run <br /> |
| `v`    | `View`: The view that should be clicked <br />                    |

### drag

Added in[API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Deprecated in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static void drag (InstrumentationTestCase test, 
                float fromX, 
                float toX, 
                float fromY, 
                float toY, 
                int stepCount)
```

Simulate touching a specific location and dragging to a new location.

<br />

|                                        Parameters                                        ||
|-------------|-----------------------------------------------------------------------------|
| `test`      | `InstrumentationTestCase`: The test case that is being run <br />           |
| `fromX`     | `float`: X coordinate of the initial touch, in screen coordinates <br />    |
| `toX`       | `float`: Xcoordinate of the drag destination, in screen coordinates <br />  |
| `fromY`     | `float`: X coordinate of the initial touch, in screen coordinates <br />    |
| `toY`       | `float`: Y coordinate of the drag destination, in screen coordinates <br /> |
| `stepCount` | `int`: How many move steps to include in the drag <br />                    |

### drag

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Deprecated in[API level 15](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static void drag (ActivityInstrumentationTestCase<T extends Activity> test, 
                float fromX, 
                float toX, 
                float fromY, 
                float toY, 
                int stepCount)
```

<br />

**This method was deprecated in API level 15.**   
[ActivityInstrumentationTestCase](https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase)is deprecated in favor of[ActivityInstrumentationTestCase2](https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase2), which provides more options for configuring the Activity under test

Simulate touching a specific location and dragging to a new location.

<br />

|                                        Parameters                                        ||
|-------------|-----------------------------------------------------------------------------|
| `test`      | `ActivityInstrumentationTestCase`: The test case that is being run <br />   |
| `fromX`     | `float`: X coordinate of the initial touch, in screen coordinates <br />    |
| `toX`       | `float`: Xcoordinate of the drag destination, in screen coordinates <br />  |
| `fromY`     | `float`: X coordinate of the initial touch, in screen coordinates <br />    |
| `toY`       | `float`: Y coordinate of the drag destination, in screen coordinates <br /> |
| `stepCount` | `int`: How many move steps to include in the drag <br />                    |

### dragQuarterScreenDown

Added in[API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Deprecated in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static void dragQuarterScreenDown (InstrumentationTestCase test, 
                Activity activity)
```

Simulate touching in the center of the screen and dragging one quarter of the way down

<br />

|                                       Parameters                                       ||
|------------|----------------------------------------------------------------------------|
| `test`     | `InstrumentationTestCase`: The test case that is being run <br />          |
| `activity` | `Activity`: The activity that is in the foreground of the test case <br /> |

### dragQuarterScreenDown

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Deprecated in[API level 15](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static void dragQuarterScreenDown (ActivityInstrumentationTestCase<T extends Activity> test)
```

<br />

**This method was deprecated in API level 15.**   
[ActivityInstrumentationTestCase](https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase)is deprecated in favor of[ActivityInstrumentationTestCase2](https://developer.android.com/reference/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

<br />

|                                    Parameters                                     ||
|--------|---------------------------------------------------------------------------|
| `test` | `ActivityInstrumentationTestCase`: The test case that is being run <br /> |

### dragQuarterScreenUp

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Deprecated in[API level 15](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static void dragQuarterScreenUp (ActivityInstrumentationTestCase<T extends Activity> test)
```

<br />

**This method was deprecated in API level 15.**   
[ActivityInstrumentationTestCase](https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase)is deprecated in favor of[ActivityInstrumentationTestCase2](https://developer.android.com/reference/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

<br />

|                                    Parameters                                     ||
|--------|---------------------------------------------------------------------------|
| `test` | `ActivityInstrumentationTestCase`: The test case that is being run <br /> |

### dragQuarterScreenUp

Added in[API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Deprecated in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static void dragQuarterScreenUp (InstrumentationTestCase test, 
                Activity activity)
```

Simulate touching in the center of the screen and dragging one quarter of the way up

<br />

|                                       Parameters                                       ||
|------------|----------------------------------------------------------------------------|
| `test`     | `InstrumentationTestCase`: The test case that is being run <br />          |
| `activity` | `Activity`: The activity that is in the foreground of the test case <br /> |

### dragViewBy

Added in[API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Deprecated in[API level 15](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static int dragViewBy (InstrumentationTestCase test, 
                View v, 
                int gravity, 
                int deltaX, 
                int deltaY)
```

<br />

**This method was deprecated in API level 15.**   
[ActivityInstrumentationTestCase](https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase)is deprecated in favor of[ActivityInstrumentationTestCase2](https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase2), which provides more options for configuring the Activity under test

Simulate touching a view and dragging it by the specified amount.

<br />

|                                                                               Parameters                                                                                ||
|-----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `test`    | `InstrumentationTestCase`: The test case that is being run <br />                                                                                            |
| `v`       | `View`: The view that should be dragged <br />                                                                                                               |
| `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) <br /> |
| `deltaX`  | `int`: Amount to drag horizontally in pixels <br />                                                                                                          |
| `deltaY`  | `int`: Amount to drag vertically in pixels <br />                                                                                                            |

|                       Returns                        ||
|-------|-----------------------------------------------|
| `int` | distance in pixels covered by the drag <br /> |

### dragViewBy

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Deprecated in[API level 15](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static int dragViewBy (ActivityInstrumentationTestCase<T extends Activity> test, 
                View v, 
                int gravity, 
                int deltaX, 
                int deltaY)
```

<br />

**This method was deprecated in API level 15.**   
[ActivityInstrumentationTestCase](https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase)is deprecated in favor of[ActivityInstrumentationTestCase2](https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase2), which provides more options for configuring the Activity under test

Simulate touching a view and dragging it by the specified amount.

<br />

|                                                                               Parameters                                                                                ||
|-----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `test`    | `ActivityInstrumentationTestCase`: The test case that is being run <br />                                                                                    |
| `v`       | `View`: The view that should be dragged <br />                                                                                                               |
| `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) <br /> |
| `deltaX`  | `int`: Amount to drag horizontally in pixels <br />                                                                                                          |
| `deltaY`  | `int`: Amount to drag vertically in pixels <br />                                                                                                            |

|                       Returns                        ||
|-------|-----------------------------------------------|
| `int` | distance in pixels covered by the drag <br /> |

### dragViewTo

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Deprecated in[API level 15](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static int dragViewTo (ActivityInstrumentationTestCase<T extends Activity> test, 
                View v, 
                int gravity, 
                int toX, 
                int toY)
```

<br />

**This method was deprecated in API level 15.**   
[ActivityInstrumentationTestCase](https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase)is deprecated in favor of[ActivityInstrumentationTestCase2](https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase2), which provides more options for configuring the Activity under test

Simulate touching a view and dragging it to a specified location.

<br />

|                                                                               Parameters                                                                                ||
|-----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `test`    | `ActivityInstrumentationTestCase`: The test case that is being run <br />                                                                                    |
| `v`       | `View`: The view that should be dragged <br />                                                                                                               |
| `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) <br /> |
| `toX`     | `int`: Final location of the view after dragging <br />                                                                                                      |
| `toY`     | `int`: Final location of the view after dragging <br />                                                                                                      |

|                       Returns                        ||
|-------|-----------------------------------------------|
| `int` | distance in pixels covered by the drag <br /> |

### dragViewTo

Added in[API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Deprecated in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static int dragViewTo (InstrumentationTestCase test, 
                View v, 
                int gravity, 
                int toX, 
                int toY)
```

Simulate touching a view and dragging it to a specified location.

<br />

|                                                                               Parameters                                                                                ||
|-----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `test`    | `InstrumentationTestCase`: The test case that is being run <br />                                                                                            |
| `v`       | `View`: The view that should be dragged <br />                                                                                                               |
| `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) <br /> |
| `toX`     | `int`: Final location of the view after dragging <br />                                                                                                      |
| `toY`     | `int`: Final location of the view after dragging <br />                                                                                                      |

|                       Returns                        ||
|-------|-----------------------------------------------|
| `int` | distance in pixels covered by the drag <br /> |

### dragViewToBottom

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Deprecated in[API level 15](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static void dragViewToBottom (ActivityInstrumentationTestCase<T extends Activity> test, 
                View v)
```

<br />

**This method was deprecated in API level 15.**   
[ActivityInstrumentationTestCase](https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase)is deprecated in favor of[ActivityInstrumentationTestCase2](https://developer.android.com/reference/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.

<br />

|                                    Parameters                                     ||
|--------|---------------------------------------------------------------------------|
| `test` | `ActivityInstrumentationTestCase`: The test case that is being run <br /> |
| `v`    | `View`: The view that should be dragged <br />                            |

### dragViewToBottom

Added in[API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Deprecated in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static void dragViewToBottom (InstrumentationTestCase test, 
                Activity activity, 
                View v, 
                int stepCount)
```

Simulate touching the center of a view and dragging to the bottom of the screen.

<br />

|                                       Parameters                                        ||
|-------------|----------------------------------------------------------------------------|
| `test`      | `InstrumentationTestCase`: The test case that is being run <br />          |
| `activity`  | `Activity`: The activity that is in the foreground of the test case <br /> |
| `v`         | `View`: The view that should be dragged <br />                             |
| `stepCount` | `int`: How many move steps to include in the drag <br />                   |

### dragViewToBottom

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Deprecated in[API level 15](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static void dragViewToBottom (ActivityInstrumentationTestCase<T extends Activity> test, 
                View v, 
                int stepCount)
```

<br />

**This method was deprecated in API level 15.**   
[ActivityInstrumentationTestCase](https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase)is deprecated in favor of[ActivityInstrumentationTestCase2](https://developer.android.com/reference/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.

<br />

|                                       Parameters                                       ||
|-------------|---------------------------------------------------------------------------|
| `test`      | `ActivityInstrumentationTestCase`: The test case that is being run <br /> |
| `v`         | `View`: The view that should be dragged <br />                            |
| `stepCount` | `int`: How many move steps to include in the drag <br />                  |

### dragViewToBottom

Added in[API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Deprecated in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static void dragViewToBottom (InstrumentationTestCase test, 
                Activity activity, 
                View v)
```

Simulate touching the center of a view and dragging to the bottom of the screen.

<br />

|                                       Parameters                                       ||
|------------|----------------------------------------------------------------------------|
| `test`     | `InstrumentationTestCase`: The test case that is being run <br />          |
| `activity` | `Activity`: The activity that is in the foreground of the test case <br /> |
| `v`        | `View`: The view that should be dragged <br />                             |

### dragViewToTop

Added in[API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Deprecated in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static void dragViewToTop (InstrumentationTestCase test, 
                View v)
```

Simulate touching the center of a view and dragging to the top of the screen.

<br />

|                                Parameters                                 ||
|--------|-------------------------------------------------------------------|
| `test` | `InstrumentationTestCase`: The test case that is being run <br /> |
| `v`    | `View`: The view that should be dragged <br />                    |

### dragViewToTop

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Deprecated in[API level 15](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static void dragViewToTop (ActivityInstrumentationTestCase<T extends Activity> test, 
                View v)
```

<br />

**This method was deprecated in API level 15.**   
[ActivityInstrumentationTestCase](https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase)is deprecated in favor of[ActivityInstrumentationTestCase2](https://developer.android.com/reference/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.

<br />

|                                    Parameters                                     ||
|--------|---------------------------------------------------------------------------|
| `test` | `ActivityInstrumentationTestCase`: The test case that is being run <br /> |
| `v`    | `View`: The view that should be dragged <br />                            |

### dragViewToTop

Added in[API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Deprecated in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static void dragViewToTop (InstrumentationTestCase test, 
                View v, 
                int stepCount)
```

Simulate touching the center of a view and dragging to the top of the screen.

<br />

|                                   Parameters                                   ||
|-------------|-------------------------------------------------------------------|
| `test`      | `InstrumentationTestCase`: The test case that is being run <br /> |
| `v`         | `View`: The view that should be dragged <br />                    |
| `stepCount` | `int`: How many move steps to include in the drag <br />          |

### dragViewToTop

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Deprecated in[API level 15](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static void dragViewToTop (ActivityInstrumentationTestCase<T extends Activity> test, 
                View v, 
                int stepCount)
```

<br />

**This method was deprecated in API level 15.**   
[ActivityInstrumentationTestCase](https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase)is deprecated in favor of[ActivityInstrumentationTestCase2](https://developer.android.com/reference/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.

<br />

|                                       Parameters                                       ||
|-------------|---------------------------------------------------------------------------|
| `test`      | `ActivityInstrumentationTestCase`: The test case that is being run <br /> |
| `v`         | `View`: The view that should be dragged <br />                            |
| `stepCount` | `int`: How many move steps to include in the drag <br />                  |

### dragViewToX

Added in[API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Deprecated in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static int dragViewToX (InstrumentationTestCase test, 
                View v, 
                int gravity, 
                int toX)
```

Simulate touching a view and dragging it to a specified location. Only moves horizontally.

<br />

|                                                                               Parameters                                                                                ||
|-----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `test`    | `InstrumentationTestCase`: The test case that is being run <br />                                                                                            |
| `v`       | `View`: The view that should be dragged <br />                                                                                                               |
| `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) <br /> |
| `toX`     | `int`: Final location of the view after dragging <br />                                                                                                      |

|                       Returns                        ||
|-------|-----------------------------------------------|
| `int` | distance in pixels covered by the drag <br /> |

### dragViewToX

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Deprecated in[API level 15](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static int dragViewToX (ActivityInstrumentationTestCase<T extends Activity> test, 
                View v, 
                int gravity, 
                int toX)
```

<br />

**This method was deprecated in API level 15.**   
[ActivityInstrumentationTestCase](https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase)is deprecated in favor of[ActivityInstrumentationTestCase2](https://developer.android.com/reference/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.

<br />

|                                                                               Parameters                                                                                ||
|-----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `test`    | `ActivityInstrumentationTestCase`: The test case that is being run <br />                                                                                    |
| `v`       | `View`: The view that should be dragged <br />                                                                                                               |
| `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) <br /> |
| `toX`     | `int`: Final location of the view after dragging <br />                                                                                                      |

|                       Returns                        ||
|-------|-----------------------------------------------|
| `int` | distance in pixels covered by the drag <br /> |

### dragViewToY

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Deprecated in[API level 15](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static int dragViewToY (ActivityInstrumentationTestCase<T extends Activity> test, 
                View v, 
                int gravity, 
                int toY)
```

<br />

**This method was deprecated in API level 15.**   
[ActivityInstrumentationTestCase](https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase)is deprecated in favor of[ActivityInstrumentationTestCase2](https://developer.android.com/reference/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.

<br />

|                                                                               Parameters                                                                                ||
|-----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `test`    | `ActivityInstrumentationTestCase`: The test case that is being run <br />                                                                                    |
| `v`       | `View`: The view that should be dragged <br />                                                                                                               |
| `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) <br /> |
| `toY`     | `int`: Final location of the view after dragging <br />                                                                                                      |

|                       Returns                        ||
|-------|-----------------------------------------------|
| `int` | distance in pixels covered by the drag <br /> |

### dragViewToY

Added in[API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Deprecated in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static int dragViewToY (InstrumentationTestCase test, 
                View v, 
                int gravity, 
                int toY)
```

Simulate touching a view and dragging it to a specified location. Only moves vertically.

<br />

|                                                                               Parameters                                                                                ||
|-----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `test`    | `InstrumentationTestCase`: The test case that is being run <br />                                                                                            |
| `v`       | `View`: The view that should be dragged <br />                                                                                                               |
| `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) <br /> |
| `toY`     | `int`: Final location of the view after dragging <br />                                                                                                      |

|                       Returns                        ||
|-------|-----------------------------------------------|
| `int` | distance in pixels covered by the drag <br /> |

### longClickView

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Deprecated in[API level 15](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static void longClickView (ActivityInstrumentationTestCase<T extends Activity> test, 
                View v)
```

<br />

**This method was deprecated in API level 15.**   
[ActivityInstrumentationTestCase](https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase)is deprecated in favor of[ActivityInstrumentationTestCase2](https://developer.android.com/reference/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.

<br />

|                                    Parameters                                     ||
|--------|---------------------------------------------------------------------------|
| `test` | `ActivityInstrumentationTestCase`: The test case that is being run <br /> |
| `v`    | `View`: The view that should be clicked <br />                            |

### longClickView

Added in[API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Deprecated in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static void longClickView (InstrumentationTestCase test, 
                View v)
```

Simulate touching the center of a view, holding until it is a long press, and then releasing.

<br />

|                                Parameters                                 ||
|--------|-------------------------------------------------------------------|
| `test` | `InstrumentationTestCase`: The test case that is being run <br /> |
| `v`    | `View`: The view that should be clicked <br />                    |

### scrollToBottom

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Deprecated in[API level 15](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static void scrollToBottom (ActivityInstrumentationTestCase<T extends Activity> test, 
                ViewGroup v)
```

<br />

**This method was deprecated in API level 15.**   
[ActivityInstrumentationTestCase](https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase)is deprecated in favor of[ActivityInstrumentationTestCase2](https://developer.android.com/reference/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)](https://developer.android.com/reference/android/test/TouchUtils#dragQuarterScreenUp(android.test.InstrumentationTestCase,%20android.app.Activity))

<br />

|                                    Parameters                                     ||
|--------|---------------------------------------------------------------------------|
| `test` | `ActivityInstrumentationTestCase`: The test case that is being run <br /> |
| `v`    | `ViewGroup`: The ViewGroup that should be dragged <br />                  |

### scrollToBottom

Added in[API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Deprecated in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static void scrollToBottom (InstrumentationTestCase test, 
                Activity activity, 
                ViewGroup v)
```

Scroll a ViewGroup to the bottom by repeatedly calling[dragQuarterScreenUp(android.test.InstrumentationTestCase, android.app.Activity)](https://developer.android.com/reference/android/test/TouchUtils#dragQuarterScreenUp(android.test.InstrumentationTestCase,%20android.app.Activity))

<br />

|                                       Parameters                                       ||
|------------|----------------------------------------------------------------------------|
| `test`     | `InstrumentationTestCase`: The test case that is being run <br />          |
| `activity` | `Activity`: The activity that is in the foreground of the test case <br /> |
| `v`        | `ViewGroup`: The ViewGroup that should be dragged <br />                   |

### scrollToTop

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Deprecated in[API level 15](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static void scrollToTop (ActivityInstrumentationTestCase<T extends Activity> test, 
                ViewGroup v)
```

<br />

**This method was deprecated in API level 15.**   
[ActivityInstrumentationTestCase](https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase)is deprecated in favor of[ActivityInstrumentationTestCase2](https://developer.android.com/reference/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)](https://developer.android.com/reference/android/test/TouchUtils#dragQuarterScreenDown(android.test.InstrumentationTestCase,%20android.app.Activity))

<br />

|                                    Parameters                                     ||
|--------|---------------------------------------------------------------------------|
| `test` | `ActivityInstrumentationTestCase`: The test case that is being run <br /> |
| `v`    | `ViewGroup`: The ViewGroup that should be dragged <br />                  |

### scrollToTop

Added in[API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Deprecated in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static void scrollToTop (InstrumentationTestCase test, 
                Activity activity, 
                ViewGroup v)
```

Scroll a ViewGroup to the top by repeatedly calling[dragQuarterScreenDown(android.test.InstrumentationTestCase, android.app.Activity)](https://developer.android.com/reference/android/test/TouchUtils#dragQuarterScreenDown(android.test.InstrumentationTestCase,%20android.app.Activity))

<br />

|                                       Parameters                                       ||
|------------|----------------------------------------------------------------------------|
| `test`     | `InstrumentationTestCase`: The test case that is being run <br />          |
| `activity` | `Activity`: The activity that is in the foreground of the test case <br /> |
| `v`        | `ViewGroup`: The ViewGroup that should be dragged <br />                   |

### tapView

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static void tapView (InstrumentationTestCase test, 
                View v)
```

Simulate touching the center of a view and releasing quickly (before the tap timeout).

<br />

|                                Parameters                                 ||
|--------|-------------------------------------------------------------------|
| `test` | `InstrumentationTestCase`: The test case that is being run <br /> |
| `v`    | `View`: The view that should be clicked <br />                    |

### touchAndCancelView

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static void touchAndCancelView (InstrumentationTestCase test, 
                View v)
```

Simulate touching the center of a view and cancelling (so no onClick should fire, etc).

<br />

|                                Parameters                                 ||
|--------|-------------------------------------------------------------------|
| `test` | `InstrumentationTestCase`: The test case that is being run <br /> |
| `v`    | `View`: The view that should be clicked <br />                    |