DeviceInteraction
class DeviceInteraction
API surface for performing device-centric operations.
Summary
Public companion functions |
|
|---|---|
DeviceInteraction |
Set device screen to be folded with the hinge in the vertical position. |
DeviceInteraction |
Set device screen to be closed. |
DeviceInteraction |
DeviceInteraction.setDisplaySize(Set device's display size. |
DeviceInteraction |
Set device screen to be completely flat, like a tablet. |
DeviceInteraction |
DeviceInteraction.setScreenOrientation(orientation: ScreenOrientation)Set device's screen orientation. |
DeviceInteraction |
Set device screen to be folded with the hinge in the horizontal position. |
Public constructors |
|---|
@Inject |
Public functions |
|
|---|---|
DeviceInteraction |
perform(action: DeviceAction)Performs the given action on the test device. |
Public companion functions
setBookMode
fun DeviceInteraction.setBookMode(): DeviceInteraction
Set device screen to be folded with the hinge in the vertical position. For details on foldable postures, see https://developer.android.com/guide/topics/large-screens/learn-about-foldables#foldable_postures
This action is for foldable devices only. Currently only supported for tests run on Android Emulators.
| Throws | |
|---|---|
androidx.test.platform.device.UnsupportedDeviceOperationException |
if used on a real device. |
androidx.test.espresso.device.controller.DeviceControllerOperationException |
when called on a non-foldable Emulator. |
setClosedMode
fun DeviceInteraction.setClosedMode(): DeviceInteraction
Set device screen to be closed.
This action is for foldable devices only. Currently only supported for tests run on Android Emulators.
| Throws | |
|---|---|
androidx.test.platform.device.UnsupportedDeviceOperationException |
if used on a real device. |
androidx.test.espresso.device.controller.DeviceControllerOperationException |
when called on a non-foldable Emulator. |
setDisplaySize
fun DeviceInteraction.setDisplaySize(
widthSizeClass: WidthSizeClass,
heightSizeClass: HeightSizeClass
): DeviceInteraction
Set device's display size.
| Parameters | |
|---|---|
widthSizeClass: WidthSizeClass |
the width to set the device display to |
heightSizeClass: HeightSizeClass |
the height to set the device display to |
setFlatMode
fun DeviceInteraction.setFlatMode(): DeviceInteraction
Set device screen to be completely flat, like a tablet. For details on foldable postures, see https://developer.android.com/guide/topics/large-screens/learn-about-foldables#foldable_postures
This action is for foldable devices only. Currently only supported for tests run on Android Emulators.
| Throws | |
|---|---|
androidx.test.platform.device.UnsupportedDeviceOperationException |
if used on a real device. |
androidx.test.espresso.device.controller.DeviceControllerOperationException |
when called on a non-foldable Emulator. |
setScreenOrientation
fun DeviceInteraction.setScreenOrientation(orientation: ScreenOrientation): DeviceInteraction
Set device's screen orientation.
| Parameters | |
|---|---|
orientation: ScreenOrientation |
the orientation to set the device to (portait or landscape) |
setTabletopMode
fun DeviceInteraction.setTabletopMode(): DeviceInteraction
Set device screen to be folded with the hinge in the horizontal position. For details on foldable postures, see https://developer.android.com/guide/topics/large-screens/learn-about-foldables#foldable_postures
This action is for foldable devices only. Currently only supported for tests run on Android Emulators.
| Throws | |
|---|---|
androidx.test.platform.device.UnsupportedDeviceOperationException |
if used on a real device. |
androidx.test.espresso.device.controller.DeviceControllerOperationException |
when called on a non-foldable Emulator. |
Public constructors
Public functions
perform
fun perform(action: DeviceAction): DeviceInteraction
Performs the given action on the test device. This method should not be called on the main thread. The calling thread is blocked until the requested device action is completed.
| Parameters | |
|---|---|
action: DeviceAction |
the DeviceAction to execute. |
| Returns | |
|---|---|
DeviceInteraction |
this interaction for further perform/verification calls. |
| Throws | |
|---|---|
kotlin.IllegalStateException |
when being invoked on the main thread. |