# androidx.test.espresso.device.action

# androidx.test.espresso.device.action

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/test/espresso/device/action/package-summary "View this page in Java")

## Interfaces

|------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------|
| [DeviceAction](https://developer.android.com/reference/kotlin/androidx/test/espresso/device/action/DeviceAction) | Responsible for performing an interaction on the given device. |

## Enums

|----------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------|
| [ScreenOrientation](https://developer.android.com/reference/kotlin/androidx/test/espresso/device/action/ScreenOrientation) | Enum for screen orientations a device can be set to. |

## Top-level functions summary

|------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [DeviceAction](https://developer.android.com/reference/kotlin/androidx/test/espresso/device/action/DeviceAction) | [setBookMode](https://developer.android.com/reference/kotlin/androidx/test/espresso/device/action/package-summary#setBookMode())`()` Set device screen to be folded with the hinge in the vertical position.                                                                                                                                                                                                                                                                                                                                                                      |
| [DeviceAction](https://developer.android.com/reference/kotlin/androidx/test/espresso/device/action/DeviceAction) | [setClosedMode](https://developer.android.com/reference/kotlin/androidx/test/espresso/device/action/package-summary#setClosedMode())`()` Set device screen to be closed.                                                                                                                                                                                                                                                                                                                                                                                                          |
| [DeviceAction](https://developer.android.com/reference/kotlin/androidx/test/espresso/device/action/DeviceAction) | [setDisplaySize](https://developer.android.com/reference/kotlin/androidx/test/espresso/device/action/package-summary#setDisplaySize(androidx.test.espresso.device.sizeclass.WidthSizeClass,androidx.test.espresso.device.sizeclass.HeightSizeClass))`(` ` widthSizeClass: `[WidthSizeClass](https://developer.android.com/reference/kotlin/androidx/test/espresso/device/sizeclass/WidthSizeClass)`,` ` heightSizeClass: `[HeightSizeClass](https://developer.android.com/reference/kotlin/androidx/test/espresso/device/sizeclass/HeightSizeClass) `)` Set device's window size. |
| [DeviceAction](https://developer.android.com/reference/kotlin/androidx/test/espresso/device/action/DeviceAction) | [setFlatMode](https://developer.android.com/reference/kotlin/androidx/test/espresso/device/action/package-summary#setFlatMode())`()` Set device screen to be completely flat, like a tablet.                                                                                                                                                                                                                                                                                                                                                                                      |
| [DeviceAction](https://developer.android.com/reference/kotlin/androidx/test/espresso/device/action/DeviceAction) | [setScreenOrientation](https://developer.android.com/reference/kotlin/androidx/test/espresso/device/action/package-summary#setScreenOrientation(androidx.test.espresso.device.action.ScreenOrientation))`(orientation: `[ScreenOrientation](https://developer.android.com/reference/kotlin/androidx/test/espresso/device/action/ScreenOrientation)`)` Set device's screen orientation.                                                                                                                                                                                            |
| [DeviceAction](https://developer.android.com/reference/kotlin/androidx/test/espresso/device/action/DeviceAction) | [setTabletopMode](https://developer.android.com/reference/kotlin/androidx/test/espresso/device/action/package-summary#setTabletopMode())`()` Set device screen to be folded with the hinge in the horizontal position.                                                                                                                                                                                                                                                                                                                                                            |

## Top-level functions

### setBookMode

Artifact:[androidx.test.espresso:espresso-device](https://developer.android.com/jetpack/androidx/releases/test-espresso)  
[View Source](https://cs.android.com/search?q=file:androidx/test/espresso/device/action/DeviceActions.kt+function:setBookMode)  

```
fun setBookMode(): DeviceAction
```

Set device screen to be folded with the hinge in the vertical position. For details on foldable postures, see https://developer.android.com/guide/topics/large-screens/learn-about-foldables#foldable_postures

This action is for foldable devices only. Currently only supported for tests run on Android Emulators.  

|                                                                                                  Throws                                                                                                   |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------|
| [androidx.test.platform.device.UnsupportedDeviceOperationException](https://developer.android.com/reference/kotlin/androidx/test/platform/device/UnsupportedDeviceOperationException)                     | if used on a real device.               |
| [androidx.test.espresso.device.controller.DeviceControllerOperationException](https://developer.android.com/reference/kotlin/androidx/test/espresso/device/controller/DeviceControllerOperationException) | when called on a non-foldable Emulator. |

### setClosedMode

Artifact:[androidx.test.espresso:espresso-device](https://developer.android.com/jetpack/androidx/releases/test-espresso)  
[View Source](https://cs.android.com/search?q=file:androidx/test/espresso/device/action/DeviceActions.kt+function:setClosedMode)  

```
fun setClosedMode(): DeviceAction
```

Set device screen to be closed.

This action is for foldable devices only. Currently only supported for tests run on Android Emulators.  

|                                                                                                  Throws                                                                                                   |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------|
| [androidx.test.platform.device.UnsupportedDeviceOperationException](https://developer.android.com/reference/kotlin/androidx/test/platform/device/UnsupportedDeviceOperationException)                     | if used on a real device.               |
| [androidx.test.espresso.device.controller.DeviceControllerOperationException](https://developer.android.com/reference/kotlin/androidx/test/espresso/device/controller/DeviceControllerOperationException) | when called on a non-foldable Emulator. |

### setDisplaySize

Artifact:[androidx.test.espresso:espresso-device](https://developer.android.com/jetpack/androidx/releases/test-espresso)  
[View Source](https://cs.android.com/search?q=file:androidx/test/espresso/device/action/DeviceActions.kt+function:setDisplaySize)  

```
fun setDisplaySize(
    widthSizeClass: WidthSizeClass,
    heightSizeClass: HeightSizeClass
): DeviceAction
```

Set device's window size.  

|                                                                  Parameters                                                                  |
|----------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------|
| `widthSizeClass: `[WidthSizeClass](https://developer.android.com/reference/kotlin/androidx/test/espresso/device/sizeclass/WidthSizeClass)    | the window width to set the device to  |
| `heightSizeClass: `[HeightSizeClass](https://developer.android.com/reference/kotlin/androidx/test/espresso/device/sizeclass/HeightSizeClass) | the window height to set the device to |

### setFlatMode

Artifact:[androidx.test.espresso:espresso-device](https://developer.android.com/jetpack/androidx/releases/test-espresso)  
[View Source](https://cs.android.com/search?q=file:androidx/test/espresso/device/action/DeviceActions.kt+function:setFlatMode)  

```
fun setFlatMode(): DeviceAction
```

Set device screen to be completely flat, like a tablet. For details on foldable postures, see https://developer.android.com/guide/topics/large-screens/learn-about-foldables#foldable_postures

This action is for foldable devices only. Currently only supported for tests run on Android Emulators.  

|                                                                                                  Throws                                                                                                   |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------|
| [androidx.test.platform.device.UnsupportedDeviceOperationException](https://developer.android.com/reference/kotlin/androidx/test/platform/device/UnsupportedDeviceOperationException)                     | if used on a real device.               |
| [androidx.test.espresso.device.controller.DeviceControllerOperationException](https://developer.android.com/reference/kotlin/androidx/test/espresso/device/controller/DeviceControllerOperationException) | when called on a non-foldable Emulator. |

### setScreenOrientation

Artifact:[androidx.test.espresso:espresso-device](https://developer.android.com/jetpack/androidx/releases/test-espresso)  
[View Source](https://cs.android.com/search?q=file:androidx/test/espresso/device/action/DeviceActions.kt+function:setScreenOrientation)  

```
fun setScreenOrientation(orientation: ScreenOrientation): DeviceAction
```

Set device's screen orientation.  

|                                                                Parameters                                                                 |
|-------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------|
| `orientation: `[ScreenOrientation](https://developer.android.com/reference/kotlin/androidx/test/espresso/device/action/ScreenOrientation) | the orientation to set the device to (portait or landscape) |

### setTabletopMode

Artifact:[androidx.test.espresso:espresso-device](https://developer.android.com/jetpack/androidx/releases/test-espresso)  
[View Source](https://cs.android.com/search?q=file:androidx/test/espresso/device/action/DeviceActions.kt+function:setTabletopMode)  

```
fun setTabletopMode(): DeviceAction
```

Set device screen to be folded with the hinge in the horizontal position. For details on foldable postures, see https://developer.android.com/guide/topics/large-screens/learn-about-foldables#foldable_postures

This action is for foldable devices only. Currently only supported for tests run on Android Emulators.  

|                                                                                                  Throws                                                                                                   |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------|
| [androidx.test.platform.device.UnsupportedDeviceOperationException](https://developer.android.com/reference/kotlin/androidx/test/platform/device/UnsupportedDeviceOperationException)                     | if used on a real device.               |
| [androidx.test.espresso.device.controller.DeviceControllerOperationException](https://developer.android.com/reference/kotlin/androidx/test/espresso/device/controller/DeviceControllerOperationException) | when called on a non-foldable Emulator. |