android-test
android-test copied to clipboard
ScreenOrientationRule does not restore the orientation if a test fails
Does ScreenOrientationRule need a try block around its statement evaluation?
Current:
val orientationToRestore = defaultOrientation ?: getCurrentOrientation()
statement.evaluate()
onDevice().perform(setScreenOrientation(orientationToRestore))
Proposed:
val orientationToRestore = defaultOrientation ?: getCurrentOrientation()
try {
statement.evaluate()
} finally {
onDevice().perform(setScreenOrientation(orientationToRestore))
}