# 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)

*** ** * ** ***


```
class ScreenOrientationRule : TestRule
```

<br />

*** ** * ** ***

Restores the screen orientation when a test case finishes.

## Summary

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

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

## Public constructors

### ScreenOrientationRule

```
ScreenOrientationRule()
```

### ScreenOrientationRule

```
ScreenOrientationRule(defaultOrientation: ScreenOrientation?)
```

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

## Public functions

### apply

```
open fun apply(statement: Statement, description: Description): Statement
```