Run Espresso tests on foldable devices
Learn how to run your Espresso tests on real foldable devices. Automate fold and unfold posture changes to validate your app’s responsiveness and continuity on BrowserStack App Automate.
Test the responsiveness and continuity of your application on real foldable devices with App Automate. This guide explains how to control the device’s posture (folded/unfolded) during your automated test sessions.
To have this feature enabled for your account, contact BrowserStack Support.
Testing on foldable devices is currently supported on the following device:
- Samsung Galaxy Fold 7
How to control device posture
You can change the device’s state between folded and unfolded by executing ADB shell commands using UiDevice in your Espresso test. The session always starts with the device in its default folded state.
Key commands
You control the posture by executing an ADB shell command using the executeShellCommand method from UiDevice.
Setup: Get UiDevice instance
First, you need to get an instance of UiDevice in your test.
Get available states
The state identifiers (1, 2, etc.) can vary between device models. Before running tests, it’s a good practice to verify the correct identifiers for your target device.
Set device state (Fold/Unfold)
You can set the device state by passing the state ID. Typically, state 1 is for folded and state 2 is for unfolded.
Example test workflow
Here’s a typical test flow for a foldable device:
- Start session: Begin your App Automate session on a Samsung Galaxy Fold 7. The device will be in its default folded portrait state.
- Test cover screen: Run assertions to validate your app’s UI and functionality on the cover screen.
-
Unfold the device: Send the
unfoldcommand (e.g.,cmd device_state state 2). - Wait for transition: Add a brief wait/delay to allow the app to resize and redraw its UI.
- Test main screen: Validate that the app’s layout correctly adapts to the larger screen. You can also test orientation changes (landscape/portrait) in this state.
-
Fold the device: Send the
foldcommand (e.g.,cmd device_state state 1). - Validate continuity: Verify that the app correctly transitions back to the cover screen state.
- End session: Terminate the session.
Supported features
The following features are supported when testing on foldable devices:
-
Posture automation: Switching between
foldedandunfoldedstates. -
Orientation changes: You can change the device orientation in both folded and unfolded states.
- Comprehensive logs: Full video logs and device logs capture of all state transitions.
Limitations and scope
The following limitations apply when testing on foldable devices:
-
No half-fold state: Only fully
foldedandunfoldedstates are supported. - Interactive sessions: State changes in interactive sessions must also be triggered via ADB commands. Landscape mode is not supported in interactive sessions.
- Split-screen apps: Testing apps in a split-screen view on the unfolded display is not supported.
View results
After your session is complete, you can verify the posture changes and their impact on your app using the following logs available on the App Automate dashboard. The following logs are available for your test session:
- Video recording: The session video visually shows the device folding, unfolding, and rotating as triggered by your script.
- Device logs: The device logs capture the ADB commands executed to change posture, along with any app-level logs during these transitions.
We're sorry to hear that. Please share your feedback so we can do better
Contact our Support team for immediate help while we work on improving our docs.
We're continuously improving our docs. We'd love to know what you liked
We're sorry to hear that. Please share your feedback so we can do better
Contact our Support team for immediate help while we work on improving our docs.
We're continuously improving our docs. We'd love to know what you liked
Thank you for your valuable feedback!