android / android/android-test

ScreenOrientationRule does not restore the orientation if a test fails

Open
#2,308 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
1.2k
Forks
342
Avg merge
11h 29m
Merged PRs (30d)
2

Description

Does `ScreenOrientationRule` need a `try` block around its statement evaluation?

Current:
```kotlin
val orientationToRestore = defaultOrientation ?: getCurrentOrientation()
statement.evaluate()
onDevice().perform(setScreenOrientation(orientationToRestore))
```

Proposed:
```kotlin
val orientationToRestore = defaultOrientation ?: getCurrentOrientation()
try {
statement.evaluate()
} finally {
onDevice().perform(setScreenOrientation(orientationToRestore))
}
```

Contributor guide

Open the contributing guide

Research direction

Start at the ScreenOrientationRule entry point and inspect the code around statement.evaluate() and the orientation-restoration call. Confirm the restoration is skipped when evaluation fails, then verify that the orientation is restored for both passing and failing evaluations.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, kotlin
Domain
mobile, testing
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.