# DeviceInteraction.Companion

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/DeviceInteraction.kt+class:androidx.test.espresso.device.DeviceInteraction.Companion)

*** ** * ** ***


```
public static class DeviceInteraction.Companion
```

<br />

*** ** * ** ***

## Summary

| ### Public methods |
|---|---|
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/test/espresso/device/DeviceInteraction` | `https://developer.android.com/reference/androidx/test/espresso/device/DeviceInteraction.Companion#(androidx.test.espresso.device.DeviceInteraction).setBookMode()(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/test/espresso/device/DeviceInteraction receiver)` Set device screen to be folded with the hinge in the vertical position. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/test/espresso/device/DeviceInteraction` | `https://developer.android.com/reference/androidx/test/espresso/device/DeviceInteraction.Companion#(androidx.test.espresso.device.DeviceInteraction).setClosedMode()(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/test/espresso/device/DeviceInteraction receiver)` Set device screen to be closed. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/test/espresso/device/DeviceInteraction` | `https://developer.android.com/reference/androidx/test/espresso/device/DeviceInteraction.Companion#(androidx.test.espresso.device.DeviceInteraction).setDisplaySize(androidx.test.espresso.device.sizeclass.WidthSizeClass,androidx.test.espresso.device.sizeclass.HeightSizeClass)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/test/espresso/device/DeviceInteraction receiver, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/test/espresso/device/sizeclass/WidthSizeClass widthSizeClass, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/test/espresso/device/sizeclass/HeightSizeClass heightSizeClass )` Set device's display size. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/test/espresso/device/DeviceInteraction` | `https://developer.android.com/reference/androidx/test/espresso/device/DeviceInteraction.Companion#(androidx.test.espresso.device.DeviceInteraction).setFlatMode()(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/test/espresso/device/DeviceInteraction receiver)` Set device screen to be completely flat, like a tablet. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/test/espresso/device/DeviceInteraction` | `https://developer.android.com/reference/androidx/test/espresso/device/DeviceInteraction.Companion#(androidx.test.espresso.device.DeviceInteraction).setScreenOrientation(androidx.test.espresso.device.action.ScreenOrientation)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/test/espresso/device/DeviceInteraction receiver, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/test/espresso/device/action/ScreenOrientation orientation )` Set device's screen orientation. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/test/espresso/device/DeviceInteraction` | `https://developer.android.com/reference/androidx/test/espresso/device/DeviceInteraction.Companion#(androidx.test.espresso.device.DeviceInteraction).setTabletopMode()(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/test/espresso/device/DeviceInteraction receiver)` Set device screen to be folded with the hinge in the horizontal position. |

## Public methods

### setBookMode

```
public static final @NonNull DeviceInteraction setBookMode(@NonNull DeviceInteraction receiver)
```

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 |
|---|---|
| `https://developer.android.com/reference/androidx/test/platform/device/UnsupportedDeviceOperationException` | if used on a real device. |
| `https://developer.android.com/reference/androidx/test/espresso/device/controller/DeviceControllerOperationException` | when called on a non-foldable Emulator. |

### setClosedMode

```
public static final @NonNull DeviceInteraction setClosedMode(@NonNull DeviceInteraction receiver)
```

Set device screen to be closed.

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

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

### setDisplaySize

```
public static final @NonNull DeviceInteraction setDisplaySize(
    @NonNull DeviceInteraction receiver,
    @NonNull WidthSizeClass widthSizeClass,
    @NonNull HeightSizeClass heightSizeClass
)
```

Set device's display size.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/test/espresso/device/sizeclass/WidthSizeClass widthSizeClass` | the width to set the device display to |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/test/espresso/device/sizeclass/HeightSizeClass heightSizeClass` | the height to set the device display to |

### setFlatMode

```
public static final @NonNull DeviceInteraction setFlatMode(@NonNull DeviceInteraction receiver)
```

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 |
|---|---|
| `https://developer.android.com/reference/androidx/test/platform/device/UnsupportedDeviceOperationException` | if used on a real device. |
| `https://developer.android.com/reference/androidx/test/espresso/device/controller/DeviceControllerOperationException` | when called on a non-foldable Emulator. |

### setScreenOrientation

```
public static final @NonNull DeviceInteraction setScreenOrientation(
    @NonNull DeviceInteraction receiver,
    @NonNull ScreenOrientation orientation
)
```

Set device's screen orientation.

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

### setTabletopMode

```
public static final @NonNull DeviceInteraction setTabletopMode(@NonNull DeviceInteraction receiver)
```

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 |
|---|---|
| `https://developer.android.com/reference/androidx/test/platform/device/UnsupportedDeviceOperationException` | if used on a real device. |
| `https://developer.android.com/reference/androidx/test/espresso/device/controller/DeviceControllerOperationException` | when called on a non-foldable Emulator. |