Test Kit for foldable devices
The Test Kit contains utility functions that help you write instrumented UI tests for foldable devices.
There are two library versions in the Test Kit:
- View system library:
com.microsoft.dualscreen.testing:testing-kotlin
- Jetpack Compose library:
com.microsoft.dualscreen.testing:testing-compose
The Compose version builds on the view system version and provides Compose wrappers for the utility functions.
Wichtig
You will only need to import one library version in any project. If you only use traditional views, import the testing-kotlin
version. Otherwise, if you use only composables, or a combination of composables and views, import the testing-compose
version.
Make sure you have the
mavenCentral()
repository in your top level build.gradle file:allprojects { repositories { google() mavenCentral() } }
Add the dependency you need to the module-level build.gradle file (current version may be different from what's shown here):
When working with foldable devices, there are a few terms and concepts that are helpful to understand. See Foldable concepts for UI tests.
When writing UI tests, there are a few ways to test app behavior on foldable devices.
Using the Jetpack Window Manager testing artifact, you can simulate a folding feature on any device/emulator to test how your layouts react. See Simulate folding features.
Using UiAutomator and specific device dimensions, you can simulate spanning and unspanning gestures on the Surface Duo to test how your layouts react. See Simulate swipe gestures.
Using annotations, you can create tests for single-screen mode, dual-screen mode, device orientation, and folding features. See Test Kit annotations.