Skip to content

Commit 23280ba

Browse files
Paige McAuliffecopybara-androidxtest
authored andcommitted
Make orientation value in ScreenOrientation enum private
PiperOrigin-RevId: 547329756
1 parent adc05a2 commit 23280ba

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

espresso/device/java/androidx/test/espresso/device/action/DeviceActions.kt

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ package androidx.test.espresso.device.action
2020

2121
import android.os.Handler
2222
import android.os.Looper
23+
import androidx.annotation.RestrictTo
24+
import androidx.annotation.RestrictTo.Scope
2325
import androidx.test.annotation.ExperimentalTestApi
2426
import androidx.test.espresso.device.sizeclass.HeightSizeClass
2527
import androidx.test.espresso.device.sizeclass.WidthSizeClass
@@ -112,7 +114,14 @@ fun setDisplaySize(widthSizeClass: WidthSizeClass, heightSizeClass: HeightSizeCl
112114

113115
/** Enum for screen orientations a device can be set to. */
114116
@ExperimentalTestApi
115-
enum class ScreenOrientation(val orientation: Int) {
117+
enum class ScreenOrientation(private val orientation: Int) {
116118
PORTRAIT(0),
117-
LANDSCAPE(1)
119+
LANDSCAPE(1);
120+
121+
/**
122+
* Returns the orientation.
123+
*
124+
* @hide
125+
*/
126+
@RestrictTo(Scope.LIBRARY) fun getOrientation(): Int = orientation
118127
}

espresso/device/java/androidx/test/espresso/device/action/ScreenOrientationAction.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ internal class ScreenOrientationAction(val screenOrientation: ScreenOrientation)
7676
}
7777

7878
if (isRobolectricTest()) {
79-
deviceController.setScreenOrientation(screenOrientation.orientation)
79+
deviceController.setScreenOrientation(screenOrientation.getOrientation())
8080
return
8181
}
8282

@@ -165,7 +165,7 @@ internal class ScreenOrientationAction(val screenOrientation: ScreenOrientation)
165165
}
166166
)
167167
}
168-
deviceController.setScreenOrientation(screenOrientation.orientation)
168+
deviceController.setScreenOrientation(screenOrientation.getOrientation())
169169
latch.await(5, TimeUnit.SECONDS)
170170
if (
171171
getDeviceApiLevel() >= 21 &&

espresso/device/java/androidx/test/espresso/device/controller/emulator/EmulatorController.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ constructor(
8888
val rotation: ParameterValue = physicalModelValue.getValue()
8989
val startingRotationDegrees = rotation.getDataList()[2].toFloat()
9090
var degreesToRotate =
91-
if (orientation == ScreenOrientation.PORTRAIT.orientation) {
91+
if (orientation == ScreenOrientation.PORTRAIT.getOrientation()) {
9292
DEGREES_TO_ROTATE_LANDSCAPE_TO_PORTRAIT + startingRotationDegrees
9393
} else {
9494
DEGREES_TO_ROTATE_PORTRAIT_TO_LANDSCAPE - startingRotationDegrees

0 commit comments

Comments
 (0)