# ScreenOrientationRule

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

*** ** * ** ***


```
public final class ScreenOrientationRule implements TestRule
```

<br />

*** ** * ** ***

Restores the screen orientation when a test case finishes.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/test/espresso/device/rules/ScreenOrientationRule#ScreenOrientationRule()()` |
| `https://developer.android.com/reference/androidx/test/espresso/device/rules/ScreenOrientationRule#ScreenOrientationRule(androidx.test.espresso.device.action.ScreenOrientation)(https://developer.android.com/reference/androidx/test/espresso/device/action/ScreenOrientation defaultOrientation)` |

| ### Public methods |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://junit.org/junit4/javadoc/latest/org/junit/runners/model/Statement.html` | `https://developer.android.com/reference/androidx/test/espresso/device/rules/ScreenOrientationRule#apply(org.junit.runners.model.Statement,org.junit.runner.Description)(@https://developer.android.com/reference/androidx/annotation/NonNull https://junit.org/junit4/javadoc/latest/org/junit/runners/model/Statement.html statement, @https://developer.android.com/reference/androidx/annotation/NonNull https://junit.org/junit4/javadoc/latest/org/junit/runner/Description.html description)` |

## Public constructors

### ScreenOrientationRule

```
public ScreenOrientationRule()
```

### ScreenOrientationRule

```
public ScreenOrientationRule(ScreenOrientation defaultOrientation)
```

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/test/espresso/device/action/ScreenOrientation defaultOrientation` | : the screen orientation will be set to the specified value, or the one that the test starts with if none is given. |

## Public methods

### apply

```
public @NonNull Statement apply(@NonNull Statement statement, @NonNull Description description)
```